11
Signal Coding and Estimation Theory T.E.(E&TC) EXPERIMENT NO. 7 BCH ALGORITHM AIM : Implementation of algorithms for decoding of BCH algorithm. EQUIPMENT REQUIRED : 1. PC 2. Software: Matlab THEORY : In coding theory the BCH codes form a class of cyclic error- correcting codes that are constructed using finite fields. BCH codes were invented in 1959 by Hocquenghem, and independently in 1960 by Bose and Ray-Chaudhuri The abbreviation BCH comprises the initials of these inventors' names. One of the most important and powerful classes of linear- block codes are Bose-Choudhary-Hocquenghem (BCH) codes, which are cyclic codes with a wide variety of parameters. Since BCH codes are cyclic codes they can be described in terms of their generator polynomial g(x).The most common binary BCH codes, known as primitive BCH codes, are characterized for any positive integers m(≥ 3) and t[≤ (2 m -1 )/2] by the following parameters: Block length: n=2 m -1 Number of message bits: n-k≥mt Minimum distance: d min ≥ 2t+1 The first equality determines the block length of the code. The second inequality provides a bound on the number of parity check bits of the code, and the third inequality states that this code is capable of correcting at least t errors. The resulting code is called a t-error correcting code; although it is possible that this code can correct more than t errors. Hamming single-error correcting codes can be described as BCH codes. The BCH codes offer flexibility in the choice of code parameters, like, block length and code rate. Primitive Element: A Primitive Element of GF(q) is an element α Expt. No. 7: BCH Algorithm 1 Universal College of Engineering and Research, Pune

bch algorithm

  • Upload
    poo235

  • View
    245

  • Download
    3

Embed Size (px)

Citation preview

Page 1: bch algorithm

Signal Coding and Estimation Theory T.E.(E&TC)

EXPERIMENT NO. 7

BCH ALGORITHM

AIM: Implementation of algorithms for decoding of BCH algorithm.

EQUIPMENT REQUIRED:1. PC2. Software: Matlab

THEORY:In coding theory the BCH codes form a class of cyclic error-correcting codes that are

constructed using finite fields. BCH codes were invented in 1959 by Hocquenghem, and independently in 1960 by Bose and Ray-Chaudhuri The abbreviation BCH comprises the initials of these inventors' names.

One of the most important and powerful classes of linear-block codes are Bose-Choudhary-Hocquenghem (BCH) codes, which are cyclic codes with a wide variety of parameters. Since BCH codes are cyclic codes they can be described in terms of their generator polynomial g(x).The most common binary BCH codes, known as primitive BCH codes, are characterized for any positive integers m(≥ 3) and t[≤ (2m -1 )/2] by the following parameters: Block length: n=2m -1

Number of message bits: n-k≥mt Minimum distance: dmin ≥ 2t+1

The first equality determines the block length of the code. The second inequality provides a bound on the number of parity check bits of the code, and the third inequality states that this code is capable of correcting at least t errors. The resulting code is called a t-error correcting code; although it is possible that this code can correct more than t errors. Hamming single-error correcting codes can be described as BCH codes. The BCH codes offer flexibility in the choice of code parameters, like, block length and code rate.

Primitive Element: A Primitive Element of GF(q) is an element α such that every field element except zero can be expressed as a power of α.

Primitive Polynomial: A Primitive Polynomial p(x) over GF(q) is a prime polynomial over GF(q) with the property that in the extension field constructed modulo p(x), the field element represented by x is a primitive element.

Primitive Cyclic Code: A blocklength n of the form n = qm-1 is called a Primitive Blocklength for a code over GF(q). For most of the cases it will be n=2m -1 for GF(2). A cyclic code over GF(q) of primitive blocklength is called a Primitive Cyclic Code.

Minimal Polynomial: The smallest degree polynomial with coefficients in the base field GF(q) that has a zero in the extension field GF(qm) is called the Minimal Polynomial of βj where βj

ranges over all the non-zero elements of GF(qm).

The Generator Polynomial for BCH Codes:To design a t-error correcting (primitive) BCH codes, we choose α, a primitive element

Expt. No. 7: BCH Algorithm 1

Universal College of Engineering and Research, Pune

Page 2: bch algorithm

Signal Coding and Estimation Theory T.E.(E&TC)

of GF(2m). Then g(x), the generator polynomial of the BCH code, is defined as the lowest- degree polynomial g(x) over GF (2) such that α, α2, α3,…..and α2t are its roots.

Any polynomial over GF(2) that has β Є GF(2) as a root is divisible by φβ(x), the minimal polynomial of β. Therefore g(x) must be divisible by φα

i(x) for 1≤ i ≤ 2t. Since g(x) is a polynomial of lowest degree with this property, we can write that,

g(x) = LCM{ φαi(x), 1≤ i ≤ 2t}

where LCM denotes the least common multiple of φαi(x)’s.

Let us assume that c(x) is a codeword polynomial of the designed BCH code. From the cyclic property of the code, g(x) is a divisor of c(x). Therefore, all α i for 1≤ i ≤ 2t are roots of c(x); i.e. for any codeword polynomial c(x) ,

c (αi) = 0 1≤ i ≤ 2tAbove conditions are necessary and sufficient conditions for a polynomial of degree less

than n to be a codeword polynomial of the BCH code.

Decoding of BCH codes:

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

1. Calculate the syndromes sj for the received vector2. Determine the number of errors t and the error locator polynomial Λ(x) from the

syndromes3. Calculate the roots of the error location polynomial to find the error locations Xi

4. Calculate the error values Yi at those error locations5. Correct the errors

Calculate the syndromes:The received vector is the sum of the correct codeword and an unknown error vector

The syndrome values are formed by considering as a polynomial and evaluating it at Thus the syndromes are:

for to Since are the zeros of of which is 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 all If the syndromes are all zero, then the decoding is done.

Calculate the error location polynomial: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 as where is the location of the error and

is its magnitude. Then the first two syndromes are:

So together they allow us to calculate and 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 unknowns and First step is finding locator polynomial

Expt. No. 7: BCH Algorithm 2

Universal College of Engineering and Research, Pune

Page 3: bch algorithm

Signal Coding and Estimation Theory T.E.(E&TC)

compatible with computed syndroms and with minimal possible Two popular algorithms for this task are:

1. Peterson–Gorenstein–Zierler algorithm2. Berlekamp–Massey algorithm

A. Peterson–Gorenstein–Zierler algorithm:Peterson's algorithm is the step 2 of the generalized BCH decoding procedure. Peterson's algorithm is used to calculate the error locator polynomial coefficients of a polynomial

Now the procedure of the Peterson–Gorenstein–Zierler algorithm. Expect we have at least 2t syndromes sc,...,sc+2t-1. Let v=t.

1. Start by generating the matrix with elements that are syndrome values

2. Generate a vector with elements

3. Let denote the unknown polynomial coefficients, which are given by

4. Form the matrix equation

5. If the determinant of matrix is nonzero, then we can actually find an inverse of this matrix and solve for the values of unknown values.

6. If then follow if then declare an empty error locator polynomial set continue from the beginning by making smaller .

B. Berlekamp-Massey Algorithm:This formula describes the output of a linear feedback shift register (LFSR) with coefficients

Factor error locator polynomial:Now that you have the polynomial, its roots can be found in the form

. The exponential powers of the primitive element will yield the positions where errors occur in the received word; hence the name 'error locator'

polynomial. The zeros of Λ(x) are α-i1, ..., α-i

v.

Expt. No. 7: BCH Algorithm 3

Universal College of Engineering and Research, Pune

Page 4: bch algorithm

Signal Coding and Estimation Theory T.E.(E&TC)

Calculate error values: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 weights can be determined by solving the linear system

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

ALGORITHM:

1. Enter the length of codeword frame i.e. n.2. Enter the length of message bits i.e. k.3. Find generator polynomial using bchgenpoly function4. Display array elements of generator polynomial.5. Find encoded polynomial using bchenc function.6. Add noise in encoded polynomial.7. Decode this received polynomial using bchdec function. 8. Display decoded codeword.9. If decoded codeword is same as transmitted, then display ‘received codeword is perfect’.10. If corrected codeword is same as transmitted message, display ‘all

errors are corrected,.

EXAMPLE:For the double-error-correcting BCH code of length 15,find generator polynomial if primitive polynomial is P(X)=1+X+X4.If received codeword is y(x) = x4+ x6+ x7+ x8+ x13 ,find its corrected codeword.

SOLUTION:

Representation for the elements of GF(24) generated by P(X)=1+X+X4

Expt. No. 7: BCH Algorithm 4

Universal College of Engineering and Research, Pune

Page 5: bch algorithm

Signal Coding and Estimation Theory T.E.(E&TC)

Minimal polynomials of GF(24) generated by P(X)=1+X+X4 :

Therefore,

The double-error-correcting BCH code of length n =24 -1 = 15 is generated by,

we have received the wordy = (0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0).The polynomial y(x) is then equal to,y(x) = x4+ x6+ x7+ x8+ x13 ,Therfore,

Expt. No. 7: BCH Algorithm 5

Universal College of Engineering and Research, Pune

Page 6: bch algorithm

Signal Coding and Estimation Theory T.E.(E&TC)

The polynomial is factorized as,

ω0, ω13 reveals to zero.This shows that the received word has errors at positions 0 and 13, so that the closest codeword to y is (1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0)

MATLAB FUNCTIONS:

1. bchgenpoly: Generator polynomial of BCH code Syntax : genpoly = bchgenpoly(n,k) genpoly = bchgenpoly(n,k,prim_poly) [genpoly,t] = bchgenpoly(...)

Description:genpoly = bchgenpoly(n,k) returns the narrow-sense generator polynomial of a BCH code with codeword length n and message length k. The codeword length n must have the form 2m-1 for some integer m. The output genpoly is a Galois row vector in GF(2) that represents the coefficients of the generator polynomial in order of descending powers. The narrow-sense generator polynomial is (X - A1)(X - A2)...(X- An-k) where A is a root of the default primitive polynomial for the field GF(n+1).genpoly = bchgenpoly(n,k,prim_poly) is the same as the syntax above, except that prim_poly specifies the primitive polynomial for GF(n+1) that has A as a root. prim_poly is an integer whose binary representation indicates the coefficients of the primitive polynomial. To use the default primitive polynomial for GF(n+1), set prim_poly to [].[genpoly,t] = bchgenpoly(...) returns t, the error-correction capability of the code.

2. bchenc: BCH encoder Syntax :code = bchenc(msg,n,k) code = bchenc(...,paritypos)

Description: code = bchenc(msg,n,k) encodes the message in msg using an [n,k] BCH encoder with

the narrow-sense generator polynomial. msg is a Galois array of symbols over GF(2). Each k-element row of msg represents a message word, where the leftmost symbol is the most significant symbol. Parity symbols are at the end of each word in the output Galois array code.

code = bchenc(...,paritypos) specifies whether bchenc appends or prepends the parity symbols to the input message to form code. The string paritypos can be either 'end' or 'beginning'. The default is 'end'.

Expt. No. 7: BCH Algorithm 6

Universal College of Engineering and Research, Pune

Page 7: bch algorithm

Signal Coding and Estimation Theory T.E.(E&TC)

3. bchdec:BCH decoder Syntax: decoded = bchdec(code,n,k) decoded = bchdec(...,paritypos) [decoded,cnumerr] = bchdec(...) [decoded,cnumerr,ccode] = bchdec(...)

Description:decoded = bchdec(code,n,k) attempts to decode the received signal in code using an [n,k] BCH decoder with the narrow-sense generator polynomial. code is a Galois array of symbols over GF(2). Each n-element row of code represents a corrupted systematic codeword, where the parity symbols are at the end and the leftmost symbol is the most significant symbol. In the Galois array decoded, each row represents the attempt at decoding the corresponding row in code. A decoding failure occurs if bchdec detects more than t errors in a row of code, where t is the number of correctable errors as reported by bchgenpoly. In the case of a decoding failure, bchdec forms the corresponding row of decoded by merely removing n-k symbols from the end of the row of code.decoded = bchdec(...,paritypos) specifies whether the parity symbols in code were appended or prepended to the message in the coding operation. The string paritypos can be either 'end' or 'beginning'. The default is 'end'. If paritypos is 'beginning', then a decoding failure causes bchdec to remove n-k symbols from the beginning rather than the end of the row.[decoded,cnumerr] = bchdec(...) returns a column vector cnumerr, each element of which is the number of corrected errors in the corresponding row of code. A value of -1 in cnumerr indicates a decoding failure in that row in code.[decoded,cnumerr,ccode] = bchdec(...) returns ccode, the corrected version of code. The Galois array ccode has the same format as code. If a decoding failure occurs in a certain row of code, then the corresponding row in ccode contains that row unchanged.

CONCLUSION:______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

ORAL QUESTIONS:

Expt. No. 7: BCH Algorithm 7

Universal College of Engineering and Research, Pune

Page 8: bch algorithm

Signal Coding and Estimation Theory T.E.(E&TC)

1. What is BCH code2. Explain following

a) Groupb) Fieldc) G F addition multiplication

3. Explaina) Minimal Polynomialb) Extension fieldc) Primitive polynomial

4. Solve any two problems on BCH code.5. Explain method of encoding of BCH code(solve one problem)6. Explain method of decoding of BCH code(solve one problem)7. Explain MATLAB functions used in program8. Explain Advantages, disadvantages and application of BCH codes.

Expt. No. 7: BCH Algorithm 8

Universal College of Engineering and Research, Pune