summaryrefslogtreecommitdiff
path: root/src/base/time.cc
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2011-01-19 16:22:15 -0800
committerGabe Black <gblack@eecs.umich.edu>2011-01-19 16:22:15 -0800
commit23bab6783b8fb4401543941983c36c41cd24b4ef (patch)
tree829b258359d9a2548f8a4a32c882ac3cb821520c /src/base/time.cc
parenta368fba7d4fa01b58d5c2d9b3cafd56e1102287c (diff)
downloadgem5-23bab6783b8fb4401543941983c36c41cd24b4ef.tar.xz
Time: Add setTick and getTick functions to the Time class.
Diffstat (limited to 'src/base/time.cc')
-rw-r--r--src/base/time.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/base/time.cc b/src/base/time.cc
index b9bbb0830..0fab938a4 100644
--- a/src/base/time.cc
+++ b/src/base/time.cc
@@ -33,6 +33,7 @@
#include "base/time.hh"
#include "config/use_posix_clock.hh"
+#include "sim/core.hh"
using namespace std;
@@ -48,6 +49,19 @@ Time::_set(bool monotonic)
#endif
}
+void
+Time::setTick(Tick ticks)
+{
+ uint64_t nsecs = ticks / SimClock::Int::ns;
+ set(nsecs / NSEC_PER_SEC, nsecs % NSEC_PER_SEC);
+}
+
+Tick
+Time::getTick() const
+{
+ return (nsec() + sec() * NSEC_PER_SEC) * SimClock::Int::ns;
+}
+
string
Time::date(const string &format) const
{