Documentation

comm.BCHEncoder System object

Package: comm

Encode data using BCH encoder

Description

The BCHEncoder object creates a BCH code with specified message and codeword lengths.

To encode data using a BCH coding scheme:

  1. Define and set up your BCH encoder object. See Construction.

  2. Call step to create a BCH code with message and codeword lengths specified according to the properties of comm.BCHEncoder. The behavior of step is specific to each object in the toolbox.

Construction

enc = comm.BCHEncoder creates a BCH encoder System object™, enc, that performs BCH encoding.

enc = comm.BCHEncoder(N,K) creates a BCH encoder object, enc, with the CodewordLength property set to N and the MessageLength property set to K.

enc = comm.BCHEncoder(N,K,GP) creates a BCH encoder object, enc, with the CodewordLength property set to N, the MessageLength property set to K and the GeneratorPolynomial property set to GP.

enc = comm.BCHEncoder(N,K,GP,S) creates a BCH encoder object, enc, with the CodewordLength property set to N, the MessageLength property set to K, the GeneratorPolynomial property set to GP and the ShortMessageLength property set to S.

enc = comm.BCHEncoder(N,K,GP,S,Name,Value) creates a BCH encoder object, enc, with the CodewordLength property set to N, the MessageLength property set to K, the GeneratorPolynomial property set to GP, the ShortMessageLength property set to S, and each specified property Name set to the specified Value.

enc = comm.BCHEncoder(Name,Value) creates a BCH encoder object, enc, 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).

Properties

CodewordLength

Codeword length

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 property must use the form 2M1, where M is an integer such that 3M16. The default is 15.

MessageLength

Message length

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.

ShortMessageLengthSource

Short message length source

Specify the source of the shortened message as either Auto or Property. When this property is set to Auto, the BCH code is defined by the CodewordLength, MessageLength, GeneratorPolynomial, and PrimitivePolynomial properties. When ShortMessageLengthSource is set to Property, you must specify the ShortMessageLength property that is used with the other properties to define the RS code. The default is Auto.

ShortMessageLength

Shortened message length

Specify the length of the shortened message as a double-precision positive integer scalar whose value must be less than or equal to MessageLength. When ShortMessageLength < MessageLength, the BCH code is shortened. The default is 5.

GeneratorPolynomialSource

Source of generator polynomial

Specify the source of the generator polynomial as either Auto or Property. Set this property to Auto to create the generator polynomial automatically. Set it to Property to specify a generator polynomial using the GeneratorPolynomial  property. The default is Auto.

GeneratorPolynomial

Generator polynomial

Specify the generator polynomial for encoding as a binar, 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 GeneratorPolynomialSource to Property. The default is the result of bchgenpoly(15,5,[],'double'), which corresponds to a (15,5) code.

CheckGeneratorPolynomial

Enable generator polynomial checking

Set this property to true to perform a generator polynomial check the first time you call the step method. This check verifies that the specified generator polynomial is valid. 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  GeneratorPolynomialSource   to Property. The default is true.

PrimitivePolynomialSource

Source of primitive polynomial

Specify the source of the primitive polynomial as one of Auto or Property. Set this property to Auto to create a primitive polynomial of degree M=ceil(log2(CodewordLength+1)). Set it to Property to specify a polynomial using the PrimitivePolynomial property. The default is Auto

PrimitivePolynomial

Primitive polynomial

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 x4+x+1.

PuncturePatternSource

Source of puncture pattern

Specify the source of the puncture pattern as one of None or Property. Set this property to None to disable puncturing. Set it to Property to decode punctured codewords. This decoding is based on a puncture pattern vector you specify in the PuncturePattern property. The default is None.

PuncturePattern

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 PuncturePatternSource to Property. The default is [ones(8,1); zeros(2,1)].

Methods

cloneCreate BCH encoder object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
stepEncode data using a BCH encoder

Examples

collapse all

Transmit and decode an 8-DPSK-modulated signal, then count errors

% The following code transmits a BCH-encoded, 8-DPSK-modulated bit stream
% through an AWGN channel.  Then, the example demodulates, decodes, and counts errors.

enc = comm.BCHEncoder;
mod = comm.DPSKModulator('BitInput',true);
chan = comm.AWGNChannel(...
         'NoiseMethod','Signal to noise ratio (SNR)','SNR',10);
demod = comm.DPSKDemodulator('BitOutput',true);
dec = comm.BCHDecoder;
errorRate = comm.ErrorRate('ComputationDelay',3);

for counter = 1:20
  data = randi([0 1], 30, 1);
  encodedData = step(enc, data);
  modSignal = step(mod, encodedData);
  receivedSignal = step(chan, modSignal);
  demodSignal = step(demod, receivedSignal);
  receivedBits = step(dec, demodSignal);
  errorStats = step(errorRate, data, receivedBits);
end

fprintf('Error rate = %f\nNumber of errors = %d\n', ...
  errorStats(1), errorStats(2))
Error rate = 0.015075
Number of errors = 9

Transmit and receive a BPSK-modulated signal

Transmit and receive a BPSK-modulated signal encoded with a shortened BCH code, then count errors.

N = 255;
K = 239;
S = 63;
gp = bchgenpoly(255,239);
enc = comm.BCHEncoder(N, K, gp, S); % BCH code in AMR standard
mod = comm.BPSKModulator;
chan = comm.AWGNChannel(...
   'NoiseMethod','Signal to noise ratio (SNR)','SNR', 5);
demod = comm.BPSKDemodulator;
dec = comm.BCHDecoder(N, K, gp, S);
errorRate = comm.ErrorRate('ComputationDelay',3);

for counter = 1:20
  data = randi([0 1], 630, 1);
  encodedData = step(enc, data);
  modSignal = step(mod, encodedData);
  receivedSignal = step(chan, modSignal);
  demodSignal = step(demod, receivedSignal);
  receivedBits = step(dec, demodSignal);
  errorStats = step(errorRate, data, receivedBits);
end

fprintf('Error rate = %f\nNumber of errors = %d\n', ...
  errorStats(1), errorStats(2))
Error rate = 0.000318
Number of errors = 4

Algorithms

This object implements the algorithm, inputs, and outputs described in Algorithms for BCH and RS Errors-only Decoding.

Selected Bibliography

[1] Clark, George C. Jr., and J. Bibb Cain, Error-Correction Coding for Digital Communications. New York, Plenum Press, 1981.

[2] Wicker, Stephen B., Error Control Systems for Digital Communication and Storage Upper Saddle River, NJ, Prentice Hall, 1995.

Was this topic helpful?