base: Tag API methods in sat_counter.hh
Change-Id: Id5da647f35cca30276bb34b745999f4571a47d89 Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33117 Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
@@ -65,6 +65,8 @@ class SatCounter
|
||||
*
|
||||
* @param bits How many bits the counter will have.
|
||||
* @param initial_val Starting value for the counter.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
explicit SatCounter(unsigned bits, uint8_t initial_val = 0)
|
||||
: initialVal(initial_val), maxVal((1 << bits) - 1),
|
||||
@@ -76,14 +78,22 @@ class SatCounter
|
||||
"Saturating counter's Initial value exceeds max value.");
|
||||
}
|
||||
|
||||
/** Copy constructor. */
|
||||
/**
|
||||
* Copy constructor.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter(const SatCounter& other)
|
||||
: initialVal(other.initialVal), maxVal(other.maxVal),
|
||||
counter(other.counter)
|
||||
{
|
||||
}
|
||||
|
||||
/** Copy assignment. */
|
||||
/**
|
||||
* Copy assignment.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter& operator=(const SatCounter& other) {
|
||||
if (this != &other) {
|
||||
SatCounter temp(other);
|
||||
@@ -92,7 +102,11 @@ class SatCounter
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Move constructor. */
|
||||
/**
|
||||
* Move constructor.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter(SatCounter&& other)
|
||||
{
|
||||
initialVal = other.initialVal;
|
||||
@@ -102,7 +116,11 @@ class SatCounter
|
||||
other.swap(temp);
|
||||
}
|
||||
|
||||
/** Move assignment. */
|
||||
/**
|
||||
* Move assignment.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter& operator=(SatCounter&& other) {
|
||||
if (this != &other) {
|
||||
initialVal = other.initialVal;
|
||||
@@ -119,6 +137,8 @@ class SatCounter
|
||||
* copy-assignment created by the compiler.
|
||||
*
|
||||
* @param other The other object to swap contents with.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
void
|
||||
swap(SatCounter& other)
|
||||
@@ -128,7 +148,11 @@ class SatCounter
|
||||
std::swap(counter, other.counter);
|
||||
}
|
||||
|
||||
/** Pre-increment operator. */
|
||||
/**
|
||||
* Pre-increment operator.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter&
|
||||
operator++()
|
||||
{
|
||||
@@ -138,7 +162,11 @@ class SatCounter
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Post-increment operator. */
|
||||
/**
|
||||
* Post-increment operator.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter
|
||||
operator++(int)
|
||||
{
|
||||
@@ -147,7 +175,11 @@ class SatCounter
|
||||
return old_counter;
|
||||
}
|
||||
|
||||
/** Pre-decrement operator. */
|
||||
/**
|
||||
* Pre-decrement operator.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter&
|
||||
operator--()
|
||||
{
|
||||
@@ -157,7 +189,11 @@ class SatCounter
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Post-decrement operator. */
|
||||
/**
|
||||
* Post-decrement operator.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter
|
||||
operator--(int)
|
||||
{
|
||||
@@ -166,7 +202,11 @@ class SatCounter
|
||||
return old_counter;
|
||||
}
|
||||
|
||||
/** Shift-right-assignment. */
|
||||
/**
|
||||
* Shift-right-assignment.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter&
|
||||
operator>>=(const int& shift)
|
||||
{
|
||||
@@ -175,7 +215,11 @@ class SatCounter
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Shift-left-assignment. */
|
||||
/**
|
||||
* Shift-left-assignment.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter&
|
||||
operator<<=(const int& shift)
|
||||
{
|
||||
@@ -187,7 +231,11 @@ class SatCounter
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Add-assignment. */
|
||||
/**
|
||||
* Add-assignment.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter&
|
||||
operator+=(const int& value)
|
||||
{
|
||||
@@ -203,7 +251,11 @@ class SatCounter
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Subtract-assignment. */
|
||||
/**
|
||||
* Subtract-assignment.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
SatCounter&
|
||||
operator-=(const int& value)
|
||||
{
|
||||
@@ -221,10 +273,16 @@ class SatCounter
|
||||
|
||||
/**
|
||||
* Read the counter's value.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
operator uint8_t() const { return counter; }
|
||||
|
||||
/** Reset the counter to its initial value. */
|
||||
/**
|
||||
* Reset the counter to its initial value.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
void reset() { counter = initialVal; }
|
||||
|
||||
/**
|
||||
@@ -233,6 +291,8 @@ class SatCounter
|
||||
*
|
||||
* @return A value between 0.0 and 1.0 to indicate which percentile of
|
||||
* the maximum value the current value is.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
double calcSaturation() const { return (double) counter / maxVal; }
|
||||
|
||||
@@ -240,6 +300,8 @@ class SatCounter
|
||||
* Whether the counter has achieved its maximum value or not.
|
||||
*
|
||||
* @return True if the counter saturated.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
bool isSaturated() const { return counter == maxVal; }
|
||||
|
||||
@@ -247,6 +309,8 @@ class SatCounter
|
||||
* Saturate the counter.
|
||||
*
|
||||
* @return The value added to the counter to reach saturation.
|
||||
*
|
||||
* @ingroup api_sat_counter
|
||||
*/
|
||||
uint8_t saturate()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user