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

Global system counter. More...

#include <generic_timer.hh>

Inheritance diagram for SystemCounter:
SimObject EventManager Serializable Drainable Stats::Group

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 Paramsparams () 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...
 
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 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 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 InforesolveStat (std::string name) const
 Resolve a stat by its name within this group. More...
 
 Group ()=delete
 
 Group (const Group &)=delete
 
Groupoperator= (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 SimObjectfind (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
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 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...
 

Detailed Description

Global system counter.

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

Definition at line 75 of file generic_timer.hh.

Constructor & Destructor Documentation

◆ SystemCounter() [1/2]

SystemCounter::SystemCounter ( SystemCounterParams *const  p)

Definition at line 55 of file generic_timer.cc.

References freqUpdateCallback().

◆ SystemCounter() [2/2]

SystemCounter::SystemCounter ( const SystemCounter c)
private

Member Function Documentation

◆ activeFreqEntry()

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

◆ disable()

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

◆ enable()

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

◆ enabled()

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

◆ freq()

uint32_t SystemCounter::freq ( ) const
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().

◆ freqTable()

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

◆ freqUpdateCallback()

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

◆ freqUpdateSchedule()

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.

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

◆ increment()

uint64_t SystemCounter::increment ( ) const
inline

Returns the value increment.

Definition at line 116 of file generic_timer.hh.

References _increment.

◆ notifyListeners()

void SystemCounter::notifyListeners ( void  ) const
private

Notifies counting speed changes to listeners.

Definition at line 199 of file generic_timer.cc.

References _listeners.

Referenced by freqUpdateCallback(), and setValue().

◆ period()

Tick SystemCounter::period ( ) const
inline

Returns the counter period.

Definition at line 122 of file generic_timer.hh.

References _period.

◆ registerListener()

void SystemCounter::registerListener ( SystemCounterListener listener)

Called from System Counter Listeners to register.

Definition at line 193 of file generic_timer.cc.

References _listeners.

◆ serialize()

void SystemCounter::serialize ( CheckpointOut cp) const
overridevirtual

Serialize an object.

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

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

◆ setValue()

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

◆ unserialize()

void SystemCounter::unserialize ( CheckpointIn cp)
overridevirtual

Unserialize an object.

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

Parameters
cpCheckpoint 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.

◆ updateTick()

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

◆ updateValue()

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

◆ validateCounterRef()

void SystemCounter::validateCounterRef ( SystemCounter sys_cnt)
static

Validates a System Counter reference.

Parameters
sys_cntSystem counter reference to validate

Definition at line 79 of file generic_timer.cc.

References fatal_if.

Referenced by GenericTimer::GenericTimer().

◆ value()

uint64_t SystemCounter::value ( )

◆ whenValue() [1/2]

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

◆ whenValue() [2/2]

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

Member Data Documentation

◆ _activeFreqEntry

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

◆ _enabled

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

◆ _freq

uint32_t SystemCounter::_freq
protected

Counter frequency (as specified by CNTFRQ).

Definition at line 81 of file generic_timer.hh.

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

◆ _freqTable

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

◆ _freqUpdateEvent

EventFunctionWrapper SystemCounter::_freqUpdateEvent
private

Frequency update event handling.

Definition at line 152 of file generic_timer.hh.

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

◆ _increment

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

◆ _listeners

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

Listeners to changes in counting speed.

Definition at line 97 of file generic_timer.hh.

Referenced by notifyListeners(), and registerListener().

◆ _nextFreqEntry

size_t SystemCounter::_nextFreqEntry
private

Definition at line 153 of file generic_timer.hh.

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

◆ _period

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

◆ _updateTick

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

◆ _value

uint64_t SystemCounter::_value
protected

Counter value (as specified in CNTCV).

Definition at line 83 of file generic_timer.hh.

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

◆ MAX_FREQ_ENTRIES

constexpr size_t SystemCounter::MAX_FREQ_ENTRIES = 1004
staticconstexprprotected

Maximum architectural number of frequency table entries.

Definition at line 100 of file generic_timer.hh.


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

Generated on Wed Sep 30 2020 14:02:32 for gem5 by doxygen 1.8.17