systemc: Differentiate between notifying methods and threads.
authorGabe Black <gabeblack@google.com>
Sat, 15 Sep 2018 03:19:53 +0000 (20:19 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 9 Oct 2018 21:50:23 +0000 (21:50 +0000)
The Accellera implementation notifies all types of method
sensitivities first, and then notifies all the ones for threads.

Change-Id: I5eda75958675ba518f008852148030e032f70d83
Reviewed-on: https://gem5-review.googlesource.com/c/12807
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/core/event.cc
src/systemc/core/event.hh
src/systemc/core/sensitivity.cc
src/systemc/core/sensitivity.hh

index 0daca12e13008d5f8a46e531b3c13051099554f3..e7132e08370385efdf4003d797b2c3cc0667c715 100644 (file)
@@ -133,6 +133,27 @@ Event::getParentObject() const
     return parent;
 }
 
+void
+Event::notify(StaticSensitivities &senses)
+{
+    for (auto s: senses)
+        s->notify(this);
+}
+
+void
+Event::notify(DynamicSensitivities &senses)
+{
+    int size = senses.size();
+    int pos = 0;
+    while (pos < size) {
+        if (senses[pos]->notify(this))
+            senses[pos] = senses[--size];
+        else
+            pos++;
+    }
+    senses.resize(size);
+}
+
 void
 Event::notify()
 {
@@ -145,18 +166,10 @@ Event::notify()
     if (delayedNotify.scheduled())
         scheduler.deschedule(&delayedNotify);
 
-    for (auto s: staticSensitivities)
-        s->notify(this);
-    DynamicSensitivities &ds = dynamicSensitivities;
-    int size = ds.size();
-    int pos = 0;
-    while (pos < size) {
-        if (ds[pos]->notify(this))
-            ds[pos] = ds[--size];
-        else
-            pos++;
-    }
-    ds.resize(size);
+    notify(staticSenseMethod);
+    notify(dynamicSenseMethod);
+    notify(staticSenseThread);
+    notify(dynamicSenseThread);
 }
 
 void
index bb1d0a0d6182c6f8ac0ee1bf56ce73c0ad0f5a23..3d34fa6a015f20ffef8cb934175775ad4df31dd4 100644 (file)
@@ -72,6 +72,9 @@ class Event
     bool inHierarchy() const;
     sc_core::sc_object *getParentObject() const;
 
+    void notify(StaticSensitivities &senses);
+    void notify(DynamicSensitivities &senses);
+
     void notify();
     void notify(const sc_core::sc_time &t);
     void
@@ -100,15 +103,17 @@ class Event
     {
         // Insert static sensitivities in reverse order to match Accellera's
         // implementation.
-        staticSensitivities.insert(staticSensitivities.begin(), s);
+        auto &senses = s->ofMethod() ? staticSenseMethod : staticSenseThread;
+        senses.insert(senses.begin(), s);
     }
     void
     delSensitivity(StaticSensitivity *s) const
     {
-        for (auto &t: staticSensitivities) {
+        auto &senses = s->ofMethod() ? staticSenseMethod : staticSenseThread;
+        for (auto &t: senses) {
             if (t == s) {
-                t = staticSensitivities.back();
-                staticSensitivities.pop_back();
+                t = senses.back();
+                senses.pop_back();
                 break;
             }
         }
@@ -116,15 +121,17 @@ class Event
     void
     addSensitivity(DynamicSensitivity *s) const
     {
-        dynamicSensitivities.push_back(s);
+        auto &senses = s->ofMethod() ? dynamicSenseMethod : dynamicSenseThread;
+        senses.push_back(s);
     }
     void
     delSensitivity(DynamicSensitivity *s) const
     {
-        for (auto &t: dynamicSensitivities) {
+        auto &senses = s->ofMethod() ? dynamicSenseMethod : dynamicSenseThread;
+        for (auto &t: senses) {
             if (t == s) {
-                t = dynamicSensitivities.back();
-                dynamicSensitivities.pop_back();
+                t = senses.back();
+                senses.pop_back();
                 break;
             }
         }
@@ -141,8 +148,10 @@ class Event
 
     ScEvent delayedNotify;
 
-    mutable StaticSensitivities staticSensitivities;
-    mutable DynamicSensitivities dynamicSensitivities;
+    mutable StaticSensitivities staticSenseMethod;
+    mutable StaticSensitivities staticSenseThread;
+    mutable DynamicSensitivities dynamicSenseMethod;
+    mutable DynamicSensitivities dynamicSenseThread;
 };
 
 extern Events topLevelEvents;
index 740090cd9c69e31c740d6f45c4c7bb2cc16747f6..2bd0b5fcb50b959379eb2d95e796f6ff04baa137 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "systemc/core/event.hh"
 #include "systemc/core/port.hh"
+#include "systemc/core/process.hh"
 #include "systemc/core/scheduler.hh"
 #include "systemc/ext/core/sc_export.hh"
 #include "systemc/ext/core/sc_interface.hh"
@@ -57,6 +58,12 @@ Sensitivity::notify(Event *e)
     return notifyWork(e);
 }
 
+bool
+Sensitivity::ofMethod()
+{
+    return process->procKind() == sc_core::SC_METHOD_PROC_;
+}
+
 
 /*
  * Dynamic vs. static sensitivity.
index b3f9a2e490c9cc2a7643f03f225ec8ec60845831..a412c7a63f163c05a2cffb28677f74e71a000514 100644 (file)
@@ -85,6 +85,8 @@ class Sensitivity
     bool notify(Event *e);
 
     virtual bool dynamic() = 0;
+
+    bool ofMethod();
 };