CN114443347B - Configurable CRC code calculation method - Google Patents
Configurable CRC code calculation method Download PDFInfo
- Publication number
- CN114443347B CN114443347B CN202111587754.8A CN202111587754A CN114443347B CN 114443347 B CN114443347 B CN 114443347B CN 202111587754 A CN202111587754 A CN 202111587754A CN 114443347 B CN114443347 B CN 114443347B
- Authority
- CN
- China
- Prior art keywords
- data
- crc
- bit
- init
- flip
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/08—Error detection or correction by redundancy in data representation, e.g. by using checking codes
- G06F11/10—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
- G06F11/1004—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Error Detection And Correction (AREA)
Abstract
The invention discloses a configurable CRC code calculation method, which comprises the following steps: step S1: configuring CRC parameters; configuring a CRC configuration variable according to a required CRC parameter model, and clearing a CRC result variable; step S2: preprocessing parameters; preprocessing a polynomial GPOLY of a CRC model and an initial value INIT, and aligning a most significant bit (GW bit) of a parameter to a DW bit of the most significant bit of a parameter variable or the most significant bit of data; and step S3: preprocessing data; and step S4: calculating a CRC check code; carrying out bitwise XOR operation on the shifted initial value INIT _ PRE and the shifted input DATA DATA _ PRE to obtain INIT _ OR _ DATA; and according to the setting of FlipOUT, carrying out the turnover operation on the CRC calculation result CRCOUT to obtain CRCOUT _ Flip. The invention has the advantages of simple principle, simple and convenient operation, good flexibility and the like.
Description
Technical Field
The invention mainly relates to the technical field of data communication and data storage, in particular to a configurable CRC code calculation method.
Background
CRC (Cyclic Redundancy Check) is one of the most commonly used error checking codes in the field of data communication and data storage. CRC has the characteristic of strong error detection capability. According to statistics, the error probability that the CRC check code cannot be found is less than 0.0047%. Meanwhile, CRC has a special point of low overhead, is easy to realize by using an encoder and a detection circuit, and is far superior to parity check, arithmetic, check and other modes.
The CRC algorithm is mathematically based on binary galois field GF (2) polynomial arithmetic. The GF (2) polynomial has only one variable x, the coefficients of which are only 0 and 1. The CRC algorithm maps a message of length k bits to a GF (2) polynomial M. The sending end and the receiving end agree on a GF (2) polynomial P with the degree r, which is called a generator polynomial. The polynomial corresponding to the addition of r 0 s after the message is M ', obviously M' = Mx r . Dividing M' by P will obtain a remainder polynomial R with degree equal to or less than R-1, and the corresponding R bit value is CRC check code. The transmitting end sends out k bit information together with R bit check code (namely M' + R), the receiving end divides the received polynomial corresponding to all k + R bit data by polynomial P, and judges whether remainder is 0. If 0, no error occurs, otherwise an error occurs.
A complete CRC calculation model should contain the following information:
g: a 16-ary representation of the polynomial P is generated. For example: the contract polynomial for CRC-32 is 0x04C11DB7 (ignoring the most significant "1" and the complete generator is 0x104C11DB 7).
GW: the generator polynomial width, i.e. the number of CRC bits, GW = = r. Such as CRC-8, the generated CRC is 8 bits.
INIT: CRC initial value, consistent with GW bit width
FlipiN: whether each byte of the data to be tested is bit-reversed, true or False. Such as raw data 34 16 (0011 0100 2 ) If FlipIN is True, 2C after turning over 16 (00101100 2 )。
FlipOUT: after calculation, before the exclusive-or output, whether the entire data is bit-inverted, true or False. If the calculated CRC value is 97 16 (10010111 2 ) If FlipOUT is True, a result E9 is obtained after overturning 16 (11101001 2 )。
XOROUT: and XOR-processing the calculation result and the parameter to obtain a final CRC value which is consistent with the GW bit width.
The choice of generator polynomial P affects the checking effect of the CRC. Through theoretical derivation and long-term practical verification, dozens of different standard CRC models are formed. Different fields may use different CRC check codes. For example, in the field of electronic communications, chips DS2401/DS18B20 of American letter (MAXIM), use the CRC-8/MAXIM model; the SD card or MMC uses a CRC-7/MMC model; the Modbus communication uses a CRC-16/MODBUS parameter model; CRC-5/USB and CRC-16/USB models used in the USB protocol; the hardware CRC calculation module of the STM32 uses a CRC-32 model and the like.
The following table lists three standard CRC calculation models:
in addition, the completion of the CRC calculation requires specifying the following two processing objects:
DW: the data bit width. In a practical hardware system, the minimum data granularity bit width that the hardware can provide is R, but the granularity of the data stream that may need to be processed is less than R, so one data bit width must be provided to handle this situation.
DATA: the effective width of the data to be processed, i.e. the object to be verified, is DW.
In view of the bit-wise computation nature of CRC, parallel CRC computations are typically done in hardware. However, parallel fast CRC calculation can only be performed for certain generator polynomials and cannot be configurable. However, in a general system, different CRC models are often required to be switched to adapt to different application scenarios. Therefore, the parameter configuration supporting the CRC model can effectively improve the utilization rate of the hardware and increase the audience range of the hardware.
In the parallel CRC, in the conventional art, some patent applications are proposed by practitioners, including:
CN202110442600.3 "a CRC code parallel computing method, device and application thereof";
CN201611254479.7 "a method, apparatus and network device for implementing cyclic redundancy check CRC";
CN201910028840.1 method for realizing parallel CRC by a multi-stage pipeline circuit;
CN201910927889.0 "CRC check method and apparatus";
CN201910042371.9 "a method and an apparatus for encoding a concatenated CRC code using a polar code";
CN201811295059.2 CRC parallel computing method and system;
the disclosures of the above prior patent documents are directed to parallelization implementations of deterministic polynomials.
In addition, a patent application cn202011335136.X "a method and a system for implementing a polynomial-configurable CRC digital circuit" is proposed by a practitioner, and in the technical scheme thereof, a method and a system for implementing a polynomial-configurable CRC digital circuit are disclosed.
The technical scheme of the patent application has some disadvantages:
1. the technical scheme only aims at CRC calculation of the data stream with the data granularity of bytes. Although the technical solution disclosure refers to generalized N, no method is provided how to generalize the data granularity from itself (8 bits) to N, and this is not a directly applicable procedure. Therefore, the method in this solution can only be applied to multiple 8-bit byte data streams.
2. The technical scheme only mentions the configurable polynomial and does not provide details on how to realize the configurable polynomial to participate in operation in subsequent calculation. When different polynomials are run on fixed hardware, direct participation in the calculation will bring wrong calculation results.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: aiming at the technical problems in the prior art, the invention provides a configurable CRC code calculation method which is simple in principle, simple and convenient to operate and good in flexibility.
In order to solve the technical problems, the invention adopts the following technical scheme:
a configurable CRC code calculation method, comprising the steps of:
step S1: configuring CRC parameters; configuring a CRC configuration variable according to a required CRC parameter model, and clearing a CRC result variable;
step S2: preprocessing parameters; preprocessing a polynomial GPOLY of a CRC model and an initial value INIT, and aligning a most significant bit (namely, a GW bit) of a parameter to a DW bit of the most significant bit of a parameter variable or the most significant bit of data;
and step S3: preprocessing data;
and step S4: calculating a CRC check code; carrying out bitwise XOR operation on the shifted initial value INIT _ PRE and the shifted input DATA DATA _ PRE to obtain INIT _ OR _ DATA; and according to the setting of FlipOUT, carrying out the turnover operation on the CRC calculation result CRCOUT to obtain CRCOUT _ Flip.
As a further improvement of the method of the invention: the step S2 includes:
step S201: generating a polynomial GPOLY left shift (R-GW) bit to obtain GPOLY _ PRE;
step S202: the initial value INIT is shifted left (R-GW) by a bit to obtain INIT _ PRE.
As a further improvement of the process of the invention: the step S2 includes:
step S201: clearing the high R-GW bit of GPOLY and INIT;
step S202: if GW < DW, generating polynomial GPOLY left shift (DW-GW) bit to obtain GPOLY _ PRE; moving the INIT left (DW-GW) bit to obtain INIT _ PRE;
step S203: otherwise, GPOLY and INIT remain unchanged.
As a further improvement of the method of the invention: the step S3 includes:
step S301: acquiring input data;
step S302: if the FlipIN is equal to 1, carrying out overturning operation on the input DATA DATA to obtain DATA _ flip, wherein the overturned DATA are still aligned to the right; otherwise, DATA _ flip = DATA;
step S303: the input DATA DATA _ flip is shifted left (R-DW) by a bit, resulting in DATA _ PRE.
As a further improvement of the process of the invention: the step S3 includes:
step S301: acquiring input data;
step S302: if the FlipIN is equal to 1, carrying out overturning operation on the input DATA DATA to obtain DATA _ flip, wherein the overturned DATA are still aligned to the right; otherwise DATA _ flip = DATA;
step S303: clearing the high-order R-DW bit of the DATA _ flip;
step S304: if GW > DW, DATA DATA _ flip is shifted to the left by (GW-DW) bit to obtain DATA _ PRE; otherwise DATA _ PRE = DATA _ flip.
As a further improvement of the method of the invention: if the system is a left-side high-order alignment system, in step S303, G _ CLR is used for calculation; the xor will be performed using XOROUT _ CLR in the step S304.
As a further improvement of the method of the invention: the step S4 includes:
step S401: carrying out bitwise XOR operation on the shifted initial value INIT _ PRE and the shifted input DATA DATA _ PRE to obtain INIT _ OR _ DATA;
step S402: let crc _ iteration [0] = INIT _ OR _ DATA, i =0;
step S403: for i belongs to [0, D-1], calculating by utilizing GPOLY _ PRE and crc _ iteration [ i ] to obtain crc _ iteration [ i +1]; d results, crc _ iteration [1], \ 8230, crc _ iteration [ D ], are finally obtained in the calculation process according to the sequence of i from small to large; the calculation formula is as follows:
crc _ iteration [ i ] = (crc _ iteration [ i-1] < < 1) ^ ({ R { crc _ iteration [ i-1] [ R ] } } & GPOLY _ PRE); wherein { R { } denotes stitching new data for R repetitions;
step S404: selecting crc _ iteration [ DW ] as CRCOUT according to DW;
step S405: and according to the setting of FlipOUT, carrying out the turnover operation on a CRC calculation result CRCOUT to obtain CRCOUT _ Flip.
As a further improvement of the method of the invention: the step S4 includes:
step S401: carrying out bitwise XOR operation on the shifted initial value INIT _ PRE and the shifted input DATA DATA _ PRE to obtain INIT _ OR _ DATA;
step S402: let crc _ iteration [0] = INIT _ OR _ DATA, i =0;
step S403: for i ∈ [0, D-1], calculating crc _ iteration [ i +1] by using GPOLY _ PRE and crc _ iteration [ i ]. The calculation process gets D results, crc _ iteration [1], \ 8230;, crc _ iteration [ D ], in the order of i from small to large. The calculation formula is as follows:
crc_iteration[i]=(crc_iteration[i-1]<<1)^({R{crc_iteration[i-1][max(DW,GW)]}}&GPOLY_PRE)。
wherein { R { } denotes stitching new data for R repetitions;
step S404: selecting crc _ iteration [ DW ] as CRCOUT according to DW;
step S405: and according to the setting of FlipOUT, carrying out the turnover operation on the CRC calculation result CRCOUT to obtain CRCOUT _ Flip.
As a further improvement of the process of the invention: step S5, post-processing of CRC calculation results; the step S5 includes:
step S501: if other data to be processed still exist, let INIT _ PRE = CRCOUT _ Flip, then jump to step S3, and continue to process the next data;
step S502: if no other data to be calculated exists currently, right shifting CRCOUT _ Flip by GW to obtain CRC _ RESULT;
step S503: and finally, carrying out exclusive OR on the CRC _ RESULT and XOROUT, and outputting the RESULT.
As a further improvement of the process of the invention: step S5, post-processing of CRC calculation results; the step S5 includes:
step S501: if other data to be processed still exist, let INIT _ PRE = CRCOUT _ Flip, then jump to step S3, and continue to process the next data;
step S502: if no other data to be calculated exists currently, if DW > GW, the CRCOUT _ Flip is shifted to the right by DW-GW bit to obtain CRC _ RESULT; otherwise CRC _ RESULT = CRCOUT _ Flip;
step S503: exclusive-or the CRC _ RESULT and xoriout, and output the RESULT.
Compared with the prior art, the invention has the advantages that:
1. the configurable CRC code calculation method has the advantages of simple principle, simplicity and convenience in operation and good flexibility, almost all parameters of the CRC model can be flexibly configured, a solution method is provided for processing small-granularity data by aiming at a large-data bit width system, and the flexibility is greatly improved. Meanwhile, the method provided by the invention is more beneficial to hardware implementation, and the right alignment method can effectively reduce the logic complexity.
2. The invention discloses a configurable CRC code calculation method, mainly discloses a CRC calculation method of a data stream with general width and details thereof, and discloses details of how to complete effective CRC calculation under the conditions of different polynomials and different polynomial widths and also discloses the configurable details of other aspects of a CRC model.
Drawings
FIG. 1 is a schematic flow diagram of the process of the present invention.
Detailed Description
The invention will be described in further detail below with reference to the drawings and specific examples.
In order to facilitate understanding of the technical scheme of the invention, the invention firstly explains some symbols in the technical scheme:
r: the system parameter width is R, and in a typical system, R may be 32.
GPOLY: generating 2-system data corresponding to the polynomial, wherein the width of the data type is R.
INIT: the CRC calculates an initial value, the data type being of width R.
RESULT: the width of the data type is R as a result of CRC calculation.
XOROUT: the CRC results in an exclusive or value and the data type is R wide. And after the calculation is finished, carrying out exclusive OR on the result and XOROUT to obtain a final result.
FlipIN/FlipOUT: respectively indicating whether to bit flip the input data/computation result. 1-indicates inversion, and 0-indicates no inversion.
GW: the width of the CRC, e.g., the GW value for CRC-8, is 8.
D/DW: d denotes a system minimum data bit width, and DW denotes a CRC calculation effective data width. For example, the minimum granularity of system data is 8 bits, but the effective data bit width DW of CRC calculation may be 7 bits, i.e., D > = DW. This facilitates flexible processing of small granularity data by large data bit width systems.
DATA: the input data has a data type bit width of D and an effective data width of DW.
As shown in fig. 1, the configurable CRC code calculation method of the present invention includes the steps of:
step S1: configuring CRC parameters;
and configuring CRC configuration variables according to the currently required CRC parameter model. The CRC result variable is cleared.
Step S2: preprocessing parameters;
suppose the system uses the mode of right alignment of the lower bits of data and the highest bit is on the left (in fact, the general system is right aligned; for the systems of other alignment modes, the result can be obtained through simple corresponding change).
And preprocessing a polynomial GPOLY of the CRC model and an initial value INIT according to the current configuration parameters, and aligning the most significant bit of the parameter, namely the GW bit, to the highest R bit of the parameter variable. Obviously, for the case that the most significant bit of the parameter is already aligned to the R bit, only the low-order invalid data needs to be cleared.
In a specific application example, the step S2 may include:
step S201: the generator polynomial GPOLY is left shifted (R-GW) by a bit to get GPOLY _ PRE.
Step S202: the initial value INIT is shifted left (R-GW) by a bit to obtain INIT _ PRE.
In another specific application example, in step S2, the polynomial GPOLY of the CRC model and the initial value INIT may also be preprocessed according to the current configuration parameter, and the most significant bit of the parameter, i.e., the GW bit, is aligned with the most significant bit of the data, i.e., the DW bit. Therefore, the step S2 may also include:
step S201: clearing the high R-GW bit of GPOLY and INIT;
step S202: if GW < DW, generating polynomial GPOLY left shift (DW-GW) bit to obtain GPOLY _ PRE; moving the INIT left (DW-GW) position to obtain INIT _ PRE;
step S203: otherwise, GPOLY and INIT remain unchanged.
And step S3: preprocessing data;
in a specific application example, the step S3 may include:
step S301: acquiring input data;
step S302: if the FlipIN is equal to 1, carrying out overturning operation on the input DATA DATA to obtain DATA _ flip, wherein the overturned DATA are still aligned to the right; otherwise, DATA _ flip = DATA;
step S303: the input DATA DATA _ flip is shifted left (R-DW) by a bit, resulting in DATA _ PRE.
In another specific application example, the step S3 may also include:
step S301: acquiring input data;
step S302: if FlipIN is equal to 1, the input DATA DATA is flipped to obtain DATA _ flip. The flipped data is still right aligned; otherwise DATA _ flip = DATA;
step S303: clearing the high-order R-DW bit of the DATA _ flip;
step S304: if GW > DW, DATA DATA _ flip is shifted to the left by (GW-DW) bit to obtain DATA _ PRE; otherwise DATA _ PRE = DATA _ flip.
In a specific application, if the system is a left side high alignment system, then in step S303, G _ CLR is used for calculation; xoring will be performed using xorcout _ CLR in step S304.
And step S4: calculating a CRC check code;
in a specific application example, the step S4 may include:
step S401: the shifted initial value INIT _ PRE is bitwise xored with the shifted input DATA _ PRE to obtain INIT _ OR _ DATA (the width of which is still R bits).
Step S402: let crc _ iteration [0] = INIT _ OR _ DATA, i =0;
step S403: for i ∈ [0, D-1], calculating crc _ iteration [ i +1] by using GPOLY _ PRE and crc _ iteration [ i ]. The calculation process gets D results, crc _ iteration [1], \ 8230;, crc _ iteration [ D ], in the order of i from small to large. The calculation formula is as follows:
crc_iteration[i]=(crc_iteration[i-1]<<1)^
({ R { crc _ iteration [ i-1] [ R ] } } & GPOLY _ PRE). Where { R { } denotes stitching new data for R repetitions.
Step S404: according to DW, crc _ iteration [ DW ] is selected as CRCOUT.
Step S405: and according to the setting of FlipOUT, carrying out the turnover operation on a CRC calculation result CRCOUT to obtain CRCOUT _ Flip.
In another specific application example, step S403 in step S4 may also be:
step S403: for i ∈ [0, D-1], using GPOLY _ PRE and crc _ iteration [ i ], calculating crc _ iteration [ i +1]. The calculation process gets D results, crc _ iteration [1], \ 8230;, crc _ iteration [ D ], in the order of i from small to large. The calculation formula is as follows:
crc_iteration[i]=(crc_iteration[i-1]<<1)^({R{crc_iteration[i-1][max(DW,GW)]}}&GPOLY_PRE)。
where { R { } denotes stitching new data for R repetitions.
Step S5: post-processing a CRC calculation result;
in a specific application example, the step S5 may include:
step S501: if there is other data to be processed, let INIT _ PRE = CRCOUT _ Flip, then jump to step S3 and continue processing the next data.
Step S502: if no other data to be calculated exists currently, the CRCOUT _ Flip is shifted to the right by GW bits to obtain CRC _ RESULT.
Step S503: and finally, carrying out exclusive OR on the CRC _ RESULT and XOROUT, and outputting the RESULT.
In another specific application example, the step S5 may also include:
step S501: if there are other data to be processed, let INIT _ PRE = CRCOUT _ Flip, then jump to step S3 and continue processing the next data.
Step S502: if no other data to be calculated exists currently, if DW is larger than GW, the CRCOUT _ Flip is shifted to the right by DW-GW bit to obtain CRC _ RESULT; otherwise CRC _ RESULT = CRCOUT _ Flip.
Step S503: the CRC _ RESULT is xored with xorreut, and the RESULT is output.
In a particular application, CRC calculations are often performed on a series of data. Then, by combining the above technical solutions of the present invention, it can be known that after each data has been calculated with the CRC check code, it is necessary to determine whether there are other data to be processed to determine whether to jump to the beginning to continue processing new data. There is no need to perform post-processing on the result of the CRC calculation before the jump, so that processing of consecutive data does not require re-preprocessing of INIT.
If different embodiments are considered, if the system is implemented in hardware, adding an additional selector is not actually beneficial to the circuit timing, so that the process may be returned to step S2 after the post-processing in step S5 is completed, and a more regular flow is executed. As shown by the dashed path in fig. 1.
The above are only preferred embodiments of the present invention, and the scope of the present invention is not limited to the above examples, and all technical solutions that fall under the spirit of the present invention belong to the scope of the present invention. It should be noted that modifications and embellishments within the scope of the invention may be made by those skilled in the art without departing from the principle of the invention.
Claims (8)
1. A configurable CRC code calculation method, comprising the steps of:
step S1: configuring CRC parameters; configuring a CRC configuration variable according to a required CRC parameter model, and clearing a CRC result variable;
step S2: preprocessing CRC parameters; preprocessing a polynomial GPOLY of a CRC model and an initial value INIT, and aligning a most significant bit (GW bit) of a CRC parameter to a DW bit of the most significant bit of a CRC parameter variable or the most significant bit of data; wherein R represents a system parameter width;
the step S2 comprises the following specific steps:
step S201: generating a polynomial GPOLY, and shifting the R-GW bit to the left to obtain a GPOLY _ PRE;
step S202: shifting an initial value INIT left by an R-GW bit to obtain INIT _ PRE;
and step S3: preprocessing data; the method comprises the following specific steps:
step S301: acquiring input data;
step S302: if the FlipIN is equal to 1, carrying out overturning operation on the input DATA DATA to obtain DATA _ flip, and still aligning the overturned DATA to the right; otherwise, DATA _ flip = DATA;
step S303: the input DATA DATA _ flip is shifted left by R-DW bit to obtain DATA _ PRE;
and step S4: calculating a CRC check code; carrying out bitwise XOR operation on the shifted initial value INIT _ PRE and the shifted input DATA DATA _ PRE to obtain INIT _ OR _ DATA; and according to the setting of FlipOUT, carrying out the turnover operation on the CRC calculation result CRCOUT to obtain CRCOUT _ Flip.
2. A configurable CRC code computation method,
step S1: configuring CRC parameters; configuring a CRC configuration variable according to a required CRC parameter model, and clearing a CRC result variable;
step S2: preprocessing CRC parameters; preprocessing a polynomial GPOLY of a CRC model and an initial value INIT, and aligning a most significant bit (GW bit) of a CRC parameter to a DW bit of the most significant bit of a CRC parameter variable or the most significant bit of data; wherein R represents the system parameter width;
the step S2 comprises the following specific steps:
step S201: clearing the high R-GW bit of GPOLY and INIT;
step S202: if GW < DW, generating polynomial GPOLY to shift DW-GW bit to the left to obtain GPOLY _ PRE; moving the DW-GW bit to the left by the INIT to obtain INIT _ PRE;
step S203: otherwise, GPOLY and INIT remain unchanged;
and step S3: preprocessing data; the method comprises the following specific steps:
step S301: acquiring input data;
step S302: if the FlipIN is equal to 1, carrying out overturning operation on the input DATA DATA to obtain DATA _ flip, and still aligning the overturned DATA to the right; otherwise, DATA _ flip = DATA;
step S303: the input DATA DATA _ flip is shifted to the left by the R-DW bit to obtain DATA _ PRE;
and step S4: calculating a CRC check code; carrying out bitwise XOR operation on the shifted initial value INIT _ PRE and the shifted input DATA DATA _ PRE to obtain INIT _ OR _ DATA; and according to the setting of FlipOUT, carrying out the turnover operation on the CRC calculation result CRCOUT to obtain CRCOUT _ Flip.
3. A configurable CRC code calculation method,
step S1: configuring CRC parameters; configuring a CRC configuration variable according to a required CRC parameter model, and clearing a CRC result variable;
step S2: preprocessing parameters; preprocessing a polynomial GPOLY of a CRC model and an initial value INIT, and aligning a most significant bit (namely, a GW bit) of a parameter to a DW bit of the most significant bit of a parameter variable or the most significant bit of data; wherein R represents a system parameter width;
the step S2 comprises the following specific steps:
step S201: generating a polynomial GPOLY, and shifting the R-GW bit to the left to obtain a GPOLY _ PRE;
step S202: shifting an initial value INIT left by an R-GW bit to obtain INIT _ PRE;
and step S3: preprocessing data; the method comprises the following specific steps:
step S301: acquiring input data;
step S302: if the FlipIN is equal to 1, carrying out overturning operation on the input DATA DATA to obtain DATA _ flip, wherein the overturned DATA are still aligned to the right; otherwise DATA _ flip = DATA;
step S303: clearing the high-order R-DW bit of the DATA _ flip;
step S304: if GW is larger than DW, DATA DATA _ flip is shifted to the left by GW-DW bit to obtain DATA _ PRE; otherwise DATA _ PRE = DATA _ flip;
and step S4: calculating a CRC check code; performing bitwise XOR operation on the shifted initial value INIT _ PRE and the shifted input DATA DATA _ PRE to obtain INIT _ OR _ DATA; and according to the setting of FlipOUT, carrying out the turnover operation on a CRC calculation result CRCOUT to obtain CRCOUT _ Flip.
4. A configurable CRC code computation method,
step S1: configuring CRC parameters; configuring a CRC configuration variable according to a required CRC parameter model, and clearing a CRC result variable;
step S2: preprocessing parameters; preprocessing a polynomial GPOLY of a CRC model and an initial value INIT, and aligning a most significant bit (GW bit) of a parameter to a DW bit of the most significant bit of a parameter variable or the most significant bit of data; wherein R represents a system parameter width;
the step S2 comprises the following specific steps:
step S201: clearing the high R-GW bit of GPOLY and INIT;
step S202: if GW < DW, generating polynomial GPOLY to shift DW-GW bit to the left to obtain GPOLY _ PRE; moving the DW-GW bit to the left by the INIT to obtain INIT _ PRE;
step S203: otherwise, GPOLY and INIT remain unchanged;
and step S3: preprocessing data; the method comprises the following specific steps:
step S301: acquiring input data;
step S302: if the FlipIN is equal to 1, carrying out overturning operation on the input DATA DATA to obtain DATA _ flip, wherein the overturned DATA are still aligned to the right; otherwise DATA _ flip = DATA;
step S303: clearing the high-order R-DW bit of the DATA _ flip;
step S304: if GW is larger than DW, DATA DATA _ flip is shifted to the left by GW-DW bit to obtain DATA _ PRE; otherwise DATA _ PRE = DATA _ flip;
and step S4: calculating a CRC check code; performing bitwise XOR operation on the shifted initial value INIT _ PRE and the shifted input DATA DATA _ PRE to obtain INIT _ OR _ DATA; and according to the setting of FlipOUT, carrying out the turnover operation on a CRC calculation result CRCOUT to obtain CRCOUT _ Flip.
5. The method for calculating the configurable CRC code according to any one of claims 1 to 4, wherein said step S4 comprises:
step S401: carrying out bitwise XOR operation on the shifted initial value INIT _ PRE and the shifted input DATA DATA _ PRE to obtain INIT _ OR _ DATA;
step S402: let crc _ iteration [0] = INIT _ OR _ DATA, i =0;
step S403: for i belongs to [0, D-1], calculating by utilizing GPOLY _ PRE and crc _ iteration [ i ] to obtain crc _ iteration [ i +1]; d results, crc _ iteration [1], \ 8230, crc _ iteration [ D ], are finally obtained in the calculation process according to the sequence of i from small to large; wherein D represents the minimum data bit width of the system, and the calculation formula is as follows:
crc_iteration[i]=(crc_iteration[i-1]<<1)^
({ R { crc _ iteration [ i-1] [ R ] } } & GPOLY _ PRE); wherein { R { } denotes splicing R times repeatedly into new data;
step S404: selecting crc _ iteration [ DW ] as CRCOUT according to DW;
step S405: and according to the setting of FlipOUT, carrying out the turnover operation on the CRC calculation result CRCOUT to obtain CRCOUT _ Flip.
6. The method for calculating the configurable CRC code according to any one of claims 1 to 4, wherein the step S4 comprises:
step S401: carrying out bitwise XOR operation on the shifted initial value INIT _ PRE and the shifted input DATA DATA _ PRE to obtain INIT _ OR _ DATA;
step S402: let crc _ iteration [0] = INIT _ OR _ DATA, i =0;
step S403: for i belongs to [0, D-1], calculating by utilizing GPOLY _ PRE and crc _ iteration [ i ] to obtain crc _ iteration [ i +1]; d results, crc _ iteration [1], \ 8230, crc _ iteration [ D ], are finally obtained in the calculation process according to the sequence from small to large of i; wherein D represents the system minimum data bit width, and the calculation formula is as follows:
crc_iteration[i]=(crc_iteration[i-1]<<1)^({R{crc_iteration[i-1][max(DW,GW)]}}&GPOLY_PRE);
wherein { R { } denotes splicing R times repeatedly into new data;
step S404: selecting crc _ iteration [ DW ] as CRCOUT according to DW;
step S405: and according to the setting of FlipOUT, carrying out the turnover operation on a CRC calculation result CRCOUT to obtain CRCOUT _ Flip.
7. The method for calculating the configurable CRC code according to any one of the claims 1-4, further comprising a step S5 of post-processing the result of CRC calculation; the step S5 includes:
step S501: if other data to be processed still exist, let INIT _ PRE = CRCOUT _ Flip, then jump to step S3, and continue to process the next data;
step S502: if no other data to be calculated exists currently, right shifting CRCOUT _ Flip by GW to obtain CRC _ RESULT;
step S503: and finally, performing exclusive OR on the CRC _ RESULT and the XOROUT, and outputting a RESULT.
8. The method for calculating the configurable CRC code according to any one of claims 1 to 4, further comprising a step S5 of post-processing a CRC calculation result; the step S5 includes:
step S501: if other data to be processed still exist, let INIT _ PRE = CRCOUT _ Flip, then jump to step S3, and continue to process the next data;
step S502: if no other data to be calculated exists currently, if DW > GW, the CRCOUT _ Flip is shifted to the right by DW-GW bit to obtain CRC _ RESULT; otherwise CRC _ RESULT = CRCOUT _ Flip;
step S503: the CRC _ RESULT is xored with xorreut, and the RESULT is output.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111587754.8A CN114443347B (en) | 2021-12-23 | 2021-12-23 | Configurable CRC code calculation method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111587754.8A CN114443347B (en) | 2021-12-23 | 2021-12-23 | Configurable CRC code calculation method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114443347A CN114443347A (en) | 2022-05-06 |
CN114443347B true CN114443347B (en) | 2022-11-22 |
Family
ID=81363493
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111587754.8A Active CN114443347B (en) | 2021-12-23 | 2021-12-23 | Configurable CRC code calculation method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114443347B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103731239A (en) * | 2013-12-31 | 2014-04-16 | 中国科学院自动化研究所 | Universal CRC parallel calculation component suitable for being used for vector processor and method |
CN105162551A (en) * | 2015-07-29 | 2015-12-16 | 中工科安科技有限公司 | Calculation method for CRC security check code for encoder signal processing |
Family Cites Families (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1148650A1 (en) * | 2000-04-14 | 2001-10-24 | Matsushita Electric Industrial Co., Ltd. | Crc operation unit and crc operation method |
US8255754B2 (en) * | 2007-05-15 | 2012-08-28 | Texas Instruments Incorporated | Range extension and noise mitigation for wireless communication links utilizing a CRC based single and multiple bit error correction mechanism |
CN100517214C (en) * | 2007-05-30 | 2009-07-22 | 北京天碁科技有限公司 | Hardware configuration method implementing binary system polynomial arithmetic and hardware system |
US8464125B2 (en) * | 2009-12-10 | 2013-06-11 | Intel Corporation | Instruction-set architecture for programmable cyclic redundancy check (CRC) computations |
CN101783688B (en) * | 2010-03-05 | 2013-08-14 | 苏州和迈微电子技术有限公司 | Design method of 64-bit parallel multi-mode CRC code generation circuit |
CN102761394A (en) * | 2012-07-05 | 2012-10-31 | 中兴通讯股份有限公司 | Method and device for processing data |
US8726124B2 (en) * | 2012-07-19 | 2014-05-13 | Nvidia Corporation | Cyclic redundancy check generation via distributed time multiplexed linear feedback shift registers |
JP6829024B2 (en) * | 2016-08-03 | 2021-02-10 | ルネサスエレクトロニクス株式会社 | CRC arithmetic circuit, semiconductor device and radar system |
WO2019029566A1 (en) * | 2017-08-08 | 2019-02-14 | 维沃移动通信有限公司 | Method and device for cyclic redundancy check |
US11553343B2 (en) * | 2018-12-12 | 2023-01-10 | Qualcomm Incorporated | Real-time soft combining, CRC validation, and MIC validation of decrypted packets |
JP2021039672A (en) * | 2019-09-05 | 2021-03-11 | キオクシア株式会社 | Memory system, packet protection circuit, and crc calculation method |
CN112350735A (en) * | 2020-11-24 | 2021-02-09 | 广芯微电子(广州)股份有限公司 | Method and system for realizing polynomial-configurable CRC digital circuit |
-
2021
- 2021-12-23 CN CN202111587754.8A patent/CN114443347B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103731239A (en) * | 2013-12-31 | 2014-04-16 | 中国科学院自动化研究所 | Universal CRC parallel calculation component suitable for being used for vector processor and method |
CN105162551A (en) * | 2015-07-29 | 2015-12-16 | 中工科安科技有限公司 | Calculation method for CRC security check code for encoder signal processing |
Also Published As
Publication number | Publication date |
---|---|
CN114443347A (en) | 2022-05-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8468439B2 (en) | Speed-optimized computation of cyclic redundancy check codes | |
US7590916B2 (en) | Cyclic redundancy checking value calculator | |
US20120030548A1 (en) | Method and device for implementing cyclic redundancy check codes | |
CN107239362B (en) | Parallel CRC (Cyclic redundancy check) code calculation method and system | |
CN104601275B (en) | Method, encoder, decoder and communication system for encoding data | |
KR20020036605A (en) | Circuit for detecting errors in a CRC code in which parity bits are attached reversely and a mothod therefor | |
CN108282265A (en) | Error correction/encoding method, device, equipment and computer readable storage medium | |
CN108270508B (en) | Cyclic redundancy check CRC implementation method, device and network equipment | |
CN101296053A (en) | Method and system for calculating cyclic redundancy check code | |
CN107733568B (en) | Method and device for realizing CRC parallel computation based on FPGA | |
CN114443347B (en) | Configurable CRC code calculation method | |
EP3737013B1 (en) | Encoding method, decoding method and device | |
CN114443348B (en) | Computing system capable of configuring CRC (Cyclic redundancy check) code | |
US11804855B2 (en) | Pipelined forward error correction for vector signaling code channel | |
Babaie et al. | Double bits error correction using CRC method | |
CN115882876A (en) | Data coding verification method, system, equipment, medium and circuit | |
Potey et al. | Error Detection and Correction Capability for BCH Encoder using VHDL | |
Chi et al. | Fast software-based table-less algorithm for CRC generation | |
US20100031126A1 (en) | System and method for using the universal multipole for the implementation of a configurable binary bose-chaudhuri-hocquenghem (BCH) encoder with variable number of errors | |
CN113821370A (en) | High-speed CRC (cyclic redundancy check) generation method and device for data transmission error check | |
Khalifa et al. | Cyclic redundancy encoder for error detection in communication channels | |
KR20020033227A (en) | Circuit for parallel cyclic redundancy check in data communication | |
CN110603759B (en) | Unified error correction and detection code generator | |
Shunjiang et al. | An improved CRC calibration in power communication | |
Ramesh et al. | FPGA Implementation of High Speed and Low Power Viterbi Decoder Using Reverse Algorithm of Convolution Encoder |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |