diff -r a5ede748a1d9 src/sim/simulate.cc --- a/src/sim/simulate.cc Tue Oct 02 14:35:46 2012 -0500 +++ b/src/sim/simulate.cc Fri Oct 05 18:47:12 2012 -0400 @@ -39,16 +39,20 @@ #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 * terminate the loop. Exported to Python via SWIG. * @return The SimLoopExitEvent that caused the loop to exit. */ + +// record the clock cycle for last exit event +Tick lastExitTick = 0; + SimLoopExitEvent * simulate(Tick num_cycles) { inform("Entering event queue @ %d. Starting simulation...\n", curTick()); if (num_cycles < MaxTick - curTick()) num_cycles = curTick() + num_cycles; else // counter would roll over or be set to MaxTick anyhow @@ -65,16 +69,26 @@ simulate(Tick num_cycles) 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()); Event *exit_event = mainEventQueue.serviceOne(); if (exit_event != NULL) { + /* + * if there are multiple exit events in the same cycle, drain the + * fol drain the following exit events since gem5 only allows one + * exit event in a cycle + */ + if (lastExitTick == curTick()) + continue; + else + lastExitTick = curTick(); + // hit some kind of exit event; return to Python // event must be subclass of SimLoopExitEvent... SimLoopExitEvent *se_event; se_event = dynamic_cast(exit_event); if (se_event == NULL) panic("Bogus exit event class!");