From: Gabe Black Date: Tue, 7 Aug 2018 11:49:04 +0000 (-0700) Subject: systemc: Implement a few more member functions for sc_time. X-Git-Tag: v19.0.0.0~1779 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a5fabc7064254ba9b64e0405b08539ba41176363;p=gem5.git 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 Maintainer: Gabe Black --- 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(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(static_cast(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(static_cast(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(t.value()) * d + 0.5; + return sc_time::from_value(static_cast(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(t.value()) + 0.5; + return sc_time::from_value(static_cast(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(t.value()) / d + 0.5; + return sc_time::from_value(static_cast(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 &