简体   繁体   中英

How to decode LDPC

I generate a parity matrix, and use comm.LDPCEncoder to encode codeword. But, when I use comm.LDPCDecoder to decode the LLR, the decoded word is different with the source. Could you help me find out where is wrong?

K = 4;N = 8;
H1 =  [0 0 0 1 1 0 1 1;
    0 0 0 0 1 1 0 0
    1 1 0 0 0 0 0 1
    0 0 1 0 0 1 0 1];
H = sparse(H1);
hEnc = comm.LDPCEncoder(H);
hDec = comm.LDPCDecoder(H);
msg_source = logical(randi([0 1], K, 1));
msg_coded = step(hEnc, msg_source);  
LLR = double(msg_coded);
msg_decoded = step(hDec,LLR);
errors = (sum(xor(msg_source,msg_decoded)));

Thank you so much.

It looks like LLR = double(msg_coded); is the source of the problem.

I am not a communication expert, and never used LDPC encoder and decoder.
I tried MATLAB code sample, and saw that after modulation and demodulation, the 1 s (ones) gets negative values, and the 0 s (zeros) get positive values.

Instead of LLR = double(msg_coded);
You can use the following conversion: LLR = 1 - double(msg_coded)*2; .
0 --> 1
1 --> -1

Here is the modified code:

K = 4;N = 8;
H1 =  [0 0 0 1 1 0 1 1;
    0 0 0 0 1 1 0 0
    1 1 0 0 0 0 0 1
    0 0 1 0 0 1 0 1];
H = sparse(H1);
hEnc = comm.LDPCEncoder(H);
hDec = comm.LDPCDecoder(H);
msg_source = logical(randi([0 1], K, 1));
msg_coded = step(hEnc, msg_source);  
%LLR = double(msg_coded);

%Convert from logical to double where 0 goes to -1 and 1 goes to 1.
LLR = 1 - double(msg_coded)*2;
msg_decoded = step(hDec,LLR);
errors = (sum(xor(msg_source,msg_decoded)));

Here is the code with modulation and demodulation I used for finding the problem (based on MATLAB example):

K = 4;N = 8;
H1 =  [0 0 0 1 1 0 1 1;
    0 0 0 0 1 1 0 0
    1 1 0 0 0 0 0 1
    0 0 1 0 0 1 0 1];
H = sparse(H1);
hEnc = comm.LDPCEncoder(H);
hDec = comm.LDPCDecoder(H);

hMod = comm.PSKModulator(4, 'BitInput',true);
hChan = comm.AWGNChannel(...
        'NoiseMethod','Signal to noise ratio (SNR)','SNR',10);
hDemod = comm.PSKDemodulator(4, 'BitOutput',true,...
        'DecisionMethod','Approximate log-likelihood ratio', ...
        'Variance', 1/10^(hChan.SNR/10));

msg_source = logical(randi([0 1], K, 1));
msg_coded = step(hEnc, msg_source);  

modSignal      = step(hMod, msg_coded);
receivedSignal = step(hChan, modSignal);
demodSignal    = step(hDemod, receivedSignal);
msg_decoded   = step(hDec, demodSignal);

errors = (sum(xor(msg_source,msg_decoded)));

Why do you convert the logical coded data to double? Try to decode just after the coding:

K = 4;N = 8;
H1 =  [0 0 0 1 1 0 1 1;
    0 0 0 0 1 1 0 0
    1 1 0 0 0 0 0 1
    0 0 1 0 0 1 0 1];
H = sparse(H1);
hEnc = comm.LDPCEncoder(H);
hDec = comm.LDPCDecoder(H);
msg_source = logical(randi([0 1], K, 1));
msg_coded = step(hEnc, msg_source);  
msg_decoded = step(hDec,LLR);
errors = (sum(xor(msg_source,msg_decoded)));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM