systemc: Hook up sc_time_stamp sc_delta_count.
authorGabe Black <gabeblack@google.com>
Mon, 16 Jul 2018 22:53:04 +0000 (15:53 -0700)
committerGabe Black <gabeblack@google.com>
Wed, 5 Sep 2018 06:05:12 +0000 (06:05 +0000)
sc_time_stamp reports the current simulation time. sc_delta_count was
hooked up to a dummy value. This change hooks it up to the scheduler so
that it returns the real value.

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

src/systemc/core/sc_main.cc

index fec3faeb0f89bb0210bb3ed2c0b7cdf7fcac89dc..0b385e9a0394be965e432f21c413a7431928d14e 100644 (file)
 #include "base/logging.hh"
 #include "base/types.hh"
 #include "python/pybind11/pybind.hh"
+#include "sim/core.hh"
 #include "sim/eventq.hh"
 #include "sim/init.hh"
+#include "systemc/core/scheduler.hh"
 #include "systemc/ext/core/sc_main.hh"
 #include "systemc/ext/utils/sc_report_handler.hh"
 
@@ -124,8 +126,6 @@ sc_status _status = SC_ELABORATION;
 Tick _max_tick = MaxTick;
 sc_starvation_policy _starvation = SC_EXIT_ON_STARVATION;
 
-uint64_t _deltaCycles = 0;
-
 } // anonymous namespace
 
 int
@@ -193,14 +193,17 @@ sc_stop()
 const sc_time &
 sc_time_stamp()
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-    return *(sc_time *)nullptr;
+    static sc_time tstamp;
+    Tick tick = sc_gem5::scheduler.eventQueue().getCurTick();
+    //XXX We're assuming the systemc time resolution is in ps.
+    tstamp = sc_time::from_value(tick / SimClock::Int::ps);
+    return tstamp;
 }
 
 sc_dt::uint64
 sc_delta_count()
 {
-    return _deltaCycles;
+    return sc_gem5::scheduler.numCycles();
 }
 
 bool