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.
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.
The script file RSCodingConfigExample 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.
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
respectively (since ).
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 ).
Set the RS encoder/decoder System objects so that they perform block coding with a (28,18) code shortened from a (63,53) code.
Create a (63,53)
RSEncoder System object,
RSDecoder object with an erasures input port,
and two punctures.
N = 63; % Codeword length K = 53; % Message length S = 18; numErasures = 6; numPuncs = 2; rsEncoder = comm.RSEncoder(N, K, 'BitInput', false); rsDecoder = comm.RSDecoder(N, K, 'BitInput', false, 'ErasuresInputPort', true); rsEncoder.PuncturePatternSource = 'Property'; rsEncoder.PuncturePattern = [ones(N-K-numPuncs,1); zeros(numPuncs,1)]; rsDecoder.PuncturePatternSource = 'Property'; rsDecoder.PuncturePattern = rsEncoder.PuncturePattern; % Set the shortened message length values rsEncoder.ShortMessageLength = S; rsDecoder.ShortMessageLength = S;
Specify the field of GF(26) in
the RS encoder/decoder System objects, by setting the
to 'Property' and the
to a 6th degree primitive polynomial.
rsEncoder.PrimitivePolynomialSource = 'Property'; rsEncoder.PrimitivePolynomial = de2bi(primpoly(6, 'nodisplay'), 'left-msb'); rsDecoder.PrimitivePolynomialSource = 'Property'; rsDecoder.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(S/(N - numPuncs - K + S)); channel.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 % S 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],S,1); % Encode the shortened message word. The encoded word encData is % N-numPuncs-K+S symbols long. encData = rsEncoder(data); % Modulate encoded data. modData = qamModulator(encData); % Add noise. chanOutput = channel(modData); % Demodulate channel output. demodData = qamDemodulator(chanOutput); % Get erasures vector. erasuresVec = RSCodingGetErasuresExample(chanOutput,numErasures); % Decode data. [estData,errs] = rsDecoder(demodData,erasuresVec); % If a decoding error did not occur, accumulate the number of corrected % errors using the cumulative sum object. if errs >= 0 correctedErrors = cumulativeSum(errs); end % Convert integers to bits and compute the channel BER. chanErrorStats(:,1) = ... chanBERCalc(intToBit1(encData),intToBit1(demodData)); % Convert integers to bits and compute the coded BER. codedErrorStats(:,1) = ... codedBERCalc(intToBit2(data),intToBit2(estData)); end
The error rate measurement objects,
output 3-by-1 vectors 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.
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.
This example uses the following script and helper function:
 G. C. Clark, Jr., J. B. Cain, Error-Correction Coding for Digital Communications, Plenum Press, New York, 1981.