diff options
author | Gabe Black <gabeblack@google.com> | 2018-08-07 04:49:04 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-09-20 01:40:58 +0000 |
commit | a5fabc7064254ba9b64e0405b08539ba41176363 (patch) | |
tree | 9a547cefd4eaf0327320a7e7e657ae31bf1d3a18 /src/systemc | |
parent | 88be5e34f66acaac13a0bd0f52b55eecb22cde1d (diff) | |
download | gem5-a5fabc7064254ba9b64e0405b08539ba41176363.tar.xz |
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 <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc')
-rw-r--r-- | src/systemc/core/sc_time.cc | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/systemc/core/sc_time.cc b/src/systemc/core/sc_time.cc index 93150aace..0a52a6a13 100644 --- a/src/systemc/core/sc_time.cc +++ b/src/systemc/core/sc_time.cc @@ -176,8 +176,7 @@ sc_time::value() const 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::operator -= (const sc_time &t) } 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 @@ operator - (const sc_time &a, const sc_time &b) } 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 & |