NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
nc::edac::detail Namespace Reference

Functions

bool calculateParity (const boost::dynamic_bitset<> &data) noexcept
 
template<std::size_t DataBits>
constexpr bool calculateParity (const std::bitset< DataBits > &data) noexcept
 
template<std::size_t DataBits, typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0>
bool calculateParity (const std::bitset< DataBits > &data, IntType parityBit)
 
template<std::size_t DataBits, std::size_t EncodedBits, std::enable_if_t< greaterThan_v< EncodedBits, DataBits >, int > = 0>
std::size_t checkBitsConsistent ()
 
template<typename IntType1 , typename IntType2 , std::enable_if_t< std::is_integral_v< IntType1 >, int > = 0, std::enable_if_t< std::is_integral_v< IntType2 >, int > = 0>
std::vector< std::size_t > dataBitsCovered (IntType1 numDataBits, IntType2 parityBit)
 
template<std::size_t DataBits, std::size_t EncodedBits, std::enable_if_t< greaterThan_v< EncodedBits, DataBits >, int > = 0>
std::bitset< DataBits > extractData (const std::bitset< EncodedBits > &encodedBits) noexcept
 
template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0>
constexpr bool isPowerOfTwo (IntType n) noexcept
 Tests if value is a power of two. More...
 
template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0>
std::size_t nextPowerOfTwo (IntType n)
 
template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0>
std::size_t numSecdedParityBitsNeeded (IntType numDataBits)
 
template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0>
std::vector< std::size_t > powersOfTwo (IntType n)
 

Function Documentation

◆ calculateParity() [1/3]

bool nc::edac::detail::calculateParity ( const boost::dynamic_bitset<> &  data)
inlinenoexcept

Calculates the overall parity of the data, assumes last bit is the parity bit itself

Parameters
datathe data word
Returns
overall parity bit value

◆ calculateParity() [2/3]

template<std::size_t DataBits>
constexpr bool nc::edac::detail::calculateParity ( const std::bitset< DataBits > &  data)
constexprnoexcept

Calculates the overall parity of the data, assumes last bit is the parity bit itself

Parameters
datathe data word
Returns
overall parity bit value

◆ calculateParity() [3/3]

template<std::size_t DataBits, typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0>
bool nc::edac::detail::calculateParity ( const std::bitset< DataBits > &  data,
IntType  parityBit 
)

Calculates the specified Hamming parity bit (1, 2, 4, 8, etc.) for the given data. Assumes even parity to allow for easier computation of parity using XOR.

Parameters
datathe data word
parityBitthe parity bit number
Returns
parity bit value
Exceptions
std::invalid_argumentif parityBit is not a power of two
std::bad_allocif unable to allocate return vector

◆ checkBitsConsistent()

template<std::size_t DataBits, std::size_t EncodedBits, std::enable_if_t< greaterThan_v< EncodedBits, DataBits >, int > = 0>
std::size_t nc::edac::detail::checkBitsConsistent ( )

Checks that the number of DataBits and EncodedBits are consistent

Returns
the number of parity bits
Exceptions
std::runtime_errorif DataBits and EncodedBits are not consistent
std::runtime_errorif the number of data bits does not represent a valid Hamming SECDED code

◆ dataBitsCovered()

template<typename IntType1 , typename IntType2 , std::enable_if_t< std::is_integral_v< IntType1 >, int > = 0, std::enable_if_t< std::is_integral_v< IntType2 >, int > = 0>
std::vector< std::size_t > nc::edac::detail::dataBitsCovered ( IntType1  numDataBits,
IntType2  parityBit 
)

Returns the indices of all data bits covered by a specified parity bit in a bitstring of length numDataBits. The indices are relative to DATA BITSTRING ITSELF, NOT including parity bits.

Parameters
numDataBitsthe number of data bits to encode
parityBitthe parity bit number
Returns
number of Hamming SECDED parity bits
Exceptions
std::invalid_argumentif parityBit is not a power of two
std::bad_allocif unable to allocate return vector

◆ extractData()

template<std::size_t DataBits, std::size_t EncodedBits, std::enable_if_t< greaterThan_v< EncodedBits, DataBits >, int > = 0>
std::bitset< DataBits > nc::edac::detail::extractData ( const std::bitset< EncodedBits > &  encodedBits)
noexcept

Returns the Hamming SECDED decoded bits from the endoded bits. Assumes that the DataBits and EncodedBits have been checks for consistancy already

Parameters
encodedBitsthe Hamming SECDED encoded word
Returns
data bits from the encoded word

◆ isPowerOfTwo()

template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0>
constexpr bool nc::edac::detail::isPowerOfTwo ( IntType  n)
constexprnoexcept

Tests if value is a power of two.

Parameters
ninteger value
Returns
bool true if value is a power of two, else false

◆ nextPowerOfTwo()

template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0>
std::size_t nc::edac::detail::nextPowerOfTwo ( IntType  n)

Calculates the next power of two after n

‍_next_power_of_two(768)

1024

‍_next_power_of_two(4)

8

Parameters
ninteger value
Returns
next power of two
Exceptions
std::invalid_argumentif input value is less than zero

◆ numSecdedParityBitsNeeded()

template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0>
std::size_t nc::edac::detail::numSecdedParityBitsNeeded ( IntType  numDataBits)

Calculates the number of needed Hamming SECDED parity bits to encode the data

Parameters
numDataBitsthe number of data bits to encode
Returns
number of Hamming SECDED parity bits
Exceptions
std::invalid_argumentif input value is less than zero
std::runtime_errorif the number of data bits does not represent a valid Hamming SECDED code

◆ powersOfTwo()

template<typename IntType , std::enable_if_t< std::is_integral_v< IntType >, int > = 0>
std::vector< std::size_t > nc::edac::detail::powersOfTwo ( IntType  n)

Calculates the first n powers of two

Parameters
ninteger value
Returns
first n powers of two
Exceptions
std::bad_allocif unable to allocate for return vector