summaryrefslogtreecommitdiff
path: root/src/systemc/core/event.cc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-07-16 16:14:33 -0700
committerGabe Black <gabeblack@google.com>2018-09-05 06:06:00 +0000
commitf2ab5e7a9e11783da3b9d7338775cf4b5fe2c29c (patch)
treec8b08f18270cb3131f37b6e0bfe1e8f2e94da63d /src/systemc/core/event.cc
parentd7755ec828868582e2b409ba14f1c8c920c7f184 (diff)
downloadgem5-f2ab5e7a9e11783da3b9d7338775cf4b5fe2c29c.tar.xz
systemc: Implement the sensitivity mechanism.
This change lets processes be sensitive to events, timeouts, etc. Change-Id: If30a256dfa8a2e92192c1f9c96b48e2aa28ec27e Reviewed-on: https://gem5-review.googlesource.com/11713 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/event.cc')
-rw-r--r--src/systemc/core/event.cc25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/systemc/core/event.cc b/src/systemc/core/event.cc
index 63fcabe4f..5008074f6 100644
--- a/src/systemc/core/event.cc
+++ b/src/systemc/core/event.cc
@@ -32,6 +32,8 @@
#include <cstring>
#include <utility>
+#include "base/logging.hh"
+#include "sim/core.hh"
#include "systemc/core/module.hh"
#include "systemc/core/scheduler.hh"
@@ -41,7 +43,7 @@ namespace sc_gem5
Event::Event(sc_core::sc_event *_sc_event) : Event(_sc_event, "") {}
Event::Event(sc_core::sc_event *_sc_event, const char *_basename) :
- _sc_event(_sc_event), _basename(_basename)
+ _sc_event(_sc_event), _basename(_basename), delayedNotify(this)
{
Module *p = currentModule();
@@ -81,6 +83,9 @@ Event::~Event()
EventsIt it = findEvent(_name);
std::swap(*it, allEvents.back());
allEvents.pop_back();
+
+ if (delayedNotifyEvent.scheduled())
+ scheduler.deschedule(&delayedNotifyEvent);
}
const std::string &
@@ -110,16 +115,34 @@ Event::getParentObject() const
void
Event::notify()
{
+ auto local_sensitivities = sensitivities;
+ for (auto s: local_sensitivities)
+ s->notify(this);
}
void
Event::notify(const sc_core::sc_time &t)
{
+ //XXX We're assuming the systemc time resolution is in ps.
+ Tick new_tick = t.value() * SimClock::Int::ps +
+ scheduler.eventQueue().getCurTick();
+ if (delayedNotify.scheduled()) {
+ Tick old_tick = delayedNotify.when();
+
+ if (new_tick >= old_tick)
+ return;
+
+ scheduler.eventQueue().deschedule(&delayedNotify);
+ }
+
+ scheduler.eventQueue().schedule(&delayedNotify, new_tick);
}
void
Event::cancel()
{
+ if (delayedNotify.scheduled())
+ scheduler.eventQueue().deschedule(&delayedNotify);
}
bool