/*
- * Copyright (c) 2015 ARM Limited
+ * Copyright (c) 2015-2016 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
#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;
}
- // No need to compute stats if in the same tick, update state
- // though. This can happen in cases like a) during start of the
- // simulation multiple state changes happens in init/startup phase,
- // b) one takes a decision to migrate state but decides to reverts
- // back to the original state in the 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");
+ // No need to compute stats if in the same tick, update state though. This
+ // can happen in cases like a) during start of the simulation multiple
+ // state changes happens in init/startup phase, b) one takes a decision to
+ // migrate state but decides to reverts back to the original state in the
+ // 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() && curTick() != 0) {
+ warn("ClockedObject %s: More than one power state change request "\
+ "encountered within the same simulation tick %d",
+ name(), prvEvalTick);
_currPwrState = p;
return;
}
ret.resize(Enums::PwrState::Num_PwrState);
for (unsigned i = 0; i < Enums::PwrState::Num_PwrState; i++)
- ret[i] = residencies[i] /
+ ret[i] = residencies[i] / \
(pwrStateResidencyTicks.total() + elapsed_time);
return ret;
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]);