#include "base/hostinfo.hh"
#include "base/statistics.hh"
#include "base/time.hh"
+#include "config/the_isa.hh"
+#if THE_ISA == NO_ISA
+#include "arch/noisa/cpu_dummy.hh"
+#else
#include "cpu/base.hh"
+#endif
+
#include "sim/eventq.hh"
+#include "sim/stat_control.hh"
using namespace std;
-Stats::Formula hostInstRate;
-Stats::Formula hostTickRate;
-Stats::Value hostMemory;
-Stats::Value hostSeconds;
-
+Stats::Formula simSeconds;
Stats::Value simTicks;
-Stats::Value simInsts;
Stats::Value simFreq;
-Stats::Formula simSeconds;
namespace Stats {
{
void process()
{
- statTime.set();
- startTick = curTick;
+ statTime.setTimer();
+ startTick = curTick();
}
};
double
statElapsedTime()
{
- Time now(true);
+ Time now;
+ now.setTimer();
+
Time elapsed = now - statTime;
- return elapsed();
+ return elapsed;
}
Tick
statElapsedTicks()
{
- return curTick - startTick;
+ return curTick() - startTick;
}
SimTicksReset simTicksReset;
-void
-initSimStats()
+struct Global
+{
+ Stats::Formula hostInstRate;
+ Stats::Formula hostTickRate;
+ Stats::Value hostMemory;
+ Stats::Value hostSeconds;
+
+ Stats::Value simInsts;
+
+ Global();
+};
+
+Global::Global()
{
simInsts
.functor(BaseCPU::numSimulatedInstructions)
;
simFreq
- .scalar(Clock::Frequency)
+ .scalar(SimClock::Frequency)
.name("sim_freq")
.desc("Frequency of simulated ticks")
;
registerResetCallback(&simTicksReset);
}
-class _StatEvent : public Event
+void
+initSimStats()
+{
+ static Global global;
+}
+
+class StatEvent : public Event
{
private:
bool dump;
Tick repeat;
public:
- _StatEvent(bool _dump, bool _reset, Tick _repeat)
+ StatEvent(bool _dump, bool _reset, Tick _repeat)
: Event(Stat_Event_Pri), dump(_dump), reset(_reset), repeat(_repeat)
{
setFlags(AutoDelete);
Stats::reset();
if (repeat) {
- Event *event = new _StatEvent(dump, reset, repeat);
- mainEventQueue.schedule(event, curTick + repeat);
+ Stats::schedStatEvent(dump, reset, curTick() + repeat, repeat);
}
}
};
void
-StatEvent(bool dump, bool reset, Tick when, Tick repeat)
+schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
{
- Event *event = new _StatEvent(dump, reset, repeat);
+ Event *event = new StatEvent(dump, reset, repeat);
mainEventQueue.schedule(event, when);
}
-/* namespace Stats */ }
+} // namespace Stats