Polar decoding



decbits = nrPolarDecode(rec,K,E,L) decodes the rate-recovered input rec for an (N,K) polar code, where N is the length of rec and K is the length of decoded bits decbits, as specified in TS 38.212 Section 5 [1]. The function uses a cyclic redundancy check (CRC)-aided successive-cancellation list decoder of length L. By default, output deinterleaving is enabled, the maximum length of the input is 512, and the number of appended CRC bits is 24. Use this syntax for downlink configuration.

decbits = nrPolarDecode(rec,K,E,L,padCRC) specifies whether the information block on the transmit end was prepadded with ones before CRC encoding.

decbits = nrPolarDecode(rec,K,E,L,padCRC,rnti) specifies a radio network temporary identifier (RNTI). You can use this syntax when the value of rnti masks the CRC parity bits at the transmit end.

decbits = nrPolarDecode(rec,K,E,L,nmax,iil,CRClen) decodes the input with a specified maximum length of 2nmax , output deinterleaving specified by iil, and number of appended CRC bits specified by CRClen. This syntax assumes that the information block on the transmit end was not prepadded with ones before CRC encoding and that the RNTI is equal to 0.

  • For downlink (DL) configuration, valid values for nmax, iil, and CRClen are 9, true, and 24, respectively.

  • For uplink (UL) configuration, valid values for nmax and iil are 10 and false, respectively, and for CRClen is 11 or 6.


collapse all

Transmit polar-encoded block of data and decode it using successive-cancellation list decoder.

Initial Setup

Create a channel that adds white Gaussian noise (WGN) to an input signal. Set the noise variance to 1.5.

nVar = 1.5; 
chan = comm.AWGNChannel('NoiseMethod','Variance','Variance',nVar);

Create a binary phase shift keying (BSPK) modulator and demodulator.

bpskMod = comm.BPSKModulator;
bpskDemod = comm.BPSKDemodulator('DecisionMethod', ...
    'Approximate log-likelihood ratio','Variance',nVar);

Simulate a Frame

Perform polar encoding of a random message of length K. The rate-matched output is of length E.

K = 132;
E = 256;
msg = randi([0 1],K,1,'int8');
enc = nrPolarEncode(msg,E);

Modulate the polar encoded data using BSPK modulation, add WGN, and demodulate.

mod = bpskMod(enc);
rSig = chan(mod);
rxLLR = bpskDemod(rSig); 

Perform polar decoding using successive-cancellation list decoder of length L.

L = 8;
rxBits = nrPolarDecode(rxLLR,K,E,L);

Determine the number of bit errors.

numBitErrs = biterr(rxBits,msg);
disp(['Number of bit errors: ' num2str(numBitErrs)])
Number of bit errors: 0

The transmitted and received messages are identical.

Input Arguments

collapse all

Rate-recovered input, specified as a column vector of real values. The input rec represents the log-likelihood ratios per bit with a negative bipolar mapping. So a 0 is mapped to 1, and a 1 is mapped to -1. The length of rec must be a power of two.

Data Types: single | double

Length of information block in bits, specified as a positive integer. K includes the CRC bits if applicable.

Data Types: double

Rate-matched output length in bits, specified as a positive integer.

  • If 18 ≤ K ≤ 25, E must be in the range K + 3 < E ≤ 8192.

  • If K > 30, E must be in the range K < E ≤ 8192.

Data Types: double

Length of decoding list, specified as a power of two.

Data Types: double

Prepadding before CRC encoding, specified as false or true. Set padCRC to true if the information block on the transmit end, before polar encoding, was prepadded with all ones before CRC encoding.

Data Types: logical

RNTI of the UE, specified as an integer from 0 to 65,535.

Data Types: double

Base-2 logarithm of rate-recovered input's maximum length, specified as 9 or 10.

  • For DL configuration, specify 9.

  • For UL configuration, specify 10.

If N is the length of rec in bits, N2nmax, see TS 38.212 Section

Data Types: double

Output deinterleaving, specified as true or false.

  • For DL configuration, specify true.

  • For UL configuration, specify false.

Data Types: logical

Number of appended CRC bits, specified as 24, 11, or 6.

  • For DL configuration, specify 24.

  • For UL configuration, specify 11 or 6.

The numbers 24, 11, and 6 correspond to the polynomials gCRC24C, gCRC11, and gCRC6, respectively, as described in TS 38.212. Section 5.1 [1].

Data Types: double

Output Arguments

collapse all

Decoded message, returned as a K-by-1 column vector of binary values.

Data Types: int8

Compatibility Considerations

expand all

Behavior changed in R2020a


[1] 3GPP TS 38.212. “NR; Multiplexing and channel coding.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

[2] Tal, I. and Vardy, A., “List decoding of Polar Codes“, IEEE Transactions on Information Theory. Vol. 61, No. 5, pp. 2213-2226, May 2015.

[3] Niu, K., and Chen, K., “CRC-Aided Decoding of Polar Codes“, IEEE Communications Letters, Vol. 16, No. 10, pp. 1668-1671, Oct. 2012.

[4] Stimming, A. B., Parizi, M. B., and Burg, A., “LLR-Based Successive Cancellation List Decoding of Polar Codes“, IEEE Transaction on Signal Processing, Vol. 63, No. 19, pp.5165-5179, 2015.

Extended Capabilities

Introduced in R2018b