Reed-Solomon Coding Part I – Erasures

This example shows how to configure the RSEncoder and RSDecoder System objects to perform Reed-Solomon (RS) block coding with erasures when simulating a communications system. RS decoders can correct both errors and erasures. A receiver that identifies the most unreliable symbols in a given codeword can generate erasures. When a receiver erases a symbol, it replaces that symbol with a zero. The receiver then passes a flag to the decoder, indicating that the symbol is an erasure, not a valid code symbol. In addition, an encoder can generate punctures for which specific parity symbols are always removed from its output. The decoder, which knows the puncture pattern, inserts zeros in the puncture positions and treats those symbols as erasures. The decoder treats encoder-generated punctures and receiver-generated erasures the exact same way when it decodes a symbol. Puncturing also has the added 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 energy per bit to noise power spectral density ratio (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. In addition to this example, the examples "Reed-Solomon Coding Part II – Punctures" and "Reed-Solomon Coding Part III – Shortening" show RS block coding with punctures and shortened codes, respectively.

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 includes analysis of RS coding with erasures 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.

RSCodingConfigExample

Configuring the RS Encoder/Decoder

This example shows a (63,53) RS code operating with a 64-QAM modulation scheme. This code can correct (63-53)/2 = 5 errors, or it can alternatively correct (63-53) = 10 erasures. For each codeword at the output of the 64-QAM demodulator, the receiver determines the six least reliable symbols using the RSCodingGetErasuresExampleRSCodingGetErasuresExample function. The indices that point to the location of these unreliable symbols are passed to the RS decoder via an input to the step method. The RS decoder treats these symbols as erasures resulting in an error correction capability of (10-6)/2 = 2 errors per codeword.

Create a (63,53) RSEncoder System object and set the BitInput property to false to specify that the encoder inputs and outputs are integer symbols.

N = 63;  % Codeword length
K = 53;  % Message length
hEnc = comm.RSEncoder(N,K, 'BitInput', false);
numErasures = 6;

Create an RSDecoder System object using the same settings as in the encoder. Request an additional input for specifying erasures via an input to the step method. This is done by setting the ErasuresInputPort property to true.

hDec = comm.RSDecoder(N,K, 'BitInput', false, 'ErasuresInputPort', true);

Set the NumCorrectedErrorsOutputPort property to true so that the step method of the decoder outputs the number of corrected errors. A non negative value in the error output denotes the number of corrected errors in the input codeword. A value of −1 in the error output indicates a decoding error. A decoding error occurs when the input codeword has more errors than the error correction capability of the RS code.

hDec.NumCorrectedErrorsOutputPort = true;

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.

The signal going into the AWGN channel is the encoded signal, so you must convert the uncoded Eb/N0 values so that they correspond to the energy ratio at the encoder output. This ratio is the coded Eb/N0 ratio. If you input K symbols to the encoder and obtain N output symbols, then the energy relation is given by the K/N rate. Set the EbNo property of the AWGN channel object to the computed coded Eb/N0 value.

EbNoCoded = EbNoUncoded + 10*log10(K/N);
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);
correctedErrors = 0;
while (codedErrorStats(2) < targetErrors) && ...
    (codedErrorStats(3) < maxNumTransmissions)

  % Data symbols - transmit 1 message word at a time. Each message word has
  % K symbols in the [0 N] range.
  data = randi([0 N],K,1);

  % Encode the message word. The encoded word encData is N 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);

  % Find the 6 least reliable symbols and generate an erasures vector using
  % the RSCodingGetErasuresExample function. The length of the erasures vector
  % must be equal to the number of symbols in the demodulated codeword. A
  % one in the ith element of the vector erases the ith symbol in the
  % codeword. Zeros in the vector indicate no erasures.
  erasuresVec = RSCodingGetErasuresExample(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 BER measurement updates, 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 =

     0


totalCorrectedErrors =

   882

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. The channel BER is worse than the theoretical 64-QAM BER because Eb/N0 is reduced by the code rate.

Summary

This example utilized several System objects to simulate a rectangular 64-QAM communications system over an AWGN channel with RS block coding. It showed how to configure the RS decoder to decode symbols with erasures. System performance was measured using channel and coded BER curves obtained using error rate measurement System objects.

The examples "Reed-Solomon Coding Part II − Punctures" and "Reed-Solomon Coding Part III − Shortening" show how to perform RS block coding with punctured and shortened codes, respectively.

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?