From: Gabe Black Date: Thu, 20 Sep 2018 09:51:54 +0000 (-0700) Subject: systemc: Fix the implementation of sc_event::triggered. X-Git-Tag: v19.0.0.0~1576 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1e17aca38ea0c9cdcc4445404bf8b789a360ce13;p=gem5.git systemc: Fix the implementation of sc_event::triggered. This function just returned false. The new implementation uses the scheduler's changeStamp function to keep track of how recently the event was triggered so it can return return the right value. Change-Id: Idf61cd459e53e224a33d3e53c16210f5e0a99a3a Reviewed-on: https://gem5-review.googlesource.com/c/12825 Reviewed-by: Gabe Black Maintainer: Gabe Black --- diff --git a/src/systemc/core/event.cc b/src/systemc/core/event.cc index e7132e083..4fb99e6d9 100644 --- a/src/systemc/core/event.cc +++ b/src/systemc/core/event.cc @@ -47,7 +47,7 @@ Event::Event(sc_core::sc_event *_sc_event) : Event(_sc_event, nullptr) {} Event::Event(sc_core::sc_event *_sc_event, const char *_basename_cstr) : _sc_event(_sc_event), _basename(_basename_cstr ? _basename_cstr : ""), - delayedNotify([this]() { this->notify(); }) + delayedNotify([this]() { this->notify(); }), _triggeredStamp(~0ULL) { Module *p = currentModule(); @@ -166,6 +166,8 @@ Event::notify() if (delayedNotify.scheduled()) scheduler.deschedule(&delayedNotify); + _triggeredStamp = scheduler.changeStamp(); + notify(staticSenseMethod); notify(dynamicSenseMethod); notify(staticSenseThread); @@ -194,7 +196,7 @@ Event::cancel() bool Event::triggered() const { - return false; + return _triggeredStamp == scheduler.changeStamp(); } Events topLevelEvents; diff --git a/src/systemc/core/event.hh b/src/systemc/core/event.hh index 3d34fa6a0..2d620c91b 100644 --- a/src/systemc/core/event.hh +++ b/src/systemc/core/event.hh @@ -85,6 +85,7 @@ class Event void cancel(); bool triggered() const; + uint64_t triggeredStamp() const { return _triggeredStamp; } static Event * getFromScEvent(sc_core::sc_event *e) @@ -147,6 +148,7 @@ class Event sc_core::sc_object *parent; ScEvent delayedNotify; + mutable uint64_t _triggeredStamp; mutable StaticSensitivities staticSenseMethod; mutable StaticSensitivities staticSenseThread;