summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/base/time.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/base/time.cc b/src/base/time.cc
index 6e9d7ccfb..80bc546e1 100644
--- a/src/base/time.cc
+++ b/src/base/time.cc
@@ -57,14 +57,17 @@ Time::_set(bool monotonic)
void
Time::setTick(Tick ticks)
{
- uint64_t nsecs = ticks / SimClock::Int::ns;
- set(nsecs / NSEC_PER_SEC, nsecs % NSEC_PER_SEC);
+ uint64_t secs = ticks / SimClock::Frequency;
+ ticks -= secs * SimClock::Frequency;
+ uint64_t nsecs = static_cast<uint64_t>(ticks * SimClock::Float::GHz);
+ set(secs, nsecs);
}
Tick
Time::getTick() const
{
- return (nsec() + sec() * NSEC_PER_SEC) * SimClock::Int::ns;
+ return sec() * SimClock::Frequency +
+ static_cast<uint64_t>(nsec() * SimClock::Float::ns);
}
string