Decode binary low-density parity-check (LDPC) code
System object™ uses the belief propagation algorithm to decode a binary LDPC code, which is
input to the object as the soft-decision output (log-likelihood ratio of received bits) from
demodulation. The object decodes generic binary LDPC codes where no patterns in the
parity-check matrix are assumed. For more information, see Belief Propagation Decoding.
To decode an LDPC-encoded signal:
comm.LDPCDecoder object and set its properties.
Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?.
binary LDPC decoder System object. This object performs LDPC decoding based on the specified parity-check
ldpcdecoder = comm.LDPCDecoder
ldpcdecoder = comm.LDPCDecoder(
ParityCheckMatrix property to
creates an LDPC decoder System object. The
parity input must be specified as described by the
sets properties using one or more name-value pairs, in addition to inputs from any of the
prior syntaxes. For example,
ldpcdecoder = comm.LDPCDecoder(___,
decision') configures an LDPC decoder System object to decode data using the soft-decision method and output log-likelihood
ratios of data type
double. Enclose each property name in
Unless otherwise indicated, properties are nontunable, which means you cannot change their
values after calling the object. Objects lock when you call them, and the
release function unlocks them.
If a property is tunable, you can change its value at any time.
For more information on changing property values, see System Design in MATLAB Using System Objects.
ParityCheckMatrix— Parity-check matrix
dvbs2ldpc(1/2)(default) | sparse binary matrix | nonsparse index matrix
Parity-check matrix, specified as a sparse (N –
K)-by-N binary-valued matrix.
N is the length of the received signal and must be in the range (0,
231). K is the length of the uncoded
message and must be less than N. The last (N –
K) columns in the parity-check matrix must be an invertible matrix
in the Galois field of order 2,
You can also specify the parity-check matrix as a two-column nonsparse index matrix,
I, that defines the row and column indices of the
1s in the parity-check matrix such that
This property accepts numeric data types. When you set this property to a sparse
binary matrix, this property also accepts the
The default value uses the
dvbs2ldpc function to configure a sparse parity-check matrix for half-rate
LDPC coding, as specified in the DVB-S.2 standard.
dvbs2ldpc(R,'indices') configures the index matrix for
the DVB-S.2 standard, where
R is the code rate, and
'indices' specifies the output format of
dvbs2ldpc as a two-column double-precision matrix that defines the
row and column indices of the
1s in the parity-check
OutputValue— Output value format
'Information part'(default) |
Output value format, specified as one of these values:
'Information part' — The object outputs a
K-by-1 column vector containing only the information-part of
the received log-likelihood ratio vector. K is the length of
the uncoded message.
'Whole codeword' — The object outputs an
N-by-1 column vector containing the whole log-likelihood
ratio vector. N is the length of the received signal.
N and K must align with the dimension of the (N–K)-by-K parity-check matrix.
DecisionMethod— Decision method
'Hard decision'(default) |
Decision method used for decoding, specified as one of these values:
'Hard decision' — The object outputs decoded data of data
'Soft decision' — The object outputs log-likelihood ratios
of data type
IterationTerminationCondition— Condition for iteration termination
'Maximum iteration count'(default) |
'Parity check satisfied'
Condition for iteration termination, specified as one of these values:
'Maximum iteration count' — Decoding terminates after the
number of iterations specified by the
'Parity check satisfied' — Decoding terminates after all
parity checks are satisfied. If not all parity checks are satisfied, decoding
terminates after the number of iterations specified by the
MaximumIterationCount— Maximum number of decoding iterations
50(default) | positive integer
Maximum number of decoding iterations, specified as a positive integer.
NumIterationsOutputPort— Output number of iterations executed
Output number of iterations performed, specified as
true. To output the number of iterations executed, set this
FinalParityChecksOutputPort— Output final parity checks
Output final parity checks, specified as
true. To output the final calculated parity checks, set this
x— Log-likelihood ratios
Log-likelihood ratios, specified as an N-by-1 column vector
containing the soft-decision output from demodulation. N is the
number of bits in the LDPC codeword before modulation. Each element is the
log-likelihood ratio for a received bit. Element values are more likely to be
0 if the log-likelihood ratio is positive. The first
K elements correspond to the information-part of the input
y— Decoded data
Decoded data, returned as a column vector. The
property specifies whether the object outputs hard decisions or soft decisions
OutputValue property is set to
'Information part', the output includes only the
information-part of the received log-likelihood ratio vector.
OutputValue property is set to
codeword', the output includes the whole log-likelihood ratio
numiter— Number of executed decoding iterations
Number of executed decoding iterations, returned as a positive integer.
To enable this output, set the
parity— Final parity checks
Final parity checks after decoding the input LDPC code, returned as an (N-K)-by-1 column vector. N is the number of bits in the LDPC codeword before modulation. K is the length of the uncoded message.
To enable this output, set the
To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named
Transmit an LDPC-encoded, QPSK-modulated bit stream through an AWGN channel. Demodulate and decode the received signal. Compute the error statistics for the reception of uncoded and LDPC-coded signals.
Define simulation variables. Create System objects for the LDPC encoder, LDPC decoder, QPSK modulator, and QPSK demodulators.
M = 4; % Modulation order (QPSK) snr = [0.25,0.5,0.75,1.0,1.25]; numFrames = 10; ldpcEncoder = comm.LDPCEncoder; ldpcDecoder = comm.LDPCDecoder; pskMod = comm.PSKModulator(M,'BitInput',true); pskDemod = comm.PSKDemodulator(M,'BitOutput',true,... 'DecisionMethod','Approximate log-likelihood ratio'); pskuDemod = comm.PSKDemodulator(M,'BitOutput',true,... 'DecisionMethod','Hard decision'); errRate = zeros(1,length(snr)); uncErrRate = zeros(1,length(snr));
For each SNR setting and all frames, compute the error statistics for uncoded and LDPC-coded signals.
for ii = 1:length(snr) ttlErr = 0; ttlErrUnc = 0; pskDemod.Variance = 1/10^(snr(ii)/10); % Set variance using current SNR for counter = 1:numFrames data = logical(randi([0 1],32400,1)); % Transmit and receiver uncoded signal data mod_uncSig = pskMod(data); rx_uncSig = awgn(mod_uncSig,snr(ii),'measured'); demod_uncSig = pskuDemod(rx_uncSig); numErrUnc = biterr(data,demod_uncSig); ttlErrUnc = ttlErrUnc + numErrUnc; % Transmit and receive LDPC coded signal data encData = ldpcEncoder(data); modSig = pskMod(encData); rxSig = awgn(modSig,snr(ii),'measured'); demodSig = pskDemod(rxSig); rxBits = ldpcDecoder(demodSig); numErr = biterr(data,rxBits); ttlErr = ttlErr + numErr; end ttlBits = numFrames*length(rxBits); uncErrRate(ii) = ttlErrUnc/ttlBits; errRate(ii) = ttlErr/ttlBits; end
Plot the error statistics for uncoded and LDPC-coded data.
plot(snr,uncErrRate,snr,errRate) legend('Uncoded', 'LDPC coded') xlabel('SNR (dB)') ylabel('BER')
This object performs LDPC decoding using the belief propagation algorithm, also known as a message-passing algorithm.
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 configured to stop when all parity checks are satisfied, the algorithm verifies the parity-check equation (H c' = 0) at the end of each iteration. When all 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 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).
 Gallager, Robert G. Low-Density Parity-Check Codes. Cambridge, MA: MIT Press, 1963.
Usage notes and limitations:
Using default settings,
comm.LDPCDecoder does not support code
generation. To generate code, specify the
property as a nonsparse index matrix.
See System Objects in MATLAB Code Generation (MATLAB Coder).