CN-121996468-A - Data error correction method based on optimal error correction code set
Abstract
The application discloses a data error correction method based on an optimal error correction code set, which comprises the steps of calculating the bit width required by an error correction code according to the bit width of data to be checked, combining an error correction code library according to the bit width required by the error correction code, selecting the optimal error correction code from the error correction code library, encoding pre-error correction data according to the bit position of binary 1 in the error correction code corresponding to the data to be checked in the optimal error correction code set, positioning single-bit errors according to an exclusive or result between the pre-error correction data and pre-obtained reference check data and the optimal error correction code set, and carrying out inverse operation on the data on the bit with the single-bit errors when the bit with the single-bit errors is indexed from the optimal error correction code set.
Inventors
- WANG CHAO
- LI ZHANGHUI
Assignees
- 珠海一微科技股份有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20241031
Claims (12)
- 1. The data error correction method based on the optimal error correction code set is characterized by comprising the following steps: 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; Positioning single bit errors according to an exclusive OR result between the pre-error correction data and the pre-obtained reference check data and an optimal error correction code set; And when indexing from the optimal error correction code set to the bit with single bit error, performing inversion operation on the data on the bit with single bit error to obtain corrected data, wherein the data on the bit with single bit error is positioned in reference check data or the data to be checked.
- 2. The method for correcting data according to claim 1, wherein when the error correction code corresponding to one bit of the data to be verified, which is indexed from the optimal error correction code set, is the exclusive or result, it is determined that a single bit error occurs in one bit of the data to be verified, then the data in one bit of the data to be verified is inverted, and the data in the other bits of the data to be verified are kept unchanged, so as to obtain corrected data to be verified, and then the reference verification data and the corrected data to be verified are driven to be outputted in parallel.
- 3. The data error correction method according to claim 1, wherein when the error correction code corresponding to one bit of the reference check data from the index in the optimal error correction code set is the exclusive or result, positioning the reference check data to the bit with single bit error according to the bit where the binary 1 of the error correction code corresponding to the optimal error correction code set is located, performing inversion operation on the data on the bit with single bit error and keeping the data on other bits in the reference check data unchanged, thereby obtaining corrected reference check data; the bit width of the reference check data, the bit width of the exclusive-or result and the bit width required by the error correction code are equal, so that each bit of the reference check data is aligned with each bit of the corresponding error correction code, and only one bit of data in the error correction code corresponding to each bit of the reference check data is binary 1.
- 4. A data error correction method according to claim 2 or 3, wherein the method of locating single bit errors based on the result of the exclusive or between the pre-error correction data and the pre-obtained reference check data and the optimal set of error correction codes 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.
- 5. The method for correcting data according to claim 4, 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 checked in the optimal error correction code set comprises: In addition to the error correction code corresponding to the reference check data, all error correction codes of which the data on the ith bit is binary 1 are searched out from the optimal error correction code set, and the searched error correction codes are marked 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.
- 6. The method of error correction according to claim 5, 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 the 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 performed by 1 self-increment per increment; 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.
- 7. The method of data error correction according to claim 4, wherein the method of 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.
- 8. The method of data error correction according to claim 7, wherein the method of selecting an optimal set of error correction codes from a library of error correction codes 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.
- 9. The method of error correction according to claim 8, wherein after 1 binary 1 is sequentially allocated to each bit of the error correction code in different bit sequences by executing step A3, the number of the different error correction codes obtained by allocation is equal to the bit width required by the error correction code, the different error correction codes obtained by allocation are error correction codes corresponding to each bit of the reference check data, respectively, and then the error correction codes corresponding to each bit of the reference check data are selected to be added into the optimal error correction code set.
- 10. The data error correction method of claim 8, 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.
- 11. The method for data error correction according to claim 10, wherein in the step B3, the method for obtaining the fractional 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.
- 12. The method for correcting data according to claim 1, wherein the method for calculating the bit width required for the error correction code based on the bit width of the data to be checked 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 error correction method based on optimal error correction code set Technical Field The application relates to the technical field of error correction codes, in particular to a data error correction method based on an optimal error correction code set. 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, and although single bit errors can be corrected, double bit errors cannot be detected correctly, at present, corresponding encoding algorithms generally add even check bits and multi-bit supervisory bits for the ECC to detect double bit errors, but corresponding redundant bits can be generated in the encoding process, extra storage area can be increased to store the corresponding redundant bits and supervisory bits, for example, error correction codes and corresponding redundant bits are combined into an error correction code library to be stored in the memory, so that the cost of the memory is increased. The chinese patent application number 202410607056.7 discloses a dynamic adjustment method based on error correction codes, which adjusts the current error correction policy level according to the data importance level, the operation load and/or the data error flag information, the invention point of the patent is to make the error correction codes convert between the error correction codes corresponding to different error correction policy levels, the error correction strategy level can be adjusted only by repeatedly reading the data for many times, circuit resources are consumed for converting various mark information, the calculation speed is restricted, the flexibility of the ECC algorithm selection is reduced, and correction measures for specific error data bits are not given. Disclosure of Invention The application provides a data error correction method based on an optimal error correction code set, which comprises the following specific technical scheme: The data error correction method based on the optimal error correction code set comprises the steps of calculating bit widths required by error correction codes according to bit widths of data to be checked, combining an error correction code library according to the bit widths required by the error correction codes, selecting optimal error correction codes from the error correction code library, encoding pre-error correction data according to bit positions of binary 1 in the error correction codes corresponding to the data to be checked in the optimal error correction code set, enabling data on the ith bit in the error correction codes corresponding to each bit in the data to be checked to be equal to binary 1 when the ith bit of the pre-error correction data is encoded, positioning single bit errors according to an exclusive OR result between the pre-error correction data and the pre-obtained reference check data and the optimal error correction code set, and carrying out a reverse operation on the data on the bit with the single bit errors based on the exclusive OR result when the bit with the single bit errors is indexed in the optimal error correction code set, so that the data on the bit with the single bit errors is located in the reference check data. In summary, the 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 reference check data obtained in advance on the basis of selecting the optimal error correction code set from the error correction code library, indexes the error correction code from the optimal error correction code set, positions the reference check data or single bit errors in the data to be checked, and performs the inverse operation according to the indexed bit with the single bit errors to finish the data error correction. Thereby realizing the correction of the data with single bit errors within the predesigned maximum error correction capability (the data to be checked or the reference check data have errors in the memory and the bit number of the errors is 1). Drawings FIG. 1 is a flow chart of a data error correction method based on an optimal error correction code set as disclosed in the present application. Fig. 2 is a flowchart of a method of encoding pre-error correction data according to the present disclosure. FIG. 3 is a flow chart of a method of combining error correction code libraries in accordance with the present disclosure. FIG. 4 is a flow chart of a method of selecting a candidate number of error correction codes in accordance with the present disclosure. Detailed Description The present application will be described in further detail with reference to