Gabe Black has submitted this change and it was merged. (
https://gem5-review.googlesource.com/c/public/gem5/+/12276 )
Change subject: systemc: Implement support for the default time unit.
......................................................................
systemc: Implement support for the default time unit.
This is deprecated, but still used in the tests.
Change-Id: I454540e419c53624a37f3d1271cb240415b816b6
Reviewed-on: https://gem5-review.googlesource.com/c/12276
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/core/sc_time.cc
1 file changed, 15 insertions(+), 8 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
diff --git a/src/systemc/core/sc_time.cc b/src/systemc/core/sc_time.cc
index bc35f2a..96877e8 100644
--- a/src/systemc/core/sc_time.cc
+++ b/src/systemc/core/sc_time.cc
@@ -134,6 +134,8 @@
}
} timeSetter;
+double defaultUnit = 1.0e-9;
+
} // anonymous namespace
sc_time::sc_time() : val(0) {}
@@ -152,14 +154,20 @@
sc_time::sc_time(double d, bool scale)
{
- //XXX Assuming the time resolution is 1ps, and the default unit is 1ns.
- set(this, d, scale ? SC_NS : SC_PS);
+ //XXX Assuming the time resolution is 1ps.
+ if (scale)
+ set(this, d * defaultUnit, SC_SEC);
+ else
+ set(this, d, SC_PS);
}
sc_time::sc_time(sc_dt::uint64 v, bool scale)
{
- //XXX Assuming the time resolution is 1ps, and the default unit is 1ns.
- set(this, static_cast<double>(v), scale ? SC_NS : SC_PS);
+ //XXX Assuming the time resolution is 1ps.
+ if (scale)
+ set(this, static_cast<double>(v) * defaultUnit, SC_SEC);
+ else
+ set(this, static_cast<double>(v), SC_PS);
}
sc_time &
@@ -370,16 +378,15 @@
}
void
-sc_set_default_time_unit(double, sc_time_unit)
+sc_set_default_time_unit(double d, sc_time_unit tu)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ defaultUnit = d * TimeUnitScale[tu];
}
sc_time
sc_get_default_time_unit()
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return *(sc_time *)nullptr;
+ return sc_time(defaultUnit, SC_SEC);
}
sc_time_tuple::sc_time_tuple(const sc_time &)
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12276
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: I454540e419c53624a37f3d1271cb240415b816b6
Gerrit-Change-Number: 12276
Gerrit-PatchSet: 9
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matthias Jung <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev