Add new EventWrapper constructor that takes a Tick value
authorSteve Reinhardt <stever@eecs.umich.edu>
Mon, 21 May 2007 04:43:01 +0000 (21:43 -0700)
committerSteve Reinhardt <stever@eecs.umich.edu>
Mon, 21 May 2007 04:43:01 +0000 (21:43 -0700)
and schedules the event immediately.

--HG--
extra : convert_revision : a84e729a5ef3632cbe6cff858c453c782707d983

src/cpu/base.cc
src/cpu/simple/timing.cc
src/cpu/simple/timing.hh
src/dev/ns_gige.cc
src/dev/sinic.cc
src/sim/eventq.hh

index 4dccee0d3c8aa4505a225a03d3550e22917158a6..078ae12838aafc7a65d39e51334d84a10d45f372 100644 (file)
@@ -179,10 +179,9 @@ BaseCPU::BaseCPU(Params *p)
         if (p->functionTraceStart == 0) {
             functionTracingEnabled = true;
         } else {
-            Event *e =
-                new EventWrapper<BaseCPU, &BaseCPU::enableFunctionTrace>(this,
-                                                                         true);
-            e->schedule(p->functionTraceStart);
+            new EventWrapper<BaseCPU, &BaseCPU::enableFunctionTrace>(this,
+                                                                     p->functionTraceStart,
+                                                                     true);
         }
     }
 #if FULL_SYSTEM
index fa7bb4f86d4ffe1af884174f59c9a7eae65b84a1..1c79fcf6b664bfba7118a2914f689067a8d5eee2 100644 (file)
@@ -168,9 +168,7 @@ TimingSimpleCPU::resume()
             delete fetchEvent;
         }
 
-        fetchEvent =
-            new EventWrapper<TimingSimpleCPU, &TimingSimpleCPU::fetch>(this, false);
-        fetchEvent->schedule(nextCycle());
+        fetchEvent = new FetchEvent(this, nextCycle());
     }
 
     changeState(SimObject::Running);
@@ -224,9 +222,7 @@ TimingSimpleCPU::activateContext(int thread_num, int delay)
     _status = Running;
 
     // kick things off by initiating the fetch of the next instruction
-    fetchEvent =
-        new EventWrapper<TimingSimpleCPU, &TimingSimpleCPU::fetch>(this, false);
-    fetchEvent->schedule(nextCycle(curTick + cycles(delay)));
+    fetchEvent = new FetchEvent(this, nextCycle(curTick + cycles(delay)));
 }
 
 
index ef062d24a88147dc4b47fbd0a72d985b4cdf5676..e65cbe46b4a38ae546f602b21f45c3e7a91cecc0 100644 (file)
@@ -66,8 +66,6 @@ class TimingSimpleCPU : public BaseSimpleCPU
 
     Event *drainEvent;
 
-    Event *fetchEvent;
-
   private:
 
     class CpuPort : public Port
@@ -199,7 +197,12 @@ class TimingSimpleCPU : public BaseSimpleCPU
     void completeIfetch(PacketPtr );
     void completeDataAccess(PacketPtr );
     void advanceInst(Fault fault);
+
   private:
+
+    typedef EventWrapper<TimingSimpleCPU, &TimingSimpleCPU::fetch> FetchEvent;
+    FetchEvent *fetchEvent;
+
     void completeDrain();
 };
 
index d9985f80858e0fc0a8cb11d29a3b7fbce3ad592a..e9d9c419d2e5b630037268ec62041d15ad3e8e66 100644 (file)
@@ -1270,8 +1270,7 @@ NSGigE::cpuIntrPost(Tick when)
 
     if (intrEvent)
         intrEvent->squash();
-    intrEvent = new IntrEvent(this, true);
-    intrEvent->schedule(intrTick);
+    intrEvent = new IntrEvent(this, intrTick, true);
 }
 
 void
@@ -2770,8 +2769,7 @@ NSGigE::unserialize(Checkpoint *cp, const std::string &section)
     Tick intrEventTick;
     UNSERIALIZE_SCALAR(intrEventTick);
     if (intrEventTick) {
-        intrEvent = new IntrEvent(this, true);
-        intrEvent->schedule(intrEventTick);
+        intrEvent = new IntrEvent(this, intrEventTick, true);
     }
 }
 
index 420761620e7d5ccefa80ea3e51559ea441de9559..e13fdb0bc84dff22d380e6a41df5981acf43cd9c 100644 (file)
@@ -630,8 +630,7 @@ Base::cpuIntrPost(Tick when)
 
     if (intrEvent)
         intrEvent->squash();
-    intrEvent = new IntrEvent(this, true);
-    intrEvent->schedule(intrTick);
+    intrEvent = new IntrEvent(this, intrTick, true);
 }
 
 void
@@ -1339,8 +1338,7 @@ Base::unserialize(Checkpoint *cp, const std::string &section)
     Tick intrEventTick;
     UNSERIALIZE_SCALAR(intrEventTick);
     if (intrEventTick) {
-        intrEvent = new IntrEvent(this, true);
-        intrEvent->schedule(intrEventTick);
+        intrEvent = new IntrEvent(this, intrEventTick, true);
     }
 }
 
index 974313968d38e74bc22e511f15bc178d40ca368c..6fbba46d578560f84eedd97a25d9df68ff61ef3b 100644 (file)
@@ -293,13 +293,25 @@ class EventWrapper : public Event
     T *object;
 
   public:
-    EventWrapper(T *obj, bool del = false, EventQueue *q = &mainEventQueue,
+    EventWrapper(T *obj, bool del = false,
+                 EventQueue *q = &mainEventQueue,
                  Priority p = Default_Pri)
         : Event(q, p), object(obj)
     {
         if (del)
             setFlags(AutoDelete);
     }
+
+    EventWrapper(T *obj, Tick t, bool del = false,
+                 EventQueue *q = &mainEventQueue,
+                 Priority p = Default_Pri)
+        : Event(q, p), object(obj)
+    {
+        if (del)
+            setFlags(AutoDelete);
+        schedule(t);
+    }
+
     void process() { (object->*F)(); }
 };