Encode data using BCH encoder
The BCHEncoder object creates a BCH code with specified message and codeword lengths.
To encode data using a BCH coding scheme:
H = comm.BCHEncoder creates a BCH encoder System object™, H, that performs BCH encoding.
H = comm.BCHEncoder(Name,Value) creates a BCH encoder 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 use the form . In this case, M is an integer, and corresponds to the degree of the primitive polynomial that you specify with the PrimitivePolynomialSource and PrimitivePolynomial properties. If the this property is less than , the object assumes a shortened code form.
Specify the message length as a double-precision, positive, integer scalar. The values of the CodewordLength and MessageLength properties must produce a valid narrow-sense BCH code. The default is 5.
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). Use 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 computes the generator polynomial based on the value of the PrimitivePolynomialSource property. When you set the PrimitivePolynomialSource property to Auto the object computes 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. M indicates the degree of the primitive polynomial that you specify with the PrimitivePolynomialSource and PrimitivePolynomial properties. Set this property to Property to specify a generator polynomial using the GeneratorPolynomial property.
Specify the generator polynomial for encoding as a binary, double-precision row vector or as a binary Galois row vector that represents the coefficients of the generator polynomial in order of descending powers. The length of the generator polynomial requires a value of CodewordLength-MessageLength+1. 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.
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 CodewordLength + 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. This decoding is 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. Use 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)].
|clone||Create BCH encoder 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||Encode data using a BCH encoder|
% 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 Encoder block reference page. The object properties correspond to the block parameters.