systemc: Handle sc_time_stamp before any sc_time is constructed.
authorGabe Black <gabeblack@google.com>
Thu, 23 Aug 2018 04:35:44 +0000 (21:35 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 25 Sep 2018 23:58:50 +0000 (23:58 +0000)
The time resolution won't yet be fixed, so the scaling factor will
still be set to zero.

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

src/systemc/core/sc_main.cc

index 47ca2e3544ecb5e06b74ceb42bd998833cb658c1..39f6e174b9001572d7d783c3f7d6b3991591bde9 100644 (file)
@@ -235,7 +235,9 @@ sc_time_stamp()
     static sc_time tstamp;
     Tick tick = ::sc_gem5::scheduler.getCurTick();
     //XXX We're assuming the systemc time resolution is in ps.
-    tstamp = sc_time::from_value(tick / SimClock::Int::ps);
+    // If tick is zero, the time scale may not be fixed yet, and
+    // SimClock::Int::ps may be zero.
+    tstamp = sc_time::from_value(tick ? tick / SimClock::Int::ps : 0);
     return tstamp;
 }