Gabe Black has submitted this change and it was merged. (
https://gem5-review.googlesource.com/c/public/gem5/+/12071 )
Change subject: systemc: Implement a few more member functions for sc_time.
......................................................................
systemc: Implement a few more member functions for sc_time.
Change-Id: I40a7fb278f2a0ec4124589e02e4441c1866c86ea
Reviewed-on: https://gem5-review.googlesource.com/12071
Reviewed-by: Gabe Black <gabebl...@google.com>
Maintainer: Gabe Black <gabebl...@google.com>
---
M src/systemc/core/sc_time.cc
1 file changed, 16 insertions(+), 18 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 93150aa..0a52a6a 100644
--- a/src/systemc/core/sc_time.cc
+++ b/src/systemc/core/sc_time.cc
@@ -176,8 +176,7 @@
double
sc_time::to_double() const
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return 0.0;
+ return static_cast<double>(val);
}
double
sc_time::to_seconds() const
@@ -244,16 +243,16 @@
}
sc_time &
-sc_time::operator *= (double)
+sc_time::operator *= (double d)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ val = static_cast<int64_t>(static_cast<double>(val) * d + 0.5);
return *this;
}
sc_time &
-sc_time::operator /= (double)
+sc_time::operator /= (double d)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ val = static_cast<int64_t>(static_cast<double>(val) / d + 0.5);
return *this;
}
@@ -310,31 +309,30 @@
}
const sc_time
-operator * (const sc_time &, double)
+operator * (const sc_time &t, double d)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return sc_time();
+ volatile double tmp = static_cast<double>(t.value()) * d + 0.5;
+ return sc_time::from_value(static_cast<int64_t>(tmp));
}
const sc_time
-operator * (double, const sc_time &)
+operator * (double d, const sc_time &t)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return sc_time();
+ volatile double tmp = d * static_cast<double>(t.value()) + 0.5;
+ return sc_time::from_value(static_cast<int64_t>(tmp));
}
const sc_time
-operator / (const sc_time &, double)
+operator / (const sc_time &t, double d)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return sc_time();
+ volatile double tmp = static_cast<double>(t.value()) / d + 0.5;
+ return sc_time::from_value(static_cast<int64_t>(tmp));
}
double
-operator / (const sc_time &, const sc_time &)
+operator / (const sc_time &t1, const sc_time &t2)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return 0.0;
+ return t1.to_double() / t2.to_double();
}
std::ostream &
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12071
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: I40a7fb278f2a0ec4124589e02e4441c1866c86ea
Gerrit-Change-Number: 12071
Gerrit-PatchSet: 10
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Matthias Jung <jun...@eit.uni-kl.de>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev