gem5
v20.1.0.0
|
Global system counter. More...
#include <generic_timer.hh>
Public Member Functions | |
SystemCounter (SystemCounterParams *const p) | |
bool | enabled () const |
Indicates if the counter is enabled. More... | |
uint32_t | freq () const |
Returns the counter frequency. More... | |
uint64_t | value () |
Updates and returns the counter value. More... | |
uint64_t | increment () const |
Returns the value increment. More... | |
std::vector< uint32_t > & | freqTable () |
Returns a reference to the frequency modes table. More... | |
size_t | activeFreqEntry () const |
Returns the currently active frequency table entry. More... | |
Tick | period () const |
Returns the counter period. More... | |
void | enable () |
Enables the counter after a CNTCR.EN == 1. More... | |
void | disable () |
Disables the counter after a CNTCR.EN == 0. More... | |
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. More... | |
void | setValue (uint64_t new_value) |
Sets the value explicitly from writes to CNTCR.CNTCV. More... | |
void | registerListener (SystemCounterListener *listener) |
Called from System Counter Listeners to register. More... | |
Tick | whenValue (uint64_t target_val) |
Returns the tick at which a certain counter value is reached. More... | |
Tick | whenValue (uint64_t cur_val, uint64_t target_val) const |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. More... | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. More... | |
Public Member Functions inherited from SimObject | |
const Params * | params () const |
SimObject (const Params *_params) | |
virtual | ~SimObject () |
virtual const std::string | name () const |
virtual void | init () |
init() is called after all C++ SimObjects have been created and all ports are connected. More... | |
virtual void | loadState (CheckpointIn &cp) |
loadState() is called on each SimObject when restoring from a checkpoint. More... | |
virtual void | initState () |
initState() is called on each SimObject when not restoring from a checkpoint. More... | |
virtual void | regProbePoints () |
Register probe points for this object. More... | |
virtual void | regProbeListeners () |
Register probe listeners for this object. More... | |
ProbeManager * | getProbeManager () |
Get the probe manager for this object. More... | |
virtual Port & | getPort (const std::string &if_name, PortID idx=InvalidPortID) |
Get a port with a given name and index. More... | |
virtual void | startup () |
startup() is the final initialization call before simulation. More... | |
DrainState | drain () override |
Provide a default implementation of the drain interface for objects that don't need draining. More... | |
virtual void | memWriteback () |
Write back dirty buffers to memory using functional writes. More... | |
virtual void | memInvalidate () |
Invalidate the contents of memory buffers. More... | |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. More... | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. More... | |
Public Member Functions inherited from 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. More... | |
void | setCurTick (Tick newVal) |
EventManager (EventManager &em) | |
Event manger manages events in the event queue. More... | |
EventManager (EventManager *em) | |
EventManager (EventQueue *eq) | |
Public Member Functions inherited from Serializable | |
Serializable () | |
virtual | ~Serializable () |
void | serializeSection (CheckpointOut &cp, const char *name) const |
Serialize an object into a new section. More... | |
void | serializeSection (CheckpointOut &cp, const std::string &name) const |
void | unserializeSection (CheckpointIn &cp, const char *name) |
Unserialize an a child object. More... | |
void | unserializeSection (CheckpointIn &cp, const std::string &name) |
Public Member Functions inherited from Drainable | |
DrainState | drainState () const |
Return the current drain state of an object. More... | |
virtual void | notifyFork () |
Notify a child process of a fork. More... | |
Public Member Functions inherited from Stats::Group | |
Group (Group *parent, const char *name=nullptr) | |
Construct a new statistics group. More... | |
virtual | ~Group () |
virtual void | regStats () |
Callback to set stat parameters. More... | |
virtual void | resetStats () |
Callback to reset stats. More... | |
virtual void | preDumpStats () |
Callback before stats are dumped. More... | |
void | addStat (Stats::Info *info) |
Register a stat with this group. More... | |
const std::map< std::string, Group * > & | getStatGroups () const |
Get all child groups associated with this object. More... | |
const std::vector< Info * > & | getStats () const |
Get all stats associated with this object. More... | |
void | addStatGroup (const char *name, Group *block) |
Add a stat block as a child of this block. More... | |
const Info * | resolveStat (std::string name) const |
Resolve a stat by its name within this group. More... | |
Group ()=delete | |
Group (const Group &)=delete | |
Group & | operator= (const Group &)=delete |
Static Public Member Functions | |
static void | validateCounterRef (SystemCounter *sys_cnt) |
Validates a System Counter reference. More... | |
Static Public Member Functions inherited from SimObject | |
static void | serializeAll (CheckpointOut &cp) |
Serialize all SimObjects in the system. More... | |
static SimObject * | find (const char *name) |
Find the SimObject with the given name and return a pointer to it. More... | |
Static Public Member Functions inherited from Serializable | |
static const std::string & | currentSection () |
Gets the fully-qualified name of the active section. More... | |
static void | serializeAll (const std::string &cpt_dir) |
Serializes all the SimObjects. More... | |
static void | unserializeGlobals (CheckpointIn &cp) |
Protected Attributes | |
bool | _enabled |
Indicates if the counter is enabled. More... | |
uint32_t | _freq |
Counter frequency (as specified by CNTFRQ). More... | |
uint64_t | _value |
Counter value (as specified in CNTCV). More... | |
uint64_t | _increment |
Value increment in each counter cycle. More... | |
std::vector< uint32_t > | _freqTable |
Frequency modes table with all possible frequencies for the counter. More... | |
size_t | _activeFreqEntry |
Currently selected entry in the table, its contents should match _freq. More... | |
Tick | _period |
Cached copy of the counter period (inverse of the frequency). More... | |
Tick | _updateTick |
Counter cycle start Tick when the counter status affecting its value has been updated. More... | |
std::vector< SystemCounterListener * > | _listeners |
Listeners to changes in counting speed. More... | |
Protected Attributes inherited from SimObject | |
const SimObjectParams * | _params |
Cached copy of the object parameters. More... | |
Protected Attributes inherited from EventManager | |
EventQueue * | eventq |
A pointer to this object's event queue. More... | |
Static Protected Attributes | |
static constexpr size_t | MAX_FREQ_ENTRIES = 1004 |
Maximum architectural number of frequency table entries. More... | |
Private Member Functions | |
SystemCounter (const SystemCounter &c) | |
void | freqUpdateCallback () |
Callback for the frequency update. More... | |
void | updateValue (void) |
Updates the counter value. More... | |
void | updateTick (void) |
Updates the update tick, normalizes to the lower cycle start tick. More... | |
void | notifyListeners (void) const |
Notifies counting speed changes to listeners. More... | |
Private Attributes | |
EventFunctionWrapper | _freqUpdateEvent |
Frequency update event handling. More... | |
size_t | _nextFreqEntry |
Additional Inherited Members | |
Public Types inherited from SimObject | |
typedef SimObjectParams | Params |
Protected Member Functions inherited from Drainable | |
Drainable () | |
virtual | ~Drainable () |
virtual void | drainResume () |
Resume execution after a successful drain. More... | |
void | signalDrainDone () const |
Signal that an object is drained. More... | |
Global system counter.
It is shared by the architected and memory-mapped timers.
Definition at line 75 of file generic_timer.hh.
SystemCounter::SystemCounter | ( | SystemCounterParams *const | p | ) |
Definition at line 55 of file generic_timer.cc.
References freqUpdateCallback().
|
private |
|
inline |
Returns the currently active frequency table entry.
Definition at line 120 of file generic_timer.hh.
References _activeFreqEntry.
Referenced by GenericTimerMem::counterCtrlRead(), and GenericTimerMem::counterCtrlWrite().
void SystemCounter::disable | ( | ) |
Disables the counter after a CNTCR.EN == 0.
Definition at line 94 of file generic_timer.cc.
References _enabled, DPRINTF, and updateValue().
Referenced by GenericTimerMem::counterCtrlWrite().
void SystemCounter::enable | ( | ) |
Enables the counter after a CNTCR.EN == 1.
Definition at line 86 of file generic_timer.cc.
References _enabled, DPRINTF, and updateTick().
Referenced by GenericTimerMem::counterCtrlWrite().
|
inline |
Indicates if the counter is enabled.
Definition at line 110 of file generic_timer.hh.
References _enabled.
Referenced by GenericTimerMem::counterCtrlRead(), and GenericTimerMem::counterCtrlWrite().
|
inline |
Returns the counter frequency.
Definition at line 112 of file generic_timer.hh.
References _freq.
Referenced by GenericTimer::setMiscReg(), GenericTimerMem::timerCtrlRead(), GenericTimerMem::timerCtrlWrite(), and GenericTimerFrame::timerRead().
|
inline |
Returns a reference to the frequency modes table.
Definition at line 118 of file generic_timer.hh.
References _freqTable.
Referenced by GenericTimerMem::counterCtrlRead(), and GenericTimerMem::counterCtrlWrite().
|
private |
Callback for the frequency update.
Definition at line 179 of file generic_timer.cc.
References _activeFreqEntry, _enabled, _freq, _freqTable, _increment, _nextFreqEntry, _period, DPRINTF, SimClock::Frequency, notifyListeners(), and updateValue().
Referenced by SystemCounter().
void 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 161 of file generic_timer.cc.
References _freq, _freqTable, _freqUpdateEvent, _increment, _nextFreqEntry, EventManager::reschedule(), value(), and whenValue().
Referenced by GenericTimerMem::counterCtrlWrite().
|
inline |
Returns the value increment.
Definition at line 116 of file generic_timer.hh.
References _increment.
|
private |
Notifies counting speed changes to listeners.
Definition at line 199 of file generic_timer.cc.
References _listeners.
Referenced by freqUpdateCallback(), and setValue().
|
inline |
void SystemCounter::registerListener | ( | SystemCounterListener * | listener | ) |
Called from System Counter Listeners to register.
Definition at line 193 of file generic_timer.cc.
References _listeners.
|
overridevirtual |
Serialize an object.
Output an object's state into the current checkpoint section.
cp | Checkpoint state |
Implements Serializable.
Definition at line 206 of file generic_timer.cc.
References _activeFreqEntry, _enabled, _freq, _freqTable, _freqUpdateEvent, _increment, _nextFreqEntry, _updateTick, _value, DPRINTF, Event::scheduled(), SERIALIZE_CONTAINER, SERIALIZE_SCALAR, and Event::when().
void SystemCounter::setValue | ( | uint64_t | new_value | ) |
Sets the value explicitly from writes to CNTCR.CNTCV.
Definition at line 121 of file generic_timer.cc.
References _enabled, _value, notifyListeners(), updateTick(), and warn.
Referenced by GenericTimerMem::counterCtrlWrite().
|
overridevirtual |
Unserialize an object.
Read an object's state from the current checkpoint section.
cp | Checkpoint state |
Implements Serializable.
Definition at line 226 of file generic_timer.cc.
References _activeFreqEntry, _enabled, _freq, _freqTable, _freqUpdateEvent, _increment, _nextFreqEntry, _period, _updateTick, _value, DPRINTF, SimClock::Frequency, EventManager::reschedule(), UNSERIALIZE_CONTAINER, and UNSERIALIZE_SCALAR.
|
private |
Updates the update tick, normalizes to the lower cycle start tick.
Definition at line 155 of file generic_timer.cc.
References _period, _updateTick, and curTick().
Referenced by enable(), setValue(), and updateValue().
|
private |
Updates the counter value.
Definition at line 110 of file generic_timer.cc.
References _increment, _period, _updateTick, _value, 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 79 of file generic_timer.cc.
References fatal_if.
Referenced by GenericTimer::GenericTimer().
uint64_t SystemCounter::value | ( | ) |
Updates and returns the counter value.
Definition at line 102 of file generic_timer.cc.
References _enabled, _value, and updateValue().
Referenced by GenericTimerMem::counterCtrlRead(), GenericTimerMem::counterCtrlWrite(), GenericTimerMem::counterStatusRead(), freqUpdateSchedule(), ArchTimer::value(), and whenValue().
Tick SystemCounter::whenValue | ( | uint64_t | cur_val, |
uint64_t | target_val | ||
) | const |
Definition at line 131 of file generic_timer.cc.
References _increment, _period, and curTick().
Tick SystemCounter::whenValue | ( | uint64_t | target_val | ) |
Returns the tick at which a certain counter value is reached.
Definition at line 149 of file generic_timer.cc.
References value().
Referenced by freqUpdateSchedule(), and ArchTimer::whenValue().
|
protected |
Currently selected entry in the table, its contents should match _freq.
Definition at line 89 of file generic_timer.hh.
Referenced by activeFreqEntry(), freqUpdateCallback(), serialize(), and unserialize().
|
protected |
Indicates if the counter is enabled.
Definition at line 79 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 81 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 87 of file generic_timer.hh.
Referenced by freqTable(), freqUpdateCallback(), freqUpdateSchedule(), serialize(), and unserialize().
|
private |
Frequency update event handling.
Definition at line 152 of file generic_timer.hh.
Referenced by freqUpdateSchedule(), serialize(), and unserialize().
|
protected |
Value increment in each counter cycle.
Definition at line 85 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 97 of file generic_timer.hh.
Referenced by notifyListeners(), and registerListener().
|
private |
Definition at line 153 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 91 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 94 of file generic_timer.hh.
Referenced by serialize(), unserialize(), updateTick(), and updateValue().
|
protected |
Counter value (as specified in CNTCV).
Definition at line 83 of file generic_timer.hh.
Referenced by serialize(), setValue(), unserialize(), updateValue(), and value().
|
staticconstexprprotected |
Maximum architectural number of frequency table entries.
Definition at line 100 of file generic_timer.hh.