8#include "sparta/statistics/Counter.hpp"
55 const std::string& name,
56 const std::string& group,
58 const std::string& desc,
71 sparta_assert(clk_ !=
nullptr,
"CycleCounter must be given a clock through it's parent node");
76 const std::string& name,
77 const std::string& desc,
94 CycleCounter(TreeNode* parent,
95 const std::string& name,
96 const std::string& group,
98 const std::string& desc,
110 sparta_assert(clk_ !=
nullptr,
"CycleCounter must be given a clock through it's parent node");
115 const std::string& name,
116 const std::string& desc,
144 if(parent !=
nullptr){
189 mult_ = add_per_cycle;
210 count_ += (clk_->
elapsedCycles() + delay - start_count_) * mult_;
243 if (elapsed > start_count_) {
244 count += (elapsed - start_count_) * mult_;
260 return get() == rhp.
get();
267 return get() == rhp.
get();
284 virtual std::string
stringize(
bool pretty=
false)
const override {
286 std::stringstream ss;
302 (void) child;
throw SpartaException(
"Cannot add children to a CycleCounter");
318 bool counting_ =
false;
Byte order types and byte-swapping routines.
File that defines the Clock class.
Set of macros for Sparta assertions. Caught by the framework.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
Exception class for all of Sparta.
Basic Node framework in sparta device tree composite pattern.
A representation of simulated time.
Cycle elapsedCycles() const
Return the total elapsed cycles from this Clocks POV.
The base class for all Counters.
static std::string getBehaviorName(CounterBehavior behave)
Returns a string containing the name of the given behavior.
uint64_t counter_type
Counter value type.
CounterBehavior
Behavior of this counter.
CounterBehavior getBehavior() const
Gets the behavior for this counter specified at construction.
Represents a counter of type counter_type (uint64_t). 2 and greater than 0 with a ceiling specified....
counter_type get() const override
Gets the value of this counter.
Represents a cycle counter.
void startCounting(uint32_t delay=0)
Start counting, taking into account the specified delay.
uint32_t getCurrentMultiplier() const
Return the current multipler.
void stopCounting(uint32_t delay=0)
Stop counting and increment internal count, taking into account the specified delay.
void startCountingWithMultiplier(uint32_t add_per_cycle, uint32_t delay=0)
Start counting, taking into account the specified delay.
virtual void onAddingChild_(TreeNode *child) override
React to child registration.
virtual std::string stringize(bool pretty=false) const override
Create a string representation of this node.
CycleCounter(CycleCounter &&rhp)
Move constructor.
void updateCountingMultiplier(uint32_t add_per_cycle)
virtual counter_type get() const override
Gets the value of this counter.
bool operator==(const CycleCounter &rhp) const
Comparison against another counter.
~CycleCounter()
Destructor.
bool operator==(const Counter &rhp) const
Comparison against another counter.
CycleCounter(TreeNode *parent, const std::string &name, const std::string &group, TreeNode::group_idx_type group_idx, const std::string &desc, CounterBehavior behave, const sparta::Clock *clk, visibility_t visibility)
CycleCounter constructor.
bool isCounting() const
Return whether this counter is counting or not.
virtual bool supportsCompression() const override
uint32_t visibility_t
Continuous visibility level. Several key points along continum are indicated within Visibility.
static constexpr visibility_t DEFAULT_VISIBILITY
Default node visibility.
visibility_t getVisibility() const
Gets the visibility hint of this node. This is invariant after construction.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Node in a composite tree representing a sparta Tree item.
static const group_idx_type GROUP_IDX_NONE
GroupIndex indicating that a node has no group index because it belongs to no group.
std::string getLocation() const override final
static constexpr char GROUP_NAME_NONE[]
Group name indicating that a node belongs to no group.
TreeNode()=delete
Not default-constructable.
void addChild(TreeNode *child, bool inherit_phase=true)
Adds a TreeNode to this node as a child.
virtual TreeNode * getParent()
Gets immediate parent of this node if one exists.
uint32_t group_idx_type
Index within a group.
Macros for handling exponential backoff.