# Viterbi Decoder

Decode convolutionally encoded data using Viterbi algorithm

• Library:
• Communications Toolbox / Error Detection and Correction / Convolutional

Communications Toolbox HDL Support / Error Detection and Correction / Convolutional

## Description

The Viterbi Decoder block decodes convolutionally encoded input symbols to produce binary output symbols by using the Viterbi algorithm. A trellis structure specifies the convolutional encoding scheme. For more information, see Trellis Description of a Convolutional Code.

This block can process several symbols at a time for faster performance and can accept inputs that vary in length during simulation. For more information about variable-size signals, see Variable-Size Signal Basics (Simulink).

This icon shows all the optional block ports enabled.

## Ports

### Input

expand all

Convolutionally encoded codeword, specified as a column vector. If the decoder takes N input bit streams (that is, it can receive 2N possible input symbols), the block input vector length is L×N for some positive integer L. For more information, see Input and Output Sizes, Input Values and Decision Types, and the `Operation mode` parameter.

This port is unnamed until a second input port is enabled.

Data Types: `double` | `single` | `Boolean` | `int8` | `int16` | `int32` | `uint8` | `uint16` | `uint32` | `ufixn`

Erasure bits in the codeword, specified as a binary-valued vector. Values of `1` in the vector correspond to erased bits, and values of `0` correspond to nonerased bits.

For these erasures in the incoming data stream, the decoder does not update the branch metric. The widths and the sample times of the erasure and the input data ports must be the same.

#### Dependencies

To enable this port, select Enable erasures input port.

Data Types: `double` | `Boolean`

Option to reset the state of decoder registers, specified as scalar value. When this port receives a nonzero input value, the block sets its internal memory to the initial state before processing the input data. Resetting the decoder registers to the initial state sets:

• The all-zeros state metric to zero

• All other state metrics to the maximum value

• The traceback memory to zero

Using the reset port on this block is analogous to setting Operation mode for the Convolutional Encoder block to `Reset on nonzero input via port`.

#### Dependencies

To enable this port, set the Operation mode parameter to `Continuous` and select Enable reset input port.

Data Types: `double` | `Boolean`

### Output

expand all

Output message, returned as a binary column vector. If the decoder produces K output bit streams (that is, it can produce 2K possible output symbols), the block output vector length is L×K for some positive integer L. For more information, see Input and Output Sizes.

This port is unnamed on the block icon.

Data Types: `double` | `single` | `Boolean` | `int8` | `int16` | `int32` | `uint8` | `uint16` | `uint32` | `ufix1`

## Parameters

expand all

Main

Trellis description of the convolutional code, specified as a structure that contains the trellis description for a rate KN code. K is the number of input bit streams, and N is the number of output bit streams.

You can either use the `poly2trellis` function to create the trellis structure or create it manually. For more about this structure, see Trellis Description of a Convolutional Code and the `istrellis` function.

The trellis structure contains these fields.

Number of symbols input to the encoder, specified as an integer equal to 2K, where K is the number of input bit streams.

Data Types: `double`

Number of symbols output from the encoder, specified as an integer equal to 2N, where N is the number of output bit streams.

Data Types: `double`

Number of states in the encoder, specified as a power of 2.

Data Types: `double`

Next states for all combinations of current states and current inputs, specified as a matrix of integers. The matrix size must be `numStates` by 2K.

Data Types: `double`

Outputs for all combinations of current states and current inputs, specified as a matrix of octal numbers. The matrix size must be `numStates` by 2K.

Data Types: `double`

Select this parameter to view and enable the Puncture vector parameter.

Puncture pattern vector to puncture the decoded data, specified as a column vector. The vector must contain `1`s and `0`s, where `0` indicates the position of the punctured bits. This puncture pattern must match the puncture pattern used by the convolutional encoder.

For some commonly used puncture patterns for specific rates and polynomials, see the Yasuda [4], Haccoun [5], and Begin [6] references.

#### Dependencies

This parameter appears only when you select the Punctured code parameter.

Select this parameter to add the `Era` input port to the block.

Decoder decision type, specified as `Unquantized`, ```Hard decision```, or `Soft Decision`.

• `Unquantized` — The decoder uses the Euclidean distance to calculate the branch metrics. The input data must be a real-valued vector of double- or single-precision soft values that are unquantized. The object maps positive values to logical `1`s and negative values to logical `0`s

• `Hard decision` — The decoder uses Hamming distance to calculate the branch metrics. The input must be a vector of hard decision values, which are `0`s or `1`s. The data type of the inputs must be double precision, single precision, logical, or numeric.

• `Soft Decision` — The decoder uses Hamming distance to calculate the branch metrics. The input requires a vector of quantized soft values that are represented as integers between 0 and 2SoftInputWordLength – 1. The data type of the inputs must be double precision, single precision, logical, or numeric. Alternatively, you can specify the data type as an unsigned and unscaled fixed-point object using the `fi` (Fixed-Point Designer) object with a word length (SoftInputWordLength) equal to the word length that you specify for the Number of soft decision bits parameter. `0` is considered as most confident `0` and 2SoftInputWordLength – 1 as the most confident `1`.

Soft input word length that represents the number of bits for each quantized soft input value, specified as an integer.

#### Dependencies

This parameter appears only when you set the Decision type parameter to ```Soft decision```.

Select this parameter to error if the quantized input values are out of range. If you do not select this parameter, out of range input values are ignored.

#### Dependencies

This parameter appears only when you set the Decision type parameter to ```Hard decision``` or ```Soft decision```.

Traceback depth, specified as an integer that indicates the number of trellis branches used to construct each traceback path.

The traceback depth influences the decoding delay. The decoding delay is the number of zero symbols that precede the first decoded symbol in the output.

• For the continuous operating mode, the decoding delay is equal to the number of traceback depth symbols.

• For the truncated or terminated operating mode, the decoding delay is zero. In this case, the traceback depth must be less than or equal to the number of symbols in each input.

As a general estimate, a typical traceback depth value is approximately two to three times (ConstraintLength – 1) / (1 – coderate). The constraint length of the code, ConstraintLength, is equal to (log2(`trellis`.`numStates`) + 1). The coderate is equal to (K / N) × (length(PuncturePattern) / sum(PuncturePattern).

K is the number of input symbols, N is the number of output symbols, and PuncturePattern is the puncture pattern vector.

For example, applying this general estimate, results in these approximate traceback depths.

• A rate 1/2 code has a traceback depth of 5(ConstraintLength – 1).

• A rate 2/3 code has a traceback depth of 7.5(ConstraintLength – 1).

• A rate 3/4 code has a traceback depth of 10(ConstraintLength – 1).

• A rate 5/6 code has a traceback depth of 15(ConstraintLength – 1).

Method for transitioning between successive input frames, specified as one of these mode values.

• `Continuous` — The block saves its internal state metric at the end of each input, for use with the next frame. Each traceback path is treated independently. This mode results in a decoding delay of Traceback depth×K zero bits for a rate K/N convolutional code. K is the number of message symbols, and N is the number of coded symbols. If the Enable reset input port is selected, the decoder states are reset if the `Rst` port receives a nonzero value.

• `Truncated` — The block treats each input independently. The traceback path starts at the state with the best metric and always ends in all-zeros state. This mode is appropriate when the corresponding Convolutional Encoder block has its Operation mode set to `Truncated (reset every frame)`. There is no output delay for this mode.

• `Terminated` — The block treats each input independently, and the traceback path always starts and ends in all-zeros state. This mode is appropriate when the uncoded message signal (that is, the input to the corresponding Convolutional Encoder block) has enough zeros at the end of each input to fill all memory registers of the feed-forward encoder. Specifically, there are at least `k*max(constr-1)` zeros at the end of the input, for an encoder that has `k` input streams and constraint length vector `constr` (using the polynomial description). For feedback encoders, this mode is appropriate if the corresponding Convolutional Encoder block has Operation mode set to ```Terminate trellis by appending bits```.

Note

The decoder states reset at every input time step when the block outputs sequences that vary in length during simulation and you set the Operation mode to `Truncated` or `Terminated`.

When the input signal contains only one symbol, use the `Continuous` operation mode .

Select this parameter to add the `Rst` input port.

#### Dependencies

This parameter appears only when you set the Operation mode parameter to `Continuous`.

Select this parameter to delay reset of the decoder until after computing the encoded data received in the current time step. You must enable this option for HDL support. Generating HDL code requires HDL Coder™ software.

#### Dependencies

This parameter appears only when you set the Operation mode parameter to `Continuous` and select Enable reset input port.

Data Types

State metric word length, specified as a positive integer.

Output data type, specified as `double`, `single`, `boolean`, `int8`, `uint8`, `int16`, `uint16`, `int32`, or `uint32`, or set to ```'Inherit via internal rule'``` or ```'Smallest unsigned integer'```.

• When set to `'Smallest unsigned integer'`, the output data type is selected based on the settings used in the Hardware Implementation pane of the Configuration Parameters dialog box of the model. If `ASIC/FPGA` is selected in the Hardware Implementation pane, the output data type is `ufix(1)`. For all other selections, it is an unsigned integer with the smallest specified word length corresponding to the char value (for example, `uint8`).

• When set to `'Inherit via internal rule'`, the block:

• Outputs data type double for double inputs

• Outputs data type single for single inputs

• Behaves similar to the ```'Smallest unsigned integer'``` option for all other data type inputs

## Block Characteristics

 Data Types `Boolean` | `double` | `fixed pointa` | `integer` | `single` Multidimensional Signals `no` Variable-Size Signals `yes` a Input can be ufix(1) for hard decision, and ufix(N) for soft decision; output can be ufix(1) only.

expand all

## References

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

[2] Gitlin, Richard D., Jeremiah F. Hayes, and Stephen B. Weinstein. Data Communications Principles. Applications of Communications Theory. New York: Plenum Press, 1992.

[3] Heller, J., and I. Jacobs. “Viterbi Decoding for Satellite and Space Communication.” IEEE Transactions on Communication Technology 19, no. 5 (October 1971): 835–48. https://doi.org/10.1109/TCOM.1971.1090711.

[4] Yasuda, Y., K. Kashiki, and Y. Hirata. “High-Rate Punctured Convolutional Codes for Soft Decision Viterbi Decoding.” IEEE Transactions on Communications 32, no. 3 (March 1984): 315–19. https://doi.org/10.1109/TCOM.1984.1096047.

[5] Haccoun, D., and G. Begin. “High-Rate Punctured Convolutional Codes for Viterbi and Sequential Decoding.” IEEE Transactions on Communications 37, no. 11 (November 1989): 1113–25. https://doi.org/10.1109/26.46505.

[6] Begin, G., D. Haccoun, and C. Paquin. “Further Results on High-Rate Punctured Convolutional Codes for Viterbi and Sequential Decoding.” IEEE Transactions on Communications 38, no. 11 (November 1990): 1922–28. https://doi.org/10.1109/26.61470.

[7] Moision, B. "A Truncation Depth Rule of Thumb for Convolutional Codes." In Information Theory and Applications Workshop (January 27 2008-February 1 2008, San Diego, California), 555-557. New York: IEEE, 2008.

## Version History

Introduced before R2006a

expand all