Communications Toolbox    

Creating and Decoding Convolutional Codes

The functions for encoding and decoding convolutional codes are convenc and vitdec. This section discusses using these functions to create and decode convolutional codes.

Encoding

A simple way to use convenc to create a convolutional code is shown in the commands below.

The first command converts a polynomial description of a feedforward convolutional encoder to the corresponding trellis description. The second command encodes 100 bits, or 50 two-bit symbols. Because the code rate in this example is 2/3, the output vector code contains 150 bits (that is, 100 input bits times 3/2).

Hard-Decision Decoding

To decode using hard decisions, use the vitdec function with the flag 'hard' and with binary input data. Because the output of convenc is binary, hard-decision decoding can use the output of convenc directly, without additional processing. This example extends the previous example and implements hard decision decoding.

Soft-Decision Decoding

To decode using soft decisions, use the vitdec function with the flag 'soft'. You must also specify the number, nsdec, of soft-decision bits and use input data consisting of integers between 0 and 2^nsdec-1.

An input of 0 represents the most confident 0, while an input of 2^nsdec-1 represents the most confident 1. Other values represent less confident decisions. For example, the table below lists interpretations of values for 3-bit soft decisions.

Input Values for 3-bit Soft Decisions
Input Value
Interpretation
0
Most confident 0
1
Second most confident 0
2
Third most confident 0
3
Least confident 0
4
Least confident 1
5
Third most confident 1
6
Second most confident 1
7
Most confident 1

Example: Soft-Decision Decoding.   The script below illustrates decoding with 3-bit soft decisions. First it creates a convolutional code with convenc and adds white Gaussian noise to the code with awgn. Then, to prepare for soft-decision decoding, the example uses quantiz to map the noisy data values to appropriate decision-value integers between 0 and 7. The second argument in quantiz is a partition vector that determines which data values map to 0, 1, 2, etc. The partition is chosen so that values near 0 map to 0, and values near 1 map to 7. (You can refine the partition to obtain better decoding performance if your application requires it.) Finally, the example decodes the code and computes the bit error rate. Notice that when comparing the decoded data with the original message, the example must take the decoding delay into account. The continuous operation mode of vitdec causes a delay equal to the traceback length, so msg(1) corresponds to decoded(tblen+1) rather than to decoded(1).

The output is below.


  Trellis Description of a Convolutional Encoder Examples of Convolutional Coding