Main Content

nrPolarEncode

Polar encoding

Description

example

enc = nrPolarEncode(in,E) returns the polar-encoded output for the input message in and rate-matched output length E as specified in TS 38.212 Section 5 [1]. By default, input interleaving is enabled and the maximum length of the encoded message is 512. Use this syntax for downlink configuration.

enc = nrPolarEncode(in,E,nmax,iil) encodes the input with a specified maximum length of 2nmax and input interleaving specified by iil.

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

  • For uplink (UL) configuration, valid values for nmax and iil are 10 and false, respectively.

Examples

collapse all

Perform polar encoding of a random message of length K. E specifies the length of the rate-matched output which is different from the length of the encoded message enc. The length of enc is always a power of two.

K = 132;
E = 300;
msg = randi([0 1],K,1,'int8');
enc = nrPolarEncode(msg,E)
enc = 512x1 int8 column vector

   0
   0
   0
   0
   0
   0
   1
   1
   1
   0
      ⋮

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

Input message, specified as a column vector of binary values. in includes the CRC bits if applicable.

Data Types: double | int8

Rate-matched output length in bits, specified as a positive integer. E depends on K, the length of the input message in.

  • 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

Base-2 logarithm of the encoded message's maximum length, specified as 9 or 10.

  • For DL configuration, specify 9.

  • For UL configuration, specify 10.

If N is the length of the polar-encoded message in bits, then N2nmax. See TS 38.212 Section 5.3.1.2 [1].

Data Types: double

Input interleaving, specified as true or false.

  • For DL configuration, specify true.

  • For UL configuration, specify false.

Data Types: logical

Output Arguments

collapse all

Polar-encoded message, returned as a column vector of binary values. enc inherits its data type from the input message in.

The length of the polar-encoded message, N, is a power of two. For more information, see TS 38.212 Section 5.3.1.

  • For DL configuration, N ≤ 512.

  • For UL configuration, N ≤ 1024.

Data Types: double | int8

References

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

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2018b