# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# BCH Decoder

Decode BCH code to recover binary vector data

## Library

Block sublibrary of Error Detection and Correction

## Description

The BCH Decoder block recovers a binary message vector from a binary BCH codeword vector. For proper decoding, the first two parameter values in this block must match the parameters in the corresponding BCH Encoder block.

The full length values of N and K must produce a valid narrow-sense BCH code.

If the decoder is processing multiple codewords per frame, then the same puncture pattern holds for all codewords.

For a given codeword length, N, only specific message length Ks are valid for a BCH code. For a full-length BCH code, N must be of the form 2M-1, where $3\le M\le 16$.

No known analytic formula describes the relationship among the codeword length, message length, and error-correction capability. For a list of some valid values of K corresponding to values of N up to 511, see the table on the BCH Encoder reference page.

You can specify the shortened message length, the primitive polynomial, and generator polynomial in their respective text boxes, which appear after selecting their corresponding check boxes.

To output error information from the block, select Output number of corrected errors. Selecting this option creates a second output port, which outputs the number of errors detected during decoding of the codeword. A negative integer indicates that the block detected more errors than it could correct using the coding scheme.

If decoding fails, the message portion of the decoder input is returned unchanged as the decoder output.

The sample times of all input and output signals are equal.

For information about the data types each block port supports, see the Supported Data Type table on this page.

## Punctured Codes

This block supports puncturing when you select Punctured code. This selection enables the Puncture vector parameter, which takes in a binary vector to specify the puncturing pattern. For a puncture vector, `1` represents that the data symbol passes unaltered, and `0` represents that the data symbol gets punctured, or removed, from the data stream. This convention applies for both the encoder and the decoder. For more information, see Shortening, Puncturing, and Erasures.

 Note:   `1`s and `0`s have precisely opposite meanings for the puncture and erasure vectors. For an erasure vector, `1` means that the data symbol is to be replaced with an erasure symbol, and `0` means that the data symbol is passed unaltered. This convention is carried for both the encoder and the decoder.

## Input and Output Signal Length in BCH and RS Blocks

The notation `y = c * x` denotes that `y` is an integer multiple of `x`.

The number of punctures value is equal to the number of zeros in the puncture vector.

M is the degree of the primitive polynomial. Each group of M bits represents an integer between `0` and `2M–1` that belongs to the finite Galois field `GF(2M)`.

Specify shortened message length

BCH Encoder

Integer-Input RS Encoder

BCH Decoder

Integer-Output RS Decoder

Binary-Input RS Encoder

Binary-Output RS Decoder

off

`Input Length:`

```c * Message length```

```Output Length:```

```c * (Codeword length – number of punctures) ```

`Input Length: `

```c * (Codeword length – number of punctures) ```

`Output Length: `

```c * Message length```

```Erasures Length: ```

```c * ( Codeword length – number of punctures)```

`Input Length:`

```c * (Message length * M)```

```Output Length:```

```c * (( Codeword length – number of punctures) * M)```

`Input Length: `

```c * ( (Codeword length – number of punctures) * M)```

`Output Length:`

```c * (Message length * M)```

```Erasures Length: ```

```c * (Codeword length – number of punctures)```

on

`Input Length: `

```c * Shortened message length```

```Output Length:```

```c * (Codeword length - Message length + Shortened message length - number of punctures)```

`Input Length: `

```c * (Codeword length - Message length + Shortened message length - number of punctures)```

```Output Length:```

```c * Shortened message length```

```Erasures Length:```

```c * (Codeword length - Message length + Shortened message length - number of punctures)```

`Input Length: `

```c * (Shortened message length * M)```

`Output Length:`

```c * ( (Codeword length - Message length + Shortened message length - number of punctures) * M)```

`Input Length: `

```c * ((Codeword length - Message length + Shortened message length - number of punctures) * M)```

```Output Length:```

```c * (Shortened message length * M)```

```Erasures Length:```

```c * (Codeword length - Message length + Shortened message length - number of punctures) ```

## Parameters

Codeword length, N

The codeword length.

Message length, K

The message length.

Specify shortened message length

Selecting this check box enables the Shortened message length, S text box.

Shortened message length, S

The shortened message length. When you specify this parameter, provide full-length N and K values to specify the (N,K) code that is shortened to an (NK+S,S) code.

Specify generator polynomial

Selecting this check box enables the Generator polynomial text box.

Generator polynomial

A row vector that represents the generator polynomial as a character vector or as binary coefficients in order of descending powers.

The length of the Generator polynomial must be NK+1.

This field defaults to ```'X^10 + X^8 + X^5 + X^4 + X^2 + X + 1'```, which is equivalent to `bchgenpoly(15,5)`.

This parameter appears only when you select Specify generator polynomial.

Disable generator polynomial checking

Each time a model initializes, the block performs a polynomial check. This check verifies that X N + 1 is divisible by the user-defined generator polynomial, where N represents the full code word length. Selecting this check box disables the polynomial check. For larger codes, disabling the check speeds up the simulation process. You should always run the check at least once before disabling this feature.

This check box appears only when you select Specify generator polynomial.

Specify primitive polynomial

Selecting this check box enables the Primitive polynomial text box.

Primitive polynomial

A row vector that represents the binary coefficients of the primitive polynomial in order of descending powers.

This field defaults to `'X^4 + X + 1'`. This is the primitive polynomial used for a (15,5) code, `de2bi(primpoly(4,'nodisplay'),'left-msb')`.

This parameter appears only when you select Specify primitive polynomial.

Puncture code

Selecting this check box enables the Puncture vector text box.

Puncture vector

This parameter appears only when you select Puncture code.

A column vector of length NK. In the Puncture vector, a value of `1` represents that the data symbol passes unaltered, and `0` represents that the data symbol gets punctured, or removed, from the data stream.

The default value is `[ones(8,1); zeros(2,1)]`.

Enable erasures input port

Selecting this check box opens the erasures port, `Era`.

Through the port, you can input a binary column vector the same size as the codeword input.

Erasure values of `1` correspond to erased bits in the same position in the codeword. Values of `0` correspond to bits that are not erased.

Output number of corrected errors

Selecting this check box gives the block an additional output port, `Err`, which indicates the number of errors the block corrected in the input codeword.

## Supported Data Type

PortSupported Data Types
In
• Double-precision floating point

• Single-precision floating point

• Boolean

• 8-, 16-, and 32-bit signed integers

• 8-, 16-, and 32-bit unsigned integers

Out
• Double-precision floating point

• Single-precision floating point

• Boolean

• 8-, 16-, and 32-bit signed integers

• 8-, 16-, and 32-bit unsigned integers

Era
• Double-precision floating point

• Boolean

Err
• Double-precision floating point

• Single-precision floating point

• Boolean

• 8-, 16-, and 32-bit signed integers

• 8-, 16-, and 32-bit unsigned integers

BCH Encoder

## Algorithms

This object implements the algorithm, inputs, and outputs described in Algorithms for BCH and RS Errors-only Decoding.

## References

[1] Wicker, Stephen B., Error Control Systems for Digital Communication and Storage, Upper Saddle River, N.J., Prentice Hall, 1995.

[2] Berlekamp, Elwyn R., Algebraic Coding Theory, New York, McGraw-Hill, 1968.

[3] Clark, George C., Jr., and J. Bibb Cain, Error-Correction Coding for Digital Communications, New York, Plenum Press, 1981.