Jump to content

BCH code

From Wikipedia, the free encyclopedia
(Redirected fromBCH codes)

Incoding theory,theBose–Chaudhuri–Hocquenghem codes(BCH codes) form a class ofcyclicerror-correcting codesthat are constructed usingpolynomialsover afinite field(also called aGalois field). BCH codes were invented in 1959 by French mathematicianAlexis Hocquenghem,and independently in 1960 byRaj Chandra BoseandD.K. Ray-Chaudhuri.[1][2][3]The nameBose–Chaudhuri–Hocquenghem(and the acronymBCH) arises from the initials of the inventors' surnames (mistakenly, in the case of Ray-Chaudhuri).

One of the key features of BCH codes is that during code design, there is a precise control over the number of symbol errors correctable by the code. In particular, it is possible to design binary BCH codes that can correct multiple bit errors. Another advantage of BCH codes is the ease with which they can be decoded, namely, via analgebraicmethod known assyndrome decoding.This simplifies the design of the decoder for these codes, using small low-power electronic hardware.

BCH codes are used in applications such as satellite communications,[4]compact discplayers,DVDs,disk drives,USB flash drives,solid-state drives,[5]andtwo-dimensional bar codes.

Definition and illustration

[edit]

Primitive narrow-sense BCH codes

[edit]

Given aprime numberqandprime powerqmwith positive integersmanddsuch thatdqm− 1,a primitive narrow-sense BCH code over thefinite field(or Galois field)GF(q)with code lengthn=qm− 1anddistanceat leastdis constructed by the following method.

Letαbe aprimitive elementofGF(qm). For any positive integeri,letmi(x)be theminimal polynomialwith coefficients inGF(q)ofαi. Thegenerator polynomialof the BCH code is defined as theleast common multipleg(x) = lcm(m1(x),…,md− 1(x)). It can be seen thatg(x)is a polynomial with coefficients inGF(q)and dividesxn− 1. Therefore, thepolynomial codedefined byg(x)is a cyclic code.

Example

[edit]

Letq= 2andm= 4(thereforen= 15). We will consider different values ofdforGF(16) = GF(24)based on the reducing polynomialz4+z+ 1,using primitive elementα(z) =z.There are fourteen minimum polynomialsmi(x)with coefficients inGF(2)satisfying

The minimal polynomials are

The BCH code withhas the generator polynomial

It has minimalHamming distanceat least 3 and corrects up to one error. Since the generator polynomial is of degree 4, this code has 11 data bits and 4 checksum bits. It is also denoted as:(15, 11) BCHcode.

The BCH code withhas the generator polynomial

It has minimal Hamming distance at least 5 and corrects up to two errors. Since the generator polynomial is of degree 8, this code has 7 data bits and 8 checksum bits. It is also denoted as:(15, 7) BCHcode.

The BCH code withhas the generator polynomial

It has minimal Hamming distance at least 7 and corrects up to three errors. Since the generator polynomial is of degree 10, this code has 5 data bits and 10 checksum bits. It is also denoted as:(15, 5) BCHcode. (This particular generator polynomial has a real-world application, in the "format information" of theQR code.)

The BCH code withand higher has the generator polynomial

This code has minimal Hamming distance 15 and corrects 7 errors. It has 1 data bit and 14 checksum bits. It is also denoted as:(15, 1) BCHcode. In fact, this code has only two codewords: 000000000000000 and 111111111111111 (a trivialrepetition code).

General BCH codes

[edit]

General BCH codes differ from primitive narrow-sense BCH codes in two respects.

First, the requirement thatbe a primitive element ofcan be relaxed. By rela xing this requirement, the code length changes fromtotheorderof the element

Second, the consecutive roots of the generator polynomial may run frominstead of

Definition.Fix a finite fieldwhereis a prime power. Choose positive integerssuch thatandis themultiplicative orderofmodulo

As before, letbe aprimitiveth root of unityinand letbe theminimal polynomialoveroffor all The generator polynomial of the BCH code is defined as theleast common multiple

Note:ifas in the simplified definition, thenis 1, and the order ofmodulois Therefore, the simplified definition is indeed a special case of the general one.

Special cases

[edit]
  • A BCH code withis called anarrow-sense BCH code.
  • A BCH code withis calledprimitive.

The generator polynomialof a BCH code has coefficients from In general, a cyclic code overwithas the generator polynomial is called a BCH code over The BCH code overand generator polynomialwith successive powers ofas roots is one type ofReed–Solomon codewhere the decoder (syndromes) Alpha bet is the same as the channel (data and generator polynomial) Alpha bet, all elements of.[6]The other type of Reed Solomon code is anoriginal view Reed Solomon codewhich is not a BCH code.

Properties

[edit]

The generator polynomial of a BCH code has degree at most.Moreover, ifand,the generator polynomial has degree at most.

Proof

Each minimal polynomialhas degree at most.Therefore, the least common multiple ofof them has degree at most.Moreover, ifthenfor all.Therefore,is the least common multiple of at mostminimal polynomialsfor odd indiceseach of degree at most.

A BCH code has minimal Hamming distance at least.

Proof

Suppose thatis a code word with fewer thannon-zero terms. Then

Recall thatare roots ofhence of.This implies thatsatisfy the following equations, for each:

In matrix form, we have

The determinant of this matrix equals

The matrixis seen to be aVandermonde matrix,and its determinant is

which is non-zero. It therefore follows thathence

A BCH code is cyclic.

Proof

A polynomial code of lengthis cyclic if and only if its generator polynomial dividesSinceis the minimal polynomial with rootsit suffices to check that each ofis a root ofThis follows immediately from the fact thatis, by definition, anth root of unity.

Encoding

[edit]

Because any polynomial that is a multiple of the generator polynomial is a valid BCH codeword, BCH encoding is merely the process of finding some polynomial that has the generator as a factor.

The BCH code itself is not prescriptive about the meaning of the coefficients of the polynomial; conceptually, a BCH decoding algorithm's sole concern is to find the valid codeword with the minimal Hamming distance to the received codeword. Therefore, the BCH code may be implemented either as asystematic codeor not, depending on how the implementor chooses to embed the message in the encoded polynomial.

Non-systematic encoding: The message as a factor

[edit]

The most straightforward way to find a polynomial that is a multiple of the generator is to compute the product of some arbitrary polynomial and the generator. In this case, the arbitrary polynomial can be chosen using the symbols of the message as coefficients.

As an example, consider the generator polynomial,chosen for use in the (31, 21) binary BCH code used byPOCSAGand others. To encode the 21-bit message {101101110111101111101}, we first represent it as a polynomial over:

Then, compute (also over):

Thus, the transmitted codeword is {1100111010010111101011101110101}.

The receiver can use these bits as coefficients inand, after error-correction to ensure a valid codeword, can recompute

Systematic encoding: The message as a prefix

[edit]

A systematic code is one in which the message appears verbatim somewhere within the codeword. Therefore, systematic BCH encoding involves first embedding the message polynomial within the codeword polynomial, and then adjusting the coefficients of the remaining (non-message) terms to ensure thatis divisible by.

This encoding method leverages the fact that subtracting the remainder from a dividend results in a multiple of the divisor. Hence, if we take our message polynomialas before and multiply it by(to "shift" the message out of the way of the remainder), we can then useEuclidean divisionof polynomials to yield:

Here, we see thatis a valid codeword. Asis always of degree less than(which is the degree of), we can safely subtract it fromwithout altering any of the message coefficients, hence we have ouras

Over(i.e. with binary BCH codes), this process is indistinguishable from appending acyclic redundancy check,and if a systematic binary BCH code is used only for error-detection purposes, we see that BCH codes are just a generalization of themathematics of cyclic redundancy checks.

The advantage to the systematic coding is that the receiver can recover the original message by discarding everything after the firstcoefficients, after performing error correction.

Decoding

[edit]

There are many algorithms for decoding BCH codes. The most common ones follow this general outline:

  1. Calculate the syndromessjfor the received vector
  2. Determine the number of errorstand the error locator polynomialΛ(x)from the syndromes
  3. Calculate the roots of the error location polynomial to find the error locationsXi
  4. Calculate the error valuesYiat those error locations
  5. Correct the errors

During some of these steps, the decoding algorithm may determine that the received vector has too many errors and cannot be corrected. For example, if an appropriate value oftis not found, then the correction would fail. In a truncated (not primitive) code, an error location may be out of range. If the received vector has more errors than the code can correct, the decoder may unknowingly produce an apparently valid message that is not the one that was sent.

Calculate the syndromes

[edit]

The received vectoris the sum of the correct codewordand an unknown error vectorThe syndrome values are formed by consideringas a polynomial and evaluating it atThus the syndromes are[7]

forto

Sinceare the zeros ofof whichis a multiple,Examining the syndrome values thus isolates the error vector so one can begin to solve for it.

If there is no error,for allIf the syndromes are all zero, then the decoding is done.

Calculate the error location polynomial

[edit]

If there are nonzero syndromes, then there are errors. The decoder needs to figure out how many errors and the location of those errors.

If there is a single error, write this aswhereis the location of the error andis its magnitude. Then the first two syndromes are

so together they allow us to calculateand provide some information about(completely determining it in the case of Reed–Solomon codes).

If there are two or more errors,

It is not immediately obvious how to begin solving the resulting syndromes for the unknownsand

The first step is finding, compatible with computed syndromes and with minimal possiblelocator polynomial:

Three popular algorithms for this task are:

  1. Peterson–Gorenstein–Zierler algorithm
  2. Berlekamp–Massey algorithm
  3. Sugiyama Euclidean algorithm

Peterson–Gorenstein–Zierler algorithm

[edit]

Peterson's algorithm is the step 2 of the generalized BCH decoding procedure. Peterson's algorithm is used to calculate the error locator polynomial coefficientsof a polynomial

Now the procedure of the Peterson–Gorenstein–Zierler algorithm.[8]Expect we have at least 2tsyndromessc,…,sc+2t−1.Letv=t.

  1. Start by generating thematrix with elements that are syndrome values
  2. Generate avector with elements
  3. Letdenote the unknown polynomial coefficients, which are given by
  4. Form the matrix equation
  5. If the determinant of matrixis nonzero, then we can actually find an inverse of this matrix and solve for the values of unknownvalues.
  6. Ifthen follow
    if
    then
    declare an empty error locator polynomial
    stop Peterson procedure.
    end
    set
    
    continue from the beginning of Peterson's decoding by making smaller
  7. After you have values of,you have the error locator polynomial.
  8. Stop Peterson procedure.

Factor error locator polynomial

[edit]

Now that you have thepolynomial, its roots can be found in the formby brute force for example using theChien searchalgorithm. The exponential powers of the primitive elementwill yield the positions where errors occur in the received word; hence the name 'error locator' polynomial.

The zeros of Λ(x) areαi1,…,αiv.

Calculate error values

[edit]

Once the error locations are known, the next step is to determine the error values at those locations. The error values are then used to correct the received values at those locations to recover the original codeword.

For the case of binary BCH, (with all characters readable) this is trivial; just flip the bits for the received word at these positions, and we have the corrected code word. In the more general case, the error weightscan be determined by solving the linear system

Forney algorithm

[edit]

However, there is a more efficient method known as theForney algorithm.

Let

And the error evaluator polynomial[9]

Finally:

where

Than if syndromes could be explained by an error word, which could be nonzero only on positions,then error values are

For narrow-sense BCH codes,c= 1, so the expression simplifies to:

Explanation of Forney algorithm computation

[edit]

It is based onLagrange interpolationand techniques ofgenerating functions.

Considerand for the sake of simplicity supposeforandforThen

We want to compute unknownsand we could simplify the context by removing theterms. This leads to the error evaluator polynomial

Thanks towe have

Thanks to(the Lagrange interpolation trick) the sum degenerates to only one summand for

To getwe just should get rid of the product. We could compute the product directly from already computed rootsofbut we could use simpler form.

Asformal derivative

we get again only one summand in

So finally

This formula is advantageous when one computes the formal derivative ofform

yielding:

where

Decoding based on extended Euclidean algorithm

[edit]

An alternate process of finding both the polynomial Λ and the error locator polynomial is based on Yasuo Sugiyama's adaptation of theExtended Euclidean algorithm.[10]Correction of unreadable characters could be incorporated to the algorithm easily as well.

Letbe positions of unreadable characters. One creates polynomial localising these positions Set values on unreadable positions to 0 and compute the syndromes.

As we have already defined for the Forney formula let

Let us run extended Euclidean algorithm for locating least common divisor of polynomialsand The goal is not to find the least common divisor, but a polynomialof degree at mostand polynomialssuch that Low degree ofguarantees, thatwould satisfy extended (by) defining conditions for

Definingand usingon the place ofin the Fourney formula will give us error values.

The main advantage of the algorithm is that it meanwhile computesrequired in the Forney formula.

Explanation of the decoding process

[edit]

The goal is to find a codeword which differs from the received word minimally as possible on readable positions. When expressing the received word as a sum of nearest codeword and error word, we are trying to find error word with minimal number of non-zeros on readable positions. Syndromrestricts error word by condition

We could write these conditions separately or we could create polynomial

and compare coefficients near powersto

Suppose there is unreadable letter on positionwe could replace set of syndromesby set of syndromesdefined by equationSuppose for an error word all restrictions by original setof syndromes hold, than

New set of syndromes restricts error vector

the same way the original set of syndromes restricted the error vectorExcept the coordinatewhere we haveanis zero, ifFor the goal of locating error positions we could change the set of syndromes in the similar way to reflect all unreadable characters. This shortens the set of syndromes by

In polynomial formulation, the replacement of syndromes setby syndromes setleads to

Therefore,

After replacement ofby,one would require equation for coefficients near powers

One could consider looking for error positions from the point of view of eliminating influence of given positions similarly as for unreadable characters. If we foundpositions such that eliminating their influence leads to obtaining set of syndromes consisting of all zeros, than there exists error vector with errors only on these coordinates. Ifdenotes the polynomial eliminating the influence of these coordinates, we obtain

In Euclidean algorithm, we try to correct at mosterrors (on readable positions), because with bigger error count there could be more codewords in the same distance from the received word. Therefore, forwe are looking for, the equation must hold for coefficients near powers starting from

In Forney formula,could be multiplied by a scalar giving the same result.

It could happen that the Euclidean algorithm findsof degree higher thanhaving number of different roots equal to its degree, where the Fourney formula would be able to correct errors in all its roots, anyway correcting such many errors could be risky (especially with no other restrictions on received word). Usually after gettingof higher degree, we decide not to correct the errors. Correction could fail in the casehas roots with higher multiplicity or the number of roots is smaller than its degree. Fail could be detected as well by Forney formula returning error outside the transmitted Alpha bet.

Correct the errors

[edit]

Using the error values and error location, correct the errors and form a corrected code vector by subtracting error values at error locations.

Decoding examples

[edit]

Decoding of binary code without unreadable characters

[edit]

Consider a BCH code in GF(24) withand.(This is used inQR codes.) Let the message to be transmitted be [1 1 0 1 1], or in polynomial notation, The "checksum" symbols are calculated by dividingbyand taking the remainder, resulting inor [ 1 0 0 0 0 1 0 1 0 0 ]. These are appended to the message, so the transmitted codeword is [ 1 1 0 1 1 1 0 0 0 0 1 0 1 0 0 ].

Now, imagine that there are two bit-errors in the transmission, so the received codeword is [ 100 1 1 1 0 0 011 0 1 0 0 ]. In polynomial notation:

In order to correct the errors, first calculate the syndromes. Takingwe haveand Next, apply the Peterson procedure by row-reducing the following augmented matrix.

Due to the zero row,S3×3is singular, which is no surprise since only two errors were introduced into the codeword. However, the upper-left corner of the matrix is identical to[S2×2|C2×1],which gives rise to the solution The resulting error locator polynomial iswhich has zeros atand The exponents ofcorrespond to the error locations. There is no need to calculate the error values in this example, as the only possible value is 1.

Decoding with unreadable characters

[edit]

Suppose the same scenario, but the received word has two unreadable characters [ 100? 1 1? 0 011 0 1 0 0 ]. We replace the unreadable characters by zeros while creating the polynomial reflecting their positionsWe compute the syndromesand(Using log notation which is independent on GF(24) isomorphisms. For computation checking we can use the same representation for addition as was used in previous example. Hexadecimal description of the powers ofare consecutively 1,2,4,8,3,6,C,B,5,A,7,E,F,D,9 with the addition based on bitwise xor.)

Let us make syndrome polynomial

compute

Run the extended Euclidean algorithm:

We have reached polynomial of degree at most 3, and as

we get

Therefore,

LetDon't worry thatFind by brute force a root ofThe roots areand(after finding for examplewe can divideby corresponding monomand the root of resulting monom could be found easily).

Let

Let us look for error values using formula

whereare roots ofWe get

Fact, thatshould not be surprising.

Corrected code is therefore [ 11011 100 001 0 1 0 0].

Decoding with unreadable characters with a small number of errors

[edit]

Let us show the algorithm behaviour for the case with small number of errors. Let the received word is [ 100? 1 1? 0 0 0 1 0 1 0 0 ].

Again, replace the unreadable characters by zeros while creating the polynomial reflecting their positions Compute the syndromesand Create syndrome polynomial

Let us run the extended Euclidean algorithm:

We have reached polynomial of degree at most 3, and as

we get

Therefore,

LetDon't worry thatThe root ofis

Let

Let us look for error values using formulawhereare roots of polynomial

We get

The fact thatshould not be surprising.

Corrected code is therefore [ 11011 100 0 0 1 0 1 0 0].

Citations

[edit]
  1. ^Reed & Chen 1999,p. 189
  2. ^Hocquenghem 1959
  3. ^Bose & Ray-Chaudhuri 1960
  4. ^"Phobos Lander Coding System: Software and Analysis"(PDF).Archived(PDF)from the original on 2022-10-09.Retrieved25 February2012.
  5. ^Marelli, Alessia; Micheloni, Rino (2018)."BCH Codes for Solid-State-Drives".Inside Solid State Drives (SSDS).Springer Series in Advanced Microelectronics. Vol. 37. pp. 369–406.doi:10.1007/978-981-13-0599-3_11.ISBN978-981-13-0598-6.Retrieved23 September2023.
  6. ^Gill n.d.,p. 3
  7. ^Lidl & Pilz 1999,p. 229
  8. ^Gorenstein, Peterson & Zierler 1960
  9. ^Gill n.d.,p. 47
  10. ^Yasuo Sugiyama, Masao Kasahara, Shigeichi Hirasawa, and Toshihiko Namekawa. A method for solving key equation for decoding Goppa codes. Information and Control, 27:87–99, 1975.

References

[edit]

Primary sources

[edit]

Secondary sources

[edit]

Further reading

[edit]