diff options
Diffstat (limited to 'src/cpu/base.hh')
-rw-r--r-- | src/cpu/base.hh | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/src/cpu/base.hh b/src/cpu/base.hh index 13c56a945..52598fd22 100644 --- a/src/cpu/base.hh +++ b/src/cpu/base.hh @@ -63,6 +63,7 @@ #include "sim/full_system.hh" #include "sim/insttracer.hh" #include "sim/probe/pmu.hh" +#include "sim/probe/probe.hh" #include "sim/system.hh" #include "debug/Mwait.hh" @@ -277,7 +278,7 @@ class BaseCPU : public MemObject virtual void suspendContext(ThreadID thread_num); /// Notify the CPU that the indicated context is now halted. - virtual void haltContext(ThreadID thread_num) {} + virtual void haltContext(ThreadID thread_num); /// Given a Thread Context pointer return the thread num int findContext(ThreadContext *tc); @@ -489,6 +490,7 @@ class BaseCPU : public MemObject */ virtual void probeInstCommit(const StaticInstPtr &inst); + protected: /** * Helper method to instantiate probe points belonging to this * object. @@ -498,9 +500,6 @@ class BaseCPU : public MemObject */ ProbePoints::PMUUPtr pmuProbePoint(const char *name); - /** CPU cycle counter */ - ProbePoints::PMUUPtr ppCycles; - /** * Instruction commit probe point. * @@ -519,9 +518,58 @@ class BaseCPU : public MemObject /** Retired branches (any type) */ ProbePoints::PMUUPtr ppRetiredBranches; + /** CPU cycle counter even if any thread Context is suspended*/ + ProbePoints::PMUUPtr ppAllCycles; + + /** CPU cycle counter, only counts if any thread contexts is active **/ + ProbePoints::PMUUPtr ppActiveCycles; + + /** + * ProbePoint that signals transitions of threadContexts sets. + * The ProbePoint reports information through it bool parameter. + * - If the parameter is true then the last enabled threadContext of the + * CPU object was disabled. + * - If the parameter is false then a threadContext was enabled, all the + * remaining threadContexts are disabled. + */ + ProbePointArg<bool> *ppSleeping; /** @} */ + enum CPUState { + CPU_STATE_ON, + CPU_STATE_SLEEP, + CPU_STATE_WAKEUP + }; + + Cycles previousCycle; + CPUState previousState; + /** base method keeping track of cycle progression **/ + inline void updateCycleCounters(CPUState state) + { + uint32_t delta = curCycle() - previousCycle; + + if (previousState == CPU_STATE_ON) { + ppActiveCycles->notify(delta); + } + + switch (state) + { + case CPU_STATE_WAKEUP: + ppSleeping->notify(false); + break; + case CPU_STATE_SLEEP: + ppSleeping->notify(true); + break; + default: + break; + } + + ppAllCycles->notify(delta); + + previousCycle = curCycle(); + previousState = state; + } // Function tracing private: |