简体   繁体   English

如何解码 LDPC

[英]How to decode LDPC

I generate a parity matrix, and use comm.LDPCEncoder to encode codeword.我生成一个奇偶校验矩阵,并使用 comm.LDPCEncoder 对码字进行编码。 But, when I use comm.LDPCDecoder to decode the LLR, the decoded word is different with the source.但是,当我使用 comm.LDPCDecoder 解码 LLR 时,解码后的字与源不同。 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);看起来LLR = double(msg_coded); is the source of the problem.是问题的根源。

I am not a communication expert, and never used LDPC encoder and decoder.我不是通信专家,从未使用过 LDPC 编码器和解码器。
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.我尝试了 MATLAB 代码示例,看到调制解调后, 1 s(1)得到负值, 0 s(0)得到正值。

Instead of LLR = double(msg_coded);而不是LLR = double(msg_coded);
You can use the following conversion: LLR = 1 - double(msg_coded)*2;您可以使用以下转换: 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):这是我用于查找问题的调制和解调代码(基于 MATLAB 示例):

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?为什么要将逻辑编码数据转换为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)));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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