Add a clock multiplier for simple CPU so that it is possible
authorNathan Binkert <binkertn@umich.edu>
Thu, 15 Jul 2004 03:01:54 +0000 (23:01 -0400)
committerNathan Binkert <binkertn@umich.edu>
Thu, 15 Jul 2004 03:01:54 +0000 (23:01 -0400)
to do multiple instructions per cycle.

--HG--
extra : convert_revision : 5588ae38071f170792aad93899fef6842b7d818d

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

index d70f0ccfa48e990f6c8e6362cc15224706414b9d..6c22d7c81ba5cd08c4c4a7f7dec0ba72ad1f1490 100644 (file)
 using namespace std;
 
 SimpleCPU::TickEvent::TickEvent(SimpleCPU *c)
-    : Event(&mainEventQueue, CPU_Tick_Pri), cpu(c)
+    : Event(&mainEventQueue, CPU_Tick_Pri), cpu(c), multiplier(1)
 {
 }
 
 void
 SimpleCPU::TickEvent::process()
 {
-    cpu->tick();
+    int count = multiplier;
+    do {
+        cpu->tick();
+    } while (--count > 0 && cpu->status() == Running);
 }
 
 const char *
@@ -269,6 +272,11 @@ SimpleCPU::regStats()
         .desc("Number of memory references")
         ;
 
+    notIdleFraction
+        .name(name() + ".not_idle_fraction")
+        .desc("Percentage of non-idle cycles")
+        ;
+
     idleFraction
         .name(name() + ".idle_fraction")
         .desc("Percentage of idle cycles")
@@ -799,6 +807,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(SimpleCPU)
     SimObjectParam<BaseMem *> dcache;
 
     Param<bool> defer_registration;
+    Param<int> multiplier;
 
 END_DECLARE_SIM_OBJECT_PARAMS(SimpleCPU)
 
@@ -830,7 +839,9 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(SimpleCPU)
     INIT_PARAM_DFLT(icache, "L1 instruction cache object", NULL),
     INIT_PARAM_DFLT(dcache, "L1 data cache object", NULL),
     INIT_PARAM_DFLT(defer_registration, "defer registration with system "
-                    "(for sampling)", false)
+                    "(for sampling)", false),
+
+    INIT_PARAM_DFLT(multiplier, "clock multiplier", 1)
 
 END_INIT_SIM_OBJECT_PARAMS(SimpleCPU)
 
@@ -861,6 +872,8 @@ CREATE_SIM_OBJECT(SimpleCPU)
 
 #endif // FULL_SYSTEM
 
+    cpu->setTickMultiplier(multiplier);
+
     return cpu;
 }
 
index 3692ab5117777b642b5651b98dc85be431f71d18..6ab231e7e404f1a1f82ee95649cd206ce2ecab1e 100644 (file)
@@ -68,12 +68,11 @@ class SimpleCPU : public BaseCPU
     void tick();
 
   private:
-    class TickEvent : public Event
+    struct TickEvent : public Event
     {
-      private:
         SimpleCPU *cpu;
+        int multiplier;
 
-      public:
         TickEvent(SimpleCPU *c);
         void process();
         const char *description();
@@ -97,6 +96,12 @@ class SimpleCPU : public BaseCPU
             tickEvent.squash();
     }
 
+  public:
+    void setTickMultiplier(int multiplier)
+    {
+        tickEvent.multiplier = multiplier;
+    }
+
   private:
     Trace::InstRecord *traceData;
     template<typename T>