#include "sim/clocked_object.hh"
#include "base/misc.hh"
+#include "sim/power/power_model.hh"
+
+ClockedObject::ClockedObject(const ClockedObjectParams *p) :
+ SimObject(p), Clocked(*p->clk_domain),
+ _currPwrState(p->default_p_state),
+ prvEvalTick(0)
+{
+ // Register the power_model with the object
+ for (auto & power_model: p->power_model)
+ power_model->setClockedObject(this);
+}
void
ClockedObject::serialize(CheckpointOut &cp) const
{
// Function should ideally be called only when there is a state change
if (_currPwrState == p) {
- warn("ClockedObject: Already in the requested power state, request "\
- "ignored");
+ warn_once("ClockedObject: Already in the requested power state, " \
+ "request ignored");
return;
}
// same tick if other conditions are not met elsewhere.
// Any state change related stats would have been recorded on previous call
// to the pwrState() function.
- if (prvEvalTick == curTick()) {
- warn("ClockedObject: More than one power state change request "\
- "encountered within the same simulation tick");
+ if (prvEvalTick == curTick() && curTick() != 0) {
+ warn("ClockedObject %s: More than one power state change request "\
+ "encountered within the same simulation tick %d",
+ name(), prvEvalTick);
_currPwrState = p;
return;
}
numPwrStateTransitions
.name(params()->name + ".numPwrStateTransitions")
.desc("Number of power state transitions")
+ .flags(nozero)
;
// Each sample is time in ticks
(params()->p_state_clk_gate_max / num_bins))
.name(params()->name + ".pwrStateClkGateDist")
.desc("Distribution of time spent in the clock gated state")
- .flags(pdf)
+ .flags(pdf | nozero | nonan)
;
pwrStateResidencyTicks
.init(Enums::PwrState::Num_PwrState)
.name(params()->name + ".pwrStateResidencyTicks")
.desc("Cumulative time (in ticks) in various power states")
+ .flags(nozero)
;
for (int i = 0; i < Enums::PwrState::Num_PwrState; i++) {
pwrStateResidencyTicks.subname(i, Enums::PwrStateStrings[i]);