Accelerating the pace of engineering and science

# Binary-Output RS Decoder

Decode Reed-Solomon code to recover binary vector data

## Library

Block sublibrary of Error Detection and Correction

## Description

The Binary-Output RS Decoder block recovers a binary message vector from a binary Reed-Solomon codeword vector. For proper decoding, the parameter values in this block should match those in the corresponding Binary-Input RS Encoder block.

The Reed-Solomon code has message length, K, and codeword length, (N - number of punctures). You specify both N and K directly in the dialog box. The symbols for the code are binary sequences of length M, corresponding to elements of the Galois field GF(2M), where the first bit in each sequence is the most significant bit. Restrictions on M and N are described in Restrictions on the M and the Codeword Length N.

This block can output shortened codewords when N and K are appropriately specified. To specify output codewords that are shortened by a length S, N and K must be specified in the dialog box as NfullS and KfullS, where Nfull and Kfull are the N and K of an unshortened code. If $\text{S}<\left({\text{N}}_{\text{full}}+1\right)/2$, the encoder can automatically determine the value of Nfull and Kfull. However, if $\text{S}\ge \left({\text{N}}_{\text{full}}+1\right)/2$, Primitive polynomial must be specified in order to properly define the extension field for the code.

The input and output are binary-valued signals that represent codewords and messages, respectively. This block accepts a column vector input signal with a length that is an integer multiple of M * (N - number of punctures). This block outputs a column vector with a length that is the same integer multiple of M*K. The output signal inherits its data type from the input signal. For information about the data types each block port supports, see the Supported Data Type table on this page.

For more information on representing data for Reed-Solomon codes, see Integer Format (Reed-Solomon Only) in Communications System Toolbox™ User's Guide.

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

The default value of M is ceil(log2(N+1)), that is, the smallest integer greater than or equal to log2(N+1). You can change the value of M from the default by specifying the primitive polynomial for GF(2M), as described in Specifying the Primitive Polynomial below. If N is less than 2M-1, the block uses a shortened Reed-Solomon code.

You can also specify the generator polynomial for the Reed-Solomon code, as described in Specifying the Generator Polynomial.

Each M*K input bits represent K integers between 0 and 2M-1. Similarly, each M*(N - number of punctures) output bits represent N integers between 0 and 2M-1. These integers in turn represent elements of the Galois field GF(2M).

The second output is a vector of the number of errors detected during decoding of the codeword. A -1 indicates that the block detected more errors than it could correct using the coding scheme. An (N,K) Reed-Solomon code can correct up to floor((N-K)/2) symbol errors (not bit errors) in each codeword.

You can disable the second output by deselecting Output port for number of corrected errors. This removes the block's second output port.

## Punctured Codes

This block supports puncturing when you select the Punctured code parameter. 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 is carried for both the encoder and the decoder. For more information, see Shortening, Puncturing, and Erasures.

 Note:   1s and 0s 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.

## Dialog Box

Codeword length N

The codeword length. The input has vector length NC*M*(N - NP), where NC is the number of codewords being output, and NP is the number of punctures per codeword.

Message length K

The message length. The first output has vector length NM*M*K, where NM is the number of messages per frame being output.

Specify primitive polynomial

Selecting this check box enables the Primitive polynomial field.

Primitive polynomial

Binary row vector representing the primitive polynomial in descending order of powers. When you provide a Primitive polynomial, the number of input bits must be an integer multiple of K times the order of the Primitive polynomial instead.

This parameter applies only when you select Specify primitive polynomial.

Specify generator polynomial

Selecting this check box enables the Generator polynomial field.

Generator polynomial

Integer row vector, whose entries are in the range from 0 to 2M-1, representing the generator polynomial in descending order of powers. Each coefficient is an element of the Galois field defined by the primitive polynomial.

This parameter applies only when you select Specify generator polynomial.

Puncture code

Selecting this check box enables the Puncture vector field.

Puncture vector

A column vector of length N-K. For a puncture vector, 1 represents an M-bit symbol that passes unaltered, and 0 represents an M-bit symbol that gets punctured, or removed, from the data stream.

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

This parameter applies only when you select Punctured code.

Enable erasures input port

Select this check to open the erasures port, Era.

Through the port, you can input a binary column vector that is 1/M times as long as the codeword input.

Erasure values of 1 correspond to erased symbols in the same position in the bit-packed codeword, and values of 0 correspond to nonerased symbols.

Output number of corrected errors

When you select this box, the block outputs the number of corrected errors in each word through a second output port. A decoding failure occurs when a certain received word in the input contains more than (N-K)/2 symbol errors. The value -1 indicates the corresponding position in the second output vector.

Output data type

The output type of the block can be specified as Same as input, boolean, or double. By default, the block sets this to Same as input.

## 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

• 1-bit unsigned integer (ufix(1))

Out
• Double-precision floating point

• Single-precision floating point

• Boolean

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

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

• 1-bit unsigned integer (ufix(1))

Era
• Double-precision floating point

• Boolean

Err
• Double-precision floating point

## Algorithm

This block uses the Berlekamp-Massey decoding algorithm. For information about this algorithm, see the references listed below.

## Pair Block

Binary-Input RS Encoder

## 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.