bchdec

Syntax

Description

decoded = bchdec(code,N,K)
attempts to decode the received signal in code using an
(N,K) BCH decoder with the
narrow-sense generator polynomial. Parity symbols are at the end and the leftmost
symbol is the most significant symbol.

In the decoded Galois array, each row represents the attempt
at decoding the corresponding row in code.

decoded = bchdec(code,N,K,paritypos)
specifies in paritypos whether the parity symbols in
code were appended or prepended to the message in the
coding operation.

[decoded,cnumerr] = bchdec(___)
returns a column vector, cnumerr, where each element is the
number of corrected errors in the corresponding row of code.
You can return cnumerr with either of the preceding
syntaxes.

Examples

Results of Error Correction

BCH-decode an input that has more errors per codeword than the error correcting capability of the BCH decoder. Decode a BCH coded message with two errors per codeword using a single-error correcting BCH decoder. View the effects of the error mismatch on the output codeword.

Check the number of errors per codeword a [63,57] BCH decoder is capable of correcting.

n = 63;
k = 57;
t = bchnumerr(n,k)

t = 1

The [63,57] BCH decoder is capable of correcting one error per codeword.

Create a random stream and use it to generate a GF array. Encode the message.

Increase the number of possible errors, and generate another noisy codeword.

t2 = t + 1;
noisycode2 = enc + randerr(nwords,n,1:t2);

Decode the new received codeword.

[msgRx2,numerr] = bchdec(noisycode2,n,k);

Determine if the message was properly decoded by examining the number of corrected errors, numerr. Entries of -1 correspond to decoding failures, which occur when the codeword has more errors than can be corrected for the specified [n,k] pair.

code — Encoded messageGalois array

N — Codeword lengthinteger

Codeword length, specified as an integer of the form
N =
2M–1, where
M is an integer from 3 to 16. See Tips for information about valid
N values, valid
(N,K) pairs, and error
correcting capabilities for a given BCH code.

Example: 15 for
M=4

K — Message lengthinteger

Message length, specified as an integer. N and
K must produce a narrow-sense BCH code.

Example: 5 specifies a Galois array with five
elements.

paritypos — Parity position'end' (default) | 'beginning'

Parity position, specified as 'end' or
'beginning'. Parity symbols are at the end or
beginning of each word in the output Galois array. If
paritypos is 'beginning', then a
decoding failure causes bchdec to remove
N-K symbols from the beginning
rather than the end of the row.

Output Arguments

decoded — Decoded messageGalois array of symbols over GF(2)

Decoded message, returned as a Galois array of symbols over GF(2). Each
row represents the attempt at decoding the corresponding row in
code. A decoding failure occurs if
bchdec detects more than T
errors in a row of code, where T is
the number of errors per codeword that the decoder is capable of correcting.
When a decoding failure occurs, bchdec forms the
corresponding row of decoded by removing
N-K symbols from the end of
the row of code. For more information, see Error Correcting Capability.

cnumerr — Number of corrected errorscolumn vector

Number of corrected errors in the corresponding row of
code, returned as a column vector. A value of –1 in
cnumerr indicates a decoding failure in that row in
code.

ccode — Corrected version of codeGalois array

Corrected version of code, returned as a Galois
array. ccode has the same format as the input
code. If a decoding failure occurs in a certain row
of code, the corresponding row in
ccode contains that row unchanged.

More About

Error Correcting Capability

BCH decoders correct up to a specified number of errors per
codeword based on the (N,K) pair used to
BCH encode that message. The error correcting capability, T, of a
given (N,K) pair is returned by bchnumerr. See Tips for information about valid
N values, valid
(N,K) pairs, and error correcting
capabilities for a given BCH code.

If the coded message contains more errors per codeword than the decoder is capable
of correcting, the decoder is unlikely to decode to the correct codeword. For
example, when a single-error-correcting BCH decoder (T=1) is
given an input with two errors per codeword, it decodes it to a valid codeword but
not the correct codeword. When a double-error-correcting BCH decoder
(T=2) is given an input with three errors per codeword, the
decoder sometimes decodes to an invalid codeword. The cnumerr
and ccode output provide feedback to analyze the correctness of
the decoded message.

Tips

To generate the list of valid (N,K) pairs along with
the corresponding values of the error-correction capability, run bchnumerr(N).

Valid values for N = 2M–1,
where M is an integer from 3 through 16. The maximum allowable
value of N is 65,535.

Algorithms

bchdec uses the Berlekamp-Massey decoding algorithm. For
information about this algorithm, see the works listed in References.