This application claims priority to Indian patent application no. 4467/CHE/2015 filed on Aug. 25, 2015, the complete disclosure of which, in its entirety, is herein incorporated by reference.
Technical Field
The embodiments herein generally relate to a system and a method for validating transmitted data or received data, and, more particularly, to a system and a method for validating transmitted data or received data by computing cyclic redundancy check (CRC) of a data stream by combining CRCs of segments of data stream using a CRC combiner which reduces a hardware area and a number of clock cycles.
Description of the Related Art
In telecommunication, error detection and correction or error control are techniques that enable reliable delivery of digital data over unreliable communication channels. Many communication channels are subject to channel noise, and thus errors may be introduced during transmission from the source to a receiver. Error detection techniques allow detecting such errors, while error correction enables reconstruction of the original data in many cases. In several communication systems, the error correction may be validated using cyclic redundancy check (CRC). Cyclic redundancy check (CRC) refers to an error-detecting code commonly used in digital networks and storage devices to detect accidental changes in raw data. Pursuant to an exemplary scenario, blocks of data entering the communication systems may get a short check value attached based on the remainder of a polynomial division of their contents, on retrieval the calculation is repeated, and corrective action may be taken against presumed data corruption if the check values do not match.
Conventional CRC computation for high throughput applications requires segmenting input data stream into multiple segments and computing CRCs of each of the segments. These CRCs are appended with variable number of zeroes based on the segment number and a CRC is computed on each of the resulting streams producing intermediate CRCs. These intermediate CRC outputs are then XORed to compute the final CRC of the input stream of data as described in the
CRC(M)=CRC(Σi=0N−1Cixi*k)
Another conventional approach replaces each of n*(N−K) shift of
During decoding process in the receiver, the data stream is processed in segments to decode the segments in parallel. Inherently, the CRC requires the complete packet of data stream to be available for computation. When data is available in segments and/or when there is a high throughput requirement for the CRC computation, the CRC is computed on the segments, and the results are combined to get the final CRC. The shifting logic increases area in hardware as the length of the message increases. This affects the high throughput requirement when the parallel CRC computation is required.
Accordingly, there remains a need for a system and method that computes parallel CRCs, and combines the parallel CRC efficiently to reduce memory requirements, clock cycles, and/or latency.
In view of foregoing embodiments herein is provided a method of performing cyclic redundancy check (CRC) of an input data stream. a) A plurality of segments corresponding to the input data stream is obtained. b) A CRC is computed for each of the plurality of segments for obtaining a plurality of partial CRCs. c) A register is initialized with a partial CRC of Nth segment of the plurality of segments. The Nth segment is a most significant segment of the plurality of segments of the input data stream. d) A Boolean operation is performed, using at least one Boolean function unit, on the partial CRC of Nth segment to obtain a first intermediate CRC based on a length of (N−1)th segment of the plurality of segments. e) The first intermediate CRC is added to a partial CRC of (N−1)th segment of the plurality of segments to obtain a second intermediate CRC. f) The steps d) and e) are repeated until a partial CRC associated with a least significant segment of the plurality of segments is added to a first intermediate CRC corresponding to a second segment of the plurality of segments to obtain a final CRC corresponding to the input data stream.
The final CRC of the input data stream may be computed in accordance with an equation CRC(M)=CRC(CRC(CRC . . . (CRC(CRC(SN−1*xL
The final CRC of the input data stream may be computed in accordance with an equation CRC(M,G)=F(F . . . (F((F(CN−1,LN−2,G)+CN−2),LN−3,G), . . . +C1)L0,G)+C0). The F is Boolean operation for a particular CRC polynomial, Ci is a CRC of a particular segment i, LN−2 is an amount of zero padding based on a length of a third most significant segment, LN−3 is an amount of zero padding based on a length of a fourth most significant segment, L0 is an amount of zero padding based on a length of a least significant segment, and G is a generator polynomial. The Boolean operation (F), for a particular CRC polynomial G, may be implemented in k stages. A stage ‘t’ of the k stages includes a Boolean function, that performs CRC of an input of the stage ‘t’ padded with 2t zeroes, which may be implemented using a XOR operator per output bit j that ranges from 0 to r−1 on a predetermined set of selected input bits of the stage ‘t’ based on a generator polynomial G, t and j. Each output of the Boolean function may be selected as an output of a stage when a bit Li(t) is 1, where T is equal to 0:(k−1). The k stages is equal to r stages, where r is a number of bits required to represent a length Li in binary form as Li(r−1) to Li(0).
A stage ‘t’ of the k stages includes a Boolean function, that performs CRC of an input of the stage ‘t’ padded with 2Xt zeroes, implemented using a XOR operator per output bit j that ranges from 0 to r−1, on a predetermined selected input bits of the each stage based on a generator polynomial G, t and j. The ‘t’ ranges from 0 to (k−1) and sum of Xt is Li. In one embodiment, the Boolean function may be implemented using other possible logic operators. Boolean operation (F), for a selectable CRC polynomial G, may be implemented in r stages, r being a number of bits required to represent a length Li in binary form as Li(r−1) to Li(0). A stage ‘t’ of the r stages includes a Boolean function, that performs CRC of an input of said stage ‘t’ padded with 2t zeroes, which may be implemented using a XOR operator per output bit j that ranges from 0 to r−1, on input bits corresponding to the ‘t’ stage and are selected by G, t, and j. The j is stage output hit position of the stage ‘t’. Each output of the Boolean function ay be selected as an output of a stage when a bit Li(t) is 1. The input data stream may include a plurality of segments of equal size. The input data stream may include at least one segment which differs in size with respect to other segments of the plurality of segments.
In another aspect, a cyclic redundancy check combiner circuit is provided. The CRC combiner circuit includes a register for storing partial CRCs of a plurality of segments corresponding to an input data stream, a Boolean function unit communicatively associated with the register for performing a Boolean operation on partial CRC of an Nth segment from among the plurality of segments to obtain an intermediate CRC based on a length of (N−1)th segment of the plurality of segments, and an XOR unit communicatively associated with the Boolean function unit for adding the intermediate CRC to a partial CRC of (N−1)th segment of the plurality of segments to obtain a second intermediate CRC. The Nth is a most significant segment of the plurality of segments of the input data stream. The XOR unit may add a partial CRC associated with a least significant segment of the plurality of segments to a first intermediate CRC corresponding to a second segment of the plurality of segments to obtain a final CRC corresponding to the input data stream.
The final CRC of the input data stream may be computed in accordance with an equation CRC(M)=CRC(CRC(CRC . . . (CRC(CRC(SN−1*xL
The final CRC of the input data stream may be computed in accordance with an equation CRC(M,G)=F(F . . . (F((F(CN−1,LN−2,G)+CN−2),LN−3,G), . . . +C1)L0,G)+C0). The F is Boolean operation for a particular CRC polynomial, Ci is a CRC of a particular segment i, LN−2 is an amount of zero padding based on a length of a third most significant segment, LN−3 is an amount of zero padding based on a length of a fourth most significant segment, L0 is an amount of zero padding based on a length of a least significant segment, and G is a generator polynomial. The Boolean operation (F), for a particular CRC polynomial G, may be implemented in k stages. A stage ‘t’ of the k stages includes a Boolean function, that performs CRC of an input of the stage ‘t’ padded with 2t zeroes, which may be implemented using a XOR operator per output bit j that ranges from 0 to r−1, on a predetermined set of selected input bits of the stage ‘t’ based on a generator polynomial G, t and j. Each output of the Boolean function may be selected as an output of a stage when a bit Li(t) is 1, where ‘t’ is equal to 0:(k−1). The k stages are equal to r stages, and where r is a number of bits required to represent a length Li in binary form as Li(r−1) to Li(0).
A stage ‘t’ of the k stages includes a Boolean function, that performs CRC of an input of the stage ‘t’ padded with 2Xt zeroes, implemented using a XOR operator per output bit j that ranges from 0 to r−1, on a predetermined selected input bits of the each stage based on a generator polynomial G, t and j. The ‘t’ ranges from 0 to (k−1) and sum of Xt is Li. In one embodiment, the Boolean function may be implemented using other possible logic operators. Boolean operation (F), for a selectable CRC polynomial G, may be implemented in r stages, r being a number of bits required to represent a length Li in binary form as Li(r−1) to Li(0). A stage ‘t’ of the r stages includes a Boolean function, that performs CRC of an input of said stage ‘t’ padded with 2t zeroes, which may be implemented using a XOR operator per output bit j that ranges from 0 to r−1, on input bits corresponding to the ‘t’ stage and are selected by G, t, and j. The j is stage output bit position of the stage ‘t’. Each output of the Boolean function may be selected as an output of a stage when a bit Li(t) is 1. The input data stream may include a plurality of segments of equal size.
These and other aspects of the embodiments herein will be better appreciated and understood when considered in conjunction with the following description and the accompanying drawings. It should be understood, however, that the following descriptions, while indicating preferred embodiments and numerous specific details thereof, are given by way of illustration and not of limitation. Many changes and modifications may be made within the scope of the embodiments herein without departing from the spirit thereof, and the embodiments herein include all such modifications.
The embodiments herein will be better understood from the following detailed description with reference to the drawings, in which:
The embodiments herein and the various features and advantageous details thereof are explained more fully with reference to the non-limiting embodiments that are illustrated in the accompanying drawings and detailed in the following description. Descriptions of well-known components and processing techniques are omitted so as to not unnecessarily obscure the embodiments herein. The examples used herein are intended merely to facilitate an understanding of ways in which the embodiments herein may be practiced and to further enable those of skill in the art to practice the embodiments herein. Accordingly, the examples should not be construed as limiting the scope of the embodiments herein.
As mentioned, there remains a need for a system and a method that computes segment CRCs, and combines the segment CRCs to reduce the hardware area and the number of clock cycles. Referring now to the drawings, and more particularly to
The second intermediate CRC of the first stage is provided as an input to the register 302, which again undergoes a Boolean operation based on a length of the (N−2) segment of the plurality of segments to obtain a first intermediate CRC of a second stage. The XOR unit 306 adds the first intermediate CRC of the second stage to a partial CRC of next segment 308 (i.e., (N−2)th segment) of the plurality of segments to obtain a second intermediate CRC of the second stage. The steps of performing a Boolean operation by the Boolean function unit 304 and adding a first intermediate CRC of a stage to a partial CRC of a next most significant segment by the XOR unit 306, are repeated until a partial CRC associated with a least significant segment of the plurality of segments is added to a first intermediate CRC corresponding to a second segment of the plurality of segments to obtain a final CRC of the input data stream. Consider for example, if the input data stream is segmented into 3 segments (the most significant segment S2, the intermediate segment S1, and the least significant segment S0) of equal or unequal size. The segment CRC associated with the segment S2, S1, S0 are C2. C1 and C0 respectively. The CRC combination of the 3 segments CRCs is performed over 2 stages. In the first stage, the register 302 is initialized with the segment CRC (C1). The Boolean function unit 304 performs a Boolean operation on the segment CRC C2, based on the length of segment S1 to obtain a first intermediate CRC of the first stage. The XOR unit 306 adds the first intermediate CRC of the first stage to the segment CRC C1 to obtain a second intermediate CRC of the first stage.
In the second stage, the register 302 is initialized with the second intermediate CRC of the first stage. Thus, the register 302 stores the segment CRC associated with the segment S2 of the input data stream initially, and subsequently stores one or more intermediate CRCs computed at one or more stages of computing a final CRC of the input data stream. The Boolean function unit 304 performs a Boolean operation on the second intermediate CRC based on a length of segment S0 to obtain a first intermediate CRC of the second stage. The XOR unit 306 adds the first intermediate CRC of the second stage to the segment CRC of the segment S0 to obtain a final CRC of the input data stream.
In one embodiment, a final CRC of a message (M) is computed in accordance with an equation
CRC(M)=CRC(CRC(CRC . . . (CRC(CRC(SN−1*xL
The below table indicates an example of computing a final CRC of an input data stream consisting 4 segments S3, S2, S1 and S0 of length L3, L2, L1 and L0 and having segment CRC C3, C2, C1 and C0 respectively using the CRC combiner circuit 204 disclosed herein. As indicated in the table, when S3 is most significant segment and S0 is least significant segment. In this example segment lengths are L3=20, L2=53, Li=31 and L0=44.
A mathematical expression for computing a final CRC of an input data stream (Message M) using the CRC combiner circuit 204 is described below. When an input data stream is divided into segments of equal lengths or unequal lengths, the lengths of segments depend on a size of the input data stream. Hence, the Boolean function unit 304 makes a shift amount to be configurable. For a shift amount “R” which requires r bits for its representation in binary system, a maximum shift of 2r−1 can be accommodated by the same circuit.
Let M be a message of length “K” bits divided into “N” segments of equal length “n” bits each. The message is divided into segments of consecutive bits.
M=M
N−1
∥M
N−2
∥ . . . ∥M
1
∥M
0 (1)
where ∥ represents concatenation of bits.
Each Mi , where i=0 to N−1 is a segment of n bits as shown below.
M
i
=M
i(n−1)∥Mi(n−2)∥ . . . ∥Mi(1)∥Mi(0) (2)
In polynomial form, Mi is written as
In polynomial form, M can be written as
M(x)=MN−1(x)+MN−2(x)+ . . . +M1(x)+M0(x) (5)
Substituting each of Mi(x) to form the polynomial form of M,
M(x)=MN−1′(x)*x(N−1)*(n)+MN−2′(x)*x(N−2)*(n)+ . . . +M0′(x)*x(1)*(n)+M0′(x)*x(0)*(n) (6)
CRC of a message polynomial for a given generator polynomial is the remainder of the message polynomial when divided by the generator polynomial. Hence CRC can also be defined as
CRC(M)=mod(M(x),G(x)) (7)
G(x) is the generator polynomial for the CRC
Applying modulo to M(x) and using distributive property of modulo operation.
CRC(M)=mod([x(N−1)*(n)*mod(MN−1′(x),G(x))+x(N−2)*(n)*mod(MN−2′(x),G(x))+ . . . +x(1)*(n)*mod(M1′(x),G(x))+x(0)*(n)*mod(M0′(x),G(x))],G(x)) (8)
Letting Ci=mod(Mi′(x),G(x)) (9)
Hence equation (8) can be written compactly as,
CRC(M)=CRC[x(N−1)*(n)*CN+1+xN−2)*(n)*CN−2+ . . . +x(1)*(n)*C1+x(0)*(n)*C0] (10)
From prior art, the parallel CRC can be written concisely as
CRC(M)=CRC(Σi=0N−1Cixi*n) (11)
The CRC has some interesting properties due to its definition in equation (7)
If A and B are two binary streams, then
CRC(A*B)=CRC(CRC(A)*CRC(B)) (12)
CRC(xn*B)=CRC(xn*CRC(B)) (13)
Applying equation (13) to first two terms of equation (10), we get
CRC (x(N−1)*(n)*CN−1+x(N−2)*(n)*CN−2)=CRC(x(N−2)*(n)*CRC(x(n)*CN−1+CN−2)) (14)
The expression within outer CRC in equation (8), can be expressed in a nested form by applying equation (13) recursively as shown in equation (14).
CRC(M)=CRC(CRC(CRC . . . (CRC(CRC(CN−1*xn+CN−2)*xn+CN−3)*xn+CN−4) . . . *xn+C1)*xn+C0) (15)
Defining C′(0)=CN−1, (16)
And using the above recursive relation for i=1 to N−1
C′(i)=CRC(C′(i−1)*xn+CN−i−1) (17)
CRC(M)=C′(N−1) (18)
Where multiplication (*) by xn is right shift (by appending n zeros) n bits and addition (+) is XOR in hardware.
Equation (11) can also be written in another form as shown below due to the distributive property of modulo operation
CRC(M)=Σi=0N−1CRC(Cixi*n) (19)
Implementing the above equation in hardware requires the CRC of segment i, which is C1 , to be shifted by i*n bits by inserting those many zeroes and taking CRC of the resulting sequence. Each of the above calculated CRCs (after zero insertion and additional CRC) are then XORed to give the final CRC of the input data stream. This requires a maximum shift of (N−1)*n and taking CRC of a resulting sequence which requires (N−1)*n clock cycles for completion.
This prior art implementation is improved by using the CRC combiner circuit 204, which is equivalent to operation of zero appending a data stream and computing CRC on a resulting stream. In one embodiment, when implemented using equation (19), the CRC combiner circuit 204 requires 1 clock cycle for completion. The logic associated with each segment is different as shift length required for each segment is different.
Using equation (15) with the CRC combiner circuit 204, there is a requirement for only one value of shift that is n. Hence, using the CRC combiner 204 reduces area requirement and computation is done recursively over N cycles. In an example embodiment, implementing the equation (19) requires variable shifts for each segment CRC, which is as large as 1000*7 when a segment size n=1000 and number of segments is 8. Typically, a hardware area required to compute, CRC with variable shifts, is over 50K NAND gates. Implementing equation (15) requires constant shift of n=1000. The hardware area to compute this shift using the CRC combiner circuit 204 is 5 k NAND gates.
With reference to
Let M be a message of any length and its 5-bit CRC be represented as {a, b, c, d, e}. The 5-bit CRC “a” to “e” is bit values in the bit registers 404A-E from left to right respectively after all data bits are processed by the CRC circuit. This instant of time is denoted as “t0”. Assuming that M is padded with a single zero. In the next clock pulse (at time t0+1), an input data bit for the CRC circuit would be zero and the bit registers 404A-E would get updated as shown below in the below table. Updated values form CRC of the data padded with one zero. If M is padded with 2 zeroes, in a next clock pulse (at time t0+2), the input data bit for the CRC circuit would be zero and the updated register contents are shown below in the below table. After padding a given number of zeroes and taking CRC over a resulting stream, a resulting CRC is derivable from unpadded CRC.
{A, B, C, D, and E} are outputs of Boolean function units (e.g., F1 and F2) as depicted in
In general, every bit of CRC output of zero appended input stream is a function of CRC bits of original data. Mapping to a CRC bit of padded data from the CRC bits of unpadded data depends on amount of zero padding and a generator polynomial (as the generator polynomial decides which registers are directly influenced by an input data bit).
The Boolean function F applied on its input CN−1,i and given amount of zero pad “Li”, is mathematically equivalent to F(CN−1,i−1,Li,G)=CRC(xLi*SN−1,i). Segment SN−1,i is the segment of message M, formed by concatenation of segments from SN−1 to Si (i.e., a segment of n bits), where N>i. The arguments of F show the dependence of F on the zero padding amount Li and generator polynomial G. This is equivalent to padding an input SN−1,i with “Li” zeros and then taking CRC of the resulting stream. Since the function F is dependent on a number of padded zeroes (Li), given an arbitrary shift Li, it can be represented as an r bit number [Li(r−1) Li(r−2). Li(1) Li(0)] where
L
i=2r−1*Li(r-31 1)+2r−2*Li(r−2)+2r−3*Li(r−3)+ . . . +21*Li(1)+20*L0(0)
r is a number of binary bits used to represent a shift Li.
Li(r−1) to Li(0) are bit values of binary representation of Li.
For example if Li=9=8+1=1001 in binary system
x
Li
*C
i
=x
9
*C
i
=x
8
*x
1
*C
i
=x
8*(x1*Ci)
By the property of CRC, CRC (xLi*Ci)=CRC (x8*CRC (x1*Ci))
The final CRC of the input data stream is computed in accordance with an equation CRC(M)=CRC(CRC(CRC . . . (CRC(CRC(SN−1*xL
The Boolean operation (F), for a particular CRC polynomial G, is implemented in k stages as described above in the description of
The Boolean operation (F), for a selectable CRC polynomial G, is implemented in r stages, where r is a number of bits required to represent a length Li in binary form as Li(r−1) to Li(0), as described and depicted in the
The foregoing description of the specific embodiments will so fully reveal the general nature of the embodiments herein that others can, by applying current knowledge, readily modify and/or adapt for various applications such specific embodiments without departing from the generic concept, and, therefore, such adaptations and modifications should and are intended to be comprehended within the meaning and range of equivalents of the disclosed embodiments. It is to be understood that the phraseology or terminology employed herein is for the purpose of description and not of limitation. Therefore, while the embodiments herein have been described in terms of preferred embodiments, those skilled in the art will recognize that the embodiments herein can be practiced with modification within the spirit and scope of the appended claims,
Number | Date | Country | Kind |
---|---|---|---|
4467/CHE/2015 | Aug 2015 | IN | national |