diff options
author | Steve Reinhardt <stever@eecs.umich.edu> | 2003-12-09 14:21:46 -0800 |
---|---|---|
committer | Steve Reinhardt <stever@eecs.umich.edu> | 2003-12-09 14:21:46 -0800 |
commit | a1dcdeb3d85031e851bb9227a9b1fb2b20e3172d (patch) | |
tree | b0f502733192a2c05fd33c8d7cde669335578d03 /cpu/simple_cpu/simple_cpu.cc | |
parent | 5e360051cff91763b71a214e820d24ac22146988 (diff) | |
parent | 368de4109f9decca72faac1a6eb0909da712f43f (diff) | |
download | gem5-a1dcdeb3d85031e851bb9227a9b1fb2b20e3172d.tar.xz |
Merge zizzer:/bk/m5 into isabel.reinhardt.house:/z/stever/bk/m5
--HG--
extra : convert_revision : c74b502bf44ac300e44c9aa7d6d6e3c55a511893
Diffstat (limited to 'cpu/simple_cpu/simple_cpu.cc')
-rw-r--r-- | cpu/simple_cpu/simple_cpu.cc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/cpu/simple_cpu/simple_cpu.cc b/cpu/simple_cpu/simple_cpu.cc index 8b99a0105..77f0c41ed 100644 --- a/cpu/simple_cpu/simple_cpu.cc +++ b/cpu/simple_cpu/simple_cpu.cc @@ -216,6 +216,63 @@ SimpleCPU::execCtxStatusChg(int thread_num) { setStatus(Idle); } +void +SimpleCPU::setStatus(Status new_status) +{ + Status old_status = status(); + + // We should never even get here if the CPU has been switched out. + assert(old_status != SwitchedOut); + + _status = new_status; + + switch (status()) { + case IcacheMissStall: + assert(old_status == Running); + lastIcacheStall = curTick; + if (tickEvent.scheduled()) + tickEvent.squash(); + break; + + case IcacheMissComplete: + assert(old_status == IcacheMissStall); + if (tickEvent.squashed()) + tickEvent.reschedule(curTick + 1); + else if (!tickEvent.scheduled()) + tickEvent.schedule(curTick + 1); + break; + + case DcacheMissStall: + assert(old_status == Running); + lastDcacheStall = curTick; + if (tickEvent.scheduled()) + tickEvent.squash(); + break; + + case Idle: + assert(old_status == Running); + notIdleFraction--; + if (tickEvent.scheduled()) + tickEvent.squash(); + break; + + case Running: + assert(old_status == Idle || + old_status == DcacheMissStall || + old_status == IcacheMissComplete); + if (old_status == Idle) + notIdleFraction++; + + if (tickEvent.squashed()) + tickEvent.reschedule(curTick + 1); + else if (!tickEvent.scheduled()) + tickEvent.schedule(curTick + 1); + break; + + default: + panic("can't get here"); + } +} void SimpleCPU::regStats() @@ -251,6 +308,7 @@ SimpleCPU::regStats() .prereq(dcacheStallCycles) ; + idleFraction = constant(1.0) - notIdleFraction; numInsts = Statistics::scalar(numInst) - Statistics::scalar(startNumInst); simInsts += numInsts; } @@ -259,6 +317,7 @@ void SimpleCPU::resetStats() { startNumInst = numInst; + notIdleFraction = (_status != Idle); } void |