Skip to content

Class hal::overflow_counter

template <size_t CountBitWidth>

ClassList > hal > overflow_counter

Extend a counter's count from an arbitrary bit width to 64-bits by detecting overflows in the count. Each detected overflow is added to an overflow counter which is combined with the current count in order create a count up to 64-bits in length. More...

  • #include <overflow_counter.hpp>

Public Functions

Type Name
constexpr void reset ()
Reset the overflow count back to zero.
constexpr uint64_t update (uint32_t p_new_count)
update the overflow counter, detect if an overflow has occurred, and return the combined

Detailed Description

Template parameters:

  • CountBitWidth - the bit width of the counter before the count value overflows.

Public Functions Documentation

function reset

inline constexpr void hal::overflow_counter::reset () 

function update

update the overflow counter, detect if an overflow has occurred, and return the combined

inline constexpr uint64_t hal::overflow_counter::update (
    uint32_t p_new_count
) 

Parameters:

  • p_new_count - must be an increasing value and should only decrease when an overflow event occurs.

Returns:

constexpr uint64_t - 64-bit count combining the new count value and the overflow count value.


The documentation for this class was generated from the following file libraries/include/libhal-util/overflow_counter.hpp