clocked_object.hh (10236:79af6cc0384d) | clocked_object.hh (11009:32e374b7cbdb) |
---|---|
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 --- 41 unchanged lines hidden (view full) --- 50#include "base/intmath.hh" 51#include "base/misc.hh" 52#include "params/ClockedObject.hh" 53#include "sim/core.hh" 54#include "sim/clock_domain.hh" 55#include "sim/sim_object.hh" 56 57/** | 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 --- 41 unchanged lines hidden (view full) --- 50#include "base/intmath.hh" 51#include "base/misc.hh" 52#include "params/ClockedObject.hh" 53#include "sim/core.hh" 54#include "sim/clock_domain.hh" 55#include "sim/sim_object.hh" 56 57/** |
58 * The ClockedObject class extends the SimObject with a clock and 59 * accessor functions to relate ticks to the cycles of the object. | 58 * Helper class for objects that need to be clocked. Clocked objects 59 * typically inherit from this class. Objects that need SimObject 60 * functionality as well should inherit from ClockedObject. |
60 */ | 61 */ |
61class ClockedObject : public SimObject | 62class Clocked |
62{ 63 64 private: | 63{ 64 65 private: |
65 | |
66 // the tick value of the next clock edge (>= curTick()) at the 67 // time of the last call to update() 68 mutable Tick tick; 69 70 // The cycle counter value corresponding to the current value of 71 // 'tick' 72 mutable Cycles cycle; 73 74 /** | 66 // the tick value of the next clock edge (>= curTick()) at the 67 // time of the last call to update() 68 mutable Tick tick; 69 70 // The cycle counter value corresponding to the current value of 71 // 'tick' 72 mutable Cycles cycle; 73 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. When 83 * complete, tick must be at least curTick(). 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() --- 23 unchanged lines hidden (view full) --- 113 ClockDomain &clockDomain; 114 115 protected: 116 117 /** 118 * Create a clocked object and set the clock domain based on the 119 * parameters. 120 */ | 75 * Align cycle and tick to the next clock edge if not already done. When 76 * complete, tick must be at least curTick(). 77 */ 78 void update() const 79 { 80 // both tick and cycle are up-to-date and we are done, note 81 // that the >= is important as it captures cases where tick 82 // has already passed curTick() --- 23 unchanged lines hidden (view full) --- 106 ClockDomain &clockDomain; 107 108 protected: 109 110 /** 111 * Create a clocked object and set the clock domain based on the 112 * parameters. 113 */ |
121 ClockedObject(const ClockedObjectParams* p) : 122 SimObject(p), tick(0), cycle(0), clockDomain(*p->clk_domain) | 114 Clocked(ClockDomain &clk_domain) 115 : tick(0), cycle(0), clockDomain(clk_domain) |
123 { 124 // Register with the clock domain, so that if the clock domain 125 // frequency changes, we can update this object's tick. 126 clockDomain.registerWithClockDomain(this); 127 } 128 | 116 { 117 // Register with the clock domain, so that if the clock domain 118 // frequency changes, we can update this object's tick. 119 clockDomain.registerWithClockDomain(this); 120 } 121 |
122 Clocked(Clocked &) = delete; 123 Clocked &operator=(Clocked &) = delete; 124 |
|
129 /** 130 * Virtual destructor due to inheritance. 131 */ | 125 /** 126 * Virtual destructor due to inheritance. 127 */ |
132 virtual ~ClockedObject() { } | 128 virtual ~Clocked() { } |
133 134 /** 135 * Reset the object's clock using the current global tick value. Likely 136 * to be used only when the global clock is reset. Currently, this done 137 * only when Ruby is done warming up the memory system. 138 */ 139 void resetClock() const 140 { --- 75 unchanged lines hidden (view full) --- 216 return clockDomain.clockPeriod(); 217 } 218 219 inline Cycles ticksToCycles(Tick t) const 220 { return Cycles(divCeil(t, clockPeriod())); } 221 222}; 223 | 129 130 /** 131 * Reset the object's clock using the current global tick value. Likely 132 * to be used only when the global clock is reset. Currently, this done 133 * only when Ruby is done warming up the memory system. 134 */ 135 void resetClock() const 136 { --- 75 unchanged lines hidden (view full) --- 212 return clockDomain.clockPeriod(); 213 } 214 215 inline Cycles ticksToCycles(Tick t) const 216 { return Cycles(divCeil(t, clockPeriod())); } 217 218}; 219 |
220/** 221 * The ClockedObject class extends the SimObject with a clock and 222 * accessor functions to relate ticks to the cycles of the object. 223 */ 224class ClockedObject 225 : public SimObject, public Clocked 226{ 227 public: 228 ClockedObject(const ClockedObjectParams *p) 229 : SimObject(p), Clocked(*p->clk_domain) { } 230}; 231 |
|
224#endif //__SIM_CLOCKED_OBJECT_HH__ | 232#endif //__SIM_CLOCKED_OBJECT_HH__ |