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>
This commit is contained in:
Gabe Black
2018-09-14 20:19:53 -07:00
parent d737358ac6
commit f8126c66ce
4 changed files with 53 additions and 22 deletions

View 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

View 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;

View 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.

View File

@@ -85,6 +85,8 @@ class Sensitivity
bool notify(Event *e);
virtual bool dynamic() = 0;
bool ofMethod();
};