267,300c267
< if (val == 0) {
< os << "0 s";
< } else {
< Tick frequency = SimClock::Frequency;
<
< // Shrink the frequency by scaling down the time period, ie converting
< // it from cycles per second to cycles per millisecond, etc.
< sc_time_unit tu = SC_SEC;
< while (tu > 1 && (frequency % 1000 == 0)) {
< tu = (sc_time_unit)((int)tu - 1);
< frequency /= 1000;
< }
<
< // Convert the frequency into a period.
< Tick period;
< if (frequency > 1) {
< tu = (sc_time_unit)((int)tu - 1);
< period = 1000 / frequency;
< } else {
< period = frequency;
< }
<
< // Scale our integer value by the period.
< uint64_t scaled = val * period;
<
< // Shrink the scaled time value by increasing the size of the units
< // it's measured by, avoiding fractional parts.
< while (tu < SC_SEC && (scaled % 1000) == 0) {
< tu = (sc_time_unit)((int)tu + 1);
< scaled /= 1000;
< }
<
< os << scaled << ' ' << sc_gem5::TimeUnitNames[tu];
< }
---
> os << sc_time_tuple(*this).to_string();
488c455,456
< sc_time_tuple::sc_time_tuple(const sc_time &)
---
> sc_time_tuple::sc_time_tuple(const sc_time &t) :
> _value(), _unit(SC_SEC), _set(true)
490c458,487
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
---
> if (!t.value())
> return;
>
> Tick frequency = SimClock::Frequency;
>
> // Shrink the frequency by scaling down the time period, ie converting
> // it from cycles per second to cycles per millisecond, etc.
> while (_unit > 1 && (frequency % 1000 == 0)) {
> _unit = (sc_time_unit)((int)_unit - 1);
> frequency /= 1000;
> }
>
> // Convert the frequency into a period.
> Tick period;
> if (frequency > 1) {
> _unit = (sc_time_unit)((int)_unit - 1);
> period = 1000 / frequency;
> } else {
> period = frequency;
> }
>
> // Scale our integer value by the period.
> _value = t.value() * period;
>
> // Shrink the scaled time value by increasing the size of the units
> // it's measured by, avoiding fractional parts.
> while (_unit < SC_SEC && (_value % 1000) == 0) {
> _unit = (sc_time_unit)((int)_unit + 1);
> _value /= 1000;
> }
496,497c493
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return false;
---
> return _set;
500,505c496
< sc_dt::uint64
< sc_time_tuple::value() const
< {
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return 0;
< }
---
> sc_dt::uint64 sc_time_tuple::value() const { return _value; }
510,511c501
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return "";
---
> return sc_gem5::TimeUnitNames[_unit];
514,519c504
< double
< sc_time_tuple::to_double() const
< {
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return 0.0;
< }
---
> double sc_time_tuple::to_double() const { return static_cast<double>(_value); }
524,525c509,511
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return "";
---
> std::ostringstream ss;
> ss << _value << ' ' << unit_symbol();
> return ss.str();