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:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
/**
|
||||
* @{
|
||||
|
||||
Reference in New Issue
Block a user