CRC calculation using Rocksoft^tm Model characteristics.
More...
#include </mnt/devel/pabigot-cxx/include/pabigot/crc.hpp>
|
static constexpr bool | refout = Rout |
| true iff the output CRC is to be reflected.
|
|
static constexpr fast_type | poly = super_::mask & Poly |
| The CRC polynomial in normal form (all bits except bit width which is known to be 1 are provided).
|
|
static constexpr least_type | init = super_::mask & Init |
| The initial value of the CRC register before any message bits have been processed.
|
|
static constexpr least_type | xorout = super_::mask & XorOut |
| A value subtracted (xor'd) from the calculated result prior to returning it.
|
|
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...
|
|
template<unsigned int W, uintmax_t Poly, bool Rin = false, bool Rout = false, uintmax_t Init = 0, uintmax_t XorOut = 0>
class pabigot::crc::crc< W, Poly, Rin, Rout, Init, XorOut >
CRC calculation using Rocksoft^tm Model characteristics.
- Template Parameters
-
- See also
- http://www.ross.net/crc/download/crc_v3.txt
-
http://reveng.sourceforge.net/crc-catalogue/
-
http://users.ece.cmu.edu/~koopman/crc/index.html
-
https://en.wikipedia.org/wiki/Mathematics_of_cyclic_redundancy_checks especially the Koopman references
◆ fast_type
template<unsigned int W, uintmax_t Poly, bool Rin = false, bool Rout = false, uintmax_t Init = 0, uintmax_t XorOut = 0>
A fast native unsigned integral type capable of holding width-bit CRC values.
- Warning
- This value may have more octets or bits than are required to store the CRC.
◆ least_type
template<unsigned int W, uintmax_t Poly, bool Rin = false, bool Rout = false, uintmax_t Init = 0, uintmax_t XorOut = 0>
A small native unsigned integral type capable of holding width-bit CRC values.
- Warning
- This value may have more octets or bits than are required to store the CRC.
◆ append()
template<unsigned int W, uintmax_t Poly, bool Rin = false, bool Rout = false, uintmax_t Init = 0, uintmax_t XorOut = 0>
template<typename InputIterator >
Augment a checksum with additional data.
- Template Parameters
-
InputIterator | iterator over inputs. InputIterator::value_type must be convertible to an unsigned 8-bit value without changing the value content. |
- Parameters
-
first | beginning of the range over which CRCs will be calculated. |
last | beginning of the range over which CRCs will be calculated. |
crc | the CRC value calculated over all previous message bits. Start with init, which is the defaulted value. |
- Returns
- the unreflected CRC value over all message bits through this invocation. This may be passed as
crc
to process more message content.
- See also
- finalize()
◆ finalize()
template<unsigned int W, uintmax_t Poly, bool Rin = false, bool Rout = false, uintmax_t Init = 0, uintmax_t XorOut = 0>
Calculate the final CRC value for a sequence.
refout and xorout are applied to the final register value and the result returned.
- Note
- A common operation on CRCs is to store them into a buffer for transfer to another system, particularly to enable use of residue(). Be aware that if width is not a power of 2 then least_type is likely to have padding bits in it, for which a basic byte-swap for endianness will produce anomalous results. See store() for a partial solution.
- Parameters
-
crc | the CRC resulting after all message bits have been calculated. |
- Returns
- the CRC of the message in smallest type capable of holding it.
◆ residue()
template<unsigned int W, uintmax_t Poly, bool Rin = false, bool Rout = false, uintmax_t Init = 0, uintmax_t XorOut = 0>
Value expected for CRC(x || XE(CRC(x)))
.
When the checksum of the message is stored at the end of the message a receiver can calculate the finalized checksum of the message plus the stored checksum. This value will be equal to the residue() if no errors are discovered.
- Note
- The residues produced by this function may not match those specified by the reveng catalog because the classic check algorithm used for residues does not apply crc::xorout to the final value. See, for example, this code for the classic CRC-32 algorithm. The value here is correct when compared with a finalized checksum.
- Warning
- This library does not properly handle residue calculation for messages that are not an integral number of bytes, or CRCs with a width that is not a multiple of 8 bits.
◆ store()
template<unsigned int W, uintmax_t Poly, bool Rin = false, bool Rout = false, uintmax_t Init = 0, uintmax_t XorOut = 0>
Store a finalized CRC into a buffer in a way that enables crc::residue().
- Warning
- If the CRC width is not a multiple of 8 the stored value will not be correct, as this namespace provides no API to operate on messages that are not an integral number of octets.
- Parameters
-
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. |
- Returns
- pointer into the region identified by
bp
immediately following the stored CRC.
The documentation for this class was generated from the following file:
- /mnt/devel/pabigot-cxx/include/pabigot/crc.hpp