systemc: Handle nonstandard cthread sensitivities.
authorGabe Black <gabeblack@google.com>
Sat, 15 Sep 2018 04:28:16 +0000 (21:28 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 9 Oct 2018 21:51:03 +0000 (21:51 +0000)
Accellera allows some non-standard values in the second position of the
SC_CTHREAD macro. Do that as well, with the same special handling which
automatically selects the positive edge of boolean ports/interfaces.

Change-Id: I79594980898a17afc30fea6f77384589cbc3c250
Reviewed-on: https://gem5-review.googlesource.com/c/12809
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/core/sc_sensitive.cc
src/systemc/ext/core/sc_module.hh
src/systemc/ext/core/sc_sensitive.hh

index b254f68615d91284f0e3036508c894a041706a39..9b8ae2de45a63585934933a9401d639ef8aa3a04 100644 (file)
@@ -29,6 +29,9 @@
 
 #include "base/logging.hh"
 #include "systemc/core/process.hh"
+#include "systemc/ext/channel/sc_in.hh"
+#include "systemc/ext/channel/sc_inout.hh"
+#include "systemc/ext/channel/sc_signal_in_if.hh"
 #include "systemc/ext/core/sc_interface.hh"
 #include "systemc/ext/core/sc_sensitive.hh"
 
@@ -72,4 +75,51 @@ sc_sensitive::operator << (::sc_gem5::Process *p)
     return *this;
 }
 
+
+void
+sc_sensitive::operator () (::sc_gem5::Process *p,
+                           const sc_signal_in_if<bool> &i)
+{
+    sc_gem5::newStaticSensitivityEvent(p, &i.posedge_event());
+}
+
+void
+sc_sensitive::operator () (::sc_gem5::Process *p,
+                           const sc_signal_in_if<sc_dt::sc_logic> &i)
+{
+    sc_gem5::newStaticSensitivityEvent(p, &i.posedge_event());
+}
+
+void
+sc_sensitive::operator () (::sc_gem5::Process *p, const sc_in<bool> &port)
+{
+    sc_gem5::newStaticSensitivityFinder(p, &port.pos());
+}
+
+void
+sc_sensitive::operator () (::sc_gem5::Process *p,
+                           const sc_in<sc_dt::sc_logic> &port)
+{
+    sc_gem5::newStaticSensitivityFinder(p, &port.pos());
+}
+
+void
+sc_sensitive::operator () (::sc_gem5::Process *p, const sc_inout<bool> &port)
+{
+    sc_gem5::newStaticSensitivityFinder(p, &port.pos());
+}
+
+void
+sc_sensitive::operator () (::sc_gem5::Process *p,
+                           const sc_inout<sc_dt::sc_logic> &port)
+{
+    sc_gem5::newStaticSensitivityFinder(p, &port.pos());
+}
+
+void
+sc_sensitive::operator () (::sc_gem5::Process *p, sc_event_finder &f)
+{
+    sc_gem5::newStaticSensitivityFinder(p, &f);
+}
+
 } // namespace sc_core
index e5e4c2086160f894aa7411802d40c0ae790c4f14..d318a755ea33b3ef1be4f3ef40487cf03d265d32 100644 (file)
@@ -310,10 +310,8 @@ bool timed_out();
                 #name, new ::sc_gem5::ProcessMemberFuncWrapper< \
                     SC_CURRENT_USER_MODULE>(this, \
                         &SC_CURRENT_USER_MODULE::name)); \
-        if (p) { \
-            this->sensitive << p; \
-            this->sensitive << clk; \
-        } \
+        if (p) \
+            this->sensitive(p, clk); \
     }
 
 // Nonstandard
index 72d401f683ae66bfbf4e24634ffb4f6802704cbe..51ee45900ab6249ed07061d7315b077c1094cba5 100644 (file)
@@ -37,6 +37,13 @@ class Process;
 
 } // namespace sc_gem5
 
+namespace sc_dt
+{
+
+class sc_logic;
+
+} // namespace sc_dt
+
 namespace sc_core
 {
 
@@ -46,6 +53,15 @@ class sc_interface;
 class sc_module;
 class sc_port_base;
 
+template <class T>
+class sc_signal_in_if;
+
+template <class T>
+class sc_in;
+
+template <class T>
+class sc_inout;
+
 class sc_sensitive
 {
   public:
@@ -56,6 +72,17 @@ class sc_sensitive
 
     sc_sensitive &operator << (::sc_gem5::Process *p);
 
+    // Nonstandard.
+    void operator () (::sc_gem5::Process *p, const sc_signal_in_if<bool> &);
+    void operator () (::sc_gem5::Process *p,
+                      const sc_signal_in_if<sc_dt::sc_logic> &);
+    void operator () (::sc_gem5::Process *p, const sc_in<bool> &);
+    void operator () (::sc_gem5::Process *p, const sc_in<sc_dt::sc_logic> &);
+    void operator () (::sc_gem5::Process *p, const sc_inout<bool> &);
+    void operator () (::sc_gem5::Process *p,
+                      const sc_inout<sc_dt::sc_logic> &);
+    void operator () (::sc_gem5::Process *p, sc_event_finder &);
+
   private:
     friend class sc_module;