Shortened BCH decoding error

7 views (last 30 days)
Casey N
Casey N on 29 Nov 2022
Answered: Sachin Lodhi on 6 Oct 2023
I'm trying to BCH encode and decode using a DVB-S2 generator polynomial and a shortened message length of 38,688 bits with 192 parity bits. The decoder is giving errors = -1, indicating that the frame is uncorrectable, but the size of the data output is correct and it matches the original input data to the encoder. Where am I going wrong?
Here's my code:
N_BCH_BITS = 38880; % Nbch, codeword length, in bits
K_BCH_BITS = 38688; % Kbch, message (BBFRAME) length, in bits
N_BCH_PARITY_BITS = N_BCH_BITS - K_BCH_BITS;
% Construct generator polynomial using spec Table 6a
polyCell = {...
'1+x2+x3+x5+x16 ', ...
'1+x+x4+x5+x6+x8+x16 ',...
'1+x2+x3+x4+x5+x7+x8+x9+x10+x11+x16'...
'1+x2+x4+x6+x9+x11+x12+x14+x16 '...
'1+x+x2+x3+x5+x8+x9+x10+x11+x12+x16 '...
'1+x2+x4+x5+x7+x8+x9+x10+x12+x13+x14+x15+x16 '...
'1+x2+x5+x6+x8+x9+x10+x11+x13+x15+x16 '...
'1+x+x2+x5+x6+x8+x9+x12+x13+x14+x16 '...
'1+x5+x7+x9+x10+x11+x16 '...
'1+x+x2+x5+x7+x8+x10+x12+x13+x14+x16 '...
'1+x2+x3+x5+x9+x11+x12+x13+x16'...
'1+x+x5+x6+x7+x9+x11+x12+x16'...
};
% Multiply above polys and flip
bch_gp = fliplr( gfconv( polyCell ) );
% Create the encoder object for the DVB-S2 shortened code, based on 2^16-1
bch_encoder = comm.BCHEncoder( 65535, ( 65535 - N_BCH_PARITY_BITS ), bch_gp, K_BCH_BITS );
% Create random data bits
data_in = randi( [ 0 1 ], K_BCH_BITS, 1 );
% Encode the data bits
data_enc = bch_encoder( data_in );
% Create the decoder object for the DVB-S2 shortened code, based on 2^16-1
bch_decoder = comm.BCHDecoder( 65535, ( 65535 - N_BCH_PARITY_BITS ), bch_gp, K_BCH_BITS );
% Decode the data
[ data_dec, errors ] = bch_decoder( data_enc );
% Check for BCH-reported errors
if errors == -1
disp ( [ 'Frame had UNCORRECTABLE errors!' ] )
elseif any( errors )
disp ( [ 'Frame had ' num2str( errors ) ' CORRECTABLE errors' ] )
else
disp ( [ 'Frame had no errors' ] )
end
Frame had UNCORRECTABLE errors!
% Compare decoded data to input data
if isequal( data_dec, data_in )
disp( 'Data MATCHES' )
else
disp( 'Data DOES NOT match' )
end
Data MATCHES
Thank you!

Answers (1)

Sachin Lodhi
Sachin Lodhi on 6 Oct 2023
Hello Casey,
Based on my understanding, you encountered an error (-1) while using ‘BHCEncoder' and ‘BHCDecoder’ to encode and decode a message. However, despite the error, you noticed that the decoded message matches the input message.
It is important to note that although the size and matching of the data output are correct, it does not guarantee that the decoded output is completely error-free.
To further investigate the issue, I recommend examining the specific values of the 'err' variable and comparing the decoded message with the original message. If there are considerable number of corrected errors or if you observe decoding errors indicated by -1 values in 'err', it may indicate potential issues with the received codeword or the decoding process.
I hope this explanation helps you in troubleshooting the situation
Best regards,
Sachin

Tags

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!