systemc: Use the stage of simulation and not port size in add_trace.
authorGabe Black <gabeblack@google.com>
Mon, 1 Oct 2018 05:40:28 +0000 (22:40 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 16 Oct 2018 00:40:46 +0000 (00:40 +0000)
The assumption was that a port wouldn't have any interfaces until
after elaboration, and that if it would be traced, it would have
interfaces. Checking if the simulation has started (and hence
elaboration has finished) is a more accurate and direct way to check
the same thing.

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

src/systemc/ext/channel/sc_in.hh
src/systemc/ext/channel/sc_inout.hh

index a76840161ea607b90b7337c97803fe4d5935fb47..3fea8a8034b297d472c5d2eb78e1ed7da3938367 100644 (file)
@@ -33,6 +33,7 @@
 #include <string>
 
 #include "../core/sc_event.hh"
+#include "../core/sc_main.hh"
 #include "../core/sc_port.hh"
 #include "../utils/sc_trace_file.hh"
 #include "sc_signal_in_if.hh"
@@ -155,10 +156,10 @@ template <class T>
 inline void
 sc_trace(sc_trace_file *tf, const sc_in<T> &i, const std::string &name)
 {
-    if (i.size())
-        sc_trace(tf, i->read(), name);
-    else
+    if (::sc_core::sc_get_status() < ::sc_core::SC_START_OF_SIMULATION)
         i.add_trace(tf, name);
+    else
+        sc_trace(tf, i->read(), name);
 }
 
 template <>
@@ -316,10 +317,10 @@ inline void
 sc_trace<bool>(sc_trace_file *tf, const sc_in<bool> &i,
         const std::string &name)
 {
-    if (i.size())
-        sc_trace(tf, i->read(), name);
-    else
+    if (::sc_core::sc_get_status() < ::sc_core::SC_START_OF_SIMULATION)
         i.add_trace(tf, name);
+    else
+        sc_trace(tf, i->read(), name);
 }
 
 template <>
@@ -475,10 +476,10 @@ inline void
 sc_trace<sc_dt::sc_logic>(sc_trace_file *tf, const sc_in<sc_dt::sc_logic> &i,
         const std::string &name)
 {
-    if (i.size())
-        sc_trace(tf, i->read(), name);
-    else
+    if (::sc_core::sc_get_status() < ::sc_core::SC_START_OF_SIMULATION)
         i.add_trace(tf, name);
+    else
+        sc_trace(tf, i->read(), name);
 }
 
 } // namespace sc_core
index 7f19443d5e2c7eaa3a6bd3cbe389b09636a82180..2973a5414f6a0a1c6f1f14056bb21d71bfef7f07 100644 (file)
@@ -33,6 +33,7 @@
 #include <string>
 
 #include "../core/sc_event.hh"
+#include "../core/sc_main.hh"
 #include "../core/sc_port.hh"
 #include "../dt/bit/sc_logic.hh"
 #include "../utils/sc_trace_file.hh"
@@ -184,10 +185,10 @@ template <class T>
 inline void
 sc_trace(sc_trace_file *tf, const sc_inout<T> &i, const std::string &name)
 {
-    if (i.size())
-        sc_trace(tf, i->read(), name);
-    else
+    if (::sc_core::sc_get_status() < ::sc_core::SC_START_OF_SIMULATION)
         i.add_trace(tf, name);
+    else
+        sc_trace(tf, i->read(), name);
 }
 
 template <>
@@ -357,10 +358,10 @@ template <>
 inline void sc_trace<bool>(
         sc_trace_file *tf, const sc_inout<bool> &i, const std::string &name)
 {
-    if (i.size())
-        sc_trace(tf, i->read(), name);
-    else
+    if (::sc_core::sc_get_status() < ::sc_core::SC_START_OF_SIMULATION)
         i.add_trace(tf, name);
+    else
+        sc_trace(tf, i->read(), name);
 }
 
 template <>
@@ -549,10 +550,10 @@ inline void
 sc_trace<sc_dt::sc_logic>(sc_trace_file *tf,
         const sc_inout<sc_dt::sc_logic> &i, const std::string &name)
 {
-    if (i.size())
-        sc_trace(tf, i->read(), name);
-    else
+    if (::sc_core::sc_get_status() < ::sc_core::SC_START_OF_SIMULATION)
         i.add_trace(tf, name);
+    else
+        sc_trace(tf, i->read(), name);
 }
 
 } // namespace sc_core