Instead of keeping track of the fraction of time that we're
authorNathan Binkert <binkertn@umich.edu>
Mon, 8 Dec 2003 19:01:48 +0000 (14:01 -0500)
committerNathan Binkert <binkertn@umich.edu>
Mon, 8 Dec 2003 19:01:48 +0000 (14:01 -0500)
idle, keep track of the fraction of time we're not idle.  This
works better because the default processor state is idle, and
the default stat value is 0.
Keep the stat as idleFraction which is a formula that is equal
to 1 - notIdleFraction

--HG--
extra : convert_revision : 331c2e46f45ae0abda46988567ac2c4f7c42ccad

cpu/simple_cpu/simple_cpu.cc
cpu/simple_cpu/simple_cpu.hh

index 4b9a7c6bdf49ba93b32d74f61257b9d56a870428..aaf8a9dc58df8001e8d6aad3bf5a6fb64cbfcb63 100644 (file)
@@ -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
index e497559ce086b4387928453fc877772d17ad0095..666fe490b1806a5640f18afd59ed8db00101e72a 100644 (file)
@@ -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;