Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/12037
Change subject: systemc: Fix the time resolution when constructing an
sc_time.
......................................................................
systemc: Fix the time resolution when constructing an sc_time.
This is (sort of) mandated by the spec. More specifically the spec says
that the systemc API for changing the time resolution can only be
called once, and can only be called before a non-zero sc_time is
constructed.
Because sc_time can be constructed during elaboration and the gem5
version of time resolution is generally not locked down until the
actual simulation starts (after elaboration), the sc_time constructor
needs to call the fixing function itself to ensure that, for instance,
the scaling factors for various real life time units within gem5 are
initialized.
Change-Id: Ied4b43659834761b55b5ae49ea62779af891d9e3
---
M src/systemc/core/sc_time.cc
1 file changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/systemc/core/sc_time.cc b/src/systemc/core/sc_time.cc
index 002121e..f51b158 100644
--- a/src/systemc/core/sc_time.cc
+++ b/src/systemc/core/sc_time.cc
@@ -28,6 +28,7 @@
*/
#include "base/logging.hh"
+#include "python/pybind11/pybind.hh"
#include "systemc/ext/core/sc_time.hh"
namespace sc_core
@@ -54,6 +55,19 @@
[SC_SEC] = 1.0
};
+void
+fixTimeResolution()
+{
+ static bool fixed = false;
+ if (fixed)
+ return;
+
+ auto ticks = pybind11::module::import("m5.ticks");
+ auto fix_global_frequency = ticks.attr("fixGlobalFrequency");
+ fix_global_frequency();
+ fixed = true;
+}
+
} // anonymous namespace
sc_time::sc_time() : val(0) {}
@@ -62,6 +76,7 @@
{
val = 0;
if (d != 0) {
+ fixTimeResolution();
//XXX Assuming the time resolution is 1ps.
double scale = TimeUnitScale[tu] / TimeUnitScale[SC_PS];
// Accellera claims there is a linux bug, and that these next two
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12037
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ied4b43659834761b55b5ae49ea62779af891d9e3
Gerrit-Change-Number: 12037
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev