Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/12208 )

Change subject: systemc: Implement a little more of sc_time.
......................................................................

systemc: Implement a little more of sc_time.

This change implements a pair of constructors, and some conversion
functions.

Change-Id: Ibd0e9ec5bcc24f4a17896313996b3112b5ef1934
Reviewed-on: https://gem5-review.googlesource.com/12208
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/core/sc_time.cc
1 file changed, 14 insertions(+), 9 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 0a52a6a..bc35f2a 100644
--- a/src/systemc/core/sc_time.cc
+++ b/src/systemc/core/sc_time.cc
@@ -150,14 +150,16 @@
     val = t.val;
 }

-sc_time::sc_time(double, bool)
+sc_time::sc_time(double d, bool scale)
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+    //XXX Assuming the time resolution is 1ps, and the default unit is 1ns.
+    set(this, d, scale ? SC_NS : SC_PS);
 }

-sc_time::sc_time(sc_dt::uint64, bool)
+sc_time::sc_time(sc_dt::uint64 v, bool scale)
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+    //XXX Assuming the time resolution is 1ps, and the default unit is 1ns.
+    set(this, static_cast<double>(v), scale ? SC_NS : SC_PS);
 }

 sc_time &
@@ -181,8 +183,10 @@
 double
 sc_time::to_seconds() const
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-    return 0.0;
+    double d = to_double();
+    //XXX Assuming the time resolution is 1ps.
+    double scale = TimeUnitScale[SC_PS] / TimeUnitScale[SC_SEC];
+    return d * scale;
 }

 const std::string
@@ -283,10 +287,11 @@
 }

 sc_time
-sc_time::from_seconds(double)
+sc_time::from_seconds(double d)
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-    return sc_time();
+    sc_time t;
+    set(&t, d, SC_SEC);
+    return t;
 }

 sc_time

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12208
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: Ibd0e9ec5bcc24f4a17896313996b3112b5ef1934
Gerrit-Change-Number: 12208
Gerrit-PatchSet: 9
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[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

Reply via email to