You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
srsRAN_4G/matlab/tests/turbodecoder_bler.m

50 lines
1.4 KiB
Matlab

clear
blen=1008;
SNR_values_db=linspace(-1,0.5,6);
Nrealizations=10000;
addpath('../../debug/lte/phy/lib/fec/test')
errors1=zeros(1,length(SNR_values_db));
errors2=zeros(1,length(SNR_values_db));
for snr_idx=1:length(SNR_values_db)
SNRdB = SNR_values_db(snr_idx); % Desired SNR in dB
SNR = 10^(SNRdB/20); % Linear SNR
for i=1:Nrealizations
Data = randi(2,blen,1)==1;
codedData = lteTurboEncode(Data);
codedsymbols = 2*double(codedData)-1;
%% Additive Noise
N0 = 1/SNR;
% Create additive white Gaussian noise
noise = N0*randn(size(codedsymbols));
noisysymbols = noise + codedsymbols;
decodedData = lteTurboDecode(noisysymbols);
interleavedSymbols = reshape(reshape(noisysymbols,[],3)',1,[]);
[decodedData2] = liblte_turbodecoder(interleavedSymbols);
errors1(snr_idx) = errors1(snr_idx) + any(decodedData ~= Data);
errors2(snr_idx) = errors2(snr_idx) + any(decodedData2 ~= Data);
end
fprintf('SNR: %.2f\n', SNR_values_db(snr_idx));
end
if (length(SNR_values_db) > 1)
semilogy(SNR_values_db, errors1/Nrealizations, ...
SNR_values_db, errors2/Nrealizations)
grid on
xlabel('SNR (dB)')
ylabel('BLER')
legend('Matlab','libLTE');
else
disp(errors1);
disp(errors2);
end