summaryrefslogtreecommitdiff
path: root/src/systemc/core/process.hh
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-10-04 14:59:28 -0700
committerGabe Black <gabeblack@google.com>2018-10-16 00:52:24 +0000
commitee3e3278fd7e0d805ea0ecbf97a113cc5086c0af (patch)
tree261da6679e08b18cec591f4a2c5d5f189bed978d /src/systemc/core/process.hh
parentd1a86fd7007dbdc6f6a5771c61ef45e72429e374 (diff)
downloadgem5-ee3e3278fd7e0d805ea0ecbf97a113cc5086c0af.tar.xz
systemc: Change how signal based resets work.
The previous implementation used the value changed event to track when signals changed value, but there were a couple problems with this approach. First, this piggybacked on the sensitivity mechanism in some ways, but diverged in others. The sensitivity didn't notify a process when it was satisfied like other sensitivity types would, and it also ignored whether the process was disabled. Second, the value_changed_event is notified by a signal instance as a delta notification, but reset signals are supposed to act immediately. That means they should happen before all delta notifications, or in other words all delta notifications should see the reset status of a given process. That's particularly important in the case of wait(int n) where setting the reset clears the reset count, and the count is checked when determining whether or not to wake up a process when its sensitivity is satisfied, potentially by a delta notification. Third, by removing the middle man and not trying to repurpose the sensitivity mechanism, the code gets simpler and easier to understand. Change-Id: I0d05d11437291d368b060f6a45a207813615f113 Reviewed-on: https://gem5-review.googlesource.com/c/13294 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/process.hh')
-rw-r--r--src/systemc/core/process.hh46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/systemc/core/process.hh b/src/systemc/core/process.hh
index 9bddbdd04..a0657f4be 100644
--- a/src/systemc/core/process.hh
+++ b/src/systemc/core/process.hh
@@ -40,6 +40,7 @@
#include "systemc/core/object.hh"
#include "systemc/core/sched_event.hh"
#include "systemc/core/sensitivity.hh"
+#include "systemc/ext/channel/sc_signal_in_if.hh"
#include "systemc/ext/core/sc_event.hh"
#include "systemc/ext/core/sc_module.hh"
#include "systemc/ext/core/sc_process_handle.hh"
@@ -57,6 +58,9 @@ namespace sc_gem5
class ScHalt
{};
+class Process;
+class Reset;
+
class Process : public ::sc_core::sc_process_b, public ListNode
{
public:
@@ -103,7 +107,7 @@ class Process : public ::sc_core::sc_process_b, public ListNode
void addStatic(StaticSensitivity *);
void setDynamic(DynamicSensitivity *);
void clearDynamic() { setDynamic(nullptr); }
- void addReset(ResetSensitivity *);
+ void addReset(Reset *);
ScEvent timeoutEvent;
void setTimeout(::sc_core::sc_time t);
@@ -189,7 +193,7 @@ class Process : public ::sc_core::sc_process_b, public ListNode
StaticSensitivities staticSensitivities;
DynamicSensitivity *dynamicSensitivity;
- ResetSensitivities resetSensitivities;
+ std::vector<Reset *> resets;
std::unique_ptr<::sc_core::sc_report> _lastReport;
@@ -198,6 +202,44 @@ class Process : public ::sc_core::sc_process_b, public ListNode
UniqueNameGen nameGen;
};
+class Reset
+{
+ public:
+ Reset(Process *p, bool s, bool v) :
+ _process(p), _signal(nullptr), _sync(s), _value(v)
+ {}
+
+ bool
+ install(const sc_core::sc_signal_in_if<bool> *s)
+ {
+ _signal = s;
+
+ if (_signal->_addReset(this)) {
+ _process->addReset(this);
+ if (_signal->read() == _value)
+ update();
+ return true;
+ }
+ return false;
+ }
+ void update() { _process->signalReset(_signal->read() == _value, _sync); }
+
+ Process *process() { return _process; }
+ const sc_core::sc_signal_in_if<bool> *signal() { return _signal; }
+ bool sync() { return _sync; }
+ bool value() { return _value; }
+
+ private:
+ Process *_process;
+ const sc_core::sc_signal_in_if<bool> *_signal;
+ bool _sync;
+ bool _value;
+};
+
+void newReset(const sc_core::sc_port_base *pb, Process *p, bool s, bool v);
+void newReset(const sc_core::sc_signal_in_if<bool> *sig, Process *p,
+ bool s, bool v);
+
} // namespace sc_gem5
#endif //__SYSTEMC_CORE_PROCESS_HH__