In simple terms, CRC-modulo 2 Operation

Source: Internet
Author: User

Key words: CRC algorithm principle; CRC verification; modulo 2 (mod 2); mod 2


The CRC verification algorithm adopts a binary algorithm called "modulo 2 operation. The modulo 2 operation is the core part of the CRC operation. Therefore, before analyzing the CRC algorithm, you should first understand the modulo 2 operation.


Same as the four arithmetic operations, the modulo 2 operation also includes four binary operations: modulo 2 plus, modulo 2 minus, modulo 2 multiplication, and modulo 2 division. In addition, the modulo 2 operation also uses the same operator as the four arithmetic operations, that is, "+" modulo 2 plus, "-" modulo 2 minus, "×" or "·" modulo 2 multiplication, "division" or "/" modulo Division 2. Different from the four arithmetic operations, the modulo 2 operation does not consider carry and borrow bits. That is, the modulo 2 addition does not include binary addition operations of BITs, and the modulo 2 subtraction does not include binary subtraction operations of bits. In this way, when two binary phase operations are performed, the values of these two bits can determine the operation result, regardless of the previous operation or the next operation.


① Model 2 addition operation is defined:

0 + 0 = 0 0 + 1 = 1 1 + 0 = 1
1 + 1 = 0

For example, if the value is 0101 + 0011 = 0110, the column-based vertical calculation is as follows:
0 1 0 1
+ 0 0 1 1
── ─
0 1 1 0

② Modulus 2 subtraction operation is defined:

0-0 = 0 0-1 = 1 1-0 = 1 1-1 = 0

For example, 0110-0011 = 0101, column-vertical calculation:
0 1 1 0
-0 0 1 1
── ─
0 1 0 1

③ Model 2 multiplication is defined:

0x0 = 0 0x1 = 0 1x0 = 0 1x1 = 1

The multi-bit binary modulo 2 multiplication is similar to the multi-bit binary multiplication in the general sense. The difference is that the latter uses the addition of the incoming bits when accumulating the intermediate result (or partial product, the Processing Method of the intermediate result by modulo 2 multiplication is the modulo 2 addition. For example, 1011 × 101 = 100111, column-vertical calculation:
1 0 1 1
× 1 0 1
── ─
1 0 1 1
0 0 0 0
+ 1 0 1 1
── ─
1 0 0 1 1 1

4. The division operation of model 2 is defined:

0 bytes 1 = 0 1 bytes 1 = 1

The multi-bit binary modulo 2 division is similar to the multi-bit binary division in the general sense, but the two adopt different rules on how to determine the quotient. The latter is based on the binary subtraction with a bid. Based on the remainder subtraction, the number of operators is equal to or equal to 1. If the remainder Subtraction is equal to 0, the number of operators is equal to 1. Otherwise, the number of operators is equal to 0. The multi-bitwise Modulo-2 Division adopts the Modulo-2 subtraction without the binary subtraction of the borrowed bits. Therefore, it is meaningless to consider whether the remainder is equal to or not. In fact, in CRC operations, the first part of the Division is always 1. Then, the operator of the division operation in mod 2 is determined by the result of the division operation between the first part of the remainder and the first part of the Division. Because the first divisor is always 1, according to the division algorithm of mod 2, then the first remainder is 1, and the first is 1, and the first is 0. For example, 1100100 bytes 1011 = 1110 ...... 110, Column Vertical calculation:
1 1 1 0
── ─
1 0 1) 1 1 0 0 1 0 0
-1 0 1 1
── ─
1 1 1 1
-1 0 1 1
── ─
1 0 0 0
-1 0 1 1
── ─
0 1 1 0
-0 0 0 0
── ─
1 1 0
Conclusion: By comparison, we can easily find that the two operations, modulo 2 plus and modulo 2 minus, are identical to the logic exclusive or operation. In addition, modulo 2 multiplication and division are all based on Modulo 2 addition and subtraction. Therefore, we can regard modulo 2 as a simple XOR operation. In fact, the CRC splitter is composed of an exclusive OR gate and a timing circuit.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.