diff --git a/src/sim/simulate.hh b/src/sim/simulate.hh --- a/src/sim/simulate.hh +++ b/src/sim/simulate.hh @@ -33,3 +33,4 @@ #include "sim/sim_events.hh" GlobalSimLoopExitEvent *simulate(Tick num_cycles = MaxTick); +extern GlobalSimLoopExitEvent *simulate_limit_event; # Node ID d36816fed3fd564a18a2e18c3a613861d28ee383 # Parent 8a20e2a1562debfc20b92be4581457c4147b3733 diff --git a/src/sim/simulate.cc b/src/sim/simulate.cc --- a/src/sim/simulate.cc +++ b/src/sim/simulate.cc @@ -71,6 +71,8 @@ } } +GlobalSimLoopExitEvent *simulate_limit_event = nullptr; + /** 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. @@ -96,6 +98,10 @@ } threads_initialized = true; + + simulate_limit_event = + new GlobalSimLoopExitEvent(mainEventQueue[0]->getCurTick(), + "simulate() limit reached", 0); } inform("Entering event queue @ %d. Starting simulation...\n", curTick()); @@ -105,8 +111,7 @@ else // counter would roll over or be set to MaxTick anyhow num_cycles = MaxTick; - GlobalEvent *limit_event = new GlobalSimLoopExitEvent(num_cycles, - "simulate() limit reached", 0, 0); + simulate_limit_event->reschedule(num_cycles); GlobalSyncEvent *quantum_event = NULL; if (numMainEventQueues > 1) { @@ -137,13 +142,6 @@ dynamic_cast(global_event); assert(global_exit_event != NULL); - // if we didn't hit limit_event, delete it. - if (global_exit_event != limit_event) { - assert(limit_event->scheduled()); - limit_event->deschedule(); - delete limit_event; - } - //! Delete the simulation quantum event. if (quantum_event != NULL) { quantum_event->deschedule();