gem5 v24.0.0.0
|
Global system counter. More...
#include <generic_timer.hh>
Public Member Functions | |
SystemCounter (const SystemCounterParams &p) | |
bool | enabled () const |
Indicates if the counter is enabled. | |
uint32_t | freq () const |
Returns the counter frequency. | |
uint64_t | value () |
Updates and returns the counter value. | |
uint64_t | increment () const |
Returns the value increment. | |
std::vector< uint32_t > & | freqTable () |
Returns a reference to the frequency modes table. | |
size_t | activeFreqEntry () const |
Returns the currently active frequency table entry. | |
Tick | period () const |
Returns the counter period. | |
void | enable () |
Enables the counter after a CNTCR.EN == 1. | |
void | disable () |
Disables the counter after a CNTCR.EN == 0. | |
void | freqUpdateSchedule (size_t new_freq_entry) |
Schedules a counter frequency update after a CNTCR.FCREQ == 1 This complies with frequency transitions as per the architecture. | |
void | setValue (uint64_t new_value) |
Sets the value explicitly from writes to CNTCR.CNTCV. | |
void | registerListener (SystemCounterListener *listener) |
Called from System Counter Listeners to register. | |
Tick | whenValue (uint64_t target_val) |
Returns the tick at which a certain counter value is reached. | |
Tick | whenValue (uint64_t cur_val, uint64_t target_val) const |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. | |
Public Member Functions inherited from gem5::SimObject | |
const Params & | params () const |
SimObject (const Params &p) | |
virtual | ~SimObject () |
virtual void | init () |
init() is called after all C++ SimObjects have been created and all ports are connected. | |
virtual void | loadState (CheckpointIn &cp) |
loadState() is called on each SimObject when restoring from a checkpoint. | |
virtual void | initState () |
initState() is called on each SimObject when not restoring from a checkpoint. | |
virtual void | regProbePoints () |
Register probe points for this object. | |
virtual void | regProbeListeners () |
Register probe listeners for this object. | |
ProbeManager * | getProbeManager () |
Get the probe manager for this object. | |
virtual Port & | getPort (const std::string &if_name, PortID idx=InvalidPortID) |
Get a port with a given name and index. | |
virtual void | startup () |
startup() is the final initialization call before simulation. | |
DrainState | drain () override |
Provide a default implementation of the drain interface for objects that don't need draining. | |
virtual void | memWriteback () |
Write back dirty buffers to memory using functional writes. | |
virtual void | memInvalidate () |
Invalidate the contents of memory buffers. | |
Public Member Functions inherited from gem5::EventManager | |
EventQueue * | eventQueue () const |
void | schedule (Event &event, Tick when) |
void | deschedule (Event &event) |
void | reschedule (Event &event, Tick when, bool always=false) |
void | schedule (Event *event, Tick when) |
void | deschedule (Event *event) |
void | reschedule (Event *event, Tick when, bool always=false) |
void | wakeupEventQueue (Tick when=(Tick) -1) |
This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues which host gem5 on other schedulers. | |
void | setCurTick (Tick newVal) |
EventManager (EventManager &em) | |
Event manger manages events in the event queue. | |
EventManager (EventManager *em) | |
EventManager (EventQueue *eq) | |
Public Member Functions inherited from gem5::Serializable | |
Serializable () | |
virtual | ~Serializable () |
void | serializeSection (CheckpointOut &cp, const char *name) const |
Serialize an object into a new section. | |
void | serializeSection (CheckpointOut &cp, const std::string &name) const |
void | unserializeSection (CheckpointIn &cp, const char *name) |
Unserialize an a child object. | |
void | unserializeSection (CheckpointIn &cp, const std::string &name) |
Public Member Functions inherited from gem5::Drainable | |
DrainState | drainState () const |
Return the current drain state of an object. | |
virtual void | notifyFork () |
Notify a child process of a fork. | |
Public Member Functions inherited from gem5::statistics::Group | |
Group (Group *parent, const char *name=nullptr) | |
Construct a new statistics group. | |
virtual | ~Group () |
virtual void | regStats () |
Callback to set stat parameters. | |
virtual void | resetStats () |
Callback to reset stats. | |
virtual void | preDumpStats () |
Callback before stats are dumped. | |
void | addStat (statistics::Info *info) |
Register a stat with this group. | |
const std::map< std::string, Group * > & | getStatGroups () const |
Get all child groups associated with this object. | |
const std::vector< Info * > & | getStats () const |
Get all stats associated with this object. | |
void | addStatGroup (const char *name, Group *block) |
Add a stat block as a child of this block. | |
const Info * | resolveStat (std::string name) const |
Resolve a stat by its name within this group. | |
void | mergeStatGroup (Group *block) |
Merge the contents (stats & children) of a block to this block. | |
Group ()=delete | |
Group (const Group &)=delete | |
Group & | operator= (const Group &)=delete |
Public Member Functions inherited from gem5::Named | |
Named (const std::string &name_) | |
virtual | ~Named ()=default |
virtual std::string | name () const |
Static Public Member Functions | |
static void | validateCounterRef (SystemCounter *sys_cnt) |
Validates a System Counter reference. | |
Static Public Member Functions inherited from gem5::SimObject | |
static void | serializeAll (const std::string &cpt_dir) |
Create a checkpoint by serializing all SimObjects in the system. | |
static SimObject * | find (const char *name) |
Find the SimObject with the given name and return a pointer to it. | |
static void | setSimObjectResolver (SimObjectResolver *resolver) |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. | |
static SimObjectResolver * | getSimObjectResolver () |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. | |
Static Public Member Functions inherited from gem5::Serializable | |
static const std::string & | currentSection () |
Gets the fully-qualified name of the active section. | |
static void | generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream) |
Generate a checkpoint file so that the serialization can be routed to it. | |
Protected Attributes | |
bool | _enabled |
Indicates if the counter is enabled. | |
uint32_t | _freq |
Counter frequency (as specified by CNTFRQ). | |
uint64_t | _value |
Counter value (as specified in CNTCV). | |
uint64_t | _increment |
Value increment in each counter cycle. | |
std::vector< uint32_t > | _freqTable |
Frequency modes table with all possible frequencies for the counter. | |
size_t | _activeFreqEntry |
Currently selected entry in the table, its contents should match _freq. | |
Tick | _period |
Cached copy of the counter period (inverse of the frequency). | |
Tick | _updateTick |
Counter cycle start Tick when the counter status affecting its value has been updated. | |
std::vector< SystemCounterListener * > | _listeners |
Listeners to changes in counting speed. | |
Protected Attributes inherited from gem5::SimObject | |
const SimObjectParams & | _params |
Cached copy of the object parameters. | |
Protected Attributes inherited from gem5::EventManager | |
EventQueue * | eventq |
A pointer to this object's event queue. | |
Static Protected Attributes | |
static constexpr size_t | MAX_FREQ_ENTRIES = 1004 |
Maximum architectural number of frequency table entries. | |
Private Member Functions | |
SystemCounter (const SystemCounter &c) | |
void | freqUpdateCallback () |
Callback for the frequency update. | |
void | updateValue (void) |
Updates the counter value. | |
void | updateTick (void) |
Updates the update tick, normalizes to the lower cycle start tick. | |
void | notifyListeners (void) const |
Notifies counting speed changes to listeners. | |
Private Attributes | |
EventFunctionWrapper | _freqUpdateEvent |
Frequency update event handling. | |
size_t | _nextFreqEntry |
Additional Inherited Members | |
Public Types inherited from gem5::SimObject | |
typedef SimObjectParams | Params |
Protected Member Functions inherited from gem5::Drainable | |
Drainable () | |
virtual | ~Drainable () |
virtual void | drainResume () |
Resume execution after a successful drain. | |
void | signalDrainDone () const |
Signal that an object is drained. | |
Global system counter.
It is shared by the architected and memory-mapped timers.
Definition at line 86 of file generic_timer.hh.
gem5::SystemCounter::SystemCounter | ( | const SystemCounterParams & | p | ) |
Definition at line 67 of file generic_timer.cc.
References freqUpdateCallback().
|
private |
|
inline |
Returns the currently active frequency table entry.
Definition at line 131 of file generic_timer.hh.
References _activeFreqEntry.
Referenced by gem5::GenericTimerMem::counterCtrlRead(), and gem5::GenericTimerMem::counterCtrlWrite().
void gem5::SystemCounter::disable | ( | ) |
Disables the counter after a CNTCR.EN == 0.
Definition at line 106 of file generic_timer.cc.
References _enabled, DPRINTF, and updateValue().
Referenced by gem5::GenericTimerMem::counterCtrlWrite().
void gem5::SystemCounter::enable | ( | ) |
Enables the counter after a CNTCR.EN == 1.
Definition at line 98 of file generic_timer.cc.
References _enabled, DPRINTF, and updateTick().
Referenced by gem5::GenericTimerMem::counterCtrlWrite().
|
inline |
Indicates if the counter is enabled.
Definition at line 121 of file generic_timer.hh.
References _enabled.
Referenced by gem5::GenericTimerMem::counterCtrlRead(), and gem5::GenericTimerMem::counterCtrlWrite().
|
inline |
Returns the counter frequency.
Definition at line 123 of file generic_timer.hh.
References _freq.
Referenced by gem5::GenericTimer::setMiscReg(), gem5::GenericTimerMem::timerCtrlRead(), gem5::GenericTimerMem::timerCtrlWrite(), and gem5::GenericTimerFrame::timerRead().
|
inline |
Returns a reference to the frequency modes table.
Definition at line 129 of file generic_timer.hh.
References _freqTable.
Referenced by gem5::GenericTimerMem::counterCtrlRead(), and gem5::GenericTimerMem::counterCtrlWrite().
|
private |
Callback for the frequency update.
Definition at line 191 of file generic_timer.cc.
References _activeFreqEntry, _enabled, _freq, _freqTable, _increment, _nextFreqEntry, _period, DPRINTF, gem5::sim_clock::Frequency, notifyListeners(), and updateValue().
Referenced by SystemCounter().
void gem5::SystemCounter::freqUpdateSchedule | ( | size_t | new_freq_entry | ) |
Schedules a counter frequency update after a CNTCR.FCREQ == 1 This complies with frequency transitions as per the architecture.
new_freq_entry | Index in CNTFID of the new freq |
Definition at line 173 of file generic_timer.cc.
References _freq, _freqTable, _freqUpdateEvent, _increment, _nextFreqEntry, gem5::EventManager::reschedule(), value(), and whenValue().
Referenced by gem5::GenericTimerMem::counterCtrlWrite().
|
inline |
Returns the value increment.
Definition at line 127 of file generic_timer.hh.
References _increment.
|
private |
Notifies counting speed changes to listeners.
Definition at line 211 of file generic_timer.cc.
References _listeners.
Referenced by freqUpdateCallback(), and setValue().
|
inline |
void gem5::SystemCounter::registerListener | ( | SystemCounterListener * | listener | ) |
Called from System Counter Listeners to register.
Definition at line 205 of file generic_timer.cc.
References _listeners.
|
overridevirtual |
Serialize an object.
Output an object's state into the current checkpoint section.
cp | Checkpoint state |
Reimplemented from gem5::SimObject.
Definition at line 218 of file generic_timer.cc.
References _activeFreqEntry, _enabled, _freq, _freqTable, _freqUpdateEvent, _increment, _nextFreqEntry, _updateTick, _value, DPRINTF, gem5::Event::scheduled(), SERIALIZE_CONTAINER, SERIALIZE_SCALAR, and gem5::Event::when().
void gem5::SystemCounter::setValue | ( | uint64_t | new_value | ) |
Sets the value explicitly from writes to CNTCR.CNTCV.
Definition at line 133 of file generic_timer.cc.
References _enabled, _value, notifyListeners(), updateTick(), and warn.
Referenced by gem5::GenericTimerMem::counterCtrlWrite().
|
overridevirtual |
Unserialize an object.
Read an object's state from the current checkpoint section.
cp | Checkpoint state |
Reimplemented from gem5::SimObject.
Definition at line 238 of file generic_timer.cc.
References _activeFreqEntry, _enabled, _freq, _freqTable, _freqUpdateEvent, _increment, _nextFreqEntry, _period, _updateTick, _value, DPRINTF, gem5::sim_clock::Frequency, gem5::EventManager::reschedule(), UNSERIALIZE_CONTAINER, and UNSERIALIZE_SCALAR.
|
private |
Updates the update tick, normalizes to the lower cycle start tick.
Definition at line 167 of file generic_timer.cc.
References _period, _updateTick, and gem5::curTick().
Referenced by enable(), setValue(), and updateValue().
|
private |
Updates the counter value.
Definition at line 122 of file generic_timer.cc.
References _increment, _period, _updateTick, _value, gem5::curTick(), and updateTick().
Referenced by disable(), freqUpdateCallback(), and value().
|
static |
Validates a System Counter reference.
sys_cnt | System counter reference to validate |
Definition at line 91 of file generic_timer.cc.
References fatal_if.
Referenced by gem5::GenericTimer::GenericTimer(), and gem5::GenericTimerMem::GenericTimerMem().
uint64_t gem5::SystemCounter::value | ( | ) |
Updates and returns the counter value.
Definition at line 114 of file generic_timer.cc.
References _enabled, _value, and updateValue().
Referenced by gem5::GenericTimerMem::counterCtrlRead(), gem5::GenericTimerMem::counterCtrlWrite(), gem5::GenericTimerMem::counterStatusRead(), freqUpdateSchedule(), gem5::GenericWatchdog::refresh(), gem5::ArchTimer::value(), and whenValue().
Tick gem5::SystemCounter::whenValue | ( | uint64_t | cur_val, |
uint64_t | target_val ) const |
Definition at line 143 of file generic_timer.cc.
References _increment, _period, and gem5::curTick().
Tick gem5::SystemCounter::whenValue | ( | uint64_t | target_val | ) |
Returns the tick at which a certain counter value is reached.
Definition at line 161 of file generic_timer.cc.
References value(), and whenValue().
Referenced by freqUpdateSchedule(), gem5::GenericWatchdog::refresh(), gem5::ArchTimer::whenValue(), and whenValue().
|
protected |
Currently selected entry in the table, its contents should match _freq.
Definition at line 100 of file generic_timer.hh.
Referenced by activeFreqEntry(), freqUpdateCallback(), serialize(), and unserialize().
|
protected |
Indicates if the counter is enabled.
Definition at line 90 of file generic_timer.hh.
Referenced by disable(), enable(), enabled(), freqUpdateCallback(), serialize(), setValue(), unserialize(), and value().
|
protected |
Counter frequency (as specified by CNTFRQ).
Definition at line 92 of file generic_timer.hh.
Referenced by freq(), freqUpdateCallback(), freqUpdateSchedule(), serialize(), and unserialize().
|
protected |
Frequency modes table with all possible frequencies for the counter.
Definition at line 98 of file generic_timer.hh.
Referenced by freqTable(), freqUpdateCallback(), freqUpdateSchedule(), serialize(), and unserialize().
|
private |
Frequency update event handling.
Definition at line 163 of file generic_timer.hh.
Referenced by freqUpdateSchedule(), serialize(), and unserialize().
|
protected |
Value increment in each counter cycle.
Definition at line 96 of file generic_timer.hh.
Referenced by freqUpdateCallback(), freqUpdateSchedule(), increment(), serialize(), unserialize(), updateValue(), and whenValue().
|
protected |
Listeners to changes in counting speed.
Definition at line 108 of file generic_timer.hh.
Referenced by notifyListeners(), and registerListener().
|
private |
Definition at line 164 of file generic_timer.hh.
Referenced by freqUpdateCallback(), freqUpdateSchedule(), serialize(), and unserialize().
|
protected |
Cached copy of the counter period (inverse of the frequency).
Definition at line 102 of file generic_timer.hh.
Referenced by freqUpdateCallback(), period(), unserialize(), updateTick(), updateValue(), and whenValue().
|
protected |
Counter cycle start Tick when the counter status affecting its value has been updated.
Definition at line 105 of file generic_timer.hh.
Referenced by serialize(), unserialize(), updateTick(), and updateValue().
|
protected |
Counter value (as specified in CNTCV).
Definition at line 94 of file generic_timer.hh.
Referenced by serialize(), setValue(), unserialize(), updateValue(), and value().
|
staticconstexprprotected |
Maximum architectural number of frequency table entries.
Definition at line 111 of file generic_timer.hh.