summaryrefslogtreecommitdiff
path: root/src/systemc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-09-14 20:19:53 -0700
committerGabe Black <gabeblack@google.com>2018-10-09 21:50:23 +0000
commitf8126c66ce65a2770ce7c524d7eb0becfbb11d4b (patch)
tree5694e12131c3cd6423f7a370acc8e3e24c5d2173 /src/systemc
parentd737358ac643ff5bdc3984138cc3ae08c7b57ff7 (diff)
downloadgem5-f8126c66ce65a2770ce7c524d7eb0becfbb11d4b.tar.xz
systemc: Differentiate between notifying methods and threads.
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>
Diffstat (limited to 'src/systemc')
-rw-r--r--src/systemc/core/event.cc37
-rw-r--r--src/systemc/core/event.hh29
-rw-r--r--src/systemc/core/sensitivity.cc7
-rw-r--r--src/systemc/core/sensitivity.hh2
4 files changed, 53 insertions, 22 deletions
diff --git a/src/systemc/core/event.cc b/src/systemc/core/event.cc
index 0daca12e1..e7132e083 100644
--- a/src/systemc/core/event.cc
+++ b/src/systemc/core/event.cc
@@ -134,6 +134,27 @@ Event::getParentObject() const
}
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()
{
if (scheduler.inUpdate()) {
@@ -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
diff --git a/src/systemc/core/event.hh b/src/systemc/core/event.hh
index bb1d0a0d6..3d34fa6a0 100644
--- a/src/systemc/core/event.hh
+++ b/src/systemc/core/event.hh
@@ -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;
diff --git a/src/systemc/core/sensitivity.cc b/src/systemc/core/sensitivity.cc
index 740090cd9..2bd0b5fcb 100644
--- a/src/systemc/core/sensitivity.cc
+++ b/src/systemc/core/sensitivity.cc
@@ -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.
diff --git a/src/systemc/core/sensitivity.hh b/src/systemc/core/sensitivity.hh
index b3f9a2e49..a412c7a63 100644
--- a/src/systemc/core/sensitivity.hh
+++ b/src/systemc/core/sensitivity.hh
@@ -85,6 +85,8 @@ class Sensitivity
bool notify(Event *e);
virtual bool dynamic() = 0;
+
+ bool ofMethod();
};