cpu: Query CPU for inst executed from Python

This patch adds the ability for the simulator to query the number of
instructions a CPU has executed so far per hw-thread. This can be used
to enable more flexible periodic events such as taking checkpoints
starting 1s into simulation and X instructions thereafter.
This commit is contained in:
Geoffrey Blake
2016-04-05 05:29:02 -05:00
parent df36764e91
commit f948f9fca9
3 changed files with 16 additions and 0 deletions

View File

@@ -101,6 +101,7 @@ class BaseCPU(MemObject):
Counter totalInsts();
void scheduleInstStop(ThreadID tid, Counter insts, const char *cause);
void scheduleLoadStop(ThreadID tid, Counter loads, const char *cause);
uint64_t getCurrentInstCount(ThreadID tid);
''')
@classmethod

View File

@@ -691,6 +691,12 @@ BaseCPU::scheduleInstStop(ThreadID tid, Counter insts, const char *cause)
comInstEventQueue[tid]->schedule(event, now + insts);
}
uint64_t
BaseCPU::getCurrentInstCount(ThreadID tid)
{
return Tick(comInstEventQueue[tid]->getCurTick());
}
AddressMonitor::AddressMonitor() {
armed = false;
waiting = false;

View File

@@ -465,6 +465,15 @@ class BaseCPU : public MemObject
*/
void scheduleLoadStop(ThreadID tid, Counter loads, const char *cause);
/**
* Get the number of instructions executed by the specified thread
* on this CPU. Used by Python to control simulation.
*
* @param tid Thread monitor
* @return Number of instructions executed
*/
uint64_t getCurrentInstCount(ThreadID tid);
public:
/**
* @{