summaryrefslogtreecommitdiff
path: root/src/systemc/core
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-09-26 03:20:09 -0700
committerGabe Black <gabeblack@google.com>2018-10-16 00:35:50 +0000
commit0cfce458003c377878aad3b15cf5fa2860a5f8e7 (patch)
treef99966a70759fde8d40b8a2e95939a4f7c3b2412 /src/systemc/core
parentf4ab64a588771391c2eebd9b1c8b089aa33cda67 (diff)
downloadgem5-0cfce458003c377878aad3b15cf5fa2860a5f8e7.tar.xz
systemc: Implement signal based resets.
The implementation is based on sc_event sensitivities. Also of note is that the way reset works in the Accellera implementation isn't consistent with the spec. That says that wait(int n) is supposed to be equivalent to calling wait() n times, assuming n is greater than 0. Instead, Accellera stores that count and then doesn't wake up the process until the count is 0, decrementing it otherwise. That means that when the process is in reset, it won't actually reset for those intermediate wait()s which it would if wait() was called repeatedly. Also, oddly, when a reset becomes asserted, it will clear the count to 0 explicitly. That may have been an attempt to make the behavior of wait(int n) match the spec, but it doesn't handle cases where the reset is already set when wait(int n) is called. Change-Id: I92f8e9a128e6618af94dc048ce570a4436e17e4b Reviewed-on: https://gem5-review.googlesource.com/c/13186 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core')
-rw-r--r--src/systemc/core/event.cc9
-rw-r--r--src/systemc/core/event.hh18
-rw-r--r--src/systemc/core/port.cc26
-rw-r--r--src/systemc/core/port.hh12
-rw-r--r--src/systemc/core/process.cc35
-rw-r--r--src/systemc/core/process.hh13
-rw-r--r--src/systemc/core/sc_module.cc46
-rw-r--r--src/systemc/core/sc_spawn.cc53
-rw-r--r--src/systemc/core/scheduler.cc2
-rw-r--r--src/systemc/core/scheduler.hh11
-rw-r--r--src/systemc/core/sensitivity.cc82
-rw-r--r--src/systemc/core/sensitivity.hh93
12 files changed, 348 insertions, 52 deletions
diff --git a/src/systemc/core/event.cc b/src/systemc/core/event.cc
index 4fb99e6d9..097961e99 100644
--- a/src/systemc/core/event.cc
+++ b/src/systemc/core/event.cc
@@ -155,6 +155,13 @@ Event::notify(DynamicSensitivities &senses)
}
void
+Event::notify(ResetSensitivities &senses)
+{
+ for (auto s: senses)
+ s->notify(this);
+}
+
+void
Event::notify()
{
if (scheduler.inUpdate()) {
@@ -167,7 +174,7 @@ Event::notify()
scheduler.deschedule(&delayedNotify);
_triggeredStamp = scheduler.changeStamp();
-
+ notify(resetSense);
notify(staticSenseMethod);
notify(dynamicSenseMethod);
notify(staticSenseThread);
diff --git a/src/systemc/core/event.hh b/src/systemc/core/event.hh
index 2d620c91b..ff72fd3b0 100644
--- a/src/systemc/core/event.hh
+++ b/src/systemc/core/event.hh
@@ -74,6 +74,7 @@ class Event
void notify(StaticSensitivities &senses);
void notify(DynamicSensitivities &senses);
+ void notify(ResetSensitivities &senses);
void notify();
void notify(const sc_core::sc_time &t);
@@ -137,6 +138,22 @@ class Event
}
}
}
+ void
+ addSensitivity(ResetSensitivity *s) const
+ {
+ resetSense.push_back(s);
+ }
+ void
+ delSensitivity(ResetSensitivity *s) const
+ {
+ for (auto &t: resetSense) {
+ if (t == s) {
+ t = resetSense.back();
+ resetSense.pop_back();
+ break;
+ }
+ }
+ }
private:
sc_core::sc_event *_sc_event;
@@ -154,6 +171,7 @@ class Event
mutable StaticSensitivities staticSenseThread;
mutable DynamicSensitivities dynamicSenseMethod;
mutable DynamicSensitivities dynamicSenseThread;
+ mutable ResetSensitivities resetSense;
};
extern Events topLevelEvents;
diff --git a/src/systemc/core/port.cc b/src/systemc/core/port.cc
index af6ecd125..8ee0549a4 100644
--- a/src/systemc/core/port.cc
+++ b/src/systemc/core/port.cc
@@ -30,6 +30,7 @@
#include "systemc/core/port.hh"
#include "systemc/core/sensitivity.hh"
+#include "systemc/ext/channel/sc_signal_in_if.hh"
namespace sc_gem5
{
@@ -49,6 +50,18 @@ Port::finalizeFinder(StaticSensitivityFinder *finder)
}
void
+Port::finalizeReset(ResetSensitivityPort *reset)
+{
+ assert(size() <= 1);
+ if (size()) {
+ auto iface =
+ dynamic_cast<sc_core::sc_signal_in_if<bool> *>(getInterface(0));
+ assert(iface);
+ reset->setSignal(iface);
+ }
+}
+
+void
Port::sensitive(StaticSensitivityPort *port)
{
if (finalized)
@@ -67,6 +80,15 @@ Port::sensitive(StaticSensitivityFinder *finder)
}
void
+Port::sensitive(ResetSensitivityPort *reset)
+{
+ if (finalized)
+ finalizeReset(reset);
+ else
+ sensitivities.push_back(new Sensitivity(reset));
+}
+
+void
Port::finalize()
{
if (finalized)
@@ -88,8 +110,10 @@ Port::finalize()
for (auto &s: sensitivities) {
if (s->port)
finalizePort(s->port);
- else
+ else if (s->finder)
finalizeFinder(s->finder);
+ else
+ finalizeReset(s->reset);
delete s;
}
diff --git a/src/systemc/core/port.hh b/src/systemc/core/port.hh
index 217269d86..eb8dbfef3 100644
--- a/src/systemc/core/port.hh
+++ b/src/systemc/core/port.hh
@@ -42,6 +42,7 @@ namespace sc_gem5
class StaticSensitivityPort;
class StaticSensitivityFinder;
+class ResetSensitivityPort;
class Port;
@@ -58,6 +59,7 @@ class Port
void finalizePort(StaticSensitivityPort *port);
void finalizeFinder(StaticSensitivityFinder *finder);
+ void finalizeReset(ResetSensitivityPort *reset);
void
addInterface(::sc_core::sc_interface *iface)
@@ -105,15 +107,20 @@ class Port
struct Sensitivity
{
Sensitivity(StaticSensitivityPort *port) :
- port(port), finder(nullptr)
+ port(port), finder(nullptr), reset(nullptr)
{}
Sensitivity(StaticSensitivityFinder *finder) :
- port(nullptr), finder(finder)
+ port(nullptr), finder(finder), reset(nullptr)
+ {}
+
+ Sensitivity(ResetSensitivityPort *reset) :
+ port(nullptr), finder(nullptr), reset(reset)
{}
StaticSensitivityPort *port;
StaticSensitivityFinder *finder;
+ ResetSensitivityPort *reset;
};
std::vector<Binding *> bindings;
@@ -148,6 +155,7 @@ class Port
void sensitive(StaticSensitivityPort *port);
void sensitive(StaticSensitivityFinder *finder);
+ void sensitive(ResetSensitivityPort *reset);
void finalize();
diff --git a/src/systemc/core/process.cc b/src/systemc/core/process.cc
index 45c01e916..78bbf91d5 100644
--- a/src/systemc/core/process.cc
+++ b/src/systemc/core/process.cc
@@ -236,6 +236,27 @@ Process::syncResetOff(bool inc_kids)
}
void
+Process::signalReset(bool set, bool sync)
+{
+ if (set) {
+ waitCount(0);
+ if (sync) {
+ syncResetCount++;
+ } else {
+ asyncResetCount++;
+ cancelTimeout();
+ clearDynamic();
+ scheduler.runNext(this);
+ }
+ } else {
+ if (sync)
+ syncResetCount--;
+ else
+ asyncResetCount--;
+ }
+}
+
+void
Process::run()
{
bool reset;
@@ -272,6 +293,12 @@ Process::setDynamic(DynamicSensitivity *s)
}
void
+Process::addReset(ResetSensitivity *s)
+{
+ resetSensitivities.push_back(s);
+}
+
+void
Process::cancelTimeout()
{
if (timeoutEvent.scheduled())
@@ -302,6 +329,11 @@ Process::timeout()
void
Process::satisfySensitivity(Sensitivity *s)
{
+ if (_waitCount) {
+ _waitCount--;
+ return;
+ }
+
// If there's a dynamic sensitivity and this wasn't it, ignore.
if ((dynamicSensitivity || timeoutEvent.scheduled()) &&
dynamicSensitivity != s) {
@@ -346,7 +378,8 @@ Process::Process(const char *name, ProcessFuncWrapper *func, bool internal) :
timeoutEvent([this]() { this->timeout(); }),
func(func), _internal(internal), _timedOut(false), _dontInitialize(false),
_needsStart(true), _isUnwinding(false), _terminated(false),
- _suspended(false), _disabled(false), _syncReset(false), refCount(0),
+ _suspended(false), _disabled(false), _syncReset(false), syncResetCount(0),
+ asyncResetCount(0), _waitCount(0), refCount(0),
stackSize(::Fiber::DefaultStackSize), dynamicSensitivity(nullptr)
{
_dynamic =
diff --git a/src/systemc/core/process.hh b/src/systemc/core/process.hh
index 9e85fc7cc..85a7a27a8 100644
--- a/src/systemc/core/process.hh
+++ b/src/systemc/core/process.hh
@@ -87,6 +87,8 @@ class Process : public ::sc_core::sc_process_b, public ListNode
void syncResetOn(bool inc_kids);
void syncResetOff(bool inc_kids);
+ void signalReset(bool set, bool sync);
+
void incref() { refCount++; }
void decref() { refCount--; }
@@ -100,6 +102,7 @@ class Process : public ::sc_core::sc_process_b, public ListNode
void addStatic(StaticSensitivity *);
void setDynamic(DynamicSensitivity *);
void clearDynamic() { setDynamic(nullptr); }
+ void addReset(ResetSensitivity *);
ScEvent timeoutEvent;
void setTimeout(::sc_core::sc_time t);
@@ -119,13 +122,15 @@ class Process : public ::sc_core::sc_process_b, public ListNode
bool hasStaticSensitivities() { return !staticSensitivities.empty(); }
bool internal() { return _internal; }
bool timedOut() { return _timedOut; }
- bool syncReset() { return _syncReset; }
+ bool inReset() { return _syncReset || syncResetCount || asyncResetCount; }
bool dontInitialize() { return _dontInitialize; }
void dontInitialize(bool di) { _dontInitialize = di; }
void joinWait(::sc_core::sc_join *join) { joinWaiters.push_back(join); }
+ void waitCount(int count) { _waitCount = count; }
+
protected:
void timeout();
@@ -170,12 +175,18 @@ class Process : public ::sc_core::sc_process_b, public ListNode
bool _syncReset;
+ int syncResetCount;
+ int asyncResetCount;
+
+ int _waitCount;
+
int refCount;
size_t stackSize;
StaticSensitivities staticSensitivities;
DynamicSensitivity *dynamicSensitivity;
+ ResetSensitivities resetSensitivities;
std::unique_ptr<::sc_core::sc_report> _lastReport;
diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc
index dfd89790c..d4ffda4e2 100644
--- a/src/systemc/core/sc_module.cc
+++ b/src/systemc/core/sc_module.cc
@@ -35,6 +35,7 @@
#include "systemc/core/kernel.hh"
#include "systemc/core/module.hh"
#include "systemc/core/process_types.hh"
+#include "systemc/core/sensitivity.hh"
#include "systemc/ext/channel/sc_signal_in_if.hh"
#include "systemc/ext/core/sc_module.hh"
#include "systemc/ext/core/sc_module_name.hh"
@@ -244,52 +245,60 @@ sc_module::end_module()
}
void
-sc_module::reset_signal_is(const sc_in<bool> &, bool)
+sc_module::reset_signal_is(const sc_in<bool> &port, bool val)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ sc_gem5::newResetSensitivityPort(
+ ::sc_gem5::Process::newest(), &port, val, true);
}
void
-sc_module::reset_signal_is(const sc_inout<bool> &, bool)
+sc_module::reset_signal_is(const sc_inout<bool> &port, bool val)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ sc_gem5::newResetSensitivityPort(
+ ::sc_gem5::Process::newest(), &port, val, true);
}
void
-sc_module::reset_signal_is(const sc_out<bool> &, bool)
+sc_module::reset_signal_is(const sc_out<bool> &port, bool val)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ sc_gem5::newResetSensitivityPort(
+ ::sc_gem5::Process::newest(), &port, val, true);
}
void
-sc_module::reset_signal_is(const sc_signal_in_if<bool> &, bool)
+sc_module::reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ sc_gem5::newResetSensitivitySignal(
+ ::sc_gem5::Process::newest(), &signal, val, true);
}
void
-sc_module::async_reset_signal_is(const sc_in<bool> &, bool)
+sc_module::async_reset_signal_is(const sc_in<bool> &port, bool val)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ sc_gem5::newResetSensitivityPort(
+ ::sc_gem5::Process::newest(), &port, val, false);
}
void
-sc_module::async_reset_signal_is(const sc_inout<bool> &, bool)
+sc_module::async_reset_signal_is(const sc_inout<bool> &port, bool val)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ sc_gem5::newResetSensitivityPort(
+ ::sc_gem5::Process::newest(), &port, val, false);
}
void
-sc_module::async_reset_signal_is(const sc_out<bool> &, bool)
+sc_module::async_reset_signal_is(const sc_out<bool> &port, bool val)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ sc_gem5::newResetSensitivityPort(
+ ::sc_gem5::Process::newest(), &port, val, false);
}
void
-sc_module::async_reset_signal_is(const sc_signal_in_if<bool> &, bool)
+sc_module::async_reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ sc_gem5::newResetSensitivitySignal(
+ ::sc_gem5::Process::newest(), &signal, val, false);
}
@@ -626,8 +635,9 @@ wait(int n)
std::string msg = csprintf("n = %d", n);
SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str());
}
- for (int i = 0; i < n; i++)
- wait();
+ sc_gem5::Process *p = sc_gem5::scheduler.current();
+ p->waitCount(n - 1);
+ wait();
}
void
diff --git a/src/systemc/core/sc_spawn.cc b/src/systemc/core/sc_spawn.cc
index 8c936bfe9..4618ea8c2 100644
--- a/src/systemc/core/sc_spawn.cc
+++ b/src/systemc/core/sc_spawn.cc
@@ -83,6 +83,18 @@ spawnWork(ProcessFuncWrapper *func, const char *name,
for (auto f: opts->_finders)
newStaticSensitivityFinder(proc, f);
+
+ for (auto p: opts->_in_resets)
+ newResetSensitivityPort(proc, p.target, p.value, p.sync);
+
+ for (auto p: opts->_inout_resets)
+ newResetSensitivityPort(proc, p.target, p.value, p.sync);
+
+ for (auto p: opts->_out_resets)
+ newResetSensitivityPort(proc, p.target, p.value, p.sync);
+
+ for (auto i: opts->_if_resets)
+ newResetSensitivitySignal(proc, i.target, i.value, i.sync);
}
if (opts && opts->_dontInitialize &&
@@ -161,59 +173,54 @@ sc_spawn_options::set_sensitivity(sc_event_finder *f)
void
-sc_spawn_options::reset_signal_is(const sc_in<bool> &, bool)
+sc_spawn_options::reset_signal_is(const sc_in<bool> &port, bool value)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ _in_resets.emplace_back(&port, value, true);
}
void
-sc_spawn_options::reset_signal_is(const sc_inout<bool> &, bool)
+sc_spawn_options::reset_signal_is(const sc_inout<bool> &port, bool value)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ _inout_resets.emplace_back(&port, value, true);
}
void
-sc_spawn_options::reset_signal_is(const sc_out<bool> &, bool)
+sc_spawn_options::reset_signal_is(const sc_out<bool> &port, bool value)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ _out_resets.emplace_back(&port, value, true);
}
void
-sc_spawn_options::reset_signal_is(const sc_signal_in_if<bool> &, bool)
+sc_spawn_options::reset_signal_is(
+ const sc_signal_in_if<bool> &iface, bool value)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ _if_resets.emplace_back(&iface, value, true);
}
void
-sc_spawn_options::async_reset_signal_is(const sc_in<bool> &, bool)
+sc_spawn_options::async_reset_signal_is(const sc_in<bool> &port, bool value)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ _in_resets.emplace_back(&port, value, false);
}
void
-sc_spawn_options::async_reset_signal_is(const sc_inout<bool> &, bool)
+sc_spawn_options::async_reset_signal_is(const sc_inout<bool> &port, bool value)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ _inout_resets.emplace_back(&port, value, false);
}
void
-sc_spawn_options::async_reset_signal_is(const sc_out<bool> &, bool)
+sc_spawn_options::async_reset_signal_is(const sc_out<bool> &port, bool value)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ _out_resets.emplace_back(&port, value, false);
}
void
-sc_spawn_options::async_reset_signal_is(const sc_signal_in_if<bool> &, bool)
-{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-}
-
-
-void
-sc_spawn_warn_unimpl(const char *func)
+sc_spawn_options::async_reset_signal_is(
+ const sc_signal_in_if<bool> &iface, bool value)
{
- warn("%s not implemented.\n", func);
+ _if_resets.emplace_back(&iface, value, false);
}
} // namespace sc_core
diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index 6d571f60b..fe1d7c2e4 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -183,7 +183,7 @@ Scheduler::yield()
auto ew = _current->excWrapper;
_current->excWrapper = nullptr;
ew->throw_it();
- } else if (_current->syncReset()) {
+ } else if (_current->inReset()) {
_current->reset(false);
}
}
diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh
index 0d853f5c6..de9d627c1 100644
--- a/src/systemc/core/scheduler.hh
+++ b/src/systemc/core/scheduler.hh
@@ -209,6 +209,17 @@ class Scheduler
yield();
}
+ // Run this process at the next opportunity.
+ void
+ runNext(Process *p)
+ {
+ // Like above, it's ok if this isn't a method. Putting it on this list
+ // just gives it priority.
+ readyListMethods.pushFirst(p);
+ if (!inEvaluate())
+ scheduleReadyEvent();
+ }
+
// Set an event queue for scheduling events.
void setEventQueue(EventQueue *_eq) { eq = _eq; }
diff --git a/src/systemc/core/sensitivity.cc b/src/systemc/core/sensitivity.cc
index 2bd0b5fcb..b0709ee91 100644
--- a/src/systemc/core/sensitivity.cc
+++ b/src/systemc/core/sensitivity.cc
@@ -33,6 +33,9 @@
#include "systemc/core/port.hh"
#include "systemc/core/process.hh"
#include "systemc/core/scheduler.hh"
+#include "systemc/ext/channel/sc_in.hh"
+#include "systemc/ext/channel/sc_inout.hh"
+#include "systemc/ext/channel/sc_out.hh"
#include "systemc/ext/core/sc_export.hh"
#include "systemc/ext/core/sc_interface.hh"
#include "systemc/ext/core/sc_port.hh"
@@ -93,6 +96,18 @@ StaticSensitivity::delFromEvent(const ::sc_core::sc_event *e)
Event::getFromScEvent(e)->delSensitivity(this);
}
+void
+ResetSensitivity::addToEvent(const ::sc_core::sc_event *e)
+{
+ Event::getFromScEvent(e)->addSensitivity(this);
+}
+
+void
+ResetSensitivity::delFromEvent(const ::sc_core::sc_event *e)
+{
+ Event::getFromScEvent(e)->delSensitivity(this);
+}
+
/*
* Static sensitivities.
@@ -228,4 +243,71 @@ DynamicSensitivityEventAndList::notifyWork(Event *e)
return true;
}
+/*
+ * Reset sensitivities.
+ */
+
+void
+newResetSensitivitySignal(
+ Process *p, const sc_core::sc_signal_in_if<bool> *signal,
+ bool val, bool sync)
+{
+ auto s = new ResetSensitivitySignal(p, signal, val, sync);
+ s->addToEvent(s->event);
+ p->addReset(s);
+}
+
+void
+newResetSensitivityPort(Process *p, const sc_core::sc_in<bool> *port,
+ bool val, bool sync)
+{
+ auto s = new ResetSensitivityPort(p, port, val, sync);
+ Port::fromPort(port)->sensitive(s);
+ p->addReset(s);
+}
+void
+newResetSensitivityPort(Process *p, const sc_core::sc_inout<bool> *port,
+ bool val, bool sync)
+{
+ auto s = new ResetSensitivityPort(p, port, val, sync);
+ Port::fromPort(port)->sensitive(s);
+ p->addReset(s);
+}
+void
+newResetSensitivityPort(Process *p, const sc_core::sc_out<bool> *port,
+ bool val, bool sync)
+{
+ auto s = new ResetSensitivityPort(p, port, val, sync);
+ Port::fromPort(port)->sensitive(s);
+ p->addReset(s);
+}
+
+ResetSensitivitySignal::ResetSensitivitySignal(
+ Process *p, const sc_core::sc_signal_in_if<bool> *signal,
+ bool _val, bool _sync) :
+ Sensitivity(p), ResetSensitivity(p, _val, _sync),
+ SensitivityEvent(p, signal ? &signal->value_changed_event() : nullptr),
+ _signal(signal)
+{
+ if (signal && signal->read() == val())
+ process->signalReset(true, sync());
+}
+
+bool
+ResetSensitivitySignal::notifyWork(Event *e)
+{
+ process->signalReset(_signal->read() == val(), sync());
+ return true;
+}
+
+void
+ResetSensitivityPort::setSignal(const ::sc_core::sc_signal_in_if<bool> *signal)
+{
+ _signal = signal;
+ event = &_signal->value_changed_event();
+ addToEvent(event);
+ if (signal->read() == val())
+ process->signalReset(true, sync());
+}
+
} // namespace sc_gem5
diff --git a/src/systemc/core/sensitivity.hh b/src/systemc/core/sensitivity.hh
index a412c7a63..0e2f4919d 100644
--- a/src/systemc/core/sensitivity.hh
+++ b/src/systemc/core/sensitivity.hh
@@ -36,6 +36,7 @@
#include "sim/eventq.hh"
#include "systemc/core/sched_event.hh"
#include "systemc/ext/core/sc_module.hh"
+#include "systemc/ext/core/sc_port.hh"
namespace sc_core
{
@@ -84,14 +85,21 @@ class Sensitivity
void satisfy();
bool notify(Event *e);
- virtual bool dynamic() = 0;
+ enum Category
+ {
+ Static,
+ Dynamic,
+ Reset
+ };
+
+ virtual Category category() = 0;
bool ofMethod();
};
/*
- * Dynamic vs. static sensitivity.
+ * Dynamic vs. static vs. reset sensitivity.
*/
class DynamicSensitivity : virtual public Sensitivity
@@ -103,7 +111,7 @@ class DynamicSensitivity : virtual public Sensitivity
void delFromEvent(const ::sc_core::sc_event *e) override;
public:
- bool dynamic() override { return true; }
+ Category category() override { return Dynamic; }
};
typedef std::vector<DynamicSensitivity *> DynamicSensitivities;
@@ -118,11 +126,34 @@ class StaticSensitivity : virtual public Sensitivity
void delFromEvent(const ::sc_core::sc_event *e) override;
public:
- bool dynamic() override { return false; }
+ Category category() override { return Static; }
};
typedef std::vector<StaticSensitivity *> StaticSensitivities;
+class ResetSensitivity : virtual public Sensitivity
+{
+ private:
+ bool _val;
+ bool _sync;
+
+ protected:
+ ResetSensitivity(Process *p, bool _val, bool _sync) :
+ Sensitivity(p), _val(_val), _sync(_sync)
+ {}
+
+ void addToEvent(const ::sc_core::sc_event *e) override;
+ void delFromEvent(const ::sc_core::sc_event *e) override;
+
+ bool val() { return _val; }
+ bool sync() { return _sync; }
+
+ public:
+ Category category() override { return Reset; }
+};
+
+typedef std::vector<ResetSensitivity *> ResetSensitivities;
+
/*
* Sensitivity to an event or events, which can be static or dynamic.
@@ -295,6 +326,60 @@ class DynamicSensitivityEventAndList :
bool notifyWork(Event *e) override;
};
+/*
+ * Reset sensitivities.
+ */
+
+void newResetSensitivitySignal(
+ Process *p, const sc_core::sc_signal_in_if<bool> *signal,
+ bool val, bool sync);
+
+void newResetSensitivityPort(
+ Process *p, const sc_core::sc_in<bool> *port, bool val, bool sync);
+void newResetSensitivityPort(
+ Process *p, const sc_core::sc_inout<bool> *port, bool val, bool sync);
+void newResetSensitivityPort(
+ Process *p, const sc_core::sc_out<bool> *port, bool val, bool sync);
+
+class ResetSensitivitySignal :
+ public ResetSensitivity, public SensitivityEvent
+{
+ protected:
+ const sc_core::sc_signal_in_if<bool> *_signal;
+
+ friend void newResetSensitivitySignal(
+ Process *p, const sc_core::sc_signal_in_if<bool> *signal,
+ bool val, bool sync);
+
+ ResetSensitivitySignal(
+ Process *p, const sc_core::sc_signal_in_if<bool> *signal,
+ bool _val, bool _sync);
+
+ bool notifyWork(Event *e) override;
+};
+
+class ResetSensitivityPort : public ResetSensitivitySignal
+{
+ private:
+ friend void newResetSensitivityPort(
+ Process *p, const sc_core::sc_in<bool> *port, bool val, bool sync);
+ friend void newResetSensitivityPort(
+ Process *p, const sc_core::sc_inout<bool> *port,
+ bool val, bool sync);
+ friend void newResetSensitivityPort(
+ Process *p, const sc_core::sc_out<bool> *port,
+ bool val, bool sync);
+
+ ResetSensitivityPort(
+ Process *p, const sc_core::sc_port_base *port,
+ bool _val, bool _sync) :
+ Sensitivity(p), ResetSensitivitySignal(p, nullptr, _val, _sync)
+ {}
+
+ public:
+ void setSignal(const ::sc_core::sc_signal_in_if<bool> *signal);
+};
+
} // namespace sc_gem5
#endif //__SYSTEMC_CORE_SENSITIVITY_HH__