Why does my LDPC-coded communication simulation result in constant parity check failures and high BER regardless of SNR?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am simulating an LDPC-coded communication system using MATLAB’s comm.LDPCEncoder and comm.LDPCDecoder for a DVB-S2 rate of 1/2. My setup includes encoding information bits, BPSK modulation, adding AWGN noise, and decoding with soft decision. However, I consistently encounter parity check failures, and the BER does not decrease with increasing SNR as expected.
Key details:
- LDPC Parameters:
- Parity check matrix dimensions: [32400, 64800].
- Number of information bits: 32400.
- Total codeword length: 64800.
2. Error:
- At each frame, the parity check fails for decoded bits, even though the decoded bits length matches the expected codeword length.
- BER remains constant (close to 1) across all tested SNR values, which is inconsistent with theoretical expectations.
Code:
%% LDPC Encoder-Decoder Simulation with Detailed Debugging
clc; clear; close all;
% Initialize LDPC parameters
disp('Initializing LDPC parameters...');
dvbS2Rate = 1/2; % Code rate for DVB-S2 LDPC
parityCheckMatrix = dvbs2ldpc(dvbS2Rate);
K = size(parityCheckMatrix, 2) - size(parityCheckMatrix, 1); % Number of information bits
N = size(parityCheckMatrix, 2); % Total number of bits in codeword
% Display matrix and vector dimensions for debugging
disp(['Parity Check Matrix Dimensions: ' num2str(size(parityCheckMatrix))]);
disp(['Information Bits: ' num2str(K) ', Total Codeword Bits: ' num2str(N)]);
% Setup LDPC Encoder and Decoder
ldpcEncoder = comm.LDPCEncoder('ParityCheckMatrix', parityCheckMatrix);
ldpcDecoder = comm.LDPCDecoder('ParityCheckMatrix', parityCheckMatrix, ...
'DecisionMethod', 'Soft decision', ...
'MaximumIterationCount', 50, ...
'IterationTerminationCondition', 'Parity check satisfied');
% Simulation Parameters
SNR_dB = 0:10; % SNR range in dB
Nstop = 10; % Number of frames to simulate per SNR (reduced for debugging)
BER = zeros(1, length(SNR_dB));
WER = zeros(1, length(SNR_dB));
% Debugging outputs and calculations
for snr_idx = 1:length(SNR_dB)
snr = SNR_dB(snr_idx);
noiseVar = 1 / (2 * 10^(snr / 10) * dvbS2Rate);
disp(['Simulating for SNR = ' num2str(snr) ' dB...']);
totalErrors = 0;
totalParityFails = 0;
totalBits = 0;
for frame = 1:Nstop
% Generate random information bits
infoBits = logical(randi([0, 1], K, 1));
disp(['Frame ' num2str(frame) ':']);
disp(['Generated bits (First 10): ' num2str(infoBits(1:min(10, end))')]);
% Encode the bits
encodedBits = ldpcEncoder(infoBits);
disp(['Encoded bits (First 10): ' num2str(encodedBits(1:min(10, end))')]);
% Modulate
modulatedSignal = 2 * double(encodedBits) - 1;
disp(['Modulated signal (First 10): ' num2str(modulatedSignal(1:min(10, end))')]);
% Add noise
noise = sqrt(noiseVar) * randn(size(modulatedSignal));
receivedSignal = modulatedSignal + noise;
disp(['Noise (First 10): ' num2str(noise(1:min(10, end))')]);
disp(['Received signal (First 10): ' num2str(receivedSignal(1:min(10, end))')]);
% Decode
llrs = 2 * receivedSignal / noiseVar; % Soft LLRs
disp(['LLRs (First 10): ' num2str(llrs(1:min(10, end))')]);
decodedBits = ldpcDecoder(llrs);
disp(['Decoded bits (First 10): ' num2str(decodedBits(1:min(10, end))')]);
% Ensure decoded bits are the correct length
if length(decodedBits) ~= N
disp(['Warning: Decoded bits length mismatch. Adjusting...']);
decodedBits = [decodedBits; zeros(N - length(decodedBits), 1)];
end
disp(['Checking decodedBits length: ' num2str(length(decodedBits)) ' expected: ' num2str(N)]);
% Parity check
parityCheckResult = mod(parityCheckMatrix * double(decodedBits), 2);
parityErrors = sum(parityCheckResult);
disp(['Parity check errors: ' num2str(parityErrors)]);
% Calculate errors
bitErrors = sum(infoBits ~= decodedBits(1:K));
disp(['Bit errors for this frame: ' num2str(bitErrors)]);
totalErrors = totalErrors + bitErrors;
totalParityFails = totalParityFails + (parityErrors > 0);
totalBits = totalBits + K;
end
% Store WER and BER for this SNR
BER(snr_idx) = totalErrors / totalBits;
WER(snr_idx) = totalParityFails / Nstop;
disp(['SNR = ' num2str(snr) ' dB: WER = ' num2str(WER(snr_idx)) ', BER = ' num2str(BER(snr_idx))]);
end
% Plotting the results
figure;
semilogy(SNR_dB, BER, 'b-o', 'DisplayName', 'Bit Error Rate');
hold on;
semilogy(SNR_dB, WER, 'r-s', 'DisplayName', 'Word Error Rate');
legend show;
xlabel('SNR (dB)');
ylabel('Error Rate');
title('Performance of LDPC Coded Communication System');
grid on;
disp('Simulation complete.');
Outputs:
Frame 7:
Generated bits (First 10): 0 1 1 0 1 1 1 0 1 0
Encoded bits (First 10): 0 1 1 0 1 1 1 0 1 0
Modulated signal (First 10): -1 1 1 -1 1 1 1 -1 1 -1
Noise (First 10): -0.29059 0.67615 -0.41689 0.52532 0.040514 0.68041 0.21785 -0.12064 -0.22048 0.07668
Received signal (First 10): -1.2906 1.6762 0.58311 -0.47468 1.0405 1.6804 1.2179 -1.1206 0.77952 -0.92332
LLRs (First 10): -25.8119 33.5231 11.6623 -9.49362 20.8103 33.6083 24.357 -22.4128 15.5905 -18.4664
Decoded bits (First 10): -11.117 38.6546 4.10057 -4.4096 43.0879 35.9085 44.0345 -23.5997 9.42597 -5.91338
Warning: Decoded bits length mismatch. Adjusting...
Checking decodedBits length: 64800 expected: 64800
Parity check errors: 32260.3326
Bit errors for this frame: 32400
Frame 8:
Generated bits (First 10): 1 0 0 1 0 0 0 0 0 1
Encoded bits (First 10): 1 0 0 1 0 0 0 0 0 1
Modulated signal (First 10): 1 -1 -1 1 -1 -1 -1 -1 -1 1
Noise (First 10): 0.0052441 -0.08655 -0.16033 0.1313 0.028423 -0.25199 -0.17154 0.050778 0.48823 0.47269
Received signal (First 10): 1.0052 -1.0866 -1.1603 1.1313 -0.97158 -1.252 -1.1715 -0.94922 -0.51177 1.4727
LLRs (First 10): 20.1049 -21.731 -23.2067 22.626 -19.4315 -25.0398 -23.4308 -18.9844 -10.2355 29.4537
Decoded bits (First 10): 12.0583 -26.1377 -40.5549 28.1106 -2.46505 -13.6139 -41.5741 -30.8501 0.207377 39.3372
Warning: Decoded bits length mismatch. Adjusting...
Checking decodedBits length: 64800 expected: 64800
Parity check errors: 32490.2446
Bit errors for this frame: 32400
Frame 9:
Generated bits (First 10): 0 0 0 1 1 0 1 1 1 1
Encoded bits (First 10): 0 0 0 1 1 0 1 1 1 1
Modulated signal (First 10): -1 -1 -1 1 1 -1 1 1 1 1
Noise (First 10): 0.1108 0.35299 -0.09093 -0.096486 -0.50138 0.061715 0.038528 0.014637 -0.106 0.26087
Received signal (First 10): -0.8892 -0.64701 -1.0909 0.90351 0.49862 -0.93828 1.0385 1.0146 0.894 1.2609
LLRs (First 10): -17.784 -12.9402 -21.8186 18.0703 9.97238 -18.7657 20.7706 20.2927 17.8801 25.2175
Decoded bits (First 10): -6.6646 -8.46542 -29.2117 30.5034 33.8576 -17.0281 30.2176 9.69181 58.7143 33.7425
Warning: Decoded bits length mismatch. Adjusting...
Checking decodedBits length: 64800 expected: 64800
Parity check errors: 32397.8821
Bit errors for this frame: 32400
Frame 10:
Generated bits (First 10): 1 0 0 1 1 0 0 0 0 0
Encoded bits (First 10): 1 0 0 1 1 0 0 0 0 0
Modulated signal (First 10): 1 -1 -1 1 1 -1 -1 -1 -1 -1
Noise (First 10): 0.094342 0.39408 -0.11717 0.10951 0.22738 -0.6926 -0.2515 0.0044263 0.1448 -0.1453
Received signal (First 10): 1.0943 -0.60592 -1.1172 1.1095 1.2274 -1.6926 -1.2515 -0.99557 -0.8552 -1.1453
LLRs (First 10): 21.8868 -12.1183 -22.3434 22.1903 24.5476 -33.852 -25.0301 -19.9115 -17.104 -22.9061
Decoded bits (First 10): -9.02684 -39.5908 -45.9525 33.2943 29.8967 -41.1415 -40.5381 -22.912 -29.2062 -26.4277
Warning: Decoded bits length mismatch. Adjusting...
Checking decodedBits length: 64800 expected: 64800
Parity check errors: 32556.1841
Bit errors for this frame: 32400
SNR = 10 dB: WER = 1, BER = 1
Simulation complete.
Questions:
- Could there be an issue with my parity check matrix or decoding configuration?
- Is there a potential bug in how LLRs are passed to comm.LDPCDecoder?
- Are there additional steps I can take to verify the encoding/decoding process or resolve parity check failures?
0 comentarios
Respuestas (1)
vidyesh
el 30 de Jul. de 2025
Hi
comm.LDPCEnocder expects llr inputs so change the modulation to
modulatedSignal = 1 - 2 * double(encodedBits);
Also the decoder outputs soft values which will have to be mapped to 1s and 0s:
decodedBits = ldpcDecoder(llrs)<0;
Refer to the below post and documentation links for more details, especially the ouptut type when 'Soft Decision' is selected.
0 comentarios
Ver también
Categorías
Más información sobre Error Detection and Correction en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!