Main Content

comm.ViterbiDecoder

Decode convolutionally encoded data using Viterbi algorithm

Description

The comm.ViterbiDecoder System object™ uses Viterbi algorithm to decode convolutionally encoded input symbols to produce binary output symbols. A trellis structure specifies a convolutional encoding scheme. For more information, see the Trellis Description of a Convolutional Code topic.

  1. Create the comm.ViterbiDecoder object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

viterbidecoder = comm.ViterbiDecoder creates a Viterbi decoder System object. This object uses the Viterbi algorithm to decode convolutionally encoded input data.

example

viterbidecoder = comm.ViterbiDecoder(trellis) sets the TrellisStructure property set to trellis.

viterbidecoder = comm.ViterbiDecoder(___,Name,Value) sets Properties using one or more name-value arguments in addition to any argument combinations in previous syntaxes. For example, viterbidecoder = comm.ViterbiDecoder('TerminationMethod','Continuous') specifies the termination method as continuous to save the internal state metric at the end of each frame for use with the next frame.

example

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

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.

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

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

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.

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: struct

Input format to the decoder, specified as 'Unquantized', 'Hard', or 'Soft'.

  • 'Unquantized' — 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 1s and negative values to logical 0s

  • 'Hard' — The input must be a vector of hard decision values, which are 0s or 1s. The data type of the inputs must be double precision, single precision, logical, or numeric.

  • 'Soft' — 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)) with a word length equal to the word length that you specify for the SoftInputWordLength property. 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

To enable this property, set the InputFormat property to 'Soft'.

Data Types: double

Option to take action for invalid quantized input (that is, when input values are out of range), specified as 'Ignore' or 'Error'. Set this property to 'Error' so that the object generates an error when the quantized input values are out of range.

Dependencies

To enable this property, set the InputFormat property to 'Soft' or 'Hard'.

Traceback depth, specified as an integer. For more information, see Traceback and Decoding Delay and Traceback Depth Estimates.

Data Types: double

Termination method of the encoded frame, specified as one of these values.

  • 'Continuous' — The System object saves the internal state metric at the end of each frame for use with the next frame. The object treats each traceback path independently. This mode results in an output decoding delay of TracebackDepth×K zero bits for a rate K/N convolutional code. K is the number of input symbols, and N is the number of output symbols.

  • 'Truncated' — The System object treats each frame independently. The traceback path starts at the state with the best metric and ends in the all-zeros state. There is no output delay for this mode.

  • 'Terminated' — The System object treats each frame independently. The traceback path always starts and ends in the all-zeros state. There is no output delay for this mode.

Option to enable the decoder reset input, specified as a logical 1(true) or 0 (false). Set this property to 1 (true) to the object. When this additional reset input is a nonzero value, the internal states of the decoder reset to their initial conditions.

Dependencies

To enable this property, set the TerminationMethod property to 'Continuous'.

Data Types: logical

Option to delay the output reset, specified as one of these logical values.

  • 1 (true) — The reset of the internal states of the decoder occurs after the object computes the decoded data.

  • 0 (false) — The reset of the internal states of the decoder occurs before the object computes the decoded data.

Dependencies

To enable this property, set the ResetInputPort property to true.

Data Types: logical

Source of the puncture pattern, specified as one of these values.

  • 'None' — The object does not apply puncturing.

  • 'Property' — The object decodes the punctured codewords based on a puncture pattern vector that you specify in the PuncturePattern property.

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

Dependencies

To enable this property, set the PuncturePatternSource property to 'Property'.

Data Types: double

Option to enable the specification of erasures in the input symbols, specified as one of these numeric or logical values.

  • 1 (true) — When you call the System object, it specifies a vector of erasures when calling it. This vector indicates which symbols of the input codewords to erase. Values of 1 indicate erased bits. The decoder does not update the branch metric for the erasures in the incoming data stream. The erasures input must be a double precision or logical column vector. The length of the erasure vector must equal the length of the input data.

  • 0 (false) — The System object assumes no erasures.

Data Types: logical

Data type of the output, specified as a "Full precision", "Smallest unsigned integer", "double", "single", "int8", "uint8", "int16", "uint16", "int32", "uint32", "logical".

When the input signal is an integer data type, you must have a Fixed-Point Designer™ user license to use this property in "Smallest unsigned integer" or "Full precision" mode.

Data type of the state metric, specified as 'Full precision' or 'Custom'

When you set this property to 'Full precision', the object sets the state metric fixed-point type to numerictype([],16).

  • When you set the InputFormat property to 'Hard', the input data must be a column vector. This vector comprises unsigned, fixed-point numbers (fi objects) of word length 1 to enable fixed-point Viterbi decoding. Based on this input (either a 0 or 1), the object calculates the internal branch metrics using an unsigned integer of word length L. In this case, L is the number of output bits as specified by the trellis structure.

  • When you set the InputFormat property to 'Soft', the input data must be a column vector. This vector comprises unsigned, fixed point numbers (fi objects) of word length N. In this case, N is the number of soft-decision bits specified by the SoftInputWordLength property.

When you call the System object, the data inputs must be integers in the range from 0 to 2N–1. The object calculates the internal branch metrics using an unsigned integer of word length L = (N + Nout – 1). In this case, Nout is the number of output bits as specified by the trellis structure.

Dependencies

To enable this property, set the InputFormat property to 'Hard' or 'Soft'.

Fixed-point data type of the state metric, specified as an unscaled numerictype (Fixed-Point Designer) object with a signedness of Auto.

Dependencies

To enable this property, set the StateMetricDataType property to 'Custom'.

Data Types: numeric

Usage

Description

decmsg = viterbidecoder(codeword) decodes the convolutionally encoded input data, codeword, by using the Viterbi algorithm. decmsg is the decoded data.

example

decmsg = viterbidecoder(codeword,erasures) specifies symbols of the input codewords for the object to erase. To enable this syntax, set the ErasuresInputPort property to 1 (true).

decmsg = viterbidecoder(codeword,resetstate) specifies the input to reset the internal states of the decoder. To enable this syntax, set the TerminationMethod property to 'Continuous' and the ResetInputPort property to 1 (true).

Input Arguments

expand all

Convolutionally encoded message, specified as a numeric-valued column vector. The data type and element value in codeword depend on how you set the InputFormat property.

When you set the InputFormat property to 'Unquantized', input values outside of the range [–1012, 1012] are clipped to –1012 and 1012, respectively.

If the convolutional code uses an alphabet of 2N possible output symbols, the length of this input vector must be L × N for some positive integer L.

This object accepts variable-size inputs. After the object is locked, you can change the size of each input channel, but you cannot change the number of channels. For more information, see Variable-Size Signal Support with System Objects.

Data Types: double

Erasure symbols in the codeword, specified as a binary-valued vector. The elements in erasures must be of data type double or logical. Values of 1 in the erasures vector correspond to erased symbols, and values of 0 correspond to nonerased symbols. The length of the codeword must equal the length of erasures.

Dependencies

To enable this argument, set the ErasuresInputPort property to 1 (true).

Reset for internal states of the decoder, specified as a numeric or logical 1 (true) or 0 (false).

Dependencies

To enable this argument, set the TerminationMethod property to 'Continuous' and the ResetInputPort property to true.

Data Types: double | logical

Output Arguments

expand all

Decoded message, returned as a binary-valued column vector. This output vector has the same data type as the OutputDataType property.

If the decoded data uses an alphabet of 2K possible output symbols, the length of this output vector is L × K.

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Transmit a convolutionally encoded 8 differential phase shift keying (DPSK) modulated bit stream through an additive white Gaussian noise (AWGN) channel. Then, demodulate and decode the modulated bit stream using a Viterbi decoder.

Create the necessary System objects.

conEnc = comm.ConvolutionalEncoder;
modDPSK = comm.DPSKModulator('BitInput',true);
chan = comm.AWGNChannel('NoiseMethod','Signal to noise ratio (SNR)','SNR',10);
demodDPSK = comm.DPSKDemodulator('BitOutput',true);
vDec = comm.ViterbiDecoder('InputFormat','Hard');
error = comm.ErrorRate('ComputationDelay',3,'ReceiveDelay',34);

Process the data by following these steps.

  1. Generate random bits.

  2. Convolutionally encode the data.

  3. Apply DPSK modulation.

  4. Pass the modulated signal through an AWGN channel.

  5. Demodulate the noisy signal.

  6. Decode the data using a Viterbi algorithm.

  7. Collect error statistics.

for counter = 1:20
    data = randi([0 1],30,1);
    encodedData = conEnc(data);
    modSignal = modDPSK(encodedData);
    receivedSignal = chan(modSignal);
    demodSignal = demodDPSK(receivedSignal);
    receivedBits = vDec(demodSignal);
    errors = error(data,receivedBits);
end

Display the number of errors.

errors(2)
ans = 
3

Encode and decode a sequence of bits using a convolutional encoder and a Viterbi decoder with a defined puncture pattern. Verify that the input and output bits are identical.

Define a puncture pattern matrix, and then reshape it into vector form for use with the encoder and decoder System objects.

pPatternMat = [1 0 1;1 1 0];
pPatternVec = reshape(pPatternMat,6,1);

Create a convolutional encoder and a Viterbi decoder in which the puncture pattern is defined by pPatternVec.

conEnc = comm.ConvolutionalEncoder('PuncturePatternSource','Property','PuncturePattern',pPatternVec);
viDec = comm.ViterbiDecoder('InputFormat','Hard','PuncturePatternSource','Property', ...
        'PuncturePattern',pPatternVec);

Create an error rate counter with the appropriate receive delay.

error = comm.ErrorRate('ReceiveDelay',viDec.TracebackDepth);

Encode a sequence of random bits, and then decode the encoded message.

dataIn = randi([0 1],600,1);
dataEncoded = conEnc(dataIn);
dataOut = viDec(dataEncoded);

Verify that no errors exist in the output data.

errStats = error(dataIn,dataOut);
errStats(2)
ans = 
0

More About

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

[4] 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.

[5] 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.

[6] 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.

Extended Capabilities

Version History

Introduced in R2012a

expand all