pabigot
0.1.1
C++ support classes
|
CRC core framework using Rocksoft^tm Model characteristics. More...
#include </mnt/devel/pabigot-cxx/include/pabigot/crc.hpp>
Public Types | |
using | uint_traits = typename support_traits::uint_traits |
using | fast_type = typename support_traits::fast_type |
A fast native unsigned integral type capable of holding width-bit CRC values. More... | |
using | least_type = typename support_traits::least_type |
A small native unsigned integral type capable of holding width-bit CRC values. More... | |
Static Public Member Functions | |
static constexpr fast_type | reflect (const fast_type &v) |
Delegate to support_traits::reflect. | |
static constexpr uint8_t * | store (fast_type crc, uint8_t *bp) |
Store a finalized CRC into a buffer in a way that enables crc::residue(). More... | |
Static Public Attributes | |
static constexpr unsigned int | width = W |
The width of the CRC in bits. | |
static constexpr unsigned int | size = (7 + width) / 8 |
The width of the CRC in bytes. | |
static constexpr fast_type | mask = support_traits::mask |
The mask that discards bits of a fast_type that would be outside the width limit. | |
static constexpr bool | refin = Rin |
true iff the input message bit stream is reflected. More... | |
Protected Types | |
using | support_traits = details::uint_support< width > |
Traits class providing native integral types and parameter-independent values supporting width-bit operations. | |
Static Protected Member Functions | |
static constexpr least_type | lookup_for_byte (const fast_type &poly, std::uint_fast8_t byte) |
Calculate a single lookup table entry using the given polynomial. More... | |
static constexpr fast_type | crc_apply (const fast_type &poly, const fast_type &crc, fast_type msg, unsigned int n) |
Apply message bits into a CRC. More... | |
CRC core framework using Rocksoft^tm Model characteristics.
This class supports the basic operations that are common when parameterized by polynomial and output processing.
using pabigot::crc::details::base_crc< W, Rin >::fast_type = typename support_traits::fast_type |
A fast native unsigned integral type capable of holding width-bit CRC values.
using pabigot::crc::details::base_crc< W, Rin >::least_type = typename support_traits::least_type |
A small native unsigned integral type capable of holding width-bit CRC values.
|
inlinestaticconstexprprotected |
Apply message bits into a 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. |
n | the number of bits in msg that carry message bits. |
msg
using poly
.
|
inlinestaticconstexprprotected |
Calculate a single lookup table entry using the given polynomial.
index | the table index for which the precomputed CRC adjustment is desired. |
poly | the polynomial for which the table is being generated. |
poly
when the next 8 bits to shift out of the CRC are index
.
|
inlinestaticconstexpr |
Store a finalized CRC into a buffer in a way that enables crc::residue().
crc | the finalized CRC of a message. |
bp | pointer to space of size bytes immediately following the message, into which the CRC can be stored. |
bp
immediately following the stored CRC.
|
staticconstexpr |
true
iff the input message bit stream is reflected.
The CRC is a linear shift register; it is necessary to know which bit in a byte should be fed in first:
refin
is false
the most significant bit of the byte is consumed first. This is the "big-endian" configuration.refin
is true
the least significant bit of the byte is consumed first. This is the "little-endian" configuration.This parameter also affects crc::store() in that CRCs with width greater than 8 must use the byte order that matches the bit order when catenated to the end of a message to ensure that the aggregate CRC matches the crc::residual().