# RS Decoder

Decode and recover message from RS codeword

• Library:
• Wireless HDL Toolbox / Error Detection and Correction

## Description

The RS Decoder block decodes and recovers a message from a Reed-Solomon (RS) codeword. The block accepts codeword data and a `samplecontrol` bus and outputs a decoded message data, a `samplecontrol` bus, whether the received data is corrupted, a block ready indicator, and (optionally) the number of corrected errors. The block provides an architecture suitable for HDL code generation and hardware deployment and supports shortened message lengths.

Because, the latency of the block varies, the block provides output port nextFrame that indicates when the block is ready to accept new input codeword data. For more details about latency, see the Algorithms section.

You can use this block to model many communication system forward error correcting (FEC) codes. The block supports digital subscriber line (DSL), WiMAX (802.16 m and e), digital video broadcast handheld (DVB-H) terminals, digital video broadcast satellite (DVB-S) services, and digital video broadcast satellite services to handheld (DVB-SH) devices below 3 MHz.

## Ports

### Input

expand all

Input codeword data, specified as a scalar representing one symbol.

The length of the codeword in symbols specified by the Codeword length (N) parameter must be an integer equal to 2M – 1, where M is an integer in the range from 3 to 16.

The input data word length must be an unsigned integer equal to `ceil`(log2(Codeword length (N))). For a codeword length of `7`, the input data word length must be 3.

`double` and `single` data types are allowed for simulation, but not for HDL code generation.

Data Types: `double` | `single` | `uint8` | `uint16` | `fixed point`

Control signals accompanying the sample stream, specified as a `samplecontrol` bus. The bus includes the `start`, `end`, and `valid` control signals, which indicate the boundaries of the frame and the validity of the samples.

• `start` — Indicates the start of the input frame

• `end` — Indicates the end of the input frame

• `valid` — Indicates that the data on the input data port is valid

For more details, see Sample Control Bus.

Data Types: `bus`

### Output

expand all

Decoded message data, returned as a scalar. This output data width is the same as the input data width.

Data Types: `double` | `single` | `uint8` | `uint16` | `fixed point`

Control signals accompanying the sample stream, returned as a `samplecontrol` bus. The bus includes the `start`, `end`, and `valid` control signals, which indicate the boundaries of the frame and the validity of the samples.

• `start` — Indicates the start of the output frame

• `end` — Indicates the end of the output frame

• `valid` — Indicates that the data on the output data port is valid

For more details, see Sample Control Bus.

Data Types: `bus`

Indication of corruption of the received data, returned as a scalar.

When this value is `1` (`true`), the output contains errors. When this value is `0` (`false`), the output contains zero errors.

If the number of errors in the input codeword is greater than (Codeword length (N)Message length (K))/2, the block outputs data without correcting the errors and sets the err port to `1` (`true`) to indicate that errors that cannot be corrected exist in the input codeword.

Data Types: ` Boolean`

Block ready indicator, returned as a scalar.

The block sets this signal to `1` (`true`) when the block is ready to accept the start of the next frame. If the block receives an input ctrl.start signal while nextFrame is `0` (`false`), the block discards the frame in progress and begins processing the new data.

Data Types: `Boolean`

Number of corrected errors, returned as a nonnegative scalar.

The maximum number of errors an RS code can correct is equal to (Codeword length (N)Message length (K))/2. If the number of errors in the input codeword is greater than (Codeword length (N)Message length (K))/2, the block outputs data without correcting the errors and sets the numErrors port to `0` to indicate that none of those errors can be corrected.

#### Dependencies

To enable this port, select the Output number of corrected symbol errors parameter.

Data Types: `uint8`

## Parameters

expand all

Specify the codeword length.

The codeword length `N` must be an integer equal to 2M – 1, where M is an integer in the range from 3 to 16. For more information on representing data for RS codes, see Integer Format (Reed-Solomon Only).

Specify the message length.

For more information on representing data for RS codes, see Integer Format (Reed-Solomon Only).

Specify the source of the primitive polynomial.

• Select `Auto` to specify the primitive polynomial based on the Codeword length (N) parameter value. The degree of the primitive polynomial is calculated as M = `ceil`(log2(Codeword length (N))).

• Select `Property` to specify the primitive polynomial using the Primitive polynomial parameter.

Specify a binary row vector representing the primitive polynomial in descending order of powers.

For more information on how to specify a primitive polynomial, see Primitive Polynomials and Element Representations.

#### Dependencies

To enable this parameter, set the Source of primitive polynomial parameter to `Property`.

Specify the source of the starting power for roots of the primitive polynomial.

• Select `Auto`, to use the default B value parameter value, `1`.

• Select `Property` to enable the B value parameter.

Specify the starting power for roots of the primitive polynomial.

#### Dependencies

To enable this parameter, set the Source of B, the starting power for roots of the primitive polynomial parameter to `Property`.

Select this parameter to enable the numErrors output port. This port outputs the number of corrected errors.

## Algorithms

expand all

This figure shows the different stages of operations performed by the RS Decoder block. The block calculates syndrome values, determines the error location polynomial using Berlekamp-Massey algorithm, finds error locations and magnitudes using Chien search [5] and Forney [6] algorithms, respectively, and corrects the errors. For information about Berlekamp-Massey algorithm, see Algorithms for BCH and RS Errors-only Decoding.

## References

[1] Wicker, Stephen B. Error Control Systems for Digital Communication and Storage. Englewood Cliffs, NJ: Prentice Hall, 1995.

[2] Berlekamp, Elwyn R. Algebraic Coding Theory. Revised edition. McGraw-Hill Series in Systems Science. New Jersey: World Scientific, 2015.

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

[4] Moon, Todd K. Chapter 6, Error Correction Coding: Mathematical Methods and Algorithms. Hoboken, N.J: Wiley-Interscience, 2005.

[5] Chien, R. “Cyclic Decoding Procedures for Bose- Chaudhuri-Hocquenghem Codes.” IEEE Transactions on Information Theory 10, no. 4 (October 1964): 357–63. https://doi.org/10.1109/TIT.1964.1053699.

[6] Forney, G. “On Decoding BCH Codes.” IEEE Transactions on Information Theory 11, no. 4 (October 1965): 549–57. https://doi.org/10.1109/TIT.1965.1053825.

## Version History

Introduced in R2020a