Decode binary low-density parity-check (LDPC) code with GPU
To use this object, you must install Parallel Computing Toolbox™ and have access to a supported GPU. If the host computer has a GPU configured, processing uses the GPU. Otherwise, processing uses the CPU. For more information about GPUs, see GPU Computing (Parallel Computing Toolbox).
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.gpu.LDPCDecoderobject 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?
creates a GPU-based binary LDPC decoder System object. This object performs LDPC decoding based on the specified parity-check
gpu_ldpcdecoder = comm.gpu.LDPCDecoder
gpu_ldpcdecoder = comm.gpu.LDPCDecoder(
ParityCheckMatrix property to
creates a GPU-based 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,
gpu_ldpcdecoder = comm.gpu.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 type
'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 performed
false (default) |
Output number of iterations executed, specified as
true. To output the number of iterations executed, set this
FinalParityChecksOutputPort — Output final parity checks
false (default) |
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
OutputValueproperty is set to
'Information part', the output includes only the information-part of the received log-likelihood ratio vector.
OutputValueproperty is set to
'Whole codeword', the output includes the whole log-likelihood ratio vector.
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
LDPC Encode and Decode QPSK-Modulated Signal Using GPU
comm.gpu.LDPCDecoder System Object™ to decode the signal, transmit an LDPC-encoded, QPSK-modulated bit stream through an AWGN channel. After adding AWGN, demodulate and decode the received signal. Compute the error statistics for the reception of uncoded and LDPC-coded signals. For more information, see Accelerate Simulation Using GPUs.
Define simulation variables. Create an LDPC encoder configuration object and System objects for the 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; gpuldpcDecoder = comm.gpu.LDPCDecoder; encoderCfg = ldpcEncoderConfig(gpuldpcDecoder.ParityCheckMatrix); 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 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 = ldpcEncode(data,encoderCfg); modSig = pskMod(encData); rxSig = awgn(modSig,snr(ii),'measured'); demodSig = pskDemod(rxSig); rxBits = gpuldpcDecoder(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')
comm.gpu.LDPCDecoderSystem object cannot be included in MATLAB System (Simulink) blocks.
Array Processing with GPU-based System Objects
A GPU-based System object accepts typical MATLAB® arrays or
gpuArray (Parallel Computing Toolbox) objects. The output signal data
type matches the input signal data type.
When the input signal to the GPU-based System object is a
gpuArrayobject, calculations take place entirely on the GPU, the data remains on the GPU, and the output signal is a
gpuArrayarguments minimizes data transfer latency by limiting the number of data transfers between the CPU and the GPU when your simulation runs. For more information, see Establish Arrays on a GPU (Parallel Computing Toolbox).
When the input signal is a MATLAB array, the GPU-based System object transfers the data between the CPU and the GPU for each object call. The output signal is a MATLAB array and data transfer latency occurs.
This object performs LDPC decoding using the belief propagation algorithm, also known as a message-passing algorithm.
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).
 Gallager, Robert G. Low-Density Parity-Check Codes. Cambridge, MA: MIT Press, 1963.
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This System object runs on a GPU, and also supports GPU array inputs. For more information, see Accelerate Simulation Using GPUs.
Version HistoryIntroduced in R2012a
R2023b: Align GPU and CPU for LLR = 0 tie-breaker
CUDA kernels, used by the
System object, for the BP algorithm have been updated to align the tie-breaker for
hard-decision with the CPU version. Specifically, for an intermediate or final LLR value of
exactly 0, the CPU version and GPU version now always choose bit 1.
Before R2023b, the CUDA kernels for the BP algorithm use a tie-breaker for hard-decisions that is different from the tie-breaker used by the CPU version. Specifically, for an intermediate or final LLR value of exactly 0, the CPU version always chooses bit 1 and the GPU version always chooses bit 0.