Create BCH code from binary vector data
Block sublibrary of Error Detection and Correction
The BCH Encoder block creates a BCH code with message length K and codeword length (N – number of punctures). To shorten the code, specify the shortened message length, S, and full length N and K values. You specify N, K, and S directly in the dialog box.
This block accepts a column vector input signal with an integer multiple of K elements (S elements if the code is shortened). Each group of input elements represents one message word to encode. The input and output signal lengths are listed in the Input and Output Signal Length in BCH and RS Blocks table on the BCH Decoder reference page.
If the encoder is processing multiple codewords per frame, then the same puncture pattern holds for all codewords.
For codeword length N, only specific message length Ks are valid for a BCH code. For a fulllength BCH code, N must be of the form 2^{M}1, where $$3\le M\le 16$$.
No known analytic formula describes the relationship among the
codeword length, message length, and errorcorrection capability.
These tables list valid fulllength [n
,k
]
pairs for small values of n
, and the corresponding
values of the errorcorrection capability, t
.
n  k  t 

7  4  1 
n  k  t 

15  11  1 
15  7  2 
15  5  3 
n  k  t 

31  26  1 
31  21  2 
31  16  3 
31  11  5 
31  6  7 
n  k  t 

63  57  1 
63  51  2 
63  45  3 
63  39  4 
63  36  5 
63  30  6 
63  24  7 
63  18  10 
63  16  11 
63  10  13 
63  7  15 
n  k  t 

127  120  1 
127  113  2 
127  106  3 
127  99  4 
127  92  5 
127  85  6 
127  78  7 
127  71  9 
127  64  10 
127  57  11 
127  50  13 
127  43  14 
127  36  15 
127  29  21 
127  22  23 
127  15  27 
127  8  31 
n  k  t 

255  247  1 
255  239  2 
255  231  3 
255  223  4 
255  215  5 
255  207  6 
255  199  7 
255  191  8 
255  187  9 
255  179  10 
255  171  11 
255  163  12 
255  155  13 
255  147  14 
255  139  15 
255  131  18 
255  123  19 
255  115  21 
255  107  22 
255  99  23 
255  91  25 
255  87  26 
255  79  27 
255  71  29 
255  63  30 
255  55  31 
255  47  42 
255  45  43 
255  37  45 
255  29  47 
255  21  55 
255  13  59 
255  9  63 
n  k  t 

511  502  1 
511  493  2 
511  484  3 
511  475  4 
511  466  5 
511  457  6 
511  448  7 
511  439  8 
511  430  9 
511  421  10 
511  412  11 
511  403  12 
511  394  13 
511  385  14 
511  376  15 
511  367  16 
511  358  18 
511  349  19 
511  340  20 
511  331  21 
511  322  22 
511  313  23 
511  304  25 
511  295  26 
511  286  27 
511  277  28 
511  268  29 
511  259  30 
511  250  31 
511  241  36 
511  238  37 
511  229  38 
511  220  39 
511  211  41 
511  202  42 
511  193  43 
511  184  45 
511  175  46 
511  166  47 
511  157  51 
511  148  53 
511  139  54 
511  130  55 
511  121  58 
511  112  59 
511  103  61 
511  94  62 
511  85  63 
511  76  85 
511  67  87 
511  58  91 
511  49  93 
511  40  95 
511  31  109 
511  28  111 
511  19  119 
511  10  121 
You can specify the primitive and generator polynomials in their respective text boxes, which appear after selecting their corresponding check boxes.
For information about the data types each block port supports, see the Supported Data Types table.
This block supports puncturing when you select the Puncture
code parameter. This selection enables the Puncture
vector parameter, which takes in a binary vector to specify
the puncturing pattern. For a puncture vector, 1
represents
that the data symbol passes unaltered, and 0
represents
that the data symbol gets punctured, or removed, from the data stream.
This convention is carried for both the encoder and the decoder.
For more information, see Shortening, Puncturing, and Erasures.
Note:

The codeword length.
The message length.
Selecting this check box enables the Shortened message length, S text box.
The shortened message length. When you specify this property, provide fulllength N and K values to specify the (N, K) code that is shortened to an (N–K+S, S) code.
Selecting this check box enables the Generator polynomial text box.
A row vector that represents the generator polynomial as a character vector or as binary coefficients in order of descending powers.
The length of the Generator polynomial must be N–K+1.
This field defaults to 'X^10 + X^8 + X^5 + X^4 + X^2
+ X + 1'
, which is equivalent to bchgenpoly(15,5)
.
This parameter applies only when you select Specify generator polynomial.
This check box appears only when you select Specify generator polynomial.
Each time a model initializes, the block performs a polynomial check. This check verifies that X ^{N} + 1 is divisible by the userdefined generator polynomial, where N represents the full code word length. Selecting this check box disables the polynomial check. For larger codes, disabling the check speeds up the simulation process. You should always run the check at least once before disabling this feature.
Selecting this check box enables the Primitive polynomial text box.
A row vector that represents the primitive polynomial as a character vector or as binary coefficients in order of descending powers.
This field defaults to 'X^4 + X + 1'
. This
is the primitive polynomial used for a (15,5) code, de2bi(primpoly(4,'nodisplay'),'leftmsb')
.
This parameter applies only when you select Specify primitive polynomial.
Selecting this check box enables the Puncture vector text box.
A column vector of length N–K.
In the Puncture vector, a value of 1
represents
that the data symbol passes unaltered, and 0
represents
that the data symbol gets punctured, or removed, from the data stream.
The field defaults to [ones(8,1); zeros(2,1)]
.
This parameter applies only when you select Puncture code.
Port  Supported Data Types 

In 

Out 

This object implements the algorithm, inputs, and outputs described in Algorithms for BCH and RS Errorsonly Decoding.
[1] Clark, George C., Jr., and J. Bibb Cain, ErrorCorrection Coding for Digital Communications, New York, Plenum Press, 1981.