Decode data using BCH decoder
The BCHDecoder object recovers a binary message vector from a binary BCH codeword vector. For proper decoding, the codeword and message length values in this object must match the properties in the corresponding BCH Encoder block.
To decode a binary message from a BCH codeword:
H = comm.BCHDecoder creates a BCH decoder System object™, H, that performs BCH decoding.
H = comm.BCHDecoder(Name,Value) creates a BCH decoder object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).
Specify the codeword length of the BCH code as a double-precision, positive, integer scalar. The default is 15. The values of the CodewordLength and MessageLength properties must produce a valid narrow-sense BCH code. For a full-length BCH code the value of the this property must take the form .M is an integer, , that corresponds to the degree of the primitive polynomial that you specify with PrimitivePolynomialSource and PrimitivePolynomial. If the this property is less than , the object assumes a shortened code.
Specify the message length as a double-precision, positive, integer scalar. The default is 5. The values of the CodewordLength and MessageLength properties must produce a valid narrow-sense BCH code.
Source of primitive polynomial
Specify the source of the primitive polynomial as one of Auto | Property. The default is Auto. When you set this property to Auto, the object uses a primitive polynomial of degree M=ceil(log2(CodewordLength+1)). The result of fliplr(de2bi(primpoly(M))), sets the value for this polynomial. Set this property to Property to specify a polynomial using the PrimitivePolynomial property.
Specify the primitive polynomial of order M, that defines the finite Galois field GF(2) as a double-precision, binary row vector with the coefficients of the polynomial in order of descending powers. This property applies when you set the PrimitivePolynomialSource property to Property. The default is fliplr(de2bi(primpoly(4))) = [1 0 0 1 1], which corresponds to the polynomial .
Source of generator polynomial
Specify the source of the generator polynomial as one of Auto | Property. The default is Auto. When you set this property to Auto, the object chooses the generator polynomial automatically. The object calculates the generator polynomial based on the value of the PrimitivePolynomialSource property. When you set the PrimitivePolynomialSource property to Auto the object calculates the generator polynomial as bchgenpoly(CodewordLength+SL,MessageLength+SL). When you set the PrimitivePolynomialSource property to Property, the object computes generator polynomial as bchgenpoly(CodewordLength+SL,MessageLength+SL, PrimitivePolynomial). In both cases, SL = ( )-CodewordLength is the shortened length. and M is the degree of the primitive polynomial that you specify with PrimitivePolynomialSource and PrimitivePolynomial. Set this property to Property to specify a generator polynomial using the GeneratorPolynomial property.
Specify the generator polynomial as a binary, double-precision, row vector or as a binary Galois field row vector that represents the coefficients of the generator polynomial in order of descending powers. You must use CodewordLength–MessageLength+1 as the length of the generator polynomial. This property applies when you set the GeneratorPolynomialSource property to Property. The default is the result of bchgenpoly((15,5,,'double')), which corresponds to a 15,5 code.
When you use this object to generate code, you must set the generator polynomial to a binary, double precision row vector.
Enable generator polynomial checking
Set this property to true to perform a generator polynomial check the first time you call the step method. The default is true. This check verifies that xCodewordLength + 1 is divisible by the generator polynomial specified in the GeneratorPolynomial property. For larger codes, disabling the check reduces processing time. As a best practice, perform the check at least once before setting this property to false. This property applies when you set the GeneratorPolynomialSource property to Property.
Source of puncture pattern
Specify the source of the puncture pattern as one of None | Property. The default is None. Set this property to None to disable puncturing. Set this property to Property to decode punctured codewords based on a puncture pattern vector you specify in the PuncturePattern property.
Puncture pattern vector
Specify the pattern that the object uses to puncture the encoded data as a double-precision, binary, column vector of length CodewordLength-MessageLength. Zeros in the puncture pattern vector indicate the position of the parity bits that the object punctures or excludes from each codeword. This property applies when you set the PuncturePatternSource property to Property. The default is [ones(8,1); zeros(2,1)].
Enable erasures input
Set this property to true to specify a vector of erasures as a step method input. The default is false. The erasures vector is a double-precision or logical, binary, column vector that indicates which bits of the input codewords to erase or ignore. The length of the vector must equal the encoded data input, (that is, the length must be an integer multiple of (CodewordLength – number of punctures)). Values of 1 in the erasures vector correspond to erased bits in the same position of the (possibly punctured) input codewords. Set the this property to false to disable erasures.
Output number of corrected errors
Set this property to true so that the step method outputs the number of corrected errors. The default is true.
|clone||Create BCH decoder object with same property values|
|getNumInputs||Number of expected inputs to step method|
|getNumOutputs||Number of outputs from step method|
|isLocked||Locked status for input attributes and nontunable properties|
|release||Allow property value and input characteristics changes|
|step||Decode data using a BCH decoder|
% The following code transmits a BCH-encoded, 8-DPSK-modulated bit stream % through an AWGN channel. Then, the example demodulates, decodes, and counts errors. hEnc = comm.BCHEncoder; hMod = comm.DPSKModulator('BitInput',true); hChan = comm.AWGNChannel(... 'NoiseMethod','Signal to noise ratio (SNR)','SNR',10); hDemod = comm.DPSKDemodulator('BitOutput',true); hDec = comm.BCHDecoder; hError = comm.ErrorRate('ComputationDelay',3); for counter = 1:20 data = randi([0 1], 30, 1); encodedData = step(hEnc, data); modSignal = step(hMod, encodedData); receivedSignal = step(hChan, modSignal); demodSignal = step(hDemod, receivedSignal); receivedBits = step(hDec, demodSignal); errorStats = step(hError, data, receivedBits); end fprintf('Error rate = %f\nNumber of errors = %d\n', ... errorStats(1), errorStats(2))
Error rate = 0.015075 Number of errors = 9
This object implements the algorithm, inputs, and outputs described on the BCH Decoder block reference. The object properties correspond to the block parameters.