sc_time.cc (13039:0c8ecf92a420) sc_time.cc (13040:877a6e22f8d4)
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 162 unchanged lines hidden (view full) ---

171sc_time::value() const
172{
173 return val;
174}
175
176double
177sc_time::to_double() const
178{
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 162 unchanged lines hidden (view full) ---

171sc_time::value() const
172{
173 return val;
174}
175
176double
177sc_time::to_double() const
178{
179 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
180 return 0.0;
179 return static_cast<double>(val);
181}
182double
183sc_time::to_seconds() const
184{
185 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
186 return 0.0;
187}
188

--- 50 unchanged lines hidden (view full) ---

239sc_time &
240sc_time::operator -= (const sc_time &t)
241{
242 val -= t.val;
243 return *this;
244}
245
246sc_time &
180}
181double
182sc_time::to_seconds() const
183{
184 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
185 return 0.0;
186}
187

--- 50 unchanged lines hidden (view full) ---

238sc_time &
239sc_time::operator -= (const sc_time &t)
240{
241 val -= t.val;
242 return *this;
243}
244
245sc_time &
247sc_time::operator *= (double)
246sc_time::operator *= (double d)
248{
247{
249 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
248 val = static_cast<int64_t>(static_cast<double>(val) * d + 0.5);
250 return *this;
251}
252
253sc_time &
249 return *this;
250}
251
252sc_time &
254sc_time::operator /= (double)
253sc_time::operator /= (double d)
255{
254{
256 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
255 val = static_cast<int64_t>(static_cast<double>(val) / d + 0.5);
257 return *this;
258}
259
260void
261sc_time::print(std::ostream &os) const
262{
263 if (val == 0) {
264 os << "0 s";

--- 40 unchanged lines hidden (view full) ---

305
306const sc_time
307operator - (const sc_time &a, const sc_time &b)
308{
309 return sc_time::from_value(a.value() - b.value());
310}
311
312const sc_time
256 return *this;
257}
258
259void
260sc_time::print(std::ostream &os) const
261{
262 if (val == 0) {
263 os << "0 s";

--- 40 unchanged lines hidden (view full) ---

304
305const sc_time
306operator - (const sc_time &a, const sc_time &b)
307{
308 return sc_time::from_value(a.value() - b.value());
309}
310
311const sc_time
313operator * (const sc_time &, double)
312operator * (const sc_time &t, double d)
314{
313{
315 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
316 return sc_time();
314 volatile double tmp = static_cast<double>(t.value()) * d + 0.5;
315 return sc_time::from_value(static_cast<int64_t>(tmp));
317}
318
319const sc_time
316}
317
318const sc_time
320operator * (double, const sc_time &)
319operator * (double d, const sc_time &t)
321{
320{
322 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
323 return sc_time();
321 volatile double tmp = d * static_cast<double>(t.value()) + 0.5;
322 return sc_time::from_value(static_cast<int64_t>(tmp));
324}
325
326const sc_time
323}
324
325const sc_time
327operator / (const sc_time &, double)
326operator / (const sc_time &t, double d)
328{
327{
329 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
330 return sc_time();
328 volatile double tmp = static_cast<double>(t.value()) / d + 0.5;
329 return sc_time::from_value(static_cast<int64_t>(tmp));
331}
332
333double
330}
331
332double
334operator / (const sc_time &, const sc_time &)
333operator / (const sc_time &t1, const sc_time &t2)
335{
334{
336 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
337 return 0.0;
335 return t1.to_double() / t2.to_double();
338}
339
340std::ostream &
341operator << (std::ostream &os, const sc_time &t)
342{
343 t.print(os);
344 return os;
345}

--- 77 unchanged lines hidden ---
336}
337
338std::ostream &
339operator << (std::ostream &os, const sc_time &t)
340{
341 t.print(os);
342 return os;
343}

--- 77 unchanged lines hidden ---