nrLDPCDecode
Low-density parity-check (LDPC) decoding
Syntax
Description
[
returns the LDPC-decoded output matrix out
,actNumIter
,finalParityChecks
] = nrLDPCDecode(in
,bgn
,maxNumIter
)out
for the input data matrix
in
, base graph number bgn
, and maximum number of
decoding iterations maxNumIter
. The function also returns the actual
number of iterations actNumIter
and the final parity checks per
codeword finalParityChecks
.
The decoder uses the sum-product message-passing algorithm. The data bits must be LDPC-encoded as defined in TS 38.212 Section 5.3.2 [1].
[
specifies optional name-value pair arguments, in addition to the input arguments in the
previous syntax.out
,actNumIter
,finalParityChecks
] = nrLDPCDecode(___,Name,Value
)
Examples
Decode LDPC Codeword
Create transmit data consisting of two code block segments of length 2560 and 36 filler bits at the end.
C = 2; K = 2560; F = 36; txcbs = ones(K-F,C); fillers = -1*ones(F,C); txcbs = [txcbs;fillers];
Generate LDPC codeword for the transmit data. Use base graph number two.
bgn = 2; txcodedcbs = nrLDPCEncode(txcbs,bgn);
Convert transmit data to soft bits. Fillers in the transmit data do not have log likelihood ratio (LLR) soft bits.
rxcodedcbs = double(1-2*txcodedcbs); FillerIndices = find(txcodedcbs(:,1) == -1); rxcodedcbs(FillerIndices,:) = 0;
Decode the encoded codeword with a maximum of 25 iterations.
[rxcbs,actualniters] = nrLDPCDecode(rxcodedcbs,bgn,25);
Replace filler bits with zero in transmit data and compare the results of encoding and decoding.
txcbs(end-F+1:end,:) = 0; isequal(rxcbs,txcbs)
ans = logical
1
actualniters
actualniters = 1×2
1 1
Input Arguments
in
— Rate recovered soft bits for input code block segments
real matrix
Rate recovered soft bits for input code block segments, specified as a real matrix.
The number of columns in in
is equal to the number of scheduled
code block segments. The number of rows in in
is equal to the
length of the codeword, with some systematic bits punctured.
Data Types: double
| single
bgn
— Base graph number
1
| 2
Base graph number, specified as 1
or 2
. The
value selects one of the two base graphs defined in TS 38.212 Section 5.3.2 [1].
Data Types: double
maxNumIter
— Maximum number of decoding iterations
positive integer scalar
Maximum number of decoding iterations, specified as a positive integer scalar. The
decoding is terminated when all parity checks are satisfied, or after
maxNumIter
number of iterations.
Data Types: double
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: [out,actNumIter,finalParityChecks] =
nrLDPCDecode(in,bgn,maxNumIter,'DecisionType','hard')
OutputFormat
— Output format
'info'
(default) | 'whole'
Output format, specified as the comma-separated pair consisting of
'OutputFormat'
and one of these values:
'info'
— The number of rows inout
is equal to the length of the information bits.'whole'
— The number of rows inout
is equal to the length of the codeword.
Data Types: char
| string
DecisionType
— Decision method used for decoding
'hard'
(default) | 'soft'
Algorithm
— LDPC decoding algorithm
'Belief propagation'
(default) | 'Layered belief propagation'
| 'Normalized min-sum'
| 'Offset min-sum'
LDPC decoding algorithm, specified as the comma-separated pair consisting of
'Algorithm'
and one of these values:
'Belief propagation'
— Use this option to specify the belief-passing or message-passing algorithm. For more information, see Belief Propagation Decoding.'Layered belief propagation'
— Use this option to specify the layered belief-passing algorithm, which is suitable for quasi-cyclic parity-check matrices (PCMs). For more information, see Layered Belief Propagation Decoding.'Normalized min-sum'
— Use this option to specify the layered belief propagation algorithm with normalized min-sum approximation. For more information, see Normalized Min-Sum Decoding.'Offset min-sum'
— Use this option to specify the layered belief propagation algorithm with offset min-sum approximation. For more information, see Offset Min-Sum Decoding.
Note
When you specify the value of this name-value pair argument as
'Normalized min-sum'
or 'Offset min-sum'
,
the function clips the input (log-likelihood ratio) LLR values to the [-1e10 1e10]
range before decoding.
Data Types: char
| string
ScalingFactor
— Scaling factor for normalized min-sum decoding
0.75
(default) | real scalar in the range (0, 1]
Scaling factor for normalized min-sum decoding, specified as the comma-separated
pair consisting of 'ScalingFactor'
and a real scalar in the range
(0, 1].
Dependencies
To enable this name-value pair argument, set the
'
name-value pair argument to
Algorithm
''Normalized min-sum'
.
Data Types: double
Offset
— Offset for offset min-sum decoding
0.5
(default) | nonnegative finite real scalar
Offset for offset min-sum decoding, specified as the comma-separated pair
consisting of 'Offset'
and a nonnegative finite real
scalar.
Dependencies
To enable this name-value pair argument, set the
'
name-value pair argument to
Algorithm
''Offset min-sum'
.
Data Types: double
Termination
— Decoding termination criteria
'early'
(default) | 'max'
Decoding termination criteria, specified as the comma-separated pair consisting of
'Termination'
and one of these values:
'early'
— The decoding terminates when all parity checks are satisfied or aftermaxNumIter
number of iterations.'max'
— The decoding terminates aftermaxNumIter
number of iterations.
Data Types: char
| string
Output Arguments
out
— Decoded LDPC codeword
real matrix
Decoded LDPC codeword or information bits, returned as a real matrix. The number of
columns in out
is equal to the number of scheduled code block
segments. The number of rows in out
depends on the name-value pair
argument 'OutputFormat'
.
The data type of out
depends on the name-value pair argument
'DecisionType'
.
Data Types: single
| double
| int8
actNumIter
— Actual number of iterations
row vector of positive integers
Actual number of iterations, returned as a row vector of positive integers. The
length of actNumIter
is equal to the number of columns in
in
. The i
th element in
actNumIter
corresponds to the actual number of iterations
executed for the i
th column of
in
.
Data Types: double
finalParityChecks
— Final parity checks
matrix
Final parity checks, returned as a matrix. The number of rows in
finalParityChecks
is equal to the number of parity-check bits in
an LDPC codeword. The i
th column in
finalParityChecks
corresponds to the final parity checks for the
i
th codeword.
Data Types: double
Algorithms
The nrLDPCDecode
function supports these four LDPC decoding
algorithms.
Belief Propagation Decoding
The implementation of the belief propagation algorithm is based on the decoding algorithm presented in [2]. For transmitted LDPC-encoded codeword, c, where , the input to the LDPC decoder is the log-likelihood ratio (LLR) value .
In each iteration, the key components of the algorithm are updated based on these equations:
,
, initialized as before the first iteration, and
.
At the end of each iteration, is an updated estimate of the LLR value for the transmitted bit . The value is the soft-decision output for . If , the hard-decision output for is 1. Otherwise, the output is 0.
Index sets and are based on the parity-check matrix (PCM). Index sets and correspond to all nonzero elements in column i and row j of the PCM, respectively.
This figure highlights the computation of these index sets in a given PCM for i = 5 and j = 3.
To avoid infinite numbers in the algorithm equations, atanh(1) and atanh(-1) are set to 19.07 and –19.07, respectively. Due to finite precision, MATLAB® returns 1 for tanh(19.07) and –1 for tanh(–19.07).
When the name-value pair argument 'Termination'
is
set to 'max'
, the decoding terminates after
maxNumIter
number of iterations. When 'Termination'
is
set to 'early'
, the decoding terminates when all parity checks are
satisfied () or after maxNumIter
number of iterations.
Layered Belief Propagation Decoding
The implementation of the layered belief propagation algorithm is based on the decoding algorithm presented in [3], Section II.A. The decoding loop iterates over subsets of rows (layers) of the PCM. For each row, m, in a layer and each bit index, j, the implementation updates the key components of the algorithm based on these equations:
(1) ,
(2) ,
(3) ,
(4) , and
(5) .
For each layer, the decoding equation (5) works on the combined input obtained from the current LLR inputs and the previous layer updates .
Because only a subset of the nodes is updated in a layer, the layered belief propagation algorithm is faster compared to the belief propagation algorithm. To achieve the same error rate as attained with belief propagation decoding, use half the number of decoding iterations when using the layered belief propagation algorithm.
Normalized Min-Sum Decoding
The implementation of the normalized min-sum decoding algorithm follows the layered belief propagation algorithm with equation (2) replaced by
,
where α is in the range (0, 1] and is the scaling factor specified by
ScalingFactor
. This equation is an adaptation of equation (4)
presented in [4].
References
[1] 3GPP TS 38.212. “NR; Multiplexing and channel coding.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.
[2] Gallager, Robert G. Low-Density Parity-Check Codes, Cambridge, MA, MIT Press, 1963.
[3] Hocevar, D.E. "A reduced complexity decoder architecture via layered decoding of LDPC codes." In IEEE Workshop on Signal Processing Systems, 2004. SIPS 2004. doi: 10.1109/SIPS.2004.1363033
[4] Chen, Jinghu, R.M. Tanner, C. Jones, and Yan Li. "Improved min-sum decoding algorithms for irregular LDPC codes." In Proceedings. International Symposium on Information Theory, 2005. ISIT 2005. doi: 10.1109/ISIT.2005.1523374
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
The
'DecisionType'
name-value argument must be compile-time constant for
code generation. For example, when you call the function with
'DecisionType','soft'
include
{coder.Constant('DecisionType'),coder.Constant('soft')}
in the
-args
value of the codegen
function. For more
information, see coder.Constant
(MATLAB Coder).
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™. (since R2024a)
The nrLDPCDecode
function
fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray
(Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2018bR2024a: GPU array support
The nrLDPCDecode
function now supports GPU arrays. For more
information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
R2023a: C/C++ code generation updates
For C/C++ code generation, the limitation to specify
'OutputFormat'
, 'Algorithm'
,
'ScalingFactor'
, 'Offset'
, or
'Termination'
name-value arguments as compile-time constants has been
removed.
See Also
Functions
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)