diff -r 4ebff121cc0e -r 02321216fe7b src/base/time.hh --- a/src/base/time.hh Wed Jan 19 11:48:00 2011 -0800 +++ b/src/base/time.hh Wed Jan 19 14:58:42 2011 -0800 @@ -42,6 +42,8 @@ #include #include +#include "base/types.hh" + class Time { protected: @@ -99,6 +101,12 @@ */ void set(time_t _sec, long _nsec) { sec(_sec); nsec(_nsec); } + /** + * Set/get the current time from a value measured in Ticks + */ + void setTick(Tick ticks); + Tick getTick() const; + const Time & operator=(const Time &other) { diff -r 4ebff121cc0e -r 02321216fe7b src/base/time.cc --- a/src/base/time.cc Wed Jan 19 11:48:00 2011 -0800 +++ b/src/base/time.cc Wed Jan 19 14:58:42 2011 -0800 @@ -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 @@ #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 {