diff options
Diffstat (limited to 'src/sim/clocked_object.hh')
-rw-r--r-- | src/sim/clocked_object.hh | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/sim/clocked_object.hh b/src/sim/clocked_object.hh index b9a2481ec..1ba5ca617 100644 --- a/src/sim/clocked_object.hh +++ b/src/sim/clocked_object.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2013 ARM Limited + * Copyright (c) 2012-2013, 2015 ARM Limited * Copyright (c) 2013 Cornell University * All rights reserved * @@ -37,6 +37,8 @@ * * Authors: Andreas Hansson * Christopher Torng + * Akash Bagdia + * David Guillen Fandos */ /** @@ -47,8 +49,10 @@ #ifndef __SIM_CLOCKED_OBJECT_HH__ #define __SIM_CLOCKED_OBJECT_HH__ +#include "base/callback.hh" #include "base/intmath.hh" #include "base/misc.hh" +#include "enums/PwrState.hh" #include "params/ClockedObject.hh" #include "sim/core.hh" #include "sim/clock_domain.hh" @@ -233,7 +237,58 @@ class ClockedObject { public: ClockedObject(const ClockedObjectParams *p) - : SimObject(p), Clocked(*p->clk_domain) { } + : SimObject(p), Clocked(*p->clk_domain), + _currPwrState(p->default_p_state), + prvEvalTick(0) + { } + + /** Parameters of ClockedObject */ + typedef ClockedObjectParams Params; + const Params* params() const + { return reinterpret_cast<const Params*>(_params); } + + void serialize(CheckpointOut &cp) const override; + void unserialize(CheckpointIn &cp) override; + + inline Enums::PwrState pwrState() const + { return _currPwrState; } + + inline std::string pwrStateName() const + { return Enums::PwrStateStrings[_currPwrState]; } + + /** Returns the percentage residency for each power state */ + std::vector<double> pwrStateWeights() const; + + /** + * Record stats values like state residency by computing the time + * difference from previous update. Also, updates the previous + * evaluation tick once all stats are recorded. + * Usually called on power state change and stats dump callback. + */ + void computeStats(); + + void pwrState(Enums::PwrState); + void regStats(); + + protected: + + /** To keep track of the current power state */ + Enums::PwrState _currPwrState; + + Tick prvEvalTick; + + Stats::Scalar numPwrStateTransitions; + Stats::Distribution pwrStateClkGateDist; + Stats::Vector pwrStateResidencyTicks; + +}; + +class ClockedObjectDumpCallback : public Callback +{ + ClockedObject *co; + public: + ClockedObjectDumpCallback(ClockedObject *co_t) : co(co_t) {} + virtual void process() { co->computeStats(); }; }; #endif //__SIM_CLOCKED_OBJECT_HH__ |