systemc: Make sc_process_b less hokey, and make WAIT* work.
authorGabe Black <gabeblack@google.com>
Thu, 23 Aug 2018 05:45:29 +0000 (22:45 -0700)
committerGabe Black <gabeblack@google.com>
Wed, 26 Sep 2018 00:00:11 +0000 (00:00 +0000)
This change puts sc_process_b into the inheritance hierarchy for the
Process types. It also adds the nonstandard sc_set_location function
and calls it from the nonstandard WAIT* macros.

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

src/systemc/core/process.cc
src/systemc/core/process.hh
src/systemc/core/sc_process_handle.cc
src/systemc/ext/core/sc_module.hh
src/systemc/ext/core/sc_process_handle.hh

index 5d5c5216f206e1189f4a989a4ec4a0a6adb75e16..1a101f749f5fe5b03ae6c69050b48efac5b90e8f 100644 (file)
@@ -371,7 +371,7 @@ Process::lastReport(::sc_core::sc_report *report)
 ::sc_core::sc_report *Process::lastReport() const { return _lastReport.get(); }
 
 Process::Process(const char *name, ProcessFuncWrapper *func, bool _dynamic) :
-    ::sc_core::sc_object(name), excWrapper(nullptr), func(func),
+    ::sc_core::sc_process_b(name), excWrapper(nullptr), func(func),
     _needsStart(true), _dynamic(_dynamic), _isUnwinding(false),
     _terminated(false), _suspended(false), _disabled(false),
     _syncReset(false), refCount(0), stackSize(::Fiber::DefaultStackSize),
index fe75aa7de82e9bc5b48c9e504489c42b6ce32e84..17f417b6e26183d813db9fda85b21183da84991d 100644 (file)
@@ -266,7 +266,7 @@ class PendingSensitivityFinder : public PendingSensitivity
 typedef std::vector<PendingSensitivity *> PendingSensitivities;
 
 
-class Process : public ::sc_core::sc_object, public ListNode
+class Process : public ::sc_core::sc_process_b, public ListNode
 {
   public:
     virtual ::sc_core::sc_curr_proc_kind procKind() const = 0;
index 256d64989ce8e55f40423893aa31152fb1af8258..8c756afa246fe6ba1663aab38a37cb330b716bf7 100644 (file)
@@ -55,18 +55,14 @@ sc_unwind_exception::sc_unwind_exception(const sc_unwind_exception &e) :
 sc_unwind_exception::~sc_unwind_exception() throw() {}
 
 
-const char *
-sc_process_b::name()
-{
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-    return "";
-}
-
-const char *
-sc_process_b::kind()
+void
+sc_set_location(const char *file, int lineno)
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-    return "";
+    sc_process_b *current = ::sc_gem5::scheduler.current();
+    if (!current)
+        return;
+    current->file = file;
+    current->lineno = lineno;
 }
 
 
index 7088c4e601cae1a2903019a9b94a5f098a530426..8de57b57562b02d198b54e4249a4da80cb4afb79 100644 (file)
@@ -33,6 +33,7 @@
 #include <vector>
 
 #include "sc_object.hh"
+#include "sc_process_handle.hh"
 #include "sc_sensitive.hh"
 #include "sc_time.hh"
 
@@ -337,17 +338,20 @@ sc_module *sc_module_sc_new(sc_module *);
 #define SC_NEW(x) ::sc_core::sc_module_sc_new(new x);
 
 // Nonstandard
-// In the Accellera implementation, this macro calls sc_set_location to record
-// the current file and line, calls wait, and then calls it again to clear the
-// file and line. We'll ignore the sc_set_location calls for now.
-#define SC_WAIT() ::sc_core::wait();
+#define SC_WAIT() \
+    ::sc_core::sc_set_location(__FILE__, __LINE__); \
+    ::sc_core::wait(); \
+    ::sc_core::sc_set_location(NULL, 0)
 
 // Nonstandard
-// Same as above, but passes through an argument.
-#define SC_WAITN(n) ::sc_core::wait(n);
+#define SC_WAITN(n) \
+    ::sc_core::sc_set_location(__FILE__, __LINE__); \
+    ::sc_core::wait(n); \
+    ::sc_core::sc_set_location(NULL, 0)
 
 // Nonstandard
-#define SC_WAIT_UNTIL(expr) do { SC_WAIT(); } while (!(expr))
+#define SC_WAIT_UNTIL(expr) \
+    do { SC_WAIT(); } while (!(expr))
 
 } // namespace sc_core
 
index 8186903182c57d6e8fdbe01c1d870744f63e5d3d..04df4728f9e44834251fe131825f1ba23f5e7378 100644 (file)
@@ -33,6 +33,8 @@
 #include <exception>
 #include <vector>
 
+#include "systemc/ext/core/sc_object.hh"
+
 namespace sc_gem5
 {
 
@@ -78,7 +80,6 @@ namespace sc_core
 {
 
 class sc_event;
-class sc_object;
 
 enum sc_curr_proc_kind
 {
@@ -114,15 +115,20 @@ class sc_unwind_exception : public std::exception
 
 // Deprecated
 // An incomplete version of sc_process_b to satisfy the tests.
-class sc_process_b
+class sc_process_b : public sc_object
 {
   public:
+    sc_process_b(const char *name) : sc_object(name), file(nullptr), lineno(0)
+    {}
+    sc_process_b() : sc_object(), file(nullptr), lineno(0) {}
+
     const char *file;
     int lineno;
-    const char *name();
-    const char *kind();
 };
 
+// Nonstandard
+void sc_set_location(const char *file, int lineno);
+
 // Deprecated
 sc_process_b *sc_get_curr_process_handle();
 static inline sc_process_b *