Main Content

LTE Symbol Demodulation of Complex Data Symbols

This example shows how to use the LTE Symbol Demodulator block to demodulate complex LTE data symbols to data bits or LLR values. You can generate HDL code from this block.

Set Input Data Parameters

Map the modulation types to values. Set the LTE Symbol Demodulator block with numerical values and configure the lteSymbolDemodulate (LTE Toolbox) function with strings.

rng(0);
framesize = 10;

% 0 - BPSK
% 1 - QPSK
% 2 - 16-QAM
% 3 - 64-QAM
% 4 - 256-QAM
% others - QPSK
modSelVal = [0;1;2;3;4];
modSelStr = {'BPSK','QPSK','16QAM','64QAM','256QAM'};

decType = 'Soft';

numframes = length(modSelVal);
dataSymbols  = cell(1,numframes);
modSelTmp = cell(1,numframes);
lteFcnOutput = cell(1,numframes);

Generate Input Data

Generate frames of random input samples. Convert the framed input data to a stream of samples and input the stream to the LTE Symbol Demodulator Simulink block.

for ii = 1:numframes
    dataSymbols{ii} = complex(randn(framesize,1),randn(framesize,1));
    modSelTmp{ii} = fi(modSelVal(ii)*ones(framesize,1),0,3,0);
end

idlecyclesbetweensamples = 0;
idlecyclesbetweenframes  = 0;
[sampleIn, ctrl] = whdlFramesToSamples(dataSymbols,idlecyclesbetweensamples,...
    idlecyclesbetweenframes);
[modSel, ~] = whdlFramesToSamples(modSelTmp,idlecyclesbetweensamples,...
    idlecyclesbetweenframes);
validIn = logical(ctrl(:,3)');

sampletime = 1;
samplesizeIn = 1;
simTime = size(ctrl,1)*8;

Run Model

Running the Simulink model exports the stream of demodulated samples from Simulink® to the MATLAB® workspace.

modelname = 'ltehdlSymbolDemodulatorModel';
open_system(modelname);
set_param([modelname '/Demod/LTE Symbol Demodulator'],'DecisionType',decType)
sim(modelname);

lteHDLOutput = sampleOut(validOut).';

Generate Reference Data

Demodulate data symbols with the lteSymbolDemodulate function and use its output as a reference data.

for ii = 1:numframes
 lteFcnOutput{ii} = lteSymbolDemodulate(dataSymbols{ii},modSelStr{ii},decType).';
end

Compare Model Output with Function Output

Compare the output of the Simulink model with the output of the lteSymbolDemodulate function.

lteFcnOutput = double(cell2mat(lteFcnOutput));

figure(1)
stem(lteHDLOutput,'b')
hold on
stem(lteFcnOutput,'--r')
grid on
legend('Reference','Simulink')
xlabel('Sample Index')
ylabel('Magnitude')
title('Comparison of Simulink Block and MATLAB Function')

See Also

Blocks