Decode convolutional code by using APP method
APPDecoder system object performs a posteriori
probability (APP) decoding of a convolutional code.
To decode convolutional code by using APP method:
comm.APPDecoder object and set its properties.
Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?.
appDec = comm.APPDecoder creates an APP decoder System object™,
appDec, that decodes a convolutional code using the
appDec = comm.APPDecoder(
sets properties using one or more name-value pairs. For example,
comm.APPDecoder('Algorithm','True APP') configures the System object,
appDec, to implement true a posteriori probability
decoding. Enclose each property name in quotes.
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.
TrellisStructure— Trellis description of constituent convolutional code
poly2trellis(7,[171 133],171)(default) | structure
Trellis description, specified as a MATLAB® structure that contains the trellis description for a rate K/N code. K represents the number of input bit streams, and N represents 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
The trellis structure contains these fields.
numInputSymbols— Number of symbols input to encoder
Number of symbols input to the encoder, specified as an integer equal to 2K, where K is the number of input bit streams.
numOutputSymbols— Number of symbols output from encoder
Number of symbols output from the encoder, specified as an integer equal to 2N, where N is the number of output bit streams.
numStates— Number of states in encoder
Number of states in the encoder, specified as a power of 2.
nextStates— Next states
Next states for all combinations of current states and current inputs, specified
as a matrix of integers. The matrix size must be
Outputs for all combinations of current states and current inputs, specified as a matrix of
octal numbers. The matrix size must be
TerminationMethod— Termination method of encoded frame
Termination method of encoded frame, specified as
'Terminated'. When you set this property to
'Truncated', this System object assumes that the encoder stops after encoding the last symbol in the input
frame. When you set this property to
'Terminated', this System object assumes that the encoder forces the trellis to end each frame in the
all-zeros state by encoding additional symbols. If you use the
System object to generate the encoded frame, this property value must match the property
value of the convolutional encoder and this System object.
Algorithm— Decoding algorithm
Decoding algorithm, specified as
'Max'. When you set this property to
'True APP', this System object implements true APP decoding. When you set this property to any other
value, this System object uses approximations to increase the speed of the computations.
For more information, see Algorithms.
NumScalingBits— Number of scaling bits
3(default) | integer in the range [0, 8]
Number of scaling bits, specified as an integer in the range [0, 8]. This property specifies the number of bits the decoder uses to scale the input data to avoid losing precision during the computations.
To enable this property, set the
Algorithm property to
CodedBitLLROutputPort— Option to enable coded-bit log-likelihood ratio output
true or 1(default) |
false or 0
Option to enable coded-bit log-likelihood ratio (LLR) output, specified as a numeric
false). To disable the second output when you call this System
object, set this property to
performs APP decoding on the sequence of LLRs of encoder input bits,
LCD] = appDec(
LU, and the sequence of LLRs of encoded bits,
LC. The System object returns
LCD. These output
values are the updated versions of
respectively, and are obtained based on the encoder information.
LU— Sequence of LLRs of encoder input data
Sequence of LLRs of encoder input data, specified as a real-valued column vector.
A positive soft input is interpreted as a logical
1, and a negative
soft input is interpreted as a logical
LC— Sequence of LLRs of encoded data
Sequence of LLRs of encoded data, specified as a real-valued column vector of. A
positive soft input is interpreted as a logical
1, and a negative
soft input is interpreted as a logical
LUD— Updated value of LU
Updated value of LU, returned as a real-valued column vector.
LCD— Updated value of LC
Updated value of LC, returned as a real-valued column vector.
If the convolutional code uses an alphabet of
2n possible symbols, where
n is the number of bits per input symbol, then the
LCD vector lengths are
L × n for some positive integer
L. Similarly, if the decoded data uses an alphabet of
2k output symbols, where
k is the number of bits per output symbol, then the
LUD vector lengths are
L × k .
This System object accepts a column vector input signal with any positive integer value for L. For variable-sized inputs, L can vary during multiple calls.
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
Specify noise variance and the frame length in bits. Create convolutional encoder, PSK modulator, and AWGN channel System objects.
noiseVar = 2e-1; frameLength = 300; convEncoder = comm.ConvolutionalEncoder('TerminationMethod','Truncated'); pskMod = comm.PSKModulator('BitInput',true,'PhaseOffset',0); awgnChan = comm.AWGNChannel('NoiseMethod','Variance', ... 'Variance',noiseVar);
Create convolutional APP decoder, PSK demodulator, and error rate System objects.
appDecoder = comm.APPDecoder(... 'TrellisStructure',poly2trellis(7,[171 133]), ... 'Algorithm','True APP','CodedBitLLROutputPort',false); pskDemod = comm.PSKDemodulator('BitOutput',true,'PhaseOffset',0, ... 'DecisionMethod','Approximate log-likelihood ratio', ... 'Variance',noiseVar); errRate = comm.ErrorRate;
Transmit a convolutionally encoded 8-PSK-modulated bit stream through an AWGN channel. Demodulate the received signal using soft-decision. Decode the demodulated signal using the APP decoder.
for counter = 1:5 data = randi([0 1],frameLength,1); encodedData = convEncoder(data); modSignal = pskMod(encodedData); receivedSignal = awgnChan(modSignal); demodSignal = pskDemod(receivedSignal); % The APP decoder assumes a polarization of the soft inputs that is % inverse to that of the demodulator soft outputs. Change the sign of % demodulated signal. receivedSoftBits = appDecoder(zeros(frameLength,1),-demodSignal); % Convert from soft-decision to hard-decision. receivedBits = double(receivedSoftBits > 0); % Count errors errorStats = errRate(data,receivedBits); end
Display the error rate information.
fprintf('Error rate = %f\nNumber of errors = %d\n', ... errorStats(1), errorStats(2))
Error rate = 0.000000 Number of errors = 0
'True APP' option of the
Algorithm property implements APP decoding as per the equations 20–23 in section V of . To gain speed, the
'Max' values of the
Algorithm property approximate expressions like by other quantities. The
'Max' option uses max(ai) as the approximation. The
'Max*' option uses max(ai) plus a correction term given by the expression .
Algorithm property to
'Max*' enables the
NumScalingBits property of this System object. This property denotes the number of bits by which this System object scales the data it processes internally (multiplies the input by
NumScalingBits and divides the
pre-output by the same factor). Use this property to avoid losing precision during
 Benedetto, S., G. Montorsi, D. Divsalar, and F. Pollara. "A Soft-Input Soft-Output Maximum A Posterior (MAP) Module to Decode Parallel and Serial Concatenated Codes." Jet Propulsion Lab TDA Progress Report, 42–127, (November 1996).
 Viterbi, A.J. “An Intuitive Justification and a Simplified Implementation of the MAP Decoder for Convolutional Codes.” IEEE Journal on Selected Areas in Communications 16, no. 2 (February 1998): 260–64. https://doi.org/10.1109/49.661114.
 Benedetto, S., and G. Montorsi. “Performance of Continuous and Blockwise Decoded Turbo Codes.” IEEE Communications Letters 1, no. 3 (May 1997): 77–79. https://doi.org/10.1109/4234.585802.
Usage notes and limitations:
See System Objects in MATLAB Code Generation (MATLAB Coder).