Hello everyone,
I am trying to reproduce the performance of 5G NR Polar code on AWGN channel which can be found at https://fr.mathworks.com/help/5g/examples/3GPP-5GNR-Polar-Coding.html
To be specific, I am trying to reproduce the DL, CRC-24, L=8 Block Error Rate curve for K/E=54/124 (the black square curve).
![](https://fr.mathworks.com/help/examples/5g/win64/xxnr5gPolarL8DL.png)
My code is here, which is just a copy-paste of the example found in the same link and I have changed the desired EbNo to -1.8dB (thus SNR=-2.4 dB) and have increased the numFrames simulated.
According to the figure, I expect the Block Error Rate at about 4e-2 and 6e-2. But, suprisingly, the performance is much much worse …
Block Error Rate: 0.868, Bit Error Rate: 0.34563, at SNR = -2.4 dB
Did I miss something? Is this simply the bug of 5G Toolbox?
Thanks.
s = rng(611); % Seed the RNG for repeatability
% Code parameters
K = 54; % Message length in bits, including CRC, K > 30
E = 124; % Rate matched output length, E <= 8192
% EbNo = 0.8; % EbNo in dB
EbNo = -1.8; % EbNo in dB
L = 8; % List length, a power of two, [1 2 4 8]
numFrames = 1000; % Number of frames to simulate
linkDir = 'DL'; % Link direction: downlink ('DL') OR uplink ('UL')
if strcmp(linkDir,'DL') % Downlink scenario (K >= 36, including CRC bits)
crcLen = 24; % Number of CRC bits for DL, Section 5.1, [6]
poly = '24C'; % CRC polynomial
nPC = 0; % Number of parity check bits, Section 5.3.1.2, [6]
nMax = 9; % Maximum value of n, for 2^n, Section 7.3.3, [6]
iIL = true; % Interleave input, Section 5.3.1.1, [6]
iBIL = false; % Interleave coded bits, Section 5.4.1.3, [6]
else % Uplink scenario (K > 30, including CRC bits)
crcLen = 11; poly = '11'; nPC = 0; nMax = 10; iIL = false; iBIL = true;endR = K/E; % Effective code rate
bps = 2; % bits per symbol, 1 for BPSK, 2 for QPSK
EsNo = EbNo + 10*log10(bps);snrdB = EsNo + 10*log10(R); % in dB
noiseVar = 1./(10.^(snrdB/10));% Modulator, Channel, Demodulator
qpskMod = comm.QPSKModulator('BitInput',true);chan = comm.AWGNChannel('NoiseMethod','Variance','Variance',noiseVar);qpskDemod = comm.QPSKDemodulator('BitOutput',true,'DecisionMethod', ... 'Approximate log-likelihood ratio','Variance',noiseVar);% Error meter
ber = comm.ErrorRate;numferr = 0;for i = 1:numFrames % Generate a random message
msg = randi([0 1],K-crcLen,1); % Attach CRC
msgcrc = nrCRCEncode(msg,poly); % Polar encode
encOut = nrPolarEncode(msgcrc,E,nMax,iIL); N = length(encOut); % Rate match
modIn = nrRateMatchPolar(encOut,K,E,iBIL); % Modulate
modOut = qpskMod(modIn); % Add White Gaussian noise
rSig = chan(modOut); % Soft demodulate
rxLLR = qpskDemod(rSig); % Rate recover
decIn = nrRateRecoverPolar(rxLLR,K,N,iBIL); % Polar decode
decBits = nrPolarDecode(decIn,K,E,L,nMax,iIL,crcLen); % Compare msg and decoded bits
errStats = ber(double(decBits(1:K-crcLen)), msg); numferr = numferr + any(decBits(1:K-crcLen)~=msg);enddisp(['Block Error Rate: ' num2str(numferr/numFrames) ... ', Bit Error Rate: ' num2str(errStats(1)) ... ', at SNR = ' num2str(snrdB) ' dB'])rng(s); % Restore RNG
Best Answer