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 return static_cast<double>(val); |
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 & |
246sc_time::operator *= (double d) |
247{ |
248 val = static_cast<int64_t>(static_cast<double>(val) * d + 0.5); |
249 return *this; 250} 251 252sc_time & |
253sc_time::operator /= (double d) |
254{ |
255 val = static_cast<int64_t>(static_cast<double>(val) / d + 0.5); |
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 |
312operator * (const sc_time &t, double d) |
313{ |
314 volatile double tmp = static_cast<double>(t.value()) * d + 0.5; 315 return sc_time::from_value(static_cast<int64_t>(tmp)); |
316} 317 318const sc_time |
319operator * (double d, const sc_time &t) |
320{ |
321 volatile double tmp = d * static_cast<double>(t.value()) + 0.5; 322 return sc_time::from_value(static_cast<int64_t>(tmp)); |
323} 324 325const sc_time |
326operator / (const sc_time &t, double d) |
327{ |
328 volatile double tmp = static_cast<double>(t.value()) / d + 0.5; 329 return sc_time::from_value(static_cast<int64_t>(tmp)); |
330} 331 332double |
333operator / (const sc_time &t1, const sc_time &t2) |
334{ |
335 return t1.to_double() / t2.to_double(); |
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 --- |