Reed-Solomon Coding Part III – Shortening

This example shows how to set up the Reed-Solomon (RS) encoder/decoder to shorten the (63,53) code to a (28,18) code.

In addition to this example, the examples "Reed-Solomon Coding Part I – Erasures" and "Reed-Solomon Coding Part II – Punctures" show a rectangular 64-QAM communications system with a (63,53) RS block code with erasures and punctures respectively. As was mentioned in the two examples, puncturing has the benefit of making the code rate more flexible, at the expense of some error correction capability. Shortened codes achieve the same code rate flexibility without degrading the error correction performance, given the same demodulator input Eb/N0. Note that puncturing is the removal of parity symbols from a codeword, and shortening is the removal of message symbols from a codeword.

Introduction

This example shows the simulation of a communication system consisting of a random source, an RS encoder, a rectangular 64-QAM modulator, an AWGN channel, a rectangular 64-QAM demodulator, and an RS decoder. It analyzes the effects of RS coding with erasures, puncturing, and shortening, by comparing the channel bit error rate (BER) performance versus the coded BER performance. This example obtains Channel BER by comparing inputs for the rectangular QAM modulator to outputs from the rectangular QAM demodulator. This example obtains Coded BER by comparing inputs for the RS encoder to outputs from the RS decoder.

Initialization

The script file RSCodingConfigExampleRSCodingConfigExample configures the rectangular 64-QAM modulator and demodulator, the AWGN channel, and the error rate measurement System objects used to simulate the communications system. The script also sets an uncoded Eb/N0 ratio to EbNoUncoded = 15 dB, and sets the simulation stop criteria by defining the target number of errors and the maximum number of bit transmissions to 500 and 5×106, respectively.

configureRSCodingDemo

Configuring the RS Encoder/Decoder

Consider the same (63,53) RS code operating in concert with a 64-QAM modulation scheme that was used in the examples Reed-Solomon Coding Part I - Erasures and Reed-Solomon Coding Part II - Punctures to showcase how to decode erasures and how to puncture the code. This example shows how to shorten the (63,53) code to a (28,18) code.

Shortening a block code removes symbols from its message portion, while puncturing removes symbols from its parity portion. You can incorporate both techniques with the RS encoder and decoder System objects.

For example, to shorten a (63,53) code to a (53,43) code, you can simply enter 53 and 43 for the CodewordLength and MessageLength properties, respectively (since 2log2(53+1)1=63). However, to shorten it by 35 symbols to a (28,18) code, you must explicitly specify that the symbols belong to the Galois field GF(26). Otherwise, the RS blocks will assume that the code is shortened from a (31,21) code (since 2log2(28+1)1=31).

Set the RS encoder/decoder System objects so that they perform block coding with a (28,18) code shortened from a (63,53) code. This corresponds to a shortening length of 35.

shortenLength = 35;

Create a (63,53) RSEncoder System object, and an RSDecoder object with an erasures input port, and two punctures.

N = 63;  % Codeword length
K = 53;  % Message length
numErasures = 6;
numPuncs = 2;
hEnc = comm.RSEncoder('BitInput', false);
hDec = comm.RSDecoder('BitInput', false, 'ErasuresInputPort', true);
hEnc.PuncturePatternSource = 'Property';
hEnc.PuncturePattern = [ones(N-K-numPuncs,1); zeros(numPuncs,1)];
hDec.PuncturePatternSource = 'Property';
hDec.PuncturePattern = hEnc.PuncturePattern;

% Set the shortened codeword length and message length values
hEnc.CodewordLength = N - shortenLength;
hEnc.MessageLength = K - shortenLength;

hDec.CodewordLength = N - shortenLength;
hDec.MessageLength = K - shortenLength;

Specify the field of GF(26) in the RS encoder/decoder System objects, by setting the PrimitivePolynomialSource property to 'Property' and the PrimitivePolynomial property to a 6th degree primitive polynomial.

hEnc.PrimitivePolynomialSource = 'Property';
hEnc.PrimitivePolynomial = de2bi(primpoly(6, 'nodisplay'), 'left-msb');

hDec.PrimitivePolynomialSource = 'Property';
hDec.PrimitivePolynomial = de2bi(primpoly(6, 'nodisplay'), 'left-msb');

Stream Processing Loop

Simulate the communications system for an uncoded Eb/N0 ratio of 15 dB. The uncoded Eb/N0 is the ratio that would be measured at the input of the channel if there was no coding in the system.

Shortening alters the code rate much like puncturing does. You must adjust the value of the coded Eb/N0 ratio to account for punctures and shortening. In this example, the uncoded Eb/N0 ratio relates to the coded Eb/N0, as shown in the following syntax. Set the property of the AWGN channel object to the computed coded Eb/N0 value.

EbNoCoded = EbNoUncoded + ...
  10*log10((K-shortenLength)/(N-numPuncs-shortenLength));

hChan.EbNo = EbNoCoded;

Loop until the simulation reaches the target number of errors or the maximum number of transmissions.

chanErrorStats = zeros(3,1);
codedErrorStats = zeros(3,1);
while (codedErrorStats(2) < targetErrors) && ...
    (codedErrorStats(3) < maxNumTransmissions)

  % Data symbols - transmit 1 message word at a time, each message word has
  % K-shortenLength symbols in the [0 2^P-1] range. P is the degree of the
  % primitive polynomial specified in the RS encoder/decoder, which in this
  % example equals 6.
  data = randi([0 2^6-1],K-shortenLength,1);

  % Encode the shortened message word. The encoded word encData is
  % N-numPuncs-shortenLength symbols long.
  encData = step(hEnc, data);

  % Modulate encoded data.
  modData = step(hMod, encData);

  % Add noise.
  chanOutput = step(hChan, modData);

  % Demodulate channel output.
  demodData = step(hDemod, chanOutput);

  % Get erasures vector.
  erasuresVec = getErasuresRSCodingDemo(chanOutput,numErasures);

  % Decode data.
  [estData, errs] = step(hDec, demodData, erasuresVec);

  % If a decoding error did not occur, accumulate the number of corrected
  % errors using the cumulative sum object.
  if errs >= 0
    correctedErrors = step(hCumSum, errs);
  end

  % Convert integers to bits and compute the channel BER.
  chanErrorStats(:,1) = ...
    step(hChanBERCalc,step(hIntToBit1,encData),step(hIntToBit1,demodData));

  % Convert integers to bits and compute the coded BER.
  codedErrorStats(:,1) = ...
    step(hCodedBERCalc,step(hIntToBit2,data),step(hIntToBit2,estData));
end

The step method of the error rate measurement objects, hChanBERCalc and hCodedBERCalc, outputs a 3-by-1 vector containing updates of the measured BER value, the number of errors, and the total number of bit transmissions. Display the coded BER and the total number of errors corrected by the RS decoder.

codedBitErrorRate = codedErrorStats(1)
totalCorrectedErrors = correctedErrors
codedBitErrorRate =

   9.6599e-05


totalCorrectedErrors =

        1436

You can add a for loop around the processing loop above to run simulations for a set of Eb/N0 values. Simulations were run offline for uncoded Eb/N0 values in 4:15 dB, target number of errors equal to 5000, and maximum number of transmissions equal to 50×106. The results from the simulation are shown in the following figure. For comparison, the figure also shows the results obtained in the examples "Reed-Solomon Coding Part I – Erasures" and "Reed-Solomon Coding Part II – Punctures". The results of "Reed-Solomon Coding Part I – Erasures" correspond to a system with erasures but no puncturing. The results of "Reed-Solomon Coding Part II – Punctures" correspond to a system with erasures and punctures.

From the curves, observe that the channel BER is worse with shortening because the coded Eb/N0 is worse. This degraded coded Eb/N0 occurs because the code rate of the shortened code is much lower than that of the nonshortened code. As a result, the coded BER is also worse with shortening than without, especially at lower Eb/N0 values.

Summary

This example utilized several System objects to simulate a rectangular 64-QAM communications system over an AWGN channel with a shortened RS block code. It showed how to configure the RS encoder/decoder to shorten a (63,53) code to a (28,18) code. System performance was measured using channel and coded BER curves obtained with the help of error rate measurement System objects.

The examples "Reed-Solomon Coding Part I – Erasures", "Reed-Solomon Coding Part II – Punctures", and "Reed-Solomon Coding Part III – Shortening" show how to configure RS encoders and decoders to perform block coding with erasures, puncturing, and shortening.

Appendix

This example uses the following script and helper function:

Selected Bibliography

[1] G. C. Clark, Jr., J. B. Cain, Error-Correction Coding for Digital Communications, Plenum Press, New York, 1981.

Was this topic helpful?