Deleted Added
sdiff udiff text old ( 13252:8814e5d87a48 ) new ( 13263:bcd6d8140486 )
full compact
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

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

259{
260 val = static_cast<int64_t>(static_cast<double>(val) / d + 0.5);
261 return *this;
262}
263
264void
265sc_time::print(std::ostream &os) const
266{
267 if (val == 0) {
268 os << "0 s";
269 } else {
270 Tick frequency = SimClock::Frequency;
271
272 // Shrink the frequency by scaling down the time period, ie converting
273 // it from cycles per second to cycles per millisecond, etc.
274 sc_time_unit tu = SC_SEC;
275 while (tu > 1 && (frequency % 1000 == 0)) {
276 tu = (sc_time_unit)((int)tu - 1);
277 frequency /= 1000;
278 }
279
280 // Convert the frequency into a period.
281 Tick period;
282 if (frequency > 1) {
283 tu = (sc_time_unit)((int)tu - 1);
284 period = 1000 / frequency;
285 } else {
286 period = frequency;
287 }
288
289 // Scale our integer value by the period.
290 uint64_t scaled = val * period;
291
292 // Shrink the scaled time value by increasing the size of the units
293 // it's measured by, avoiding fractional parts.
294 while (tu < SC_SEC && (scaled % 1000) == 0) {
295 tu = (sc_time_unit)((int)tu + 1);
296 scaled /= 1000;
297 }
298
299 os << scaled << ' ' << sc_gem5::TimeUnitNames[tu];
300 }
301}
302
303sc_time
304sc_time::from_value(sc_dt::uint64 u)
305{
306 if (u)
307 attemptToFixTime();
308 sc_time t;

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

480}
481
482sc_time
483sc_get_default_time_unit()
484{
485 return sc_time(defaultUnit, SC_SEC);
486}
487
488sc_time_tuple::sc_time_tuple(const sc_time &)
489{
490 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
491}
492
493bool
494sc_time_tuple::has_value() const
495{
496 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
497 return false;
498}
499
500sc_dt::uint64
501sc_time_tuple::value() const
502{
503 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
504 return 0;
505}
506
507const char *
508sc_time_tuple::unit_symbol() const
509{
510 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
511 return "";
512}
513
514double
515sc_time_tuple::to_double() const
516{
517 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
518 return 0.0;
519}
520
521std::string
522sc_time_tuple::to_string() const
523{
524 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
525 return "";
526}
527
528} // namespace sc_core