cpus_node.append(node)
yield cpus_node
+
+ def __init__(self, **kwargs):
+ super(BaseCPU, self).__init__(**kwargs)
+ self.power_state.possible_states=['ON', 'CLK_GATED', 'OFF']
# routine
default_state = Param.PwrState("UNDEFINED", "Default Power State")
+ # Possible power states this object can be in sorted from the most
+ # to the least performant
+ possible_states = VectorParam.PwrState(
+ [], "Power states this object can be in")
+
clk_gate_min = Param.Latency('1ns',"Min value of the distribution")
clk_gate_max = Param.Latency('1s',"Max value of the distribution")
clk_gate_bins = Param.Unsigned('20', "# bins in clk gated distribution")
PowerState::PowerState(const PowerStateParams *p) :
SimObject(p), _currState(p->default_state),
- stats(*this)
+ possibleStates(p->possible_states.begin(),
+ p->possible_states.end()),
+ prvEvalTick(0), stats(*this)
{
}
void
PowerState::set(Enums::PwrState p)
{
+ // Check if this power state is actually allowed by checking whether it is
+ // present in pwrStateToIndex-dictionary
+ panic_if(possibleStates.find(p) == possibleStates.end(),
+ "Cannot go to %s in %s \n", Enums::PwrStateStrings[p], name());
+
// Function should ideally be called only when there is a state change
if (_currState == p) {
warn_once("PowerState: Already in the requested power state, "
*/
void computeStats();
+ /**
+ * Return the power states this object can be in
+ */
+ std::set<Enums::PwrState> getPossibleStates() const
+ {
+ return possibleStates;
+ }
+
protected:
/** To keep track of the current power state */
Enums::PwrState _currState;
+ /** The possible power states this object can be in */
+ const std::set<Enums::PwrState> possibleStates;
+
/** Last tick the power stats were calculated */
Tick prvEvalTick = 0;