#include "base/misc.hh"
#include "base/pollevent.hh"
-#include "sim/stat_control.hh"
+#include "base/types.hh"
#include "sim/async.hh"
#include "sim/eventq.hh"
-#include "sim/host.hh"
#include "sim/sim_events.hh"
#include "sim/sim_exit.hh"
#include "sim/simulate.hh"
+#include "sim/stat_control.hh"
/** Simulate for num_cycles additional cycles. If num_cycles is -1
* (the default), do not limit simulation; some other event must
SimLoopExitEvent *
simulate(Tick num_cycles)
{
- warn("Entering event queue @ %d. Starting simulation...\n", curTick);
+ inform("Entering event queue @ %d. Starting simulation...\n", curTick());
if (num_cycles < 0)
fatal("simulate: num_cycles must be >= 0 (was %d)\n", num_cycles);
- else if (curTick + num_cycles < 0) //Overflow
+ else if (curTick() + num_cycles < 0) //Overflow
num_cycles = MaxTick;
else
- num_cycles = curTick + num_cycles;
+ num_cycles = curTick() + num_cycles;
- Event *limit_event;
- limit_event = schedExitSimLoop("simulate() limit reached", num_cycles);
+ Event *limit_event =
+ new SimLoopExitEvent("simulate() limit reached", 0);
+ mainEventQueue.schedule(limit_event, num_cycles);
while (1) {
// there should always be at least one event (the SimLoopExitEvent
// we just scheduled) in the queue
assert(!mainEventQueue.empty());
- assert(curTick <= mainEventQueue.nextTick() &&
+ assert(curTick() <= mainEventQueue.nextTick() &&
"event scheduled in the past");
// forward current cycle to the time of the first event on the
// queue
- curTick = mainEventQueue.nextTick();
+ curTick(mainEventQueue.nextTick());
Event *exit_event = mainEventQueue.serviceOne();
if (exit_event != NULL) {
// hit some kind of exit event; return to Python
// if we didn't hit limit_event, delete it
if (se_event != limit_event) {
assert(limit_event->scheduled());
- limit_event->deschedule();
- delete limit_event;
+ limit_event->squash();
+ hack_once("be nice to actually delete the event here");
}
return se_event;
if (async_event) {
async_event = false;
if (async_statdump || async_statreset) {
+ Stats::schedStatEvent(async_statdump, async_statreset);
async_statdump = false;
async_statreset = false;
-
- Stats::StatEvent(async_statdump, async_statreset);
}
if (async_exit) {