summaryrefslogtreecommitdiff
path: root/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'cpu')
-rw-r--r--cpu/simple_cpu/simple_cpu.cc8
-rw-r--r--cpu/simple_cpu/simple_cpu.hh3
2 files changed, 7 insertions, 4 deletions
diff --git a/cpu/simple_cpu/simple_cpu.cc b/cpu/simple_cpu/simple_cpu.cc
index 4b9a7c6bd..aaf8a9dc5 100644
--- a/cpu/simple_cpu/simple_cpu.cc
+++ b/cpu/simple_cpu/simple_cpu.cc
@@ -247,7 +247,7 @@ SimpleCPU::setStatus(Status new_status)
case Idle:
assert(old_status == Running);
- idleFraction++;
+ notIdleFraction--;
if (tickEvent.scheduled())
tickEvent.squash();
break;
@@ -256,8 +256,8 @@ SimpleCPU::setStatus(Status new_status)
assert(old_status == Idle ||
old_status == DcacheMissStall ||
old_status == IcacheMissComplete);
- if (old_status == Idle && curTick != 0)
- idleFraction--;
+ if (old_status == Idle)
+ notIdleFraction++;
if (tickEvent.squashed())
tickEvent.reschedule(curTick + 1);
@@ -304,6 +304,7 @@ SimpleCPU::regStats()
.prereq(dcacheStallCycles)
;
+ idleFraction = constant(1.0) - notIdleFraction;
numInsts = Statistics::scalar(numInst) - Statistics::scalar(startNumInst);
simInsts += numInsts;
}
@@ -312,6 +313,7 @@ void
SimpleCPU::resetStats()
{
startNumInst = numInst;
+ notIdleFraction = (_status != Idle);
}
void
diff --git a/cpu/simple_cpu/simple_cpu.hh b/cpu/simple_cpu/simple_cpu.hh
index e497559ce..666fe490b 100644
--- a/cpu/simple_cpu/simple_cpu.hh
+++ b/cpu/simple_cpu/simple_cpu.hh
@@ -193,7 +193,8 @@ class SimpleCPU : public BaseCPU
Counter startNumLoad;
// number of idle cycles
- Statistics::Average<> idleFraction;
+ Statistics::Average<> notIdleFraction;
+ Statistics::Formula idleFraction;
// number of cycles stalled for I-cache misses
Statistics::Scalar<> icacheStallCycles;