SDRAngel
4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
|
#include <CRC64.h>
Public Member Functions | |
CRC64 () | |
~CRC64 () | |
uint64_t | calculate_crc (uint8_t *stream, int length) |
Private Member Functions | |
void | build_crc_table () |
Private Attributes | |
uint64_t | m_crcTable [256] |
Static Private Attributes | |
static const uint64_t | m_poly = 0xC96C5795D7870F42ull |
CRC64::CRC64 | ( | ) |
Definition at line 40 of file CRC64.cpp.
References build_crc_table().
|
private |
input is dividend: as 0000000000000000000000000000000000000000000000000000000000000000<8-bit byte> where the lsb of the 8-bit byte is the coefficient of the highest degree term (x^71) of the dividend so division is really for input byte * x^64
you may wonder how 72 bits will fit in 64-bit data type... well as the shift-right occurs, 0's are supplied on the left (most significant) side ... when the 8 shifts are done, the right side (where the input byte was placed) is discarded
when done, table[XX] (where XX is a byte) is equal to the CRC of 00 00 00 00 00 00 00 00 XX
Definition at line 59 of file CRC64.cpp.
References i, m_crcTable, and m_poly.
Referenced by CRC64().
will give an example CRC calculation for input array {0xDE, 0xAD}
each byte represents a group of 8 coefficients for 8 dividend terms
the actual polynomial dividend is:
= DE AD 00 00 00 00 00 00 00 00 (hex) = 11011110 10101101 0000000000000000000...0 (binary) || |||| | | || | || |||| | | || +---------------------— x^71 || |||| | | |+-----------------------— x^69 || |||| | | +------------------------— x^68 || |||| | +--------------------------— x^66 || |||| +----------------------------— x^64 || |||| || |||+-------------------------------— x^78 || ||+--------------------------------— x^77 || |+---------------------------------— x^76 || +----------------------------------— x^75 |+------------------------------------— x^73 +-------------------------------------— x^72
the basic idea behind how the table lookup results can be used with one another is that:
Mod(A * x^n, P(x)) = Mod(x^n * Mod(A, P(X)), P(X))
in other words, an input data shifted towards the higher degree terms changes the pre-computed crc of the input data by shifting it also the same amount towards higher degree terms (mod the polynomial)
here is an example:
1) input:
00 00 00 00 00 00 00 00 AD DE
2) index crc table for byte DE (really for dividend 00 00 00 00 00 00 00 00 DE)
we get A8B4AFBDC5A6ACA4
3) apply that to the input stream:
00 00 00 00 00 00 00 00 AD DE
00 A8 B4 AF BD C5 A6 AC 09
4) index crc table for byte 09 (really for dividend 00 00 00 00 00 00 00 00 09)
we get 448FCBB7FCB9E309
5) apply that to the input stream
00 A8 B4 AF BD C5 A6 AC 09
44 27 7F 18 41 7C 45 A5
Definition at line 144 of file CRC64.cpp.
References i, and m_crcTable.
|
private |
Definition at line 35 of file CRC64.h.
Referenced by build_crc_table(), and calculate_crc().
|
staticprivate |
poly is: x^64 + x^62 + x^57 + x^55 + x^54 + x^53 + x^52 + x^47 + x^46 + x^45 + x^40 + x^39 + x^38 + x^37 + x^35 + x^33 + x^32 + x^31 + x^29 + x^27 + x^24 + x^23 + x^22 + x^21 + x^19 + x^17 + x^13 + x^12 + x^10 + x^9 + x^7 + x^4 + x^1 + 1
represented here with lsb = highest degree term
1100100101101100010101111001010111010111100001110000111101000010_ || | | || || | | |||| | | ||| | |||| ||| |||| | | | || | | || || | | |||| | | ||| | |||| ||| |||| | | +- x^64 (implied) || | | || || | | |||| | | ||| | |||| ||| |||| | | || | | || || | | |||| | | ||| | |||| ||| |||| | +— x^62 || | | || || | | |||| | | ||| | |||| ||| |||| +-----— x^57 ....................................................................... || |+-------------------------------------------------------------— x^1 +--------------------------------------------------------------— x^0 (1)
Definition at line 36 of file CRC64.h.
Referenced by build_crc_table().