diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-02-24 11:42:00 -0500 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-02-24 11:42:00 -0500 |
commit | 9f07d2ce7ecf435b9a1946f15fb3491bb4636637 (patch) | |
tree | 33f66ff6c258214a6b266b3cc582a52774935ae2 /src/cpu/base.cc | |
parent | ef4af8cec8b1826abff5b92b9fec32f7c2818372 (diff) | |
download | gem5-9f07d2ce7ecf435b9a1946f15fb3491bb4636637.tar.xz |
CPU: Round-two unifying instr/data CPU ports across models
This patch continues the unification of how the different CPU models
create and share their instruction and data ports. Most importantly,
it forces every CPU to have an instruction and a data port, and gives
these ports explicit getters in the BaseCPU (getDataPort and
getInstPort). The patch helps in simplifying the code, make
assumptions more explicit, andfurther ease future patches related to
the CPU ports.
The biggest changes are in the in-order model (that was not modified
in the previous unification patch), which now moves the ports from the
CacheUnit to the CPU. It also distinguishes the instruction fetch and
load-store unit from the rest of the resources, and avoids the use of
indices and casting in favour of keeping track of these two units
explicitly (since they are always there anyways). The atomic, timing
and O3 model simply return references to their already existing ports.
Diffstat (limited to 'src/cpu/base.cc')
-rw-r--r-- | src/cpu/base.cc | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/cpu/base.cc b/src/cpu/base.cc index 276995da2..86edf62cf 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -296,6 +296,21 @@ BaseCPU::regStats() threadContexts[0]->regStats(name()); } +Port * +BaseCPU::getPort(const string &if_name, int idx) +{ + // Get the right port based on name. This applies to all the + // subclasses of the base CPU and relies on their implementation + // of getDataPort and getInstPort. In all cases there methods + // return a CpuPort pointer. + if (if_name == "dcache_port") + return &getDataPort(); + else if (if_name == "icache_port") + return &getInstPort(); + else + panic("CPU %s has no port named %s\n", name(), if_name); +} + Tick BaseCPU::nextCycle() { @@ -363,8 +378,8 @@ BaseCPU::switchOut() void BaseCPU::takeOverFrom(BaseCPU *oldCPU) { - Port *ic = getPort("icache_port"); - Port *dc = getPort("dcache_port"); + CpuPort &ic = getInstPort(); + CpuPort &dc = getDataPort(); assert(threadContexts.size() == oldCPU->threadContexts.size()); _cpuId = oldCPU->cpuId(); @@ -453,16 +468,16 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU) // Connect new CPU to old CPU's memory only if new CPU isn't // connected to anything. Also connect old CPU's memory to new // CPU. - if (!ic->isConnected()) { - Port *peer = oldCPU->getPort("icache_port")->getPeer(); - ic->setPeer(peer); - peer->setPeer(ic); + if (!ic.isConnected()) { + Port *peer = oldCPU->getInstPort().getPeer(); + ic.setPeer(peer); + peer->setPeer(&ic); } - if (!dc->isConnected()) { - Port *peer = oldCPU->getPort("dcache_port")->getPeer(); - dc->setPeer(peer); - peer->setPeer(dc); + if (!dc.isConnected()) { + Port *peer = oldCPU->getDataPort().getPeer(); + dc.setPeer(peer); + peer->setPeer(&dc); } } |