pabigot
0.1.1
C++ support classes
|
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. | |
Type and policy traits providing support for operations on B
-bit values.
B | the number of bits as a positive value not exceeding 64. |
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.
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.
|
inlinestaticconstexpr |
Apply message bits into the CRC.
poly | the normal-form polynomial for the CRC. |
crc | the remainder polynomial for the previously encountered message bits. |
msg | bits of message, already reflected and shifted so the first bit is in bit n-1 and the last bit is in bit 0 . |
n | the number of bits in msg that carry message bits. This must not exceed width. |
msg
using poly
.
|
inlinestaticconstexpr |
Reflect a value around its center.
v | the value to be reflected |
n | the 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. |
|
staticconstexpr |