clocked_object.cc (11424:e07fd01651f3) clocked_object.cc (11524:3101ce98c55c)
1/*
1/*
2 * Copyright (c) 2015 ARM Limited
2 * Copyright (c) 2015-2016 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

--- 25 unchanged lines hidden (view full) ---

36 *
37 * Authors: Akash Bagdia
38 * David Guillen Fandos
39 */
40
41#include "sim/clocked_object.hh"
42
43#include "base/misc.hh"
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

--- 25 unchanged lines hidden (view full) ---

36 *
37 * Authors: Akash Bagdia
38 * David Guillen Fandos
39 */
40
41#include "sim/clocked_object.hh"
42
43#include "base/misc.hh"
44#include "sim/power/power_model.hh"
45
44
46ClockedObject::ClockedObject(const ClockedObjectParams *p) :
47 SimObject(p), Clocked(*p->clk_domain),
48 _currPwrState(p->default_p_state),
49 prvEvalTick(0)
50{
51 // Register the power_model with the object
52 if (p->power_model)
53 p->power_model->setClockedObject(this);
54}
55
56void
57ClockedObject::serialize(CheckpointOut &cp) const
58{
59 unsigned int currPwrState = (unsigned int)_currPwrState;
60
61 SERIALIZE_SCALAR(currPwrState);
62 SERIALIZE_SCALAR(prvEvalTick);
63}

--- 14 unchanged lines hidden (view full) ---

78{
79 // Function should ideally be called only when there is a state change
80 if (_currPwrState == p) {
81 warn("ClockedObject: Already in the requested power state, request "\
82 "ignored");
83 return;
84 }
85
45void
46ClockedObject::serialize(CheckpointOut &cp) const
47{
48 unsigned int currPwrState = (unsigned int)_currPwrState;
49
50 SERIALIZE_SCALAR(currPwrState);
51 SERIALIZE_SCALAR(prvEvalTick);
52}

--- 14 unchanged lines hidden (view full) ---

67{
68 // Function should ideally be called only when there is a state change
69 if (_currPwrState == p) {
70 warn("ClockedObject: Already in the requested power state, request "\
71 "ignored");
72 return;
73 }
74
86 // No need to compute stats if in the same tick, update state
87 // though. This can happen in cases like a) during start of the
88 // simulation multiple state changes happens in init/startup phase,
89 // b) one takes a decision to migrate state but decides to reverts
90 // back to the original state in the same tick if other conditions
91 // are not met elsewhere. Any state change related stats would have
92 // been recorded on previous call to the pwrState() function.
75 // No need to compute stats if in the same tick, update state though. This
76 // can happen in cases like a) during start of the simulation multiple
77 // state changes happens in init/startup phase, b) one takes a decision to
78 // migrate state but decides to reverts back to the original state in the
79 // same tick if other conditions are not met elsewhere.
80 // Any state change related stats would have been recorded on previous call
81 // to the pwrState() function.
93 if (prvEvalTick == curTick()) {
94 warn("ClockedObject: More than one power state change request "\
95 "encountered within the same simulation tick");
96 _currPwrState = p;
97 return;
98 }
99
100 // Record stats for previous state.

--- 31 unchanged lines hidden (view full) ---

132 pwrStateResidencyTicks.value(residencies);
133
134 // Account for current state too!
135 Tick elapsed_time = curTick() - prvEvalTick;
136 residencies[_currPwrState] += elapsed_time;
137
138 ret.resize(Enums::PwrState::Num_PwrState);
139 for (unsigned i = 0; i < Enums::PwrState::Num_PwrState; i++)
82 if (prvEvalTick == curTick()) {
83 warn("ClockedObject: More than one power state change request "\
84 "encountered within the same simulation tick");
85 _currPwrState = p;
86 return;
87 }
88
89 // Record stats for previous state.

--- 31 unchanged lines hidden (view full) ---

121 pwrStateResidencyTicks.value(residencies);
122
123 // Account for current state too!
124 Tick elapsed_time = curTick() - prvEvalTick;
125 residencies[_currPwrState] += elapsed_time;
126
127 ret.resize(Enums::PwrState::Num_PwrState);
128 for (unsigned i = 0; i < Enums::PwrState::Num_PwrState; i++)
140 ret[i] = residencies[i] /
129 ret[i] = residencies[i] / \
141 (pwrStateResidencyTicks.total() + elapsed_time);
142
143 return ret;
144}
145
146void
147ClockedObject::regStats()
148{

--- 40 unchanged lines hidden ---
130 (pwrStateResidencyTicks.total() + elapsed_time);
131
132 return ret;
133}
134
135void
136ClockedObject::regStats()
137{

--- 40 unchanged lines hidden ---