m Matlab simulation of BCH encoding and decoding based on money search algorithm, simulation output bit error rate curve and coding gain curve

Table of contents

1. Algorithm simulation effect

2. Algorithms involve an overview of theoretical knowledge

3. MATLAB core program

4. Complete algorithm code file


1. Algorithm simulation effect

The matlab2022a simulation results are as follows:

 

2. Algorithms involve an overview of theoretical knowledge

 BCH codec is a channel codec with strong error correction ability and simple structure. The generator polynomial of BCH encoding and decoding can be expressed by the following formula:

  

① BCH code is an error correction code, linear block code, and cyclic code.

② Number of bits of information to be transmitted: k

③ Error correction ability: t

④ Total code length (information bit + supervision bit): n

⑤ When the length of n satisfies n=2^m – 1, the original BCH code is generated; when the length of n is a factor of 2^m – 1, it is a non-original BCH code

(For example, when n=15, n=31, and n=63, it is the original BCH code; when n=21 (divisible by 63), etc., it is the non-original BCH code)

⑥ In addition, there are lengthening BCH codes and shortening BCH codes.

⑦ The specific BCH code is usually represented by BCH (n, k) code.

Lengthen BCH code and shorten BCH code:
Because the original BCH code and non-original BCH code require the length of n, but in many cases the code length we want does not satisfy n=2^m – 1 or its factor. At this time, it is necessary to lengthen the BCH code and shorten the BCH code.

(1) Shorten the BCH code

The BCH(50,32) code is a shortened code of the BCH(63,45) code on the extended field GF(2^6). The difference and connection between BCH(50,32) code and BCH(63,45) code:

① Both have the same error correction capability and the same generating polynomial.

②The realization of the shortened code only needs to add 0 to the high bit when compiling and decoding, from k = 32 to k = 45.

(2) Extended BCH code

        By multiplying the factor (x+1) in the generator polynomial of the original BCH code or the non-original BCH code, the lengthened BCH code (n+1,k) can be obtained, and a parity bit is added.

The encoded codeword contains information bytes and check bytes, and its expression is as follows:

         The BCH decoding process mainly obtains the error position polynomial by calculating the accompanying formula sj, and then calculates the root of the error position polynomial through the chein algorithm, thereby determining the number of error positions. Finally, the error value and the error pattern E(x) are obtained from the number of error positions, and finally the error is corrected by R(x)- E(x)=C(x).

3. MATLAB core program

...................................................................
for i=1:2*t
    GFalpha(i)=B2^(2*t-i+1);
end;

for j=1:data_Len2
    %Data segmentation
    rec_data = rec_data2((j-1)*n+1:(j-1)*n+n);
    BCH_tmp  = gf(zeros(1, 2*t), m);
    
    for i=1:n
        BCH_tmp = BCH_tmp.*GFalpha+rec_data(n-i+1);%GFalpha Summation and accumulation
    end;
    
    Lmds1     = gf([1, zeros(1, t)], m);
    Lmds2     = Lmds1;
    b1        = gf([0, 1, zeros(1, t)], m);
    b2        = gf([0, 0, 1, zeros(1, t)], m);
    k1        = 0;
    
    Gam       = B1;
    delta     = B0;
    
    BCH_array = gf(zeros(1, t+1), m);

    for r=1:t
        r1                = 2*t-2*r+2;
        r2                = min(r1+t, 2*t);
        num               = r2-r1+1;
        BCH_array(1: num) = BCH_tmp(r1:r2);
        
        delta             = BCH_array*Lmds1';
        Lmds2             = Lmds1;
        Lmds1             = Gam*Lmds1-delta*b2(2:t+2);
        
        if (delta~= B0) && (k1>=0)
            b2(3)     = B0;
            b2(4:3+t) = Lmds2(1:t);
            Gam       = delta;
            k1        = -k1;
        else
            b2(3:3+t) = b2(1:t+1);
            Gam       = Gam;
            k1        = k1+2;
        end
    end

    invdat = gf(zeros(1, t+1), m);
    for i=1:t+1
        invdat(i) = B2^(-i+1);
    end;

    %chein search
    Lmds3    = B0;
    acc      = gf(ones(1, t+1), m);
    for i=1:n
        Lmds3 = Lmds1*acc';
        acc   = acc.*invdat;
        
        if Lmds3==B0 
           errs(1,n-i+1) = 1;
        else
           errs(1,n-i+1) = 0;
        end
    end
    
    smll = find(errs(1,:)~=0);
    for i=1:length(smll)
        pos = smll(i);
        if pos <= k;
           rec_data(n-pos+1) = rec_data(n-pos+1) + B1;
        end
    end
    GFdec((j-1)*k+1:(j-1)*k+k) = rec_data(n-k+1:n);%the decode output
end
14_047_m

4. Complete algorithm code file

V

Guess you like

Origin blog.csdn.net/hlayumi1234567/article/details/129733041