Decode binary LDPC code
ldpcDecode function decodes the input codeword using one of
four algorithms. For more information, see Algorithms. LDPC codes are linear error control codes with sparse parity-check matrices and long block
lengths that can attain performance near the Shannon limit.
decodes the input log-likelihood ratio (LLR),
finalparitychecks] = ldpcDecode(
llr, using the LDPC
matrix specified by the input
decodercfg. A positive LLR indicates that the
corresponding bit is more likely a zero. Decoding terminates when all of the parity checks
are satisfied, up to a maximum number of iterations specified by the input
maxnumiter. LDPC codes are linear error control codes with sparse
parity-check matrices and long block lengths that can attain performance near the Shannon
Decode Rate 3/4 LDPC Codewords
Initialize parameters for the prototype matrix and block size to configure a rate 3/4 LDPC code specified in IEEE 802.11. Create the parity-check matrix by using the
P = [ 16 17 22 24 9 3 14 -1 4 2 7 -1 26 -1 2 -1 21 -1 1 0 -1 -1 -1 -1 25 12 12 3 3 26 6 21 -1 15 22 -1 15 -1 4 -1 -1 16 -1 0 0 -1 -1 -1 25 18 26 16 22 23 9 -1 0 -1 4 -1 4 -1 8 23 11 -1 -1 -1 0 0 -1 -1 9 7 0 1 17 -1 -1 7 3 -1 3 23 -1 16 -1 -1 21 -1 0 -1 -1 0 0 -1 24 5 26 7 1 -1 -1 15 24 15 -1 8 -1 13 -1 13 -1 11 -1 -1 -1 -1 0 0 2 2 19 14 24 1 15 19 -1 21 -1 2 -1 24 -1 3 -1 2 1 -1 -1 -1 -1 0 ]; blockSize = 27; pcmatrix = ldpcQuasiCyclicMatrix(blockSize,P);
Create LDPC encoder and decoder configuration objects, displaying their properties.
cfgLDPCEnc = ldpcEncoderConfig(pcmatrix)
cfgLDPCEnc = ldpcEncoderConfig with properties: ParityCheckMatrix: [162x648 logical] Read-only properties: BlockLength: 648 NumInformationBits: 486 NumParityCheckBits: 162 CodeRate: 0.7500
cfgLDPCDec = ldpcDecoderConfig(pcmatrix)
cfgLDPCDec = ldpcDecoderConfig with properties: ParityCheckMatrix: [162x648 logical] Algorithm: 'bp' Read-only properties: BlockLength: 648 NumInformationBits: 486 NumParityCheckBits: 162 CodeRate: 0.7500
Transmit an LDPC-encoded, QPSK-modulated bit stream through an AWGN channel. Demodulate the signal, decode the received codewords, and then count bit errors. Use nested
for loops to process multiple SNR settings and frames with and without LDPC forward error correction (FEC) coding of the transmitted data.
M = 4; maxnumiter = 10; snr = [20 6 3]; numframes = 10; qpskmod = comm.PSKModulator(M,'BitInput',true); qpskmod2 = comm.PSKModulator(M); ber = comm.ErrorRate; ber2 = comm.ErrorRate; for ii = 1:length(snr) qpskdemod = comm.PSKDemodulator(M,'BitOutput',true, ... 'DecisionMethod','Approximate log-likelihood ratio', ... 'Variance',1/10^(snr(ii)/10)); qpskdemod2 = comm.PSKDemodulator(M); for counter = 1:numframes data = randi([0 1],cfgLDPCEnc.NumInformationBits,1,'int8'); % Transmit and receive with LDPC coding encodedData = ldpcEncode(data,cfgLDPCEnc); modSignal = qpskmod(encodedData); receivedSignal = awgn(modSignal,snr(ii)); demodSignal = qpskdemod(receivedSignal); receivedBits = ldpcDecode(demodSignal,cfgLDPCDec,maxnumiter); errStats = ber(data,receivedBits); % Transmit and receive with no LDPC coding noCoding = qpskmod2(data); rxNoCoding = awgn(noCoding,snr(ii)); rxBitsNoCoding = qpskdemod2(rxNoCoding); errStatsNoCoding = ber2(data,int8(rxBitsNoCoding)); end fprintf(['SNR = %2d\n Coded: Error rate = %1.2f, ' ... 'Number of errors = %d\n'], ... snr(ii),errStats(1),errStats(2)) fprintf(['Noncoded: Error rate = %1.2f, ' ... 'Number of errors = %d\n'], ... errStatsNoCoding(1),errStatsNoCoding(2)) end
SNR = 20 Coded: Error rate = 0.00, Number of errors = 0
Noncoded: Error rate = 0.00, Number of errors = 0
SNR = 6 Coded: Error rate = 0.00, Number of errors = 0
Noncoded: Error rate = 0.02, Number of errors = 196
SNR = 3 Coded: Error rate = 0.02, Number of errors = 353
Noncoded: Error rate = 0.07, Number of errors = 976
llr — Log-likelihood ratios
Log-likelihood ratios, specified as a matrix with the number of rows equal to the
BlockLength property of the input
decodercfg. Each column of
llr corresponds to
a codeword. The function decodes each column independently. A positive LLR indicates
that the corresponding bit is more likely a zero.
decodercfg — LDPC decoder configuration
LDPC decoder configuration, specified as an
maxnumiter — Maximum number of decoding iterations
Maximum number of decoding iterations, specified as a positive scalar.
Specify optional pairs of arguments as
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.
OutputFormat — Output format
'info' (default) |
Output format, specified as one of these values:
'info'— Output only the decoded information bits. The number of rows that the function outputs equals the
NumInformationBitsproperty for the input
'whole'— Output all of the decoded LDPC codeword bits, including information bits and parity-check bits. The number of rows that the function outputs equals the
BlockLengthproperty for the input
DecisionType — Decision type
'hard' (default) |
Decision type for LDPC decoding, specified as one of these values:
'hard'— Perform hard-decision decoding and output decoded bits as values of
'soft'— Perform soft-decision decoding and output LLRs with the same data type as the input.
MinSumScalingFactor — Scaling factor for normalized min-sum decoding algorithm
0.75 (default) | scalar in the range (0, 1]
MinSumOffset — Offset for min-sum decoding algorithm
0.5 (default) | scalar
Termination — Decoding termination criteria
'early' (default) |
Decoding termination criteria, specified as one of these values:
Multithreaded — Enable multithreaded execution
1 (default) |
Enable multithreaded execution, specified as a logical
you run MATLAB® in interpreted mode and set this argument to
the function executes the decoding algorithm with multiple threads.
For large parity-check matrices, multithreaded execution significantly reduces the processing time for LDPC decoding.
To enable this property, run MATLAB in interpreted mode.
y — Decoded codewords
Decoded codewords, returned as a matrix with K rows that
represent the decoded bits for
K equals the
NumInformationBits property of
decodercfg. For the decoding operation, each column of
llr corresponds to a codeword. The function decodes each column
'OutputFormat' name-value argument specifies whether the output contains
decoded information bits (default) or whole LDPC codeword bits. The
'DecisionType' name-value argument specifies and determines the decoding
decision type and the data type of this output.
For more information, see Algorithms.
actualnumiter — Actual number of decoding iterations
Actual number of decoding iterations, returned as a row vector. If all of the parity
checks for a codeword are satisfied, decoding can stop before the maximum number of
is reached. This output is a row vector of the actual number of iterations that the
function executes for the codewords.
finalparitychecks — Final parity checks for each codeword
Final parity checks for each codeword, returned as a matrix with the number of rows
equal to the
ParityCheckBits property of input
decodercfg. For the decoding operation, each column of this
output is the final parity checks for the corresponding codeword.
LDPC decoding using one of these message-passing algorithms.
Belief Propagation Decoding
The implementation of the belief propagation algorithm is based on the decoding algorithm presented by Gallager .
For transmitted LDPC-encoded codeword c = c0, c1, …, cn-1, 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, L(Qi) contains the updated estimate of the LLR value for transmitted bit ci. The value L(Qi) is the soft-decision output for ci. If L(Qi) < 0, the hard-decision output for ci is 1. Otherwise, the hard-decision output for ci is 0.
If decoding is configured to stop when all of the parity checks are satisfied, the algorithm verifies the parity-check equation (H c' = 0) at the end of each iteration. When all of the parity checks are satisfied, or if the maximum number of iterations is reached, decoding stops.
Index sets and are based on the parity-check matrix (PCM). Index sets Ci and Vj correspond to all nonzero elements in column i and row j of the PCM, respectively.
This figure shows 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).
Layered Belief Propagation Decoding
The implementation of the layered belief propagation algorithm is based on the decoding algorithm presented in Hocevar , 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:
(4) , and
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 you use 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 the
MinSumScalingFactor input argument to the
ldpcDecode function. This equation is an adaptation of equation (4)
presented in Chen .
Offset Min-Sum Decoding
The implementation of the offset min-sum decoding algorithm follows the layered belief propagation algorithm with equation (2) replaced by
 IEEE Std 802.11™-2016 (Revision of IEEE Std 802.11-2012). "Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications." IEEE Standard for Information technology — Telecommunications and information exchange between systems. Local and metropolitan area networks — Specific requirements.
 Gallager, Robert G. Low-Density Parity-Check Codes. Cambridge, MA: MIT Press, 1963.
 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
 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