diff -r d879a42f78c4 -r a2b7eb136cea src/cpu/BaseCPU.py --- a/src/cpu/BaseCPU.py Mon Jun 03 14:31:18 2013 +0200 +++ b/src/cpu/BaseCPU.py Mon Jun 03 14:33:10 2013 +0200 @@ -99,6 +99,8 @@ bool switchedOut(); void flushTLBs(); Counter totalInsts(); + void scheduleInstStop(ThreadID tid, Counter insts, const char *cause); + void scheduleLoadStop(ThreadID tid, Counter loads, const char *cause); ''') @classmethod diff -r d879a42f78c4 -r a2b7eb136cea src/cpu/base.hh --- a/src/cpu/base.hh Mon Jun 03 14:31:18 2013 +0200 +++ b/src/cpu/base.hh Mon Jun 03 14:33:10 2013 +0200 @@ -395,6 +395,36 @@ virtual Counter totalOps() const = 0; + /** + * Schedule an event that exits the simulation loops after a + * predefined number of instructions. + * + * This method is usually called from the configuration script to + * get an exit event some time in the future. It is typically used + * when the script wants to simulate for a specific number of + * instructions rather than ticks. + * + * @param tid Thread monitor. + * @param insts Number of instructions into the future. + * @param cause Cause to signal in the exit event. + */ + void scheduleInstStop(ThreadID tid, Counter insts, const char *cause); + + /** + * Schedule an event that exits the simulation loops after a + * predefined number of load operations. + * + * This method is usually called from the configuration script to + * get an exit event some time in the future. It is typically used + * when the script wants to simulate for a specific number of + * loads rather than ticks. + * + * @param tid Thread monitor. + * @param loads Number of load instructions into the future. + * @param cause Cause to signal in the exit event. + */ + void scheduleLoadStop(ThreadID tid, Counter loads, const char *cause); + // Function tracing private: bool functionTracingEnabled; diff -r d879a42f78c4 -r a2b7eb136cea src/cpu/base.cc --- a/src/cpu/base.cc Mon Jun 03 14:31:18 2013 +0200 +++ b/src/cpu/base.cc Mon Jun 03 14:33:10 2013 +0200 @@ -147,10 +147,8 @@ // if (p->max_insts_any_thread != 0) { const char *cause = "a thread reached the max instruction count"; - for (ThreadID tid = 0; tid < numThreads; ++tid) { - Event *event = new SimLoopExitEvent(cause, 0); - comInstEventQueue[tid]->schedule(event, p->max_insts_any_thread); - } + for (ThreadID tid = 0; tid < numThreads; ++tid) + scheduleInstStop(tid, p->max_insts_any_thread, cause); } // Set up instruction-count-based termination events for SimPoints @@ -159,10 +157,8 @@ // exitting the simulation loop. if (!p->simpoint_start_insts.empty()) { const char *cause = "simpoint starting point found"; - for (size_t i = 0; i < p->simpoint_start_insts.size(); ++i) { - Event *event = new SimLoopExitEvent(cause, 0); - comInstEventQueue[0]->schedule(event, p->simpoint_start_insts[i]); - } + for (size_t i = 0; i < p->simpoint_start_insts.size(); ++i) + scheduleInstStop(0, p->simpoint_start_insts[i], cause); } if (p->max_insts_all_threads != 0) { @@ -189,10 +185,8 @@ // if (p->max_loads_any_thread != 0) { const char *cause = "a thread reached the max load count"; - for (ThreadID tid = 0; tid < numThreads; ++tid) { - Event *event = new SimLoopExitEvent(cause, 0); - comLoadEventQueue[tid]->schedule(event, p->max_loads_any_thread); - } + for (ThreadID tid = 0; tid < numThreads; ++tid) + scheduleLoadStop(tid, p->max_loads_any_thread, cause); } if (p->max_loads_all_threads != 0) { @@ -572,6 +566,25 @@ } void +BaseCPU::scheduleInstStop(ThreadID tid, Counter insts, const char *cause) +{ + const Tick now(comInstEventQueue[tid]->getCurTick()); + Event *event(new SimLoopExitEvent(cause, 0)); + + comInstEventQueue[tid]->schedule(event, now + insts); +} + +void +BaseCPU::scheduleLoadStop(ThreadID tid, Counter loads, const char *cause) +{ + const Tick now(comLoadEventQueue[tid]->getCurTick()); + Event *event(new SimLoopExitEvent(cause, 0)); + + comLoadEventQueue[tid]->schedule(event, now + loads); +} + + +void BaseCPU::traceFunctionsInternal(Addr pc) { if (!debugSymbolTable)