gem5  v22.1.0.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
gem5::SystemCounter Class Reference

Global system counter. More...

#include <generic_timer.hh>

Inheritance diagram for gem5::SystemCounter:
gem5::SimObject gem5::EventManager gem5::Serializable gem5::Drainable gem5::statistics::Group gem5::Named

Public Member Functions

 SystemCounter (const SystemCounterParams &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 gem5::SimObject
const Paramsparams () 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. 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...
 
ProbeManagergetProbeManager ()
 Get the probe manager for this object. More...
 
virtual PortgetPort (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 gem5::EventManager
EventQueueeventQueue () 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 gem5::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 gem5::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 gem5::statistics::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 (statistics::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 InforesolveStat (std::string name) const
 Resolve a stat by its name within this group. More...
 
void mergeStatGroup (Group *block)
 Merge the contents (stats & children) of a block to this block. More...
 
 Group ()=delete
 
 Group (const Group &)=delete
 
Groupoperator= (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. More...
 
- 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. More...
 
static SimObjectfind (const char *name)
 Find the SimObject with the given name and return a pointer to it. More...
 
static void setSimObjectResolver (SimObjectResolver *resolver)
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. More...
 
static SimObjectResolvergetSimObjectResolver ()
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. More...
 
- Static Public Member Functions inherited from gem5::Serializable
static const std::string & currentSection ()
 Gets the fully-qualified name of the active section. More...
 
static void generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream)
 Generate a checkpoint file so that the serialization can be routed to it. More...
 

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 gem5::SimObject
const SimObjectParams & _params
 Cached copy of the object parameters. More...
 
- Protected Attributes inherited from gem5::EventManager
EventQueueeventq
 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 gem5::SimObject
typedef SimObjectParams Params
 
- Protected Member Functions inherited from gem5::Drainable
 Drainable ()
 
virtual ~Drainable ()
 
virtual void drainResume ()
 Resume execution after a successful drain. More...
 
void signalDrainDone () const
 Signal that an object is drained. More...
 

Detailed Description

Global system counter.

It is shared by the architected and memory-mapped timers.

Definition at line 86 of file generic_timer.hh.

Constructor & Destructor Documentation

◆ SystemCounter() [1/2]

gem5::SystemCounter::SystemCounter ( const SystemCounterParams &  p)

Definition at line 67 of file generic_timer.cc.

References freqUpdateCallback().

◆ SystemCounter() [2/2]

gem5::SystemCounter::SystemCounter ( const SystemCounter c)
private

Member Function Documentation

◆ activeFreqEntry()

size_t gem5::SystemCounter::activeFreqEntry ( ) const
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().

◆ disable()

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().

◆ enable()

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().

◆ enabled()

bool gem5::SystemCounter::enabled ( ) const
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().

◆ freq()

uint32_t gem5::SystemCounter::freq ( ) const
inline

◆ freqTable()

std::vector<uint32_t>& gem5::SystemCounter::freqTable ( )
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().

◆ freqUpdateCallback()

void gem5::SystemCounter::freqUpdateCallback ( )
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().

◆ freqUpdateSchedule()

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.

Parameters
new_freq_entryIndex 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().

◆ increment()

uint64_t gem5::SystemCounter::increment ( ) const
inline

Returns the value increment.

Definition at line 127 of file generic_timer.hh.

References _increment.

◆ notifyListeners()

void gem5::SystemCounter::notifyListeners ( void  ) const
private

Notifies counting speed changes to listeners.

Definition at line 211 of file generic_timer.cc.

References _listeners.

Referenced by freqUpdateCallback(), and setValue().

◆ period()

Tick gem5::SystemCounter::period ( ) const
inline

Returns the counter period.

Definition at line 133 of file generic_timer.hh.

References _period.

◆ registerListener()

void gem5::SystemCounter::registerListener ( SystemCounterListener listener)

Called from System Counter Listeners to register.

Definition at line 205 of file generic_timer.cc.

References _listeners.

◆ serialize()

void gem5::SystemCounter::serialize ( CheckpointOut cp) const
overridevirtual

Serialize an object.

Output an object's state into the current checkpoint section.

Parameters
cpCheckpoint state

Implements gem5::Serializable.

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().

◆ setValue()

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().

◆ unserialize()

void gem5::SystemCounter::unserialize ( CheckpointIn cp)
overridevirtual

Unserialize an object.

Read an object's state from the current checkpoint section.

Parameters
cpCheckpoint state

Implements gem5::Serializable.

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.

◆ updateTick()

void gem5::SystemCounter::updateTick ( void  )
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().

◆ updateValue()

void gem5::SystemCounter::updateValue ( void  )
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().

◆ validateCounterRef()

void gem5::SystemCounter::validateCounterRef ( SystemCounter sys_cnt)
static

Validates a System Counter reference.

Parameters
sys_cntSystem 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().

◆ value()

uint64_t gem5::SystemCounter::value ( )

◆ whenValue() [1/2]

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().

◆ whenValue() [2/2]

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().

Referenced by freqUpdateSchedule(), gem5::GenericWatchdog::refresh(), and gem5::ArchTimer::whenValue().

Member Data Documentation

◆ _activeFreqEntry

size_t gem5::SystemCounter::_activeFreqEntry
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().

◆ _enabled

bool gem5::SystemCounter::_enabled
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().

◆ _freq

uint32_t gem5::SystemCounter::_freq
protected

Counter frequency (as specified by CNTFRQ).

Definition at line 92 of file generic_timer.hh.

Referenced by freq(), freqUpdateCallback(), freqUpdateSchedule(), serialize(), and unserialize().

◆ _freqTable

std::vector<uint32_t> gem5::SystemCounter::_freqTable
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().

◆ _freqUpdateEvent

EventFunctionWrapper gem5::SystemCounter::_freqUpdateEvent
private

Frequency update event handling.

Definition at line 163 of file generic_timer.hh.

Referenced by freqUpdateSchedule(), serialize(), and unserialize().

◆ _increment

uint64_t gem5::SystemCounter::_increment
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().

◆ _listeners

std::vector<SystemCounterListener *> gem5::SystemCounter::_listeners
protected

Listeners to changes in counting speed.

Definition at line 108 of file generic_timer.hh.

Referenced by notifyListeners(), and registerListener().

◆ _nextFreqEntry

size_t gem5::SystemCounter::_nextFreqEntry
private

Definition at line 164 of file generic_timer.hh.

Referenced by freqUpdateCallback(), freqUpdateSchedule(), serialize(), and unserialize().

◆ _period

Tick gem5::SystemCounter::_period
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().

◆ _updateTick

Tick gem5::SystemCounter::_updateTick
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().

◆ _value

uint64_t gem5::SystemCounter::_value
protected

Counter value (as specified in CNTCV).

Definition at line 94 of file generic_timer.hh.

Referenced by serialize(), setValue(), unserialize(), updateValue(), and value().

◆ MAX_FREQ_ENTRIES

constexpr size_t gem5::SystemCounter::MAX_FREQ_ENTRIES = 1004
staticconstexprprotected

Maximum architectural number of frequency table entries.

Definition at line 111 of file generic_timer.hh.


The documentation for this class was generated from the following files:

Generated on Wed Dec 21 2022 10:23:16 for gem5 by doxygen 1.9.1