BACKGROUND OF THE INVENTION

The present invention relates to a CRC operation unit and a CRC operation method for generating a cyclic redundancy check (CRC) code that is an error detection code for detection of an error occurring in transmitting/receiving data when the transmitting/receiving data is transmitted via a communication path or when the data is processed for transmission, or detecting a code error in transmitting/receiving data to which such an error detection code has been added. [0001]

CRC is an errordetecting system frequently used in digital communication, which detects an error in the following manner. On the transmitter side, transmitting data, which is considered as a highorder polynomial, is divided by a predetermined generating polynomial. The resultant remainder is added to the end of the transmitting data as a CRC code (encoding). On the receiver side, the transmitted data is divided by the same generating polynomial (decoding). If the remainder is zero, the transmitted data is determined as having no error. If the remainder is not zero, the transmitted data is determined as having an error (error detection). As the generating polynomial, the following are used in actual CRC, for example. [0002]

(1) CRC[0003] 12

(2) CRC[0004] 16

(3) CRCCCITT [0005]

The encoding and error detection as described above, which are hereinafter called CRC operation, may be implemented by a CRC operation unit that executes CRC operation by hardware. The CRC operation unit uses a divider constructed of a combination of a shift register and an exclusive OR gate. In this type of unit, the generating polynomial is determined by how the shift register is connected with the exclusive OR gate. Therefore, this type of unit is not allowed to change the generating polynomial within one unit. That is, a different unit is required if a different generating polynomial is used. Moreover, it is necessary to provide units capable of using the same generating polynomial on the transmitter and receiver sides. [0006]

A unit that executes CRC operation by software is known as a CRC operation unit capable of flexibly using various generating polynomials. This type of unit can easily use various generating polynomials by only changing a program or data. This type of unit however has the following problems. CRC operation, which is normally executed by a processor in a communication terminal, tends to put a great load on the processor, resulting in lowering the processing capability of the communication terminal. Moreover, CRC operation by software is low in operation speed and thus is not suitable for highspeed communication. [0007]

Units capable of realizing both flexible use of generating polynomials and highspeed CRC operation have been disclosed. For example, Japanese LaidOpen Patent Publication No. 5151007 discloses a unit constructed of a combination of a generating polynomial setting register, a shift register, and an exclusive OR gate. This unit performs CRC operation by hardware and thus enables highspeed processing. In addition, the unit can use various generating polynomials by changing the generating polynomial set in the generating polynomial setting register. [0008]

The CRC operation unit as described above uses exclusive circuits specialized for CRC operation. This disadvantageously increases the circuit scale of a communication unit and the like. In addition, while it is possible to use various generating polynomials having the same bit length as that of the generating polynomial setting register, no consideration is made for use of generating polynomials having different bit lengths. [0009]
SUMMARY OF THE INVENTION

An object of the present invention is providing a CRC operation unit capable of performing highspeed CRC operation and flexibly using various generating polynomials without causing significant increase in circuit scale. [0010]

The CRC operation unit of the present invention includes: generating polynomial supply means for holding data representing a generating polynomial and selectively outputting the data representing a generating polynomial or zero data of which all bits have a value of 0; operation data supply means for outputting operation data to be subjected to CRC operation; and arithmetic and logic operation means for performing exclusive OR operation between the data representing a generating polynomial or the zero data and the operation data, wherein the generating polynomial supply means selects the data representing a generating polynomial or the zero data depending on a value of the MSB of operation results from the arithmetic and logic operation means, and the operation data supply means outputs, as the operation data, data composed of: values of bits in lower order than the MSB of the operation results from the arithmetic and logic operation means as values of higherorder bits of the operation data; and a value of the MSB of unprocessed data to be subjected to CRC operation as a value of the LSB of the operation data. [0011]

The generating polynomial supply means may include: a first register for holding the data representing a generating polynomial; and a selector for selectively outputting the data representing a generating polynomial or the zero data, for example, and the operation data supply means may include: a second register for holding the operation results from the arithmetic and logic operation means; a shifter for shifting the operation results held in the second register leftward by one bit and outputting results; a memory for holding the unprocessed data to be subjected to CRC operation; and a shift register for holding part of the unprocessed data to be subjected to CRC operation transferred from the memory, outputting a value of the MSB of the held data, and shifting bits of the held data leftward one by one, for example. [0012]

With the above construction, the CRC operation unit can easily use various generating polynomials flexibly by changing the data representing a generating polynomial to be held in the generating polynomial supply means. In addition, the selection of the data representing a generating polynomial or the zero data to be input to the arithmetic and logic operation means and the generation of the operation data to be subjected to CRC operation are performed automatically, not by executing a program instruction. This realizes highspeed CRC operation. Moreover, since components provided for normal processors can be primarily used for the generating polynomial supply means, the operation data supply means, and the arithmetic and logic operation means, it is possible to minimize the circuit scale of the entire apparatus including the CRC operation unit. [0013]

The CRC operation unit may further include operation instruction execution control means, wherein the operation instruction execution control means controls, under a predetermined operation instruction, output of the data representing a generating polynomial or the zero data by the generating polynomial supply means, output of the operation data by the operation data supply means, and execution of the exclusive OR operation by the arithmetic and logic operation means. [0014]

The operation instruction execution control means may control, under a predetermined operation instruction, operations of the generating polynomial supply means, the operation data supply means, and the arithmetic and logic operation means for onetime execution of the exclusive OR operation by the arithmetic and logic operation means. [0015]

Alternatively, the operation instruction execution control means may control, under a predetermined operation instruction, operations of the generating polynomial supply means, the operation data supply means, and the arithmetic and logic operation means for execution of the exclusive OR operation for all the unprocessed data to be subjected to CRC operation by the arithmetic and logic operation means. [0016]

Otherwise, the operation instruction execution control means may control, under a predetermined operation instruction, operations of the generating polynomial supply means, the operation data supply means, and the arithmetic and logic operation means for execution of the exclusive OR operation for values of all bits held in the shift register by the arithmetic and logic operation means. [0017]

With above constructions, it is possible to enhance the flexibility of the CRC processing by increasing the degree of freedom in the combination of operation instructions or enhance the speed of the CRC processing with a small number of operation instructions. [0018]

After completion of the exclusive OR operation for all of the unprocessed data to be subjected to CRC operation by the arithmetic and logic operation means, the values held in the second register may be stored in the memory. [0019]

Alternatively, after completion of the exclusive OR operation for all of the unprocessed data to be subjected to CRC operation by the arithmetic and logic operation means, whether or not the unprocessed data to be subjected to CRC operation has an error may be determined by examining whether or not the values held in the second register are 0. [0020]

The above constructions facilitate CRC encoding and data error detection. [0021]

When the number of bits of the data representing a generating polynomial is smaller than the number of bits allowed to be held by the generating polynomial supply means, the generating polynomial supply means may leftjustify the data representing a generating polynomial and give 0 to the remaining lowerorder bit(s). [0022]

The above construction enhances the flexibility of use of various generating polynomials in the number of bits, in addition to the type. [0023]

The CRC operation unit of another embodiment of the present invention includes: generating polynomial holding means for holding data representing a generating polynomial; and CRC operation means for performing CRC operation based on the data representing a generating polynomial and data to be subjected to CRC operation, wherein, when the number of bits of the data representing a generating polynomial is smaller than the number of bits allowed to be held by the generating polynomial holding means, the generating polynomial holding means leftjustifies the data representing a generating polynomial and gives 0 to the remaining lowerorder bit(s). [0024]

The above construction enhances the flexibility of use of various generating polynomials in the number of bits, in addition to the type, even in the case of using exclusive circuits specialized for CRC operation.[0025]
BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram of a CRC operation unit of EMBODIMENT 1 of the present invention. [0026]

FIG. 2 is a flowchart of the operation of the CRC operation unit of EMBODIMENT 1. [0027]

FIG. 3 is a view for description of an example of data separation in the CRC operation unit of EMBODIMENT 1. [0028]

FIG. 4 is a view for description of an example of encoding operation of the CRC operation unit of EMBODIMENT 1. [0029]

FIG. 5 is a view for description of an example of decoding operation of the CRC operation unit of EMBODIMENT 1. [0030]

FIG. 6 is a block diagram of a CRC operation unit of EMBODIMENT [0031] 2 of the present invention.
DESCRIPTION OF THE PREFERRED EMBODIMENTS

Embodiment 1 [0032]

As EMBODIMENT 1 of the present invention, an example of a CRC operation unit incorporated in a processor such as a digital signal processor (DSP) will be described with reference to FIG. 1. This unit is constructed of circuits generally provided for the DSP and some additional circuits. [0033]

Referring to FIG. 1, the CRC operation unit includes: a generating polynomial supply section [0034] 11 (generating polynomial supply means) for holding and outputting data representing an arbitrary generating polynomial; an operation data supply section 21 (operation data supply means) for outputting operation data for CRC operation based on transmitting/receiving data; an operation section 31 (arithmetic and logic means) for performing CRC operation using the generating polynomial output from the generating polynomial supply section 11 and the operation data output from the operation data supply section 21; and an operation instruction execution control section 41 (operation instruction execution control means) for controlling the operations of the above sections.

The generating polynomial supply section [0035] 11 includes a first general register 12 that stores a generating polynomial and a selector 13. The selector 13 selects the data stored in the first general register 12 (that is, the generating polynomial) or data of which all bits have a value of 0 (“0”), and outputs the selected value. More specifically, the selector 13 selects “0” when the value of the most significant bit (MSB) in a second general register 24 to be described later is 0, or selects the generating polynomial stored in the first general register 12 when the value of the MSB is 1. The selector 13 may actually be constructed of a column of AND circuits that perform AND operation between the respective bits in the first general register 12 and the MSB value in the second general register 24, for example.

The operation data supply section [0036] 21 includes a memory 22, a shift register 23, the second general register 24, and a barrel shifter 25.

The memory [0037] 22 stores transmitting/receiving data.

The shift register [0038] 23 outputs the value of the MSB of the data held therein to the operation section 31 as the value of the LSB of the operation data every cycle of CRC operation and then shifts the held data leftward by one bit. Once all the bits of the held data have been output, subsequent data is transferred to the shift register 23 from the memory 22.

The second general register [0039] 24 holds data transferred from the memory 22 as initial values at the start of CRC operation, and thereafter holds data of the operation results output from the operation section 31 every cycle of CRC operation.

The barrel shifter [0040] 25 shifts the data held in the second general register 24 leftward by one bit, and then outputs the values of bits in higher order than the LSB of the resultant data to the operation section 31 as the values of bits in higher order than the LSB of the operation data. Note that the value of the MSB in the shift register 23 may be input to the barrel shifter 25, instead of being directly input to the operation section 31 as described above, to be used as the value of the LSB of the operation data during the leftward shifting described above.

The operation section [0041] 31 includes an arithmetic and logic unit 32 to execute exclusive OR operation between the generating polynomial or “0” output from the generating polynomial supply section 11 and the operation data output from the operation data supply section 21. The data of the operation results is stored in the second general register 24 as described above.

The respective sections described above have a bit width of M bits, for example. [0042]

The operation instruction execution control section [0043] 41 controls the operations of components constituting a DSP based on operation instructions provided as a program, and also controls principally the operations of the above sections based on operation instructions relating to CRC operation.

As the first general register [0044] 12, the memory 22, the second general register 24, the barrel shifter 25, and the arithmetic and logic unit 32, those normally provided for the processor may be used. In other words, the components specialized for CRC operation are principally the selector 13, the shift register 23, signal paths provided between the sections and the like, and the part of the operation instruction execution control section 41 that has a control function for CRC operation. Only by adding these components to a general processor, the CRC operation unit can be constructed. It is not that the entire the CRC operation unit is tailored for CRC operation. Therefore, increase in the circuit scale of the entire DSP and the like can be minimized.

The CRC operation unit constructed as described above performs CRC operation under operation instructions given to the operation instruction execution control section [0045] 41. The operation will be described with reference to the flowchart shown in FIG. 2. It should be noted that the following process steps are given for convenience of description of the operation and that the respective steps do not necessarily correspond to instruction cycles and machine cycles one on one.

Step S[0046] 1: A generating polynomial is set in the first general register 12 under a transfer instruction. The bit length N of the set generating polynomial may be smaller than the bit width M of the first general register 12 (N<M). If this is the case, the generating polynomial set in the first general register 12 is leftjustified under a leftward shift instruction and the like and the remaining lowerorder bit or bits are filled with 0.

Step S[0047] 2: Under the transfer instruction, also, data of first M bits (initial data) of the transmitting/receiving data stored in the memory 22 are set in the second general register 24.

Step S[0048] 3: Also, data of next M bits (input data 1 to X) of the transmitting/receiving data are set to the shift register 23 under the transfer instruction.

Step S[0049] 4: Next, M cycles of CRC operation for the M bits of the transmitting/receiving data held in the shift register 23 are performed. More specifically, the following operation is performed.

The arithmetic and logic unit [0050] 32 performs exclusive OR operation between operation data of total M bits and the Mbit generating polynomial or zero data output from the selector 13. The Mbit operation data is composed of values of higherorder M1 bits of the data output from the barrel shifter 25, which has shifted the Mbit data held in the second general register 24 as described above, and a value of the MSB output from the shift register 23. The Mbit generating polynomial may be composed of a string of N bits and 0 or 0's. The zero data output from the selector 13 is data of which all bits have a value of 0. The data of the operation results is stored in the second general register 24. In this way, one cycle of CRC operation corresponding to one bit of the transmitting/receiving data is performed. The data held in the shift register 23 is shifted leftward by one bit, and 0 is given to the LSB. This series of operation is repeated M times under a combination of a repeat instruction (which instructs to repeat the subsequent instruction for a given number of times) and a CRC operation instruction. This enables execution of one cycle of CRC operation (and shift operation of the shift register 23) in one machine cycle, for example. The operation performed under a combination of a repeat instruction and a CRC instruction described above may otherwise be programmed to be realized under a single instruction. It is also possible to set value M for a general register and decrement the value every cycle of CRC operation, to repeat the CRC operation until the value becomes zero, although the processing speed decreases.

Step S[0051] 5: Once M cycles of CRC operation have completed, whether or not the remaining transmitting/receiving data held in the memory 22 is the final data (whether or not the remaining bits are equal to or less than M) is determined. This determination may actually be done by determining whether or not the value of a pointer not shown indicating the address of the portion of the transmitting/receiving data in the memory 22 to be transferred to the shift register 23 indicates the address of the final data, for example. Alternatively, the determination may be done by counting (counting down) the number of times of Mcycle CRC operation performed, and determining whether or not the Mcycle CRC operation has been repeated by the number of times equal to a quotient X, which is obtained by subtracting M from the total number of bits K of the transmitting/receiving data and integerdividing the resultant value by M, represented by:

X=int((K−M)/M).

The count of the number of times of CRC operation and the determination described above may be realized under program instructions, or may be performed automatically by hardware. Note that M is subtracted from K because the first M bits are set in the second general register [0052] 24 as the initial data. If the remaining data in the memory 22 is not the final data, the steps S3 to S5 are repeated.

Step S[0053] 6: If the transmitting/receiving data remaining in the memory 22 is determined to be the final data, the final data is transferred to the shift register 23. The number of bits of the final data is equal to a remainder L obtained by subtracting M from the total number of bits K of the transmitting/receiving data and dividing the resultant value by M as shown in FIG. 3, represented by

L=(K−M)mod M.

Since the remainder L is smaller than M, the final data set in the shift register [0054] 23 is leftjustified and the remaining lowerorder bit or bits are filled with 0.

Step S[0055] 7: Finally, M+L cycles of CRC operation are performed in a manner as described in step S4. Thus, a total of M×X+M+L K cycles of the CRC operation have been performed. It should be noted that, as the number of cycles to be performed at the final CRC operation, the bit width M of the arithmetic and logic unit 32 is added to the remainder L. This is because the operation is repeated until the last bit of the transmitting/receiving data is shifted to the bit position higher by one than the MSB of the arithmetic and logic unit 32. This is equivalent to multiplying the transmitting/receiving data by the Nth power of 2 and repeating the CRC operation until reaching the LSB of the data. The values held in the second general register 24 when M+L cycles (K cycles in total) of CRC operation have completed in step S7 are the CRC operation results for the entire transmitting/receiving data. In the case of transmission, the values held in the second general register 24 are temporarily stored in the memory 22 and then added to the transmitting data, to provide CRCencoded transmitting data. In the case of reception, it is examined whether or not the values held in the second general register 24 are 0. As a concrete example, exclusive OR operation may be performed between the values in the second general register 24 and zero data of which all bits have a value of 0 and whether or not a zero flag register not shown has been set may be examined. By this examination, whether or not the received data has an error can be determined.

The above operation will be described using a specific data example with reference to FIGS. 4 and 5. [0056]

First, an example of encoding will be described. As shown in FIG. 4, assume that the transmitting data before encoding is “100000110101” (binary notation, the number of bits K=12), and the generating polynomial is “10101” (binary notation, the number of bits N=5). In this case, the number of times X of repetition of 5cycle CRC operation is [0057]

X=int((K−M)/M)=int((12−5)/5)=1,

the number of bits L of the final data is [0058]

L=(K−M)mod M=(12−5)mod 5=2,

and the number of cycles of the final CRC operation is [0059]

M+L=5+2=7.

(1) At the start of CRC operation, the generating polynomial “10101” is set in the first general register [0060] 12. Also, the values of the first five bits “10000” of the transmitting data are set in the second general register 24, and the values of the subsequent five bits “01101” are set in the shift register 23.

(2) In the first CRC operation cycle [0061] 1, the value of the MSB in the second general register 24 is “1”. The selector 13 therefore selects the generating polynomial “10101”. The arithmetic and logic unit 32 then performs exclusive OR operation between the generating polynomial “10101” and the combination of the values “0000” of the four bits in lower order than the MSB in the second general register 24 (properly, the four bits in higher order than the LSB of data obtained by the leftward shift by the barrel shifter 25) and the value “0” of the MSB in the shift register 23. The operation results are “10101”, which are stored in the second general register 24.

(3) The values held in the shift register [0062] 23 are shifted leftward by one bit. Although the value given to the LSB is 0 in the example shown in FIG. 4, it is not necessarily 0. (On the contrary, in the final CRC operation, 0 must be given to the LSB to meet the multiplication of the transmitting data by the nth power of 2.)

(4) The above series of operation is repeated, and when five cycles of CRC operation are completed, the 2bit final data “01” stored in the memory [0063] 22 is transferred to the shift register 23 and set therein in the leftjustified manner with the remaining lowerorder bit or bits filled with 0. In the final CRC operation, steps as described in (2) and (3) above are repeated for seven cycles.

(5) The values “00010” held in the second general register [0064] 24 at the completion of the final CRC operation are the CRC operation results. The CRC operation results are added to the end of the original transmitting data as shown in FIG. 5, to obtain the 17bit encoded data “10000011010100010”.

The operation of decoding the data encoded as described above is as shown in FIG. 5, which is substantially the same as that described in (1) to (4) above for the encoding. If the CRC operation results of this decoding are “00000” as shown in FIG. 5, it is determined that the data has no error. [0065]

In the illustrated example, the bit length of the transmitted data including the error detection code as described above is 17 bits. Therefore, the number of times X of repetition of 5cycle CRC operation is [0066]

X=int((K−M)/M)=int((17−5)/5)=2,

the number of bits L of the final data is [0067]

L=(K−M)mod M=(17−5)mod 5=2,

and the number of cycles of the final CRC operation is [0068]

M+L=5+2=7.

In decoding, however, it should be noted that if the remainder is 0 after the final CRC operation is repeated for two cycles corresponding to the number of bits L of the final data, it remains to be 0 in the subsequent cycles of CRC operation. If the remainder is not 0, it will never be 0 in the subsequent cycles. Thus, the same operation results are obtained even if the operation is discontinued at the end of two cycles. However, seven cycles of the final CRC operation may be completed as described above, to simplify the construction by performing the same operation on the encoding and decoding sides. [0069]

In the above example, the bit widths of the respective components were the same. Alternatively, for example, the first general register [0070] 12 and the arithmetic and logic unit 32 may have a different bit width from the other components, or the arithmetic and logic unit 32 may have a different bit width from the first general register 12 and the like.

In the above example, the transmitting/receiving data was stored in the memory [0071] 22. When the data is received as serial data, for example, the shift register 23 may be omitted, and the received data may be directly supplied to the second general register 24 and the arithmetic and logic unit 32 from a buffer (firstin, firstout (FIFO)).

In the CRC operation unit described above, the barrel shifter [0072] 25 only serves to shift the input data by one bit. Therefore, a shift register may be used instead if the cycle time has an allowance.

If an exclusive register specialized for CRC operation is provided in place of the second general register [0073] 24, the barrel shifter 25 may be omitted by shifting the data input/output by one bit.

Memories may be used in place of the first general register [0074] 12 and the second general register 24.

The switching control of the selector [0075] 13 was done based on the value of the MSB in the second general register 24. Alternatively, for example, a flag register may be provided to hold the value of the MSB of the operation results of the exclusive OR operation performed by the arithmetic and logic unit 32, and the switching may be controlled based on the value held in the flag register. In this case, in order to set the first flag register value for the first cycle of CRC operation, the data may be input to the arithmetic and logic unit 32 without being shifted leftward in the barrel shifter 25 (or by bypassing the barrel shifter 25).

It is also possible to execute the series of CRC operation as described above for all the bits of the transmitting/receiving data by a microprogram incorporated in the operation instruction execution control section [0076] 41. The microprogram can be programmed to support the CRC operation with a single or a few program instruction(s).

Embodiment 2 [0077]

As EMBODIMENT 2, described is an example of a CRC operation unit constructed by hardware including a generating polynomial setting register and capable of using a generating polynomial having an arbitrary bit length. [0078]

Referring to FIG. 6, the CRC operation unit of this embodiment includes a CRC operation section [0079] 51 and a generating polynomial supply section 61.

The CRC operation section [0080] 51 (CRC operation means) includes Mstage (corresponding to M bits) Dtype flipflops 52 connected to one another via exclusive OR gates 53. The CRC operation section 51 receives bits of operation data one by one for CRC operation for each bit. The quotients as the operation results are sequentially output from the laststage Dtype flipflop 52, while the remainders are output from the respective Dtype flipflops 52 upon completion of CRC operation at the respective stages.

The generating polynomial supply section [0081] 61 includes: an Mbit wide generating polynomial setting register 62 (generating polynomial holding means) that stores a generating polynomial; a selector 63; and a leftjustifying section 64. The selector 63 outputs the values stored in the generating polynomial setting register 62 (that is, the generating polynomial) or data of which all bits have a value of 0 (“0”) depending on the output from the laststage Dtype flipflop 52, as in the selector 13 of EMBODIMENT 1. The leftjustifying section 64 leftjustifies the generating polynomial and fills the remaining lowerorder bit or bits with 0 when the number of bits N of the generating polynomial used is smaller than the bit width M of the generating polynomial setting register 62, before storing the generating polynomial in the generating polynomial setting register 62. Specifically, the generating polynomial may be shifted leftward by use of a shift register or under a shift instruction in a program. In place of providing the leftjustifying section 64, a previously leftjustified generating polynomial may be input to the section.

With the above construction, when the number of bits N of the generating polynomial is smaller than the bit width M of the generating polynomial setting register [0082] 62, the bit or bits in lower order than the N higherorder bits in the register 62 are 0. Therefore, for each of these lowerorder bits, the selector 63 outputs 0 irrespective of the output from the laststage Dtype flipflop 52. As a result, the exclusive OR gate 53 corresponding to each of the lowerorder bits outputs the same value as that output from the preceding stage Dtype flipflop 52. With this construction, therefore, it is possible to provide the same results as those obtained when the number of bits of the generating polynomial, the bit width of the generating polynomial setting register 62, and the number of stages of the Dtype flipflops 52 are the same. This enhances the flexibility of use of various generating polynomials in the number of bits, in addition to the type.

As described above, according to the present invention, components provided for normal processors and the like can be used. This enables highspeed CRC operation and flexible use of various generating polynomials without causing significant increase in circuit scale. [0083]

While the present invention has been described in a preferred embodiment, it will be apparent to those skilled in the art that the disclosed invention may be modified in numerous ways and may assume many embodiments other than that specifically set out and described above. Accordingly, it is intended by the appended claims to cover all modifications of the invention that fall within the true spirit and scope of the invention. [0084]