Data generating method for forming desired CRC code
A method of generating a CRC code to determine a variable field value for equalizing a CRC value, which is calculated based on data including the variable field value of a variable field included in a data field according to a generator polynomial, to a desired CRC value, comprises the steps of establishing a temporary variable field value, reading all corrective values which correspond to a bit number where a bit value of said temporary variable field value is “1”, from a conversion table which stores therein corrective values for indicating a bit to be inverted in the variable field value as “1” corresponding to a predetermined bit number, and exclusive-ORing the read corrective values to calculate a first calculated value, and, determining whether the first calculated value corresponds to the desired CRC value or not.
Latest NEC Electronics Corporation Patents:
1. Field of the Invention
The present invention relates to a method of generating a CRC (Cyclic Redundancy Check) code, and more particularly to a CRC code generating method which is capable of generating a desired CRC code by changing a portion of data.
2. Description of the Related Art
In serial communications performed over cables, a voltage level may possibly suffer a drift due to a low-frequency component when a succession of data having the same voltage level occurs. To prevent such a drift, there is employed a technique called bit stuffing which, when a succession of “1s” or “0s” occurs in data to be transmitted, inserts a bit having a logic value that is opposite to the logic values in succession. For example, according to a USB data packet format that is used for a USB (Universal Serial Bus) which is known as a typical serial transmission application, it is stipulated that if a succession of seven “1s” occurs in data to be transmitted, then “0” is to be inserted after the sixth “1” in the data to be transmitted to the bus. It is also stipulated as an exception for the above provision that if a succession of seven “1s” occurs in data transmitted over a bus, then it represents an EOF (End Of Frame).
In serial communications, a CRC (Cyclic Redundancy Check) code is used to detect an error that may be caused in the transmission of data. For serial communications, there is generally used a frame format comprising a CRC field and an EOF in succession at the end of a frame which is made up of a bunch of data flowing through a network.
For conducting a transmission and reception test using a CRC code, as described in paragraph [0003] to [0006]of Japanese Patent Laid-open Application No. 2001-244820 (JP P2001-244820A), a predetermined generator polynomial is used on data in each frame unit on the transmission side to calculate a CRC code, and the calculated CRC code is added to the data to be transmitted and then transmitted. On the reception side, the received data is divided using the same generator polynomial as the one used on the transmission side, and if a residue is produced, then it is determined that an error has occurred in the transmitted data.
For conducting a test to determine whether a packet is properly transmitted and received between a transmitting apparatus and a receiving apparatus or not, it is preferable if an arbitrary code can be set in a CRC field. For performing face-to-face communications (bidirectional communications) with a product developed by a different maker (manufacturer), it is necessary to generate an arbitrary CRC code for the purpose of confirming whether proper functions of the both parties are achieved or not.
It is assumed that, as shown in
To solve the above problem, there has been employed a process of providing a variable field where data can be changed in a data field and CRC calculations are repeated one by one while changing the data of the variable field until the CRC value becomes a desired value, as shown in
In step 211 shown in
With the sequence shown in
It is an object of the present invention to provide a CRC code generating method which is capable of generating at a high speed a transmission frame having a desired CRC value.
According to a first aspect of the present invention, there is provided a method of generating a CRC code to determine a variable field value for equalizing a CRC value, which is calculated based on data including the variable field value of a variable field included in a data field according to a generator polynomial, to a desired CRC value, comprising the steps of establishing a temporary variable field value, reading all corrective values which correspond to a bit number where the bit value of the temporary variable field value is 1, from a conversion table which stores therein corrective values for indicating a bit to be inverted in the variable field value as “1” corresponding to a predetermined bit number, and exclusive-ORing the read corrective values to calculate a first calculated value, and, when the first calculated value corresponds to the desired CRC value, determining the temporary variable field value to be a variable field value for obtaining the desired CRC value.
According to a second aspect of the present invention, there is provided a method of generating a CRC code to determine a variable field value for equalizing a CRC value, which is calculated based on data including the variable field value of a variable field included in a data field according to a generator polynomial, to a desired CRC value, comprising the steps of establishing a temporary variable field value, reading a first calculated value corresponding to the temporary variable field value from a conversion table which stores therein first calculated values corresponding to a variable field value X and produced by exclusive-ORing a CRC value where the variable field value is 0 and a CRC value where the variable field value is X, where X represents an integer equal to or greater than 1 and equal to or less than 2K−1 where K represents the bit length of the variable field, and, when the read first calculated value corresponds to the desired CRC value, determining the temporary variable field value to be a variable field value for obtaining the desired CRC value.
According to a third aspect of the present invention, there is provided a method of generating a CRC code to determine a variable field value for equalizing a CRC value, which is calculated based on data including the variable field value of a variable field included in a data field according to a generator polynomial, to a desired CRC value, comprising the steps of calculating a first calculated value by exclusive-ORing a CRC value where the variable field value is 0 and the desired CRC value, and reading a variable field value corresponding to a second calculated value equal to the first calculated value, as a variable field value for obtaining the desired CRC value, from a conversion table which stores therein variable field values X corresponding to second calculated values, wherein each of the second calculated value is produced by exclusive-ORing a CRC value where the variable field value is 0 and a CRC value where the variable field value is X, where X represents an integer equal to or greater than 1 and equal to or less than 2K−1 where K represents the bit length of the variable field.
The above and other objects, features, and advantages of the present invention will become apparent from the following description with reference to the accompanying drawings which illustrate examples of the present invention.
As shown in
The transmission frame according to the present invention is of the same arrangement as the transmission frame shown in
With the CRC code generating method according to the present invention, a CRC is mathematically determined by a residue produced when the value of an input sequence is divided by a generator polynomial. In the world of mod 2 (an algorithm to modulus 2), the CRC code generating method is based on the fact that a division is expressed as an XOR per bit and the bits of a CRC that are affected if a particular bit value of an input sequence is changed depend on the bit length L of the data field of the input sequence and its bit number N, but not on the input sequence itself.
This CRC value is obtained by a CRC calculation on the data field of the frame using a generator polynomial. First, a CRC value C0 corresponding to the case of the variable field value being the initial value “0”, and a calculated value A is obtained by XORing the CRC value C0 and the desired CRC value CT. If A=0, both values C0 and CT agree with each other and the variable field in the case of the initial value “0” is the value to be obtained. If the both CRC values are different from each other, it is necessary to determine a variable field value which equalizes both CRC values to each other. The bit positions in the calculated value A where the bit value thereof is “1” indicate the data of bit positions at which bits of the C0 should be changed to equalize the C0, which is a CRC value, with the desired CRC value CT.
Consequently, each CRC value in the case that each bit position (2N) in the variable field is changed is calculated, and the XORed value between each calculated CRC value and the CRC value C0 which corresponds to the case where the variable filed is in the initial value “0”. This calculation result indicates the bit position in the calculated CRC value which is changed from the C0, and this data position is referred as “altering bit position.” The altering bit position data is obtained for each bit position (2N) of the variable field and is stored as a corrective value E in a table (CRC conversion table) with an address represented by each bit position.
Next, what value of the variable field makes the “altering bit position data equal to the “data of bit position which is desired to be changed from C0” is determined. The variable field value which makes the former equals to the latter is the variable field value providing the desired CRC value.
First, the variable field is incremented from the initial value “0,” and the corrective value E corresponds to the bit position at which a bit of “1” appears in the variable field is read from the table. Then the XORing operation on all the read corrective values are carried out. If only one bit is “1”, the XORing operation is not carried out and the single corrective value thus read from the table is treated as the calculation result.
The bit of “1” in the corrective value E indicates the bit position where a CRC value changes. When the bit value of the same bit position changed at an even-number of times, the bit value is changed back to the original value. So, the XORing operation is carried out to maintain the bit of “1” only at the position where the bit in the CRC is changed at an odd-number of times.
The calculated value B thus obtained corresponding to the variable field value indicates the data of a bit position at which the variable field is changed from the CRC value at the time of the initial value “0”. Then, the altering bit position data is obtained for each variable field value by sequentially incrementing the variable field from the initial value of “0.” Next, it is detected whether the “altering bit position data” is matched to the “data of bit position which is desired to be changed from C0” or not by, for example, XORing the both data. The variable field value at the time both value coincide with each other is a variable field value for obtaining the desired CRC value.
Next, the generation of CRC conversion table 47 will be described below with reference to
A CRC code generating process according to a first embodiment of the present invention will be described below with reference to
In step 221, a variable field value X of a transmission field is initialized to “0”. Thereafter, in step 222, data is stored in memory 3. In step 223, the data is read from memory 3. In step 224, CPU 2 calculates a CRC value corresponding to the transmission data according to a generator polynomial. In step 225, CPU 2 exclusive-ORs the CRC value corresponding to the transmission data with the variable field value X being “0” and the desired CRC value, and saves the calculated result as a calculated value A. In the description which follows, the term “exclusive-OR” is referred to as “XOR”.
In step 226, CPU 2 determines whether the calculated value A is 0 or not. If the calculated value A is 0, then since the desired CRC value has been obtained, control jumps to step 230. If the calculated value A is not 0, then control goes to step 227.
In step 227, CPU 2 increments the variable field value X to establish data for use temporarily as the variable field value X in following steps. In step 228, CPU 2 accesses CRC conversion table 31 in memory 3 using an address represented by the data length L, i.e., the bit length (data length) L of the data field, and a bit number N corresponding to a bit representation “1” in the variable field value X. CPU 2 reads corrective values E stored in all the corresponding addresses in CRC conversion table 31, and XORs the read corrective values E to produce a calculated value B. After having produced the calculated value B, CPU 2 compares the calculated value B with the calculated value A in step 229. If the calculated value B is equal to the calculated value A, then control goes to step 230. If the calculated value B is not equal to the calculated value A, then control goes back to step 227.
In step 230, the data is output in the sequence of the transmission frame to serial transmitting unit 4 under the control of CPU 2. As a result, the serial transmission data TD is transmitted from serial transmitting unit 4 to a serial transmission path.
CRC conversion table 31 will be described in detail below.
In
The CRC code generating process will be described in detail below with reference to a comparison between
When steps 221 to 224 shown in
Since the calculated value A is not “0000” in step 226, control goes to step 227. In step 227, the variable field value X is incremented to X=“0001”.
If desired CRC value 44 is CT (=“1011”), then the calculated value A (45) determined by XORing C0 and CT is “1010” in step 225. If the calculated value A is “0000”, C0 and CT agree with each other. Therefore, XT is the variable field value to be obtained. However, at this time, the calculated value A indicates that th second and fourth bits of C0 differ from those of CT. So an operation for obtaining the variable field value which changes each of the second and fourth bits of C0 to “0” is carried out on and after step 227.
In step 228, the CRC conversion table in memory 3 is accessed using addresses represented by the data length L of the data field and the bit numbers N corresponding to the bit representation “1” in the variable field value X, and the corrective values E stored at all the addresses are read and XORed to produce a calculated value B. In the illustrated example, since X=“0001”, i.e., only the least significant bit of the variable field is “1”, “1101” is read as the corrective value E corresponding to the bit number N=0D from CRC conversion table 47. Then, a calculated value B=“1101” corresponding to X=“0001” is calculated according to preprogrammed formula 48 for the calculated value B. More specifically, the bit values of the initial value X0 (=“0000”) of the variable field value which correspond to the first, third, and fourth bits, which are of “1”, of the read corrective value E (=“1101”) are inverted to produce the calculated value B=“1101”. Stated otherwise, the calculated value B is calculated by XORing the initial value X0 and the corrective value E, and the corrective value E itself becomes the calculated value B because the initial value X0 is “0000”.
As the calculated value B (=“1101”) is not equal to the calculated value A (=“1010”) in step 229, control returns from step 229 to step 227.
When steps 227 to 229 are executed in the second cycle, the variable field value X becomes “0010”, and since only the second bit thereof is “1”, “1110” is read as a corrective value E corresponding to a bit number N=1D from CRC conversion table 47. A calculated value B (=“1110”) corresponding to X=“0010” is calculated according to formula 48 for the calculated value B. Inasmuch as the calculated value B is not equal to the calculated value A, control goes back to step 227 again.
When steps 227 to 229 are executed in the third cycle, the variable field value X becomes “0011”, and since the first and second bits thereof are “1”, “1101′ is read as a corrective value E corresponding to a bit number N=0D from CRC conversion table 47, and “0111” is read as a corrective value E corresponding to a bit number N=1D from CRC conversion table 47. The two read corrective values E are XORed and a calculated value B (=“0011”) corresponding to X=“0011” is calculated according to formula 48 for the calculated value B. Inasmuch as the calculated value B is not equal to the calculated value A, control goes back to step 227 again.
Similarly, the processing from steps 227 to 229 is repeated. When steps 227 to 229 are executed in the fifth cycle, the variable field value X becomes “0101”, and since the first and third bits thereof from the low-order position are “1”, “1101” is read as a corrective value E corresponding to a bit number N=0D from CRC conversion table 47, and “0111” is read as a corrective value E corresponding to a bit number N=2D from CRC conversion table 47. The two read corrective values E are XORed and a calculated value B (=“1010”) corresponding to X=“0101” is calculated according to formula 48 for the calculated value B. Since the calculated value B is judged as being equal to the calculated value A in step 229, the variable field value X at this time is set to a variable field value XT corresponding to a desired CRC value CT(=“1011”), and control goes to step 230. In step 230, the data of variable field 46 in transmission frame 41 is replaced with XT (=“0101”), the CRC value of CRC field 43 is replaced with the desired CRC value CT(=“1011”), and the entire data are output as transmission frame 41a.
According to the first embodiment, as described above, a variable field value XT corresponding to a desired CRC value CT can be determined such that the desired CRC value CT and the data of data field 42 will not conflict with each other and an unmatched error will not be caused.
By generating in advance CRC conversion table 47 for each bit length of a data field, it is possible to obtain a variable field value XT corresponding to an arbitrary desired CRC value CT with respect to arbitrary data (data other than variable field 46 of data field 42) and the desired CRC value CT, in the manner described above with reference to
How much the calculation time for the CRC code generating process is shortened by the present embodiment will be reviewed below.
A time T0 that is required to obtain a variable field value XT corresponding to a desired CRC value CT according to the conventional sequence shown in
T0=TR+TC*M
where TR represents a time to read data from memory 3, TC a time required to calculate a CRC value once, and M the number of repetitions required to obtain a calculated value B which matches a calculated value A.
A time T1 that is required to obtain a variable field value XT corresponding to a desired CRC value CT according to the present embodiment is estimated by:
T1=TR+TC+TL*M
where TL represents a time required to calculate a variable field value XT corresponding to a desired CRC value CT using the CRC conversion table.
Transmission data comprising the data of 1 k words (i.e., 1024 words) and a 16-bit CRC added thereto will be reviewed below. It is assumed that a variable field length is represented by 16 bits. If TR is a one clock time, then TL represents a time that is equal to the sum of an average time required to read data from the CRC conversion table and one clock for XOR calculations, assuming that the reading of data from memory 3 and XOR calculations are performed by pipeline processing. The time TL is expressed by:
where pCq represents a combination for selecting q from p.
Since TC indicates that the calculation of a CRC by reading one word from the memory is repeated as many times as the length of the word, it represents clock times (1024 clock times) required to read 1024 words.
When the bit length of the variable field is large, M is very large, and
Therefore, for transmission data with a 16-bit CRC added to the data of 1 k words,
Consequently, the CRC code generating method according to the first embodiment which is illustrated in
V=(the bit length of the variable field)*(the data length of the corrective value E)
for a different bit length L of data field.
A CRC code generating method according to a second embodiment of the present invention will be described below.
According to the second embodiment, in step 221, a variable field value X of transmission data is initialized to “0”. In step 222, the transmission data is stored in memory 3. In step 223, the transmission data is read from memory 3. In step 224, CPU 2 calculates a CRC value with respect to the transmission data. Thereafter, in step 225, CPU 2 XORs the CRC value with respect to the transmission data whose variable field value is “0, and a desired CRC value, and saves the calculated result as a calculated value A.
In step 226, CPU 2 determines whether the calculated value A is 0 or not. If the calculated value A is 0, then since the desired CRC value has been obtained, control jumps to step 230. If the calculated value A is not 0, then, in step 227, CPU 2 increments the variable field value X to establish data for use temporarily as the variable field value X in following steps. After step 227, in step 231, CPU 2 accesses CRC conversion table 61 in memory 3 using an address represented by the bit length (data length) L of a data field, and the variable field value X, and reads a calculated value B stored in the corresponding address in CRC conversion table 61. After having read the calculated value B, CPU 2 compares the calculated value B with the calculated value A in step 229. If the calculated value B is equal to the calculated value A, then control goes to step 230. If the calculated value B is not equal to the calculated value A, then control goes back to step 227. In step 230, the data is output in the sequence of the transmission frame to serial transmitting unit 4 under the control of CPU 2. As a result, the serial transmission data TD is transmitted from serial transmitting unit 4 to a serial transmission path.
CRC conversion table 61 according to the second embodiment will be described in detail below.
CRC conversion table 61 stores calculated values B as calculated value data 63 corresponding to addresses 62 represented by the bit lengths L of data fields and the variable field values X. If K is an integer that is equal to or greater than 1 and equal to or less than 16 representing the bit length of the variable field, then a calculated value B can be calculated one by one as it is produced by XORing a CRC value at the time the variable field value X is 0 and a CRC value at the time the variable field value X is 2K−1. Practically, however, as with the first embodiment described above with reference to
In
When steps 221 to 224 shown in
In step 231, a calculated value B which is stored in CRC conversion table 71 in advance is read at an address represented by the bit length L of the data field and the variable field value X. Since X=“0001”, B=“1101” stored at the variable field value X=“0001” in CRC conversion table 71 is read. As the calculated value B (=“1101”) is not equal to the calculated value A (=”1010”) in step 229, control returns from step 229 to step 227.
In the same manner as described with reference to
When steps 227 to 229 are executed in the fifth cycle, the variable field value X becomes “0101” in step 227, and “1010” is then read as a calculated value B from CRC conversion table 71 in step 231. Since the calculated value B is judged as being equal to the calculated value A in step 229, the variable field value X at this time is set to a variable field value XT corresponding to a desired CRC value CT, and control goes to step 230. In step 230, the data of variable field 46 in transmission frame 41 is replaced with XT (=“0101”), the CRC value of CRC field 43 is replaced with the desired CRC value CT (=“1011”), and the entire data are output as transmission frame 41a.
According to the second embodiment, as described above, a variable field value XT can be determined such that the desired CRC value CT and the data of data field 42 will not conflict with each other and an unmatched error will not be caused.
A time T2 that is required to obtain a variable field value XT corresponding to a desired CRC value CT according to the second embodiment is estimated by:
T2=TR+TC+TR*M
If it is assumed that the variable field length is 16 bits long, with respect to transmission data with a 16-bit CRC added to the data of 1 k words, the ratio of the time T2 to the calculating time T0 according to the conventional process is expressed, as the same manner in the first embodiment, provided M is sufficiently large, by:
Therefore, for transmission data with a 16-bit CRC added to the data of 1 k words,
T2/T0≈1/1024
Consequently, the CRC code generating method according to the second embodiment is capable of reducing the processing time much more than the CRC code generating method according to the first embodiment.
A CRC code generating method according to a third embodiment of the present invention will be described below.
With the sequence according to the third embodiment as shown in
In step 232, CPU 2 accesses CRC conversion table 91 in memory 3 using an address represented by the bit length (data length) L of a data field, and the variable field value X, and reads a variable field value X stored in the corresponding address in CRC conversion table 91. Thereafter, in step 230, a transmission frame including the read variable field value X and the desired CRC value is assembled and output from serial transmitting unit 4 to the serial transmission path under the control of CPU 2.
An arrangement of CRC conversion table 91 according to the third embodiment will be described below.
In
When steps 221 to 224 shown in
According to the third embodiment, as described above, a variable field value XT can be determined such that the desired CRC value CT and the data of data field 42 will not conflict with each other and an unmatched error will not be caused.
A time T3 that is required to obtain a variable field value XT corresponding to a desired CRC value CT according to the third embodiment is estimated by:
T3=TR+TC+TR
If it is assumed that the variable field length is 16 bits long, then with respect to transmission data with a 16-bit CRC added to the data of 1 k words, the ratio of the time T3 to the calculating time T0 according to the conventional process is expressed, as with the first embodiment, by:
If the variable field length is of 16 bits, then the average number M of repetitions required to obtain a calculated value B that is in agreement with the calculated value A is about half 216, i.e., about 215. Therefore, for transmission data with a 16-bit CRC added to the data of 1 k words,
Consequently, the CRC code generating method according to the third embodiment is capable of reducing the processing time much more than the CRC code generating method according to the second embodiment.
According to the fourth embodiment, in step 221, a variable field value X of transmission data is initialized to “0”. In step 222, the transmission data is stored in memory 3. In step 223, CPU 2 reads the transmission data from memory 3. In step 224, CPU 2 calculates a CRC value corresponding to the transmission data. Thereafter, in step 225, CPU 2 XORs the CRC value corresponding to the transmission data with the variable field value being “0” and a desired CRC value, and saves the calculated result as a calculated value A.
In step 226, CPU 2 determines whether the calculated value A is 0 or not. If the calculated value A is 0, then since the desired CRC value has been obtained, control jumps to step 230. If the calculated value A is not 0, then control goes to step 227. In step 227, the variable field value X is incremented to establish data for use temporarily as the variable field value X in following steps. After step 227, in step 233, CPU 2 accesses CRC conversion table 131 in memory 3 using addresses represented by a generator polynomial P, the bit length (data length) L of a data field, and bit numbers corresponding to a bit representation “1” in the variable field value X. CPU 2 reads corrective values E stored in all the corresponding addresses in CRC conversion table 131, and XORs the read corrective values E to produce a calculated value B. After having produced the calculated value B, CPU 2 compares the calculated value B with the calculated value A in step 229. If the calculated value B is equal to the calculated value A, then control goes to step 230. If the calculated value B is not equal to the calculated value A, then control goes back to step 227. In step 230, the data is output in the sequence of the transmission frame to serial transmitting unit 4 under the control of CPU 2. As a result, the serial transmission data TD is transmitted from serial transmitting unit 4 to the serial transmission path.
CRC conversion table 131 used in the fourth embodiment will be described in detail below.
In
As with the method using the variable field, it is possible to specify a bit affected by the generator polynomial by changing the coefficients of the respective degrees of the generator polynomial. If the generator polynomial P(X) is expressed by P(X)=X2+1, then P=“101” may be input to CRC conversion table 131. As with the previous embodiments described above, readout addresses are represented by generator polynomials P, bit lengths L of data fields, and bit numbers N, and corresponding corrective value data 133 are stored in advance in CRC conversion table 131, so that calculated values B can be determined from CRC conversion table 131.
In
In the above description, generator polynomials P are added to the addresses in the first embodiment. Similarly, the second embodiment may easily be modified to include generator polynomials P in the addresses. Specifically, in
Similarly, the third embodiment may easily be modified to include generator polynomials P in the addresses. Specifically, the addresses 92 shown in
While preferred embodiments of the present invention have been described using specific terms, such description is for illustrative purposes only, and it is to be understood that changes and variations may be made without departing from the spirit or scope of the following claims.
Claims
1. A method to determine a value of a V-bit variable field so that a CRC value calculated based on a data field including the variable field according to a generator polynomial is equal to a desired CRC value, comprising the steps of:
- establishing a temporary variable field value;
- reading from a conversion table all corrective values which correspond to a bit number where a bit value of said temporary variable field value is 1, and exclusive-ORing the read corrective values to calculate a first calculated value, wherein each said corrective value in the conversion table corresponds to a given bit number in the variable field, each said corrective value identifying those bits in the CRC calculated based on the data field whose value is changed when a single bit in the given bit number in the variable field is changed; and
- determining, when said first calculated value corresponds to the desired CRC value, said temporary variable field value to be a variable field value for obtaining the desired CRC value.
2. The method according to claim 1, wherein each of the corrective values corresponds to a bit number N, each of the corrective values being produced by exclusive-ORing a CRC value of the data field for which the variable field value is 0 and a CRC value of the data field for which the variable field value is 2N, said table having a high-order address represented by a bit length of the data field and a low-order address represented by the bit number N, N representing an integer equal to or greater than 0 and less than the bit length of the variable field.
3. The method according to claim 1, wherein each of the corrective values corresponds to a bit number N, each of the corrective values being produced by exclusive-ORing a CRC value of the data field for which the variable field value is 0 and a CRC value of the data field for which the variable field value is 2N, said table having a high-order address represented by the generator polynomial for the CRC code and a bit length of the data field and a low-order address represented by the bit number N, N representing an integer equal to or greater than 0 and less than the bit length of the variable field.
4. The method according to claim 1, wherein said step of determining said temporary variable field value comprises the steps of:
- comparing the first calculated value with a second calculated value, the second calculated value being calculated in advance by exclusive-ORing a CRC value of the data field for which the variable field value is 0 and the desired CRC value; and
- determining a temporary variable field value corresponding to said first calculated value as a variable field value for obtaining said desired CRC value if said first calculated value and said second calculated value agree with each other.
5. The method according to claim 4, wherein each of the corrective values corresponds to a bit number N, each of the corrective values being produced by exclusive-ORing a CRC value of the data field for which the variable field value is 0 and a CRC value of the data field for which the variable field value is 2N, said table having a high-order address represented by a bit length of the data field and a low-order address represented by the bit number N, N representing an integer equal to or greater than 0 and less than the bit length of the variable field.
6. The method according to claim 4, wherein each of the corrective values corresponds to a bit number N, each of the corrective values being produced by exclusive-ORing a CRC value of the data field for which the variable field value is 0 and a CRC value of the data field for which the variable field value is 2N, said table having a high-order address represented by the generator polynomial for the CRC code and a bit length of the data field and a low-order address represented by the bit number N, N representing an integer equal to or greater than 0 and less than the bit length of the variable field.
7. A method of generating a CRC code to determine a variable field value for equalizing a CRC value, which is calculated based on data including the variable field value of a variable field included in a data field according to a generator polynomial, to a desired CRC value, comprising the steps of:
- establishing a temporary variable field value;
- reading a first calculated value corresponding to said temporary variable field value from a conversion table which stores therein first calculated values corresponding to a variable field value X and produced by exclusive-ORing a CRC value where the variable field value is 0 and a CRC value where the variable field value is X, where X represents an integer equal to or greater than 1 and equal to or less than 2K−1 where K represents a bit length of the variable field; and
- determining, when the read first calculated value corresponds to the desired CRC value, said temporary variable field value to be a variable field value for obtaining the desired CRC value.
8. The method according to claim 7, wherein said conversion table comprises a table which stores data of said first calculated values corresponding to said variable field value X and has a high-order address represented by a bit length of the data field and a low-order address represented by the variable field value X.
9. The method according to claim 7, wherein said conversion table comprises a table which stores data of said first calculated values corresponding to said variable field value X and has a high-order address represented by the generator polynomial and a bit length of the data field and a low-order address represented by the variable field value X.
10. The method according to claim 7, wherein said step of determining said temporary variable field value comprises the steps of:
- comparing a second calculated value which is calculated in advance by exclusive-ORing a CRC value where the variable field value is 0 and the desired CRC value, with a first calculated value; and
- determining a temporary variable field value corresponding to said first calculated value as a variable field value for obtaining said desired CRC value if said first calculated value and said second calculated value agree with each other.
11. The method according to claim 10, wherein said conversion table comprises a table which stores data of said first calculated values corresponding to said variable field value X and has a high-order address represented by a bit length of the data field and a low-order address represented by the variable field value X.
12. The method according to claim 10, wherein said conversion table comprises a table which stores data of said first calculated values corresponding to said variable field value X and has a high-order address represented by the generator polynomial and a bit length of the data field and a low-order address represented by the variable field value X.
13. A method of generating a CRC code to determine a variable field value for equalizing a CRC value, which is calculated based on data including the variable field value of a variable field included in a data field according to a generator polynomial, to a desired CRC value, comprising the steps of:
- calculating a first calculated value by exclusive-ORing a CRC value where the variable field value is 0 and the desired CRC value; and
- reading a variable field value corresponding to a second calculated value equal to said first calculated value, as a variable field value for obtaining said desired CRC value, from a conversion table which stores therein variable field values X corresponding to second calculated values, wherein each of said second calculated values is produced by exclusive-ORing a CRC value where the variable field value is 0 and a CRC value where the variable field value is X, where X represents an integer equal to or greater than 1 and equal to or less than 2K−1 where K represents a bit length of the variable field.
14. The method according to claim 13, wherein said conversion table comprises a table which stores data of said variable field values corresponding to said second calculated values and has a high-order address represented by a bit length of the data field and a low-order address represented by said second calculated values.
15. The method according to claim 13, wherein said conversion table comprises a table which stores data of said variable field values corresponding to said second calculated values and has a high-order address represented by the generator polynomial and a bit length of the data field and a low-order address represented by said second calculated values.
16. A method of generating data for forming a desired CRC code determining a variable field value of a variable field included in a data field so that a CRC value which is calculated based on data including the variable field value according to a generator polynomial, is equalized to said desired CRC value, the method comprising:
- a first step of determining a first bit position data which is a position data indicating a bit at which a bit value is different between a fundamental CRC value and said desired CRC value, said fundamental CRC value is a CRC value which is obtained when the variable field value is set to “0”;
- a second step of generating a conversion table which stores a second bit position data corresponding to at least a specific bit number, said second bit position data being a position data indicating a bit at which a bit value is different between said fundamental CRC value and a CRC value which is obtained when a bit value of a bit at said specific bit number in the variable field is set to “1”; and
- a third step of determining, when a data obtained by combining the second bit position data using said conversion table agrees with said first bit position data, a variable field value having bit of “1” only at a bit number corresponding to said second bit position data which is used in the combining to be a variable field value for obtaining the desired CRC value.
17. The method according to claim 16, wherein:
- said second step comprises the steps of:
- obtaining as a corrective value for each bit number a position data of a bit at which the CRC value which is obtained when a bit value of a bit at said specific bit number in the variable field is set to “1” differs from a CRC value in a case of the variable field value of “0,” and
- generating the conversion table which stores each corrective value corresponding to at least the bit number, and
- said third step comprises the steps of:
- sequentially varying the variable field value to read the corrective value which corresponds to a bit number at which said varied variable field value is “1,”
- when a number of bits of “1” at a same bit number where all the read corrective value are all “1” is an even number, obtaining a data in which only a bit corresponding to said same bit number is set to “1”, and
- determining, when said data agrees with said first bit position data, a variable field value corresponding to said data to be the variable field value for obtaining the desired CRC value.
18. A method of generating data for forming a desired CRC code determining a variable field value of a variable field included in a data field so that a CRC value which is calculated based on data including the variable field value according to a generator polynomial, is equalized to said desired CRC value, the method comprising:
- a first step of determining a first bit position data which is a position data indicating a bit at which a bit value is different between a fundamental CRC value and said desired CRC value, said fundamental CRC value is a CRC value which is obtained when the variable field value is set to “0”;
- a second step of obtaining for each variable field value a second bit position data, which is a position data of a bit at which a CRC value in a case of the variable field value being varied differs from a CRC value in a case of the variable field value of “0”, to generate a conversion table which stores each second bit position data corresponding to at least said varied variable field value; and
- a third step of sequentially varying the variable field value to read the second bit position data corresponding to said varied variable field value, and determining, when the read second position data agrees with said first bit position data, a variable field value corresponding to the read second bit position data to be a variable field value for obtaining the desired CRC value.
19. A method to determine a value of a V-bit variable field so that a CRC value calculated based on a data field including the variable field according to a generator polynomial is equal to a desired CRC value, comprising the steps of:
- a) determining a first calculated value that identifies those bit positions in C0 that differ from bits in the same position in CT, where C0 is a CRC of the data field when the variable field is set to 0, and CT is the desired CRC;
- b) providing a conversion table of a plurality of corrective values, each said corrective value corresponding to a given bit position in the variable field, each said corrective value indicating how a CRC generated from the data field with the variable field set to 0 except for the given bit position compares to C0;
- c) determining a test variable field value;
- d) determining a second calculated value by reading from the conversion table all of the corrective values for which the given bit position corresponds to a bit position of the test variable field value set to 1, and performing an exclusive-OR of all the read corrective values to calculate a first calculated value if there are a plurality of such read corrective values, and if only one corrective value is read, setting that corrective value as the second calculated value;
- e) comparing the first calculated value to the second calculated value;
- f) if a condition of the first and second calculated values being equal is met, setting the current test variable field value as the variable field value in the data field, and if the condition is not met, setting the test variable field value to a different value, and repeating steps d)-f) until the condition is met.
20. The method of claim 19, wherein step a) comprises performing an exclusive-OR of C0 and CT.
21. The method of claim 20, wherein each said corrective value is calculated as an exclusive-OR of:
- 1) C0, and
- 2) CRC of the data field when the given bit position of the variable field is set to 1 and all other bit positions of the variable field are set to 0.
Type: Grant
Filed: Jan 28, 2004
Date of Patent: Nov 20, 2007
Patent Publication Number: 20040187064
Assignee: NEC Electronics Corporation (Kanagawa)
Inventors: Fumio Takahashi (Kawasaki), Akihiro Shiratori (Kawasaki)
Primary Examiner: Cynthia Britt
Assistant Examiner: Fritz Alphonse
Attorney: Young & Thompson
Application Number: 10/765,191
International Classification: H03M 13/00 (20060101);