diff options
author | Gabe Black <gabeblack@google.com> | 2018-11-07 17:34:11 -0800 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-11-12 22:05:00 +0000 |
commit | 3fb91393a67515a008dae0346689ffffe5180ab8 (patch) | |
tree | cc5ff91879a416fbb80eea3e4a43da8ca0c63276 /src/sim/core.cc | |
parent | 8c8a2f12f2f8b419723e7af8e3851033c41b7b51 (diff) | |
download | gem5-3fb91393a67515a008dae0346689ffffe5180ab8.tar.xz |
sim: Push the global frequency management code into C++.
That makes it available when python is left out, and makes it available
to c++ code without having to call back into python.
Change-Id: If82e7e8eff526f2b957f84afe046e1d56fed4aa2
Reviewed-on: https://gem5-review.googlesource.com/c/14055
Reviewed-by: Srikant Bharadwaj <srikant.bharadwaj@amd.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/sim/core.cc')
-rw-r--r-- | src/sim/core.cc | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/sim/core.cc b/src/sim/core.cc index 514c4c557..cb9051f38 100644 --- a/src/sim/core.cc +++ b/src/sim/core.cc @@ -37,6 +37,8 @@ #include <string> #include "base/callback.hh" +#include "base/cprintf.hh" +#include "base/logging.hh" #include "base/output.hh" #include "sim/eventq.hh" @@ -69,11 +71,23 @@ Tick ps; } // namespace SimClock +namespace { + +bool _clockFrequencyFixed = false; + +// Default to 1 THz (1 Tick == 1 ps) +Tick _ticksPerSecond = 1e12; + +} // anonymous namespace + void -setClockFrequency(Tick ticksPerSecond) +fixClockFrequency() { + if (_clockFrequencyFixed) + return; + using namespace SimClock; - Frequency = ticksPerSecond; + Frequency = _ticksPerSecond; Float::s = static_cast<double>(Frequency); Float::ms = Float::s / 1.0e3; Float::us = Float::s / 1.0e6; @@ -91,7 +105,20 @@ setClockFrequency(Tick ticksPerSecond) Int::ns = Int::us / 1000; Int::ps = Int::ns / 1000; + cprintf("Global frequency set at %d ticks per second\n", _ticksPerSecond); + + _clockFrequencyFixed = true; +} +bool clockFrequencyFixed() { return _clockFrequencyFixed; } + +void +setClockFrequency(Tick tps) +{ + panic_if(_clockFrequencyFixed, + "Global frequency already fixed at %f ticks/s.", _ticksPerSecond); + _ticksPerSecond = tps; } +Tick getClockFrequency() { return _ticksPerSecond; } void setOutputDir(const string &dir) |