Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/12452

Change subject: systemc: Add a "changeStamp" value to the scheduler.
......................................................................

systemc: Add a "changeStamp" value to the scheduler.

This value is incremented after each delta cycle's evaluate stage and
after timed notifications happen. Its value is used by some channels
to determine whether certain events happened within the previous update
phase to implement the "event()", "posedge()", and "negedge()"
functions.

Change-Id: I9a73f0b5007dcbb6a74da9d666f28da1930b9d3d
---
M src/systemc/core/sc_prim.cc
M src/systemc/core/scheduler.cc
M src/systemc/core/scheduler.hh
M src/systemc/ext/core/sc_prim.hh
4 files changed, 18 insertions(+), 2 deletions(-)



diff --git a/src/systemc/core/sc_prim.cc b/src/systemc/core/sc_prim.cc
index 91befa8..170abb5 100644
--- a/src/systemc/core/sc_prim.cc
+++ b/src/systemc/core/sc_prim.cc
@@ -29,8 +29,16 @@

 #include "base/logging.hh"
 #include "systemc/core/channel.hh"
+#include "systemc/core/scheduler.hh"
 #include "systemc/ext/core/sc_prim.hh"

+namespace sc_gem5
+{
+
+uint64_t getChangeStamp() { return scheduler.changeStamp(); }
+
+} // namespace sc_gem5
+
 namespace sc_core
 {

diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index 9b431ac..e340f4d 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -46,7 +46,7 @@
     starvationEvent(this, false, StarvationPriority),
     _started(false), _paused(false), _stopped(false),
     maxTickEvent(this, false, MaxTickPriority),
-    _numCycles(0), _current(nullptr), initDone(false),
+    _numCycles(0), _changeStamp(0), _current(nullptr), initDone(false),
     runOnce(false)
 {}

@@ -271,8 +271,10 @@
         yield();
     } while (!readyList.empty());

-    if (!empty)
+    if (!empty) {
         _numCycles++;
+        _changeStamp++;
+    }

     // The update phase.
     update();
diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh
index f55ff1f..2bac934 100644
--- a/src/systemc/core/scheduler.hh
+++ b/src/systemc/core/scheduler.hh
@@ -275,6 +275,7 @@
     void
     completeTimeSlot(TimeSlot *ts)
     {
+        _changeStamp++;
         assert(ts == timeSlots.begin()->second);
         timeSlots.erase(timeSlots.begin());
         if (!runToTime && starved())
@@ -327,6 +328,8 @@
     bool paused() { return _paused; }
     bool stopped() { return _stopped; }

+    uint64_t changeStamp() { return _changeStamp; }
+
   private:
     typedef const EventBase::Priority Priority;
     static Priority DefaultPriority = EventBase::Default_Pri;
@@ -391,6 +394,7 @@
     EventWrapper<Scheduler, &Scheduler::pause> maxTickEvent;

     uint64_t _numCycles;
+    uint64_t _changeStamp;

     Process *_current;

diff --git a/src/systemc/ext/core/sc_prim.hh b/src/systemc/ext/core/sc_prim.hh
index 99e2314..73b8784 100644
--- a/src/systemc/ext/core/sc_prim.hh
+++ b/src/systemc/ext/core/sc_prim.hh
@@ -38,6 +38,8 @@

 class Channel;

+uint64_t getChangeStamp();
+
 } // namespace sc_gem5

 namespace sc_core

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12452
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I9a73f0b5007dcbb6a74da9d666f28da1930b9d3d
Gerrit-Change-Number: 12452
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to