pabigot  0.1.1
C++ support classes
Public Types | Static Public Member Functions | Static Public Attributes
pabigot::crc::details::uint_support< B > Struct Template Reference

Type and policy traits providing support for operations on B-bit values. More...

#include </mnt/devel/pabigot-cxx/include/pabigot/crc.hpp>

Public Types

using uint_traits = details::uint_traits< uint_category< B >()>
 Characteristics of the unsigned integer support required for a width-bit value.
 
using fast_type = typename uint_traits::fast_type
 The type used to hold values while they're being operated on. More...
 
using least_type = typename uint_traits::least_type
 The type used to hold values while they're being stored. More...
 

Static Public Member Functions

static constexpr fast_type reflect (const fast_type &v, unsigned int n=width)
 Reflect a value around its center. More...
 
static constexpr fast_type crc_apply (const fast_type &poly, const fast_type &crc, const fast_type &msg, const unsigned int n)
 Apply message bits into the CRC. More...
 

Static Public Attributes

static constexpr unsigned int width = B
 The number of bits for which this class is targeted. More...
 
static constexpr unsigned int fast_width = std::numeric_limits<fast_type>::digits
 The number of bits used in fast_type, should that be useful.
 
static constexpr unsigned int least_width = std::numeric_limits<least_type>::digits
 The number of bits used in least_type, should that be useful.
 
static constexpr fast_type mask {uint_traits::mask_for_bits(width)}
 A mask value that will discard bits at and above bit number width in a value.
 
static constexpr fast_type msbit {static_cast<fast_type>(1) << (width - 1)}
 Mask isolating the most significant bit in a value.
 
static constexpr fast_type lsbit {static_cast<fast_type>(1)}
 Mask isolating the least significant bit in a value.
 

Detailed Description

template<unsigned int B>
struct pabigot::crc::details::uint_support< B >

Type and policy traits providing support for operations on B-bit values.

Template Parameters
Bthe number of bits as a positive value not exceeding 64.

Member Typedef Documentation

◆ fast_type

template<unsigned int B>
using pabigot::crc::details::uint_support< B >::fast_type = typename uint_traits::fast_type

The type used to hold values while they're being operated on.

This is the fastest unsigned type capable of holding at least width bits.

◆ least_type

template<unsigned int B>
using pabigot::crc::details::uint_support< B >::least_type = typename uint_traits::least_type

The type used to hold values while they're being stored.

This is the smallest type capable of holding at least width bits.

Member Function Documentation

◆ crc_apply()

template<unsigned int B>
static constexpr fast_type pabigot::crc::details::uint_support< B >::crc_apply ( const fast_type poly,
const fast_type crc,
const fast_type msg,
const unsigned int  n 
)
inlinestaticconstexpr

Apply message bits into the CRC.

Parameters
polythe normal-form polynomial for the CRC.
crcthe remainder polynomial for the previously encountered message bits.
msgbits of message, already reflected and shifted so the first bit is in bit n-1 and the last bit is in bit 0.
nthe number of bits in msg that carry message bits. This must not exceed width.
Returns
the CRC after incorporating msg using poly.

◆ reflect()

template<unsigned int B>
static constexpr fast_type pabigot::crc::details::uint_support< B >::reflect ( const fast_type v,
unsigned int  n = width 
)
inlinestaticconstexpr

Reflect a value around its center.

Parameters
vthe value to be reflected
nthe number of bits of in that are valid. Bit n-1 of in is reflected into bit 0 of the returned value; similarly bit 0 of in shows up in bit n-1 of the returned value. Defaults to width, but 8 and other values may be required when reflecting input chunks.

Field Documentation

◆ width

template<unsigned int B>
constexpr unsigned int pabigot::crc::details::uint_support< B >::width = B
staticconstexpr

The number of bits for which this class is targeted.

This is a lower bound on the number of bits supported by fast_type and least_type, and influences the values of msbit, lsbit, mask, and the default upper bit position used in reflect().


The documentation for this struct was generated from the following file: