36c36
< sc_time::sc_time()
---
> namespace
38,39d37
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< }
41c39,61
< sc_time::sc_time(double, sc_time_unit)
---
> const char *TimeUnitNames[] = {
> [SC_FS] = "fs",
> [SC_PS] = "ps",
> [SC_NS] = "ns",
> [SC_US] = "us",
> [SC_MS] = "ms",
> [SC_SEC] = "s"
> };
>
> double TimeUnitScale[] = {
> [SC_FS] = 1.0e-15,
> [SC_PS] = 1.0e-12,
> [SC_NS] = 1.0e-9,
> [SC_US] = 1.0e-6,
> [SC_MS] = 1.0e-3,
> [SC_SEC] = 1.0
> };
>
> } // anonymous namespace
>
> sc_time::sc_time() : val(0) {}
>
> sc_time::sc_time(double d, sc_time_unit tu)
43c63,71
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
---
> val = 0;
> if (d != 0) {
> //XXX Assuming the time resolution is 1ps.
> double scale = TimeUnitScale[tu] / TimeUnitScale[SC_PS];
> // Accellera claims there is a linux bug, and that these next two
> // lines work around them.
> volatile double tmp = d * scale + 0.5;
> val = static_cast<uint64_t>(tmp);
> }
46c74
< sc_time::sc_time(const sc_time &)
---
> sc_time::sc_time(const sc_time &t)
48c76
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
---
> val = t.val;
62c90
< sc_time::operator = (const sc_time &)
---
> sc_time::operator = (const sc_time &t)
64c92
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
---
> val = t.val;
71,72c99
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return 0;
---
> return val;
96c123
< sc_time::operator == (const sc_time &) const
---
> sc_time::operator == (const sc_time &t) const
98,99c125
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return true;
---
> return val == t.val;
103c129
< sc_time::operator != (const sc_time &) const
---
> sc_time::operator != (const sc_time &t) const
105,106c131
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return false;
---
> return val != t.val;
110c135
< sc_time::operator < (const sc_time &) const
---
> sc_time::operator < (const sc_time &t) const
112,113c137
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return false;
---
> return val < t.val;
117c141
< sc_time::operator <= (const sc_time &) const
---
> sc_time::operator <= (const sc_time &t) const
119,120c143
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return true;
---
> return val <= t.val;
124c147
< sc_time::operator > (const sc_time &) const
---
> sc_time::operator > (const sc_time &t) const
126,127c149
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return false;
---
> return val > t.val;
131c153
< sc_time::operator >= (const sc_time &) const
---
> sc_time::operator >= (const sc_time &t) const
133,134c155
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return true;
---
> return val >= t.val;
138c159
< sc_time::operator += (const sc_time &)
---
> sc_time::operator += (const sc_time &t)
140c161
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
---
> val += t.val;
145c166
< sc_time::operator -= (const sc_time &)
---
> sc_time::operator -= (const sc_time &t)
147c168
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
---
> val -= t.val;
166c187
< sc_time::print(std::ostream &) const
---
> sc_time::print(std::ostream &os) const
168c189,201
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
---
> if (val == 0) {
> os << "0 s";
> } else {
> //XXX Assuming the time resolution is 1ps.
> sc_time_unit tu = SC_PS;
> uint64_t scaled = val;
> while (tu < SC_SEC && (scaled % 1000) == 0) {
> tu = (sc_time_unit)((int)tu + 1);
> scaled /= 1000;
> }
>
> os << scaled << ' ' << TimeUnitNames[tu];
> }
172c205
< sc_time::from_value(sc_dt::uint64)
---
> sc_time::from_value(sc_dt::uint64 u)
174,175c207,209
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
< return sc_time();
---
> sc_time t;
> t.val = u;
> return t;
235c269
< operator << (std::ostream &os, const sc_time &)
---
> operator << (std::ostream &os, const sc_time &t)
237c271
< warn("%s not implemented.\n", __PRETTY_FUNCTION__);
---
> t.print(os);