diff options
author | Gabe Black <gabeblack@google.com> | 2018-09-22 08:09:31 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-10-16 00:33:05 +0000 |
commit | b58f56bf7fe97dbe94a28123ddacae2053810932 (patch) | |
tree | e24df89fefaa4fc38ac1dd0b77767c38e3663499 /src/systemc/utils | |
parent | 9c56d8adfe5c1f9cb28842a0b9f83873db1ab22f (diff) | |
download | gem5-b58f56bf7fe97dbe94a28123ddacae2053810932.tar.xz |
systemc: Change how the default timescale is set.
The spec says that the default timescale should be 1 PS, but the
Accellera implementation uses the time resolution.
Change-Id: I7b307a33ef0856e9c19d81e401b15691275d4978
Reviewed-on: https://gem5-review.googlesource.com/c/12975
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/utils')
-rw-r--r-- | src/systemc/utils/tracefile.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/systemc/utils/tracefile.cc b/src/systemc/utils/tracefile.cc index 25d7ea6f3..cf771463b 100644 --- a/src/systemc/utils/tracefile.cc +++ b/src/systemc/utils/tracefile.cc @@ -37,6 +37,7 @@ #include "sim/core.hh" #include "systemc/core/time.hh" #include "systemc/ext/core/sc_main.hh" +#include "systemc/ext/core/sc_time.hh" #include "systemc/ext/utils/functions.hh" namespace sc_gem5 @@ -44,7 +45,7 @@ namespace sc_gem5 TraceFile::TraceFile(const std::string &name) : _os(simout.create(name, true, true)), timeUnitTicks(0), - timeUnitValue(1.0), timeUnitUnit(::sc_core::SC_PS), _traceDeltas(false) + timeUnitValue(0.0), timeUnitUnit(::sc_core::SC_PS), _traceDeltas(false) {} TraceFile::~TraceFile() @@ -76,7 +77,14 @@ TraceFile::set_time_unit(double d, ::sc_core::sc_time_unit tu) void TraceFile::finalizeTime() { - timeUnitTicks = ::sc_core::sc_time(timeUnitValue, timeUnitUnit).value(); + ::sc_core::sc_time time; + if (timeUnitValue == 0.0) { + // The time scale was never set. Use the global time resolution. + time = ::sc_core::sc_get_time_resolution(); + } else { + time = ::sc_core::sc_time(timeUnitValue, timeUnitUnit); + } + timeUnitTicks = time.value(); } } // namespace sc_gem5 |