Search

CN-121996467-A - Data verification method based on error correction code

CN121996467ACN 121996467 ACN121996467 ACN 121996467ACN-121996467-A

Abstract

The application discloses a data verification method based on error correction codes, which comprises the steps of calculating the bit width required by the error correction codes according to the bit width of data to be verified, combining an error correction code library according to the bit width required by the error correction codes, selecting an optimal error correction code set in the error correction code library, enabling each bit of the data to be verified to correspond to a corresponding error correction code in the optimal error correction code set, encoding pre-error correction data according to the bit of binary 1 in the error correction code corresponding to the data to be verified in the optimal error correction code set, so that when the ith bit of the pre-error correction data is encoded, the data on the ith bit of the error correction code corresponding to each bit in the data to be verified is equal to binary 1, and distinguishing errors, single-bit errors and double-bit errors according to the exclusive OR result between the pre-error correction data and the reference verification data obtained in advance.

Inventors

  • WANG CHAO
  • LI ZHANGHUI

Assignees

  • 珠海一微科技股份有限公司

Dates

Publication Date
20260508
Application Date
20241031

Claims (14)

  1. 1. The data verification method based on the error correction code is characterized by comprising the following steps of: calculating the bit width required by the error correction code according to the bit width of the data to be checked; combining an error correction code library according to the bit width required by the error correction code, wherein the error correction code library comprises error correction codes; Selecting an optimal error correction code from an error correction code library; According to the bit position of the binary 1 in the error correction code corresponding to the data to be checked in the optimal error correction code set, encoding pre-error correction data, so that when the ith bit position of the pre-error correction data is encoded, the data on the ith bit position in the error correction code corresponding to each bit position participating in encoding in the data to be checked is equal to the binary 1; And distinguishing the error-free error, the single-bit error and the double-bit error according to the exclusive OR result between the pre-error correction data and the pre-obtained reference check data and the optimal error correction code set.
  2. 2. The data verification method according to claim 1, wherein the method of distinguishing between no error, single bit error and double bit error based on the exclusive or result between the pre-error correction data and the pre-obtained reference verification data and the optimal error correction code set comprises: Controlling the pre-error correction data to carry out exclusive-OR operation with the pre-obtained reference check data to obtain an exclusive-OR result; if each bit of the exclusive-or result is equal to binary 0, determining that the reference check data and the data to be checked have no errors; if the exclusive-or result is one error correction code in the optimal error correction code set, determining that the bit corresponding to the exclusive-or result has a single bit error, Wherein the bit corresponding to the exclusive-or result is one bit of the reference check data or one bit of the data to be checked; If the exclusive-or result is neither any error correction code in the optimal error correction code set, and each bit of the exclusive-or result is not equal to binary 0, determining that a double-bit error exists in the data to be checked and/or the reference check data; The error correction codes in the optimal error correction code set comprise error correction codes corresponding to all bits of the reference check data and error correction codes corresponding to all bits of the data to be checked, and each bit of any error correction code in the optimal error correction code set is not equal to binary 0.
  3. 3. The method of claim 2, wherein the exclusive-or result is that in the case of one error correction code in the optimal error correction code set, there is: If the error correction code corresponding to one bit indexed to the reference check data from the optimal error correction code set is equal to the exclusive-or result, locating that one bit of the reference check data has single bit error; if the error correction code corresponding to one bit indexed to the data to be checked from the optimal error correction code set is the exclusive-or result, locating that one bit of the data to be checked has single-bit error; Wherein, the mapping relation between each bit of the reference check data and each bit of the data to be checked and the error correction code in the optimal error correction code set is preconfigured.
  4. 4. The data verification method according to claim 1, wherein the method for encoding pre-error correction data according to the bit of binary 1 in the error correction code corresponding to the data to be verified in the optimal error correction code set comprises: Except for the error correction code corresponding to the reference check data, indexing all error correction codes with the ith bit data of binary 1 from the optimal error correction code set, and marking the indexed error correction codes as error correction codes to be mapped; according to the mapping relation between each bit of the data to be checked and the error correction code in the optimal error correction code set, indexing out each bit corresponding to the data to be checked by using the error correction code to be mapped; Controlling data on each corresponding bit in the data to be checked to carry out exclusive OR operation, and identifying exclusive OR operation results of each corresponding bit in the data to be checked as i-th bit coded data, so that the data on the i-th bit is equal to data on the error correction code of binary 1, and the data on the i-th bit of the pre-error correction data is obtained through participating in exclusive OR operation, wherein the data to be checked is a bit of the data to be checked, which corresponds to the error correction code of the data on the i-th bit is equal to binary 1; Wherein i is an integer, i is less than or equal to a difference value between a bit width required by the error correction code and decimal 1, and i is greater than or equal to 0; The mapping relation between each bit of the data to be verified and the error correction code in the optimal error correction code set is preconfigured, the optimal error correction code set is arranged in the storage array, and the error correction code corresponding to each bit of the data to be verified is stored in the address corresponding to the storage array; wherein the bit width of the pre-error correction data is equal to the bit width required for the error correction code.
  5. 5. The method of data verification according to claim 4, wherein i is incremented once, all error correction codes with the (i+1) -th bit data being binary 1 are indexed from the optimal error correction code set, and the indexed error correction codes are identified as error correction codes to be mapped, each bit of the data to be verified is indexed from the error correction codes to be mapped according to the mapping relation between each bit of the data to be verified and the error correction codes in the optimal error correction code set, and then data on each bit of the data to be verified is controlled to be subjected to exclusive OR operation, and the exclusive OR operation result of each bit of the data to be verified is identified as (i+1) -th bit encoded data, wherein the (i+1) -th bit encoded data is (i+1) -th bit data of the pre-error correction data, and the (i) th bit encoded data to the (m) -th bit encoded data are incremented until each bit of the data to be verified forms the pre-error correction data, wherein each increment is self-increment by 1; Wherein the difference between the bit width required by the error correction code and decimal 1 is m, and m is an integer; Wherein the number of binary 1 s in each error correction code within the optimal error correction code set is an odd number.
  6. 6. The data verification method according to claim 5, wherein a difference between the number of error correction codes to be indexed for identifying each bit of encoded data does not exceed a decimal 1, so that a change between logical lengths generated by exclusive-or operation using a combinational logic circuit before and after i increases the data on each bit of the data to be verified.
  7. 7. The method for data verification according to claim 4, wherein the method for controlling the exclusive-or operation of the data on the corresponding bits in the data to be verified comprises: After indexing out corresponding bits in the data to be checked by using the error correction code to be mapped, dividing the corresponding bits in the data to be checked into at least two groups of bits to be operated according to the sequence from low bits to high bits; And then controlling the exclusive-or operation results of the bits to be operated to carry out exclusive-or operation to obtain the exclusive-or operation results of the corresponding bits in the data to be checked.
  8. 8. The data verification method according to claim 2, wherein the method for combining the error correction code library according to the bit width required for the error correction code comprises: Step A1, setting the number of binary 1 in the error correction code to be j under the condition of ensuring that the number of binary 1 in the error correction code is odd, and then executing step A2; step A2, judging whether j is smaller than or equal to the bit width required by the error correction code, if yes, executing step A3, otherwise, determining that the error correction code library is combined and obtaining all error correction codes in the error correction code library; step A3, controlling j binary 1 to be respectively configured at different bit positions of an error correction code to form an error correction code, and adding the current formed error correction code into an error correction library until all bit positions of the error correction code are configured by the j binary 1 in different bit sequences, so as to obtain each error correction code configured by the j binary 1 in different bit sequences; And A4, controlling j to increment once, wherein j is self-decimal 2 after each increment, and then executing the step A2.
  9. 9. The method of data verification according to claim 8, wherein the method of selecting the optimal set of error correction codes from the error correction code library comprises: Counting the number of error correcting codes obtained in the step A3 until the number of the error correcting codes obtained in the step A3 is larger than the sum of the bit width of the data to be checked and the bit width of the reference check data, selecting the number of the error correcting codes counted when all bits of the error correcting codes are configured in the j-2 binary 1 in different bit sequences as the selected number, adding the selected number of the error correcting codes into an optimal error correcting code set, calculating the difference between the bit width of the data to be checked and the selected number to obtain the candidate number, and then selecting the candidate number of the error correcting codes from the error correcting codes configured in the j binary 1 in different bit sequences and adding the candidate number of the error correcting codes into the optimal error correcting code set to form all the error correcting codes in the optimal error correcting code set; the number of the error correction codes required in the optimal error correction code set is equal to the sum of the bit width of the data to be checked and the bit width required by the error correction codes, and the bit width required by the error correction codes is smaller than the bit width of the data to be checked.
  10. 10. The data verification method according to claim 9, wherein after 1 binary system 1 is sequentially configured to each bit of the error correction code in different bit sequences by executing step A3, the number of different error correction codes obtained by configuration is equal to the bit width required by the error correction code, the different error correction codes obtained by configuration are error correction codes corresponding to each bit of the reference verification data, respectively, and then the error correction codes corresponding to each bit of the reference verification data are selected to be added into the optimal error correction code set.
  11. 11. The data verification method according to claim 10, wherein the method of selecting the candidate number of error correction codes from among the j binary 1's error correction codes configured in different bit sequences comprises: Step B1, traversing each bit of each error correction code in sequence in a residual error correction code set, and executing step B2 when traversing the current error correction code, wherein the current error correction code is one error correction code traversed in the residual error correction code set in the current round, and the residual error correction code set is formed by each error correction code configured by j binary 1 according to different bit sequences when the number of the accumulated error correction codes is larger than the sum of the bit width of the data to be checked and the bit width of the reference check data for the first time in the process of executing steps A2 to A4; Step B2, if one bit of the current error correction code is traversed to generate binary 1, counting the currently traversed bit once and marking the currently traversed bit as the count value of the currently traversed bit, and then controlling the currently traversed bit to be updated among all bits of the current error correction code so as to count the count value of all traversed bits in the current error correction code in sequence; Step B3, in the process of traversing each bit of the current error correction code, obtaining a fraction value corresponding to the current error correction code by calculating the sum of absolute values of differences between the count value of the currently traversed bit and the count value of each bit of the next traversal, and determining to complete one round of traversal on the error correction code; Step B4, judging whether all the error correction codes in the residual error correction code set are traversed, if yes, executing step B5, otherwise, updating one error correction code traversed next time into the current error correction code in the residual error correction code set, and then executing step B2; And B5, sorting the score values corresponding to all the traversed error correction codes in the residual error correction code set according to the size relation of the score values, and then selecting the error correction code corresponding to the candidate number of score values with the highest sorting or the lowest sorting to add into the optimal error correction code set.
  12. 12. The data verification method according to claim 11, wherein in the step B3, the method for obtaining the score value corresponding to the current error correction code by calculating the sum of absolute values of differences between the count value of the currently traversed bit and the count value of each bit of the subsequent traversal includes: After each bit of the current traversal is updated from one bit of the current error correction code to one bit higher or lower in the current error correction code, calculating the absolute value of the difference value between the count value of the bit of the current traversal and the count value of each bit of the subsequent traversal, and summing the absolute value of the difference value between the count value of the bit of the current traversal and the count value of each bit of the subsequent traversal to obtain a cyclic fraction value; If all bits of the current error correcting code are updated successively by the bits of the current traversal, the number of the successively calculated cyclic fraction values is equal to the bit width required by the current error correcting code for the same current error correcting code, and all the successively calculated cyclic fraction values are added to obtain the fraction value corresponding to the current error correcting code.
  13. 13. The data verification method according to claim 11, wherein each time a score value corresponding to the current error correction code is calculated, a difference between a maximum count value and a minimum count value is calculated for count values of respective bits of the current error correction code, and the difference is set as a current bit count span; When the score value corresponding to the current error correction code is smaller than a preset minimum score value, updating the score value corresponding to the current error correction code to the preset minimum score value, updating the current bit counting span to a preset bit counting span, and adding the current error correction code into the optimal error correction code set; when the fraction value corresponding to the current error correction code is equal to a preset minimum fraction value and the current bit count span is smaller than the preset bit count span, updating the fraction value corresponding to the current error correction code to the preset minimum fraction value, updating the current bit count span to the preset bit count span, and adding the current error correction code into the optimal error correction code set.
  14. 14. The data verification method according to claim 1, wherein the method for calculating the bit width required for the error correction code according to the bit width of the data to be verified comprises: Firstly, determining that a relation between a bit width required by an error correction code and a bit width of data to be checked is 2 (ecc_width-1) -ecc_width > data_width, wherein the data_width is the bit width of the data to be checked, and the ecc_width is the bit width required by the error correction code; Then, the data_width of the predetermined value is substituted into the relational expression, the obtained eccjwidth is greater than or equal to the reference bit width, and the reference bit width is set as the bit width required by the error correction code.

Description

Data verification method based on error correction code Technical Field The application relates to the technical field of error correction codes, in particular to a data verification method based on error correction codes. Background During operation, a typical memory chip may cause one or several bits to be in error in transmission due to interference, which may further cause program breakdown, so that in some important transmission scenarios, ECC (Error Correction Code ) needs to be added to ensure data transmission stability. The ECC is an error detection and correction algorithm for a memory, which can correct single bit errors but cannot correctly detect double bit errors, and the corresponding coding algorithm generally adds even check bits and multi-bit supervisory bits for the ECC to detect double bit errors, but generates corresponding redundant bits in the coding process, and adds extra storage area to store the corresponding redundant bits and supervisory bits, for example, 256 bytes of data are formed into a matrix of 256 rows and 8 columns, each element of the matrix represents one bit, error correction codes and corresponding redundant bits are formed into an error correction code library, and the error correction code library is stored in the memory, so that the cost of the memory is increased, and the flexibility of the selection of the ECC algorithm is reduced. The Chinese patent application number 202410607056.7 discloses a dynamic adjustment method based on error correction codes, which relates to a memory controller which controls data to be written in to be encoded according to an encoding rule corresponding to a current error correction strategy level to obtain encoded data, then the encoded data is written in a memory module, the encoded data can be read from the memory module, the read encoded data is decoded according to a decoding rule corresponding to the current error correction strategy level to obtain a decoding result, and the Chinese patent application number further adjusts the current error correction strategy level according to a data importance level, an operation load and/or data error flag information, and although the error correction codes corresponding to the adjusted current error correction strategy level are detected and corrected by calling the error correction codes corresponding to different error correction strategy levels, the error correction strategy level can be adjusted only once only by continuously reading data for a certain number of times, namely error detection is carried out for a plurality of times, the calculation speed is limited, and errors above 2 bits cannot be detected. Disclosure of Invention The application provides a data verification method based on error correction codes, which comprises the following specific technical scheme: The data verification method based on the error correction code comprises the steps of calculating the bit width required by the error correction code according to the bit width of the data to be verified, combining an error correction code library according to the bit width required by the error correction code, selecting an optimal error correction code set in the error correction code library, enabling each bit of the data to be verified to correspond to a corresponding error correction code in the optimal error correction code set, encoding pre-error correction data according to the bit position of binary 1 in the error correction code corresponding to the data to be verified in the optimal error correction code set, enabling data on the ith bit in the error correction code corresponding to each bit in the data to be verified to be equal to binary 1 when the ith bit of the pre-error correction data is encoded, and distinguishing no error, single-bit error and double-bit error according to an exclusive OR result between the pre-error correction data and the pre-obtained reference verification data and the optimal error correction code set. In summary, the present application utilizes the exclusive or result between the pre-error correction data obtained by encoding the corresponding error correction code by the data to be checked and the pre-obtained reference check data, and locates errors from the reference check data and the data to be checked, and because the reference check data belongs to the pre-encoded error correction data, the error correction data can be compared with the twice error correction data based on the exclusive or result and combined with the error correction code in the screened optimal error correction code set to perform matching identification, and the error free, single bit error and double bit error can be distinguished, especially, the correct detection of the data with single bit error or double bit error is conveniently performed in the transmission of multi-bit data, thereby reducing the use area of the memory device, and ensuring the verification performance of the chip running