This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

LLR vs. Hard Decision Demodulation

This example shows the BER performance improvement for QPSK modulation when using log-likelihood ratio (LLR) instead of hard-decision demodulation in a convolutionally coded communication link. With LLR demodulation, one can use the Viterbi decoder either in the unquantized decoding mode or the soft-decision decoding mode. Unquantized decoding, where the decoder inputs are real values, though better in terms of BER, is not practically viable. In the more practical soft-decision decoding, the demodulator output is quantized before being fed to the decoder. It is generally observed that this does not incur a significant cost in BER while significantly reducing the decoder complexity. We validate this experimentally through this example.


Set these parameters to run the simulation.

  • M : Modulation order

  • k : Bits per symbol

  • bitsPerIter : Number of bits to simulate

  • EbNo : Information bit Eb/No in dB

  • codeRate : Code rate of convolutional encoder

  • constLen : Constraint length of encoder

  • codeGenPoly : Code generator polynomial of encoder

  • tblen : Traceback depth of Viterbi decoder

Simulation parameters

M = 4;
k = log2(M);
bitsPerIter = 1.2e4;
EbNo = 3;

Code properties

codeRate = 1/2;
constLen = 7;
codeGenPoly = [171 133];
tblen = 32;
trellis = poly2trellis(constLen,codeGenPoly);

Create a rate 1/2, constraint length 7 ConvolutionalEncoder System object™.

enc = comm.ConvolutionalEncoder(trellis);

Modulator and Channel

Create a QPSKModulator object and two QPSKDemodulator objects. Configure the first demodulator to output hard-decision bits. Configure the second to output LLR values.

qpskMod = comm.QPSKModulator('BitInput',true);
demodHard = comm.QPSKDemodulator('BitOutput',true,...
    'DecisionMethod','Hard decision');
demodLLR = comm.QPSKDemodulator('BitOutput',true,...
    'DecisionMethod','Log-likelihood ratio');

Create an AWGNChannel object. The signal going into the AWGN channel is the modulated encoded signal. To achieve the required noise level, adjust the Eb/No for coded bits and multi-bit symbols. Set this as the EbNo of the channel object.

chan = comm.AWGNChannel('NoiseMethod','Signal to noise ratio (Eb/No)', ...
EbNoCoded = EbNo + 10*log10(codeRate);
chan.EbNo = EbNoCoded;

Viterbi Decoding

Create ViterbiDecoder objects to act as the hard-decision, unquantized, and soft-decision decoders. For all three decoders, set the traceback depth to tblen.

decHard = comm.ViterbiDecoder(trellis, 'InputFormat', 'Hard',...

decUnquant = comm.ViterbiDecoder(trellis,'InputFormat','Unquantized', ...

decSoft = comm.ViterbiDecoder(trellis,'InputFormat','Soft', ...

Quantization for soft-decoding

Before using a comm.ViterbiDecoder object in the soft-decision mode, the output of the demodulator needs to be quantized. This example uses a comm.ViterbiDecoder object with a SoftInputWordLength of 3. This value is a good compromise between short word lengths and a small BER penalty. Create a ScalarQuantizerEncoder object with 3-bit quantization.

scalQuant = dsp.ScalarQuantizerEncoder('Partitioning','Unbounded');
snrdB = EbNo + 10*log10(k);
NoiseVariance = 10.^(-snrdB/10);
scalQuant.BoundaryPoints = (-1.5:0.5:1.5)/NoiseVariance;

Calculating the Error Rate

Create ErrorRate objects to compare the decoded bits to the original transmitted bits. The Viterbi decoder creates a delay in the decoded bit stream output equal to the traceback length. To account for this delay, set the ReceiveDelay property of the comm.ErrorRate objects to tblen.

errHard = comm.ErrorRate('ReceiveDelay',tblen);
errUnquant = comm.ErrorRate('ReceiveDelay',tblen);
errSoft = comm.ErrorRate('ReceiveDelay',tblen);

System Simulation

Generate bitsPerIter message bits.

txData = randi([0 1],bitsPerIter,1);

Convolutionally encode the data.

encData = enc(txData);

Modulate the encoded data.

modData = qpskMod(encData);

Pass the modulated signal through an AWGN channel.

rxSig = chan(modData);

Demodulate the received signal and output hard-decision bits.

hardData = demodHard(rxSig);

Demodulate the received signal and output LLR values.

LLRData = demodLLR(rxSig);

Hard-decision decoding

Pass the demodulated data through the Viterbi decoder. Compute the error statistics.

rxDataHard = decHard(hardData);
berHard = errHard(txData,rxDataHard);

Unquantized decoding

Pass the demodulated data through the Viterbi decoder. Compute the error statistics.

rxDataUnquant = decUnquant(LLRData);
berUnquant = errUnquant(txData,rxDataUnquant);

Soft-decision decoding

Pass the demodulated data to the quantizer. This data must be multiplied by -1 before being passed to the quantizer, because, in soft-decision mode, the Viterbi decoder assumes that positive numbers correspond to 1s and negative numbers to 0s. Pass the quantizer output to the Viterbi decoder. Compute the error statistics.

quantizedValue = scalQuant(-LLRData);
rxDataSoft = decSoft(double(quantizedValue));
berSoft = errSoft(txData,rxDataSoft);

Running Simulation Example

Simulate the previously described communications system over a range of Eb/No values by executing the simulation file simLLRvsHD. It plots BER results as they are generated. BER results for hard-decision demodulation and LLR demodulation with unquantized and soft-decision decoding are plotted in red, blue, and black, respectively. A comparison of simulation results with theoretical results is also shown. Observe that the BER is only slightly degraded by using soft-decision decoding instead of unquantized decoding. The gap between the BER curves for soft-decision decoding and the theoretical bound can be narrowed by increasing the number of quantizer levels.

This example may take some time to compute BER results, so we have configured it to run in parallel if you have the Parallel Computing Toolbox™ (PCT) installed. In this case, the file LLRvsHDwithPCT is run.

To obtain results over a larger range of Eb/No values, modify the appropriate supporting files. Note that you can obtain more statistically reliable results by collecting more errors.

[licensePCT,~] = license('checkout','Distrib_Computing_Toolbox');
if licensePCT && ~isempty(ver('distcomp'))
Starting parallel pool (parpool) using the 'local' profile ... connected to 12 workers.


The following functions are used in this example:

Was this topic helpful?