Data transmitted over network connections or retrieved from a storage device, for example, may be corrupted for a variety of reasons. For instance, a noisy transmission line may change a “1” signal to a “0”, or vice versa. To detect corruption, data is often accompanied by some value derived from the data such as a checksum. A receiver of the data can recompute the checksum and compare with the original checksum to confirm that the data was likely transmitted without error.
A common technique to identify data corruption is known as a Cyclic Redundancy Check (CRC). Though not literally a checksum, a CRC value can be used much in the same way. That is, a comparison of an originally computed CRC and a recomputed CRC can identify data corruption with a very high likelihood. CRC computation is based on interpreting message bits as a polynomial, where each bit of the message represents a polynomial coefficient. For example, a message of “1110” corresponds to a polynomial of x3+x2+x+0. The message is divided by another polynomial known as the key. For example, the other polynomial may be “11” or x+1. A CRC is the remainder of a division of the message by the key. CRC polynomial division, however, is somewhat different than ordinary division in that it is computed over the finite field GF(2) (i.e., the set of integers modulo 2). More simply put: even number coefficients become zeroes and odd number coefficients become ones.
A wide variety of techniques have been developed to perform CRC calculations. A first technique uses a dedicated CRC circuit to implement a specific polynomial key. This approach can produce very fast circuitry with a very small footprint. The speed and size, however, often come at the cost of inflexibility with respect to the polynomial key used. Additionally, supporting multiple keys may increase the circuitry footprint nearly linearly for each key supported.
A second commonly used technique features a CRC lookup table where, for a given polynomial and set of data inputs and remainders, all possible CRC results are calculated and stored. Determining a CRC becomes a simple matter of performing table lookups. This approach, however, generally has a comparatively large circuit footprint and may require an entire re-population of the lookup table to change the polynomial key being used.
A third technique is a programmable CRC circuit. This allows nearly any polynomial to be supported in a reasonably efficient amount of die area. Unfortunately, this method can suffer from much slower performance than the previously described methods.
The circuit 100 uses a series of pre-computed polynomials 100a-100d derived from a polynomial key. Bits of the pre-computed polynomials 100a-100d are loaded into storage elements (e.g., registers or memory locations) and fed into a series of stages 106a-106d that successively reduce an initial message into smaller intermediate values en route to a final CRC result output by stage 106d. For example, as shown, the width of data, rb−rd, output by stages 106a-106d decreases with each successive stage. The pre-computed polynomials 100a-100d and stages 106d-106a are constructed such that the initial input, ra, and the stage outputs, rb−rd, are congruent to each other with respect to the final residue (i.e., ra≡rb≡rc≡rd). In addition, the pre-computed polynomials 100a-100d permit the stages 106a-106d to perform many of the calculations in parallel, reducing the number of gate delays needed to determine a CRC residue. Reprogramming the circuitry 110 for a different key can simply be a matter of loading the appropriate set of pre-computed polynomials into the storage elements 100a-100d.
More rigorously, let g(x) be a kth-degree CRC polynomial of k+1 bits, where the leading bit is always set in order that the residue may span k bits. The polynomial g(x) is defined as
The polynomial gi(x) is then defined as:
gi(x)=xk+i+[xk+i mod g(x)]
In accordance with this definition of gi(x), a sequence of polynomials can be computed as a function of selected values of i and the original polynomial g(x).
The CRC polynomial, g(x), divides gi(x):
From this, a recurrence can be defined, where at each stage a message, m(x), is partially reduced by one of the pre-computed polynomials.
Let m(x) be a 2L bit message and r(x) be the k-bit result:
rj,mjεGF(2)
r(x)=[m(x)·xk mod g(x)]
where m(x) is shifted by xk, creating room to append the resulting CRC residue to the message, m(x). Thus:
r0(x)=m(x)·xk
ri(x)=[ri−1(x)mod g2
for i≧1. Thus, ri(x)≡r0(x) mod g(x), which is proved by induction on i:
Finally, rL(x)=r(x), which follows from the observations made above:
These equations provide an approach to CRC computation that can be implemented in a wide variety of circuitry. For example,
The sample implementation shown features stages 106a-106d that AND 110a-110d (e.g., multiply) the k-least significant bits 104 of gi(x) by respective bits of input data. The i-zeroes 102 and initial “1” of gi(x) are not needed by the stage since they do not affect the results of stage computation. Thus, only the k-least significant bits of gi(x) need to be stored by the circuitry.
To illustrate operation, assuming r0 had a value starting “1010 . . . ” and the k-least significant bits of g4(x) had a value of “001010010”, the first 110a and third 110c AND gates would output “001010010” while the second 110b and fourth 110d AND gates would output zeros. As indicated by the shaded nodes in
As shown, the AND gates 110a-110d of a stage 106a may operate in parallel since they work on mutually-exclusive portions of the input data. That is, AND gates 110a-110d can each simultaneously process a different bit of r0 in parallel. This parallel processing can significantly speed CRC calculation. Additionally, different stages may also process data in parallel. For example, gate 110e of stage 106b can perform its selection near the very outset of operation since the most significant bit of r0 passes through unaltered to stage 106b.
The architecture shown in
The architecture shown above may be used in deriving the pre-computed polynomials. For example, derivation can be performed by zeroing the storage elements associated with gi(x) and loading g0 with the k-least significant bits of the polynomial key. The bits associated with successive gi-s can be determined by applying xk+i as the data input to the circuit and storing the resulting k-least significant bits output by the g0 stage as the value associated with gi. For example, to derive the polynomial for g2, xk+2 can be applied as the circuit, the resulting k-bit output of the g0 stage can be loaded as the value of the g2 polynomial.
The system shown in
Techniques described above can be used to improve CRC calculation speed, power efficiency, and circuit footprint. As such, techniques described above may be used in a variety of environments such as network processors, security processors, chipsets, ASICs (Application Specific Integrated Circuits), and as a functional unit within a processor or processor core where the ability to handle high clock speeds, while supporting arbitrary polynomials, is of particular value. As an example, CRC circuitry as described above may be integrated into a device having one or more media access controllers (e.g., Ethernet MACs) coupled to one or more processors/processor cores. Such circuitry may be integrated into the processor itself, in a network interface card (NIC), chipset, as a co-processor, and so forth. The CRC circuitry may operate on data included within a network packet (e.g., the packet header and/or payload). Additionally, while described in conjunction with a CRC calculation, this technique may be applied in a variety of calculations such as other residue calculations over GF(2) (e.g., Elliptic Curve Cryptography).
The term circuitry as used herein includes implementations of hardwired circuitry, digital circuitry, analog circuitry, programmable circuitry, and so forth. The programmable circuitry may operate on computer instructions disposed on a storage medium.
Other embodiments are within the scope of the following claims.
Number | Name | Date | Kind |
---|---|---|---|
3980874 | Vora | Sep 1976 | A |
4945537 | Harada | Jul 1990 | A |
4949294 | Wambergue | Aug 1990 | A |
4979174 | Cheng et al. | Dec 1990 | A |
5166978 | Quisquater | Nov 1992 | A |
5363107 | Gertz et al. | Nov 1994 | A |
5384786 | Dudley et al. | Jan 1995 | A |
5642367 | Kao | Jun 1997 | A |
5768296 | Langer et al. | Jun 1998 | A |
5942005 | Hassner et al. | Aug 1999 | A |
6038577 | Burshtein | Mar 2000 | A |
6128766 | Fahmi et al. | Oct 2000 | A |
6223320 | Dubey et al. | Apr 2001 | B1 |
6484192 | Matsuo | Nov 2002 | B1 |
6609410 | Axe et al. | Aug 2003 | B2 |
6721771 | Chang | Apr 2004 | B1 |
6728052 | Kondo et al. | Apr 2004 | B2 |
6732317 | Lo | May 2004 | B1 |
6795946 | Drummond-Murray et al. | Sep 2004 | B1 |
6904558 | Cavanna et al. | Jun 2005 | B2 |
7058787 | Brognara et al. | Jun 2006 | B2 |
7171604 | Sydir et al. | Jan 2007 | B2 |
7190681 | Wu | Mar 2007 | B1 |
7243289 | Madhusudhana et al. | Jul 2007 | B1 |
7343541 | Oren | Mar 2008 | B2 |
7428693 | Obuchi et al. | Sep 2008 | B2 |
7458006 | Cavanna et al. | Nov 2008 | B2 |
7461115 | Eberle, Hans et al. | Dec 2008 | B2 |
7543214 | Ricci | Jun 2009 | B2 |
20020053232 | Axe et al. | May 2002 | A1 |
20020144208 | Gallezot et al. | Oct 2002 | A1 |
20030167440 | Cavanna et al. | Sep 2003 | A1 |
20030202657 | She | Oct 2003 | A1 |
20030212729 | Eberle et al. | Nov 2003 | A1 |
20040059984 | Cavanna et al. | Mar 2004 | A1 |
20040083251 | Geiringer et al. | Apr 2004 | A1 |
20050044134 | Krueger et al. | Feb 2005 | A1 |
20050138368 | Sydir et al. | Jun 2005 | A1 |
20050149725 | Sydir et al. | Jul 2005 | A1 |
20050149744 | Sydir et al. | Jul 2005 | A1 |
20050149812 | Hall et al. | Jul 2005 | A1 |
20050154960 | Sydir et al. | Jul 2005 | A1 |
20060059219 | Koshy et al. | Mar 2006 | A1 |
20060282743 | Kounavis | Dec 2006 | A1 |
20060282744 | Kounavis | Dec 2006 | A1 |
20070083585 | St Denis et al. | Apr 2007 | A1 |
20070150795 | King et al. | Jun 2007 | A1 |
20070297601 | Hasenplaugh et al. | Dec 2007 | A1 |
20080092020 | Hasenplaugh et al. | Apr 2008 | A1 |
20090157784 | Gopal et al. | Jun 2009 | A1 |
20090158132 | Gopal et al. | Jun 2009 | A1 |
Number | Date | Country |
---|---|---|
2006016857 | Feb 2006 | WO |
2008002828 | Jan 2008 | WO |
2008002828 | Feb 2008 | WO |
2008046078 | Apr 2008 | WO |
2008046078 | Apr 2008 | WO |
2009012050 | Jan 2009 | WO |
2009012050 | Mar 2009 | WO |
2009082598 | Jul 2009 | WO |
2009085489 | Jul 2009 | WO |
2009085489 | Aug 2009 | WO |
Number | Date | Country | |
---|---|---|---|
20080092020 A1 | Apr 2008 | US |