【Hardware】 【CRC check】

For example, the calculation process of CRC7 under replay:

  • Original data (14bit): 11 0100 1110 1100
  • CRC (3bit), the corresponding polynomial is: X 3 + x 1 +1, which is 1011

Step.1: Shift the original data (14bit) to the left by three digits, with zero padding:

11010011101100 000 <--- input right padded by 3 bits
1011               <--- divisor (4 bits) = x³ + x + 1
------------------
01100011101100 000 <--- result

Step.2: The original data (14bit + 3bit) successively removes the polynomial (1011), in fact, it does XOR operation:

11010011101100 000 <--- input right padded by 3 bits
1011               <--- divisor
01100011101100 000 <--- result (note the first four bits are the XOR with the divisor beneath, the rest of the bits are unchanged)
 1011              <--- divisor ...
00111011101100 000
  1011
00010111101100 000
   1011
00000001101100 000 <--- note that the divisor moves over to align with the next 1 in the dividend (since quotient for that step was zero)
       1011             (in other words, it doesn't necessarily move one bit per iteration)
00000000110100 000
        1011
00000000011000 000
         1011
00000000001110 000
          1011
00000000000101 000
           101 1
-----------------
00000000000000 100 <--- remainder (3 bits).  Division algorithm stops here as dividend is equal to zero.

The CRC value is: 100

The data stream: original data (14bit) + CRC (3bit) = 11010011101100 100 , packaged and sent to the receiving end.


Step.3: The receiving end checks the data after receiving it, that is, the received data stream is divided by the polynomial value. If there is no error, the remaining number must be zero:

11010011101100 100 <--- input with check value
1011               <--- divisor
01100011101100 100 <--- result
 1011              <--- divisor ...
00111011101100 100

......

00000000001110 100
          1011
00000000000101 100
           101 1
------------------
00000000000000 000 <--- remainder



Reference materials:
  1. Wikipedia - Cyclic Redundancy Check
  2. Cyclic Redundancy Check (CRC) algorithm principle
  3. CRC algorithm implementation
Published 30 original articles · won 12 · views 8261

Guess you like

Origin blog.csdn.net/syjie19900426/article/details/104516322