Main Content

Decode CCSDS Reed-Solomon and Convolutional Concatenated Code

This example shows how to use the CCSDS RS Decoder block with the Viterbi Decoder block to decode a Reed-Solomon (RS) and convolutional concatenated code according to the Consultative Committee for Space Data Systems (CCSDS) standard. The synchronization and channel coding sublayer of the CCSDS TM standard includes concatenated coding scheme with Reed-Solomon code as the outer code and convolutional code as the inner code. The example supports HDL code generation for the HDL CCSDS Concatenated Decoder subsystem.

Set Up Concatenated Code Parameters

Specify input variables. You can change only k and i variable values in this section based on your requirements.

% Reed-Solomon code parameters
n = 255;  % Codeword length
k = 223;  % Message length
i = 1;    % Interleaving depth

% Convolutional code parameters
convRate = '1/2';     % Convolutional code rate
K = 7;                % Constraint length
codePoly = [171 133]; % Code generator polynomial
trBackDepth = 32;     % Traceback depth

Generate Transmitter Waveform

Generate transmitter waveform using the ccsdsTMWaveformGenerator (Satellite Communications Toolbox) System object™ in Satellite Communications Toolbox. The System object performs RS encoding, convolutional encoding, and QPSK modulation on the input data and generates a transmitter waveform.

% Generate random input data
dataBits = randi([0,1],k*i*8,1);

% Configure |ccsdsTMWaveformGenerator| System object
obj = ccsdsTMWaveformGenerator('WaveformSource','synchronization and channel coding',...
    'ChannelCoding','concatenated',...
    'ConvolutionalCodeRate',convRate,...
    'RSInterleavingDepth',i,...
    'RSMessageLength',223,...
    'HasRandomizer',false,...
    'HasASM',false,...
    'PulseShapingFilter','none',...
    'Modulation','QPSK');

% Call System object to generate RS and convolutional encoded and QPSK
% modulated transmitter waveform
tmWaveform = obj(dataBits);

Add AWGN Channel

Add white Gaussian noise to the transmitter waveform.

snrdB = 5; % SNR of noise in dB
snr = 10^(snrdB/10);
noiseVar = 1/snr;

% Generate noise with unit power
awgnUnitPow = (1/sqrt(2))*(randn(length(tmWaveform),1) ...
              +1i*randn(length(tmWaveform),1));

% Add noise to the transmitter waveform
chOut = tmWaveform + sqrt(noiseVar)*awgnUnitPow;

Demodulate Receiver Waveform

Demodulate the received AWGN channel output waveform using the comm.PSKDemodulator System object and prepare input for the Simulink® model.

% Configure the |comm.PSKDemodulator| System object for QPSK demodulation
qpskDemod = comm.PSKDemodulator('ModulationOrder',4,...
    'PhaseOffset',pi/4,...
    'SymbolMapping','Custom',...
    'CustomSymbolMapping',[0 2 3 1],...  % Mapping as per the CCSDS standard
    'BitOutput',true,...
    'DecisionMethod','Approximate log-likelihood ratio',...
    'Variance',noiseVar);

% Call the System object to demodulate the received waveform and output the
% LLR values
demodOut = qpskDemod(chOut);

% Invert every alternate LLR value (starting from second LLR) to remove
% symbol inversion, according to the CCSDS standard
demodOut(2:2:end) = -demodOut(2:2:end);

% Normalize all LLR values with required soft wordlength
llrWL = 4;
maxDemodOut = max(abs(demodOut));
vitInput = fi(-demodOut*(2^(llrWL-1))/maxDemodOut,1,llrWL,0);

Decode Demodulated Waveform Using Simulink Model

To decode the demodulated waveform, simulate the CCSDSConcatenateDecoder.slx model. The model contains Viterbi Decoder and CCSDS RS Decoder blocks.

% Input signals for the Simulink model
dataIn = vitInput;
startIn = true;
endIn = [false(length(dataIn)/2 -1,1); true];
validIn = true(length(dataIn)/2,1);

% Set mask parameters of CCSDS RS Decoder block
modelName = 'CCSDSConcatenateDecoder';
subsystem = 'HDL CCSDS Concatenated Decoder';
open_system(modelName);
set_param([modelName '/' subsystem '/CCSDS RS Decoder'], ...
        'MessageLength',num2str(k), ...
        'InterleavingDepth',num2str(i));

% Stop time
vitLatency = 148;
upsampleFac = 8;
rsLatency = 3065; % Maximum latency of the CCSDS RS Decoder block
rsOutLen = k*i;
pipelineDelay = 17;
stopTime = vitLatency + (rsLatency+rsOutLen)*upsampleFac + pipelineDelay;

% Simulate the model
sim(modelName);

Compare Simulink Block Output with MATLAB System Object Input

Compare the output of the CCSDS RS Decoder block with the input of the ccsdsTMWaveformGenerator System object.

fprintf('\nHDL CCSDS RS Decoder\n');
fprintf('Number of bits mismatched between decoded block output and System object input: %d',nnz(decodedBits~=dataBits))
HDL CCSDS RS Decoder
Number of bits mismatched between decoded block output and System object input: 0

See Also

Blocks

Functions