clocked_object.hh (10000:99bd071911cf) clocked_object.hh (10236:79af6cc0384d)
1/*
2 * Copyright (c) 2012-2013 ARM Limited
3 * Copyright (c) 2013 Cornell University
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

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

74 /**
75 * Prevent inadvertent use of the copy constructor and assignment
76 * operator by making them private.
77 */
78 ClockedObject(ClockedObject&);
79 ClockedObject& operator=(ClockedObject&);
80
81 /**
1/*
2 * Copyright (c) 2012-2013 ARM Limited
3 * Copyright (c) 2013 Cornell University
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

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

74 /**
75 * Prevent inadvertent use of the copy constructor and assignment
76 * operator by making them private.
77 */
78 ClockedObject(ClockedObject&);
79 ClockedObject& operator=(ClockedObject&);
80
81 /**
82 * Align cycle and tick to the next clock edge if not already done.
82 * Align cycle and tick to the next clock edge if not already done. When
83 * complete, tick must be at least curTick().
83 */
84 void update() const
85 {
86 // both tick and cycle are up-to-date and we are done, note
87 // that the >= is important as it captures cases where tick
88 // has already passed curTick()
89 if (tick >= curTick())
90 return;

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

149 *
150 */
151 inline void updateClockPeriod() const
152 {
153 update();
154 }
155
156 /**
84 */
85 void update() const
86 {
87 // both tick and cycle are up-to-date and we are done, note
88 // that the >= is important as it captures cases where tick
89 // has already passed curTick()
90 if (tick >= curTick())
91 return;

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

150 *
151 */
152 inline void updateClockPeriod() const
153 {
154 update();
155 }
156
157 /**
157 * Determine the tick when a cycle begins, by default the current
158 * one, but the argument also enables the caller to determine a
159 * future cycle.
158 * Determine the tick when a cycle begins, by default the current one, but
159 * the argument also enables the caller to determine a future cycle. When
160 * curTick() is on a clock edge, the number of cycles in the parameter is
161 * added to curTick() to be returned. When curTick() is not aligned to a
162 * clock edge, the number of cycles in the parameter is added to the next
163 * clock edge.
160 *
161 * @param cycles The number of cycles into the future
162 *
164 *
165 * @param cycles The number of cycles into the future
166 *
163 * @return The tick when the clock edge occurs
167 * @return The start tick when the requested clock edge occurs. Precisely,
168 * this tick can be
169 * curTick() + [0, clockPeriod()) + clockPeriod() * cycles
164 */
165 inline Tick clockEdge(Cycles cycles = Cycles(0)) const
166 {
167 // align tick to the next clock edge
168 update();
169
170 // figure out when this future cycle is
171 return tick + clockPeriod() * cycles;
172 }
173
174 /**
175 * Determine the current cycle, corresponding to a tick aligned to
176 * a clock edge.
177 *
170 */
171 inline Tick clockEdge(Cycles cycles = Cycles(0)) const
172 {
173 // align tick to the next clock edge
174 update();
175
176 // figure out when this future cycle is
177 return tick + clockPeriod() * cycles;
178 }
179
180 /**
181 * Determine the current cycle, corresponding to a tick aligned to
182 * a clock edge.
183 *
178 * @return The current cycle count
184 * @return When curTick() is on a clock edge, return the Cycle corresponding
185 * to that clock edge. When curTick() is not on a clock edge, return the
186 * Cycle corresponding to the next clock edge.
179 */
180 inline Cycles curCycle() const
181 {
182 // align cycle to the next clock edge.
183 update();
184
185 return cycle;
186 }
187
188 /**
187 */
188 inline Cycles curCycle() const
189 {
190 // align cycle to the next clock edge.
191 update();
192
193 return cycle;
194 }
195
196 /**
189 * Based on the clock of the object, determine the tick when the next
190 * cycle begins, in other words, return the next clock edge.
191 * (This can never be the current tick.)
197 * Based on the clock of the object, determine the start tick of the first
198 * cycle that is at least one cycle in the future. When curTick() is at the
199 * current cycle edge, this returns the next clock edge. When calling this
200 * during the middle of a cycle, this returns 2 clock edges in the future.
192 *
201 *
193 * @return The tick when the next cycle starts
202 * @return The start tick of the first cycle that is at least one cycle in
203 * the future. Precisely, the returned tick can be in the range
204 * curTick() + [clockPeriod(), 2 * clockPeriod())
194 */
195 Tick nextCycle() const
196 { return clockEdge(Cycles(1)); }
197
198 inline uint64_t frequency() const
199 {
200 return SimClock::Frequency / clockPeriod();
201 }

--- 12 unchanged lines hidden ---
205 */
206 Tick nextCycle() const
207 { return clockEdge(Cycles(1)); }
208
209 inline uint64_t frequency() const
210 {
211 return SimClock::Frequency / clockPeriod();
212 }

--- 12 unchanged lines hidden ---