41#ifndef __BASE_SAT_COUNTER_HH__
42#define __BASE_SAT_COUNTER_HH__
82 "Number of bits exceeds counter size");
84 "Saturating counter's initial value exceeds max value.");
104 if (
this != &other) {
131 if (
this != &other) {
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Implements an n bit saturating counter and provides methods to increment, decrement,...
GenericSatCounter()=delete
The default constructor should never be used.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
GenericSatCounter & operator+=(const long long &value)
Add-assignment.
GenericSatCounter< uint32_t > SatCounter32
bool isSaturated() const
Whether the counter has achieved its maximum value or not.
GenericSatCounter & operator<<=(const int &shift)
Shift-left-assignment.
GenericSatCounter operator--(int)
Post-decrement operator.
GenericSatCounter(unsigned bits, T initial_val=0)
Constructor for the counter.
GenericSatCounter(const GenericSatCounter &other)
Copy constructor.
GenericSatCounter & operator=(const GenericSatCounter &other)
Copy assignment.
GenericSatCounter & operator=(GenericSatCounter &&other)
Move assignment.
GenericSatCounter operator++(int)
Post-increment operator.
double calcSaturation() const
Calculate saturation percentile of the current counter's value with regard to its maximum possible va...
GenericSatCounter(GenericSatCounter &&other)
Move constructor.
T saturate()
Saturate the counter.
void swap(GenericSatCounter &other)
Swap the contents of every member of the class.
GenericSatCounter & operator>>=(const int &shift)
Shift-right-assignment.
GenericSatCounter< uint16_t > SatCounter16
GenericSatCounter< uint8_t > SatCounter8
GenericSatCounter< uint64_t > SatCounter64
void reset()
Reset the counter to its initial value.
GenericSatCounter & operator++()
Pre-increment operator.
GenericSatCounter & operator-=(const long long &value)
Subtract-assignment.
GenericSatCounter & operator--()
Pre-decrement operator.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.