tpcenc
Turbo product code (TPC) encoder
Description
performs 2-D TPC encoding of the input message, code
= tpcenc(msg
,N
,K
)msg
, using two
linear block codes specified by codeword length N
and message
length K
. For a description of 2-D TPC encoding, see Turbo Product Code Construction.
Examples
Encode Using Full-Length TPC Codes
Encode a random bit vector using 2-D turbo product coding (TPC) with extended Hamming codes and extended BCH codes.
Specify (N,K) code pairs for TPC encoding.
N = [32;64]; K = [21;57];
Generate a column vector of random message bits. The desired length for the message bits is the product of elements in K
.
msg = randi([0 1],prod(K),1);
TPC-encode the message.
code = tpcenc(msg,N,K);
Verify that the length of the encoded codeword is the product of elements in N
.
size(code)
ans = 1×2
2048 1
prod(N)
ans = 2048
Encode Shortened Message Using Turbo Product Coding
Encode a random bit vector using 2-D turbo product coding (TPC), applying message shortening.
Specify (N,K) code pairs and S for TPC encoding.
N = [32;64]; K = [21;57]; S = [19;24];
Generate a column vector of random message bits. The desired length for the shortened message bits is the product of the elements in S
.
msg = randi([0 1],prod(S),1);
TPC-encode the shortened message.
code = tpcenc(msg,N,K,S);
Verify that the length of the encoded codeword is the product of elements in (N-K+S
).
size(code)
ans = 1×2
930 1
prod(N-K+S)
ans = 930
Input Arguments
msg
— Input message bits to encode
column vector
Input message bits to encode, specified as a column vector.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| logical
N
— Codeword length
two-element integer vector
Codeword length, specified as a two-element integer vector, [NR; NC]. NR represents the number of rows in the product code matrix. NC represents the number of columns in the product code matrix. For more information about NR and NC, see Turbo Product Code Construction. For a list of valid (N(i),K(i)) code pairs, see Component Codes.
Data Types: double
K
— Message length
two-element integer vector
Message length, specified as a two-element integer vector, [KR; KC]. For a full-length message, the input column vector containing the message bits to encode is arranged into a KR-by-KC matrix. KR represents the number of rows in the message matrix. KC represents the number of columns in the message matrix. For more information about KR and KC, see Turbo Product Code Construction. For a list of valid (N(i),K(i)) code pairs, see Component Codes.
Data Types: double
S
— Shortened message length
two-element integer vector
Shortened message length, specified as a two-element integer vector, [SR; SC]. For a shortened message, the input column vector containing the message bits to encode is arranged into an SR-by-SC matrix. SR represents the number of rows in the matrix. SC represents the number of columns in the matrix. For more information about SR and SC, see Turbo Product Code Construction.
When you specify this parameter, specify N and K vectors for the full-length TPC codes that are shortened to (N(i)–K(i)+S(i), S(i)) codes.
Data Types: double
Output Arguments
code
— TPC-encoded message
column vector
TPC-encoded message, returned as a column vector with the same data type as the input message bits.
More About
Component Codes
This table lists the supported component code pairs for the row (NR,KR) and column (NC,KC) parameters.
NR and KR represent the number of rows in the product code matrix and message matrix, respectively.
NC and KC represent the number of columns in the product code matrix and message matrix, respectively.
Within each code type, any two component code pairs can form a 2-D TPC code. The table also includes the error-correction capability for each code pair.
Code type | Component Code Pairs(NR,KR) and (NC,KC) | Error-Correction Capability (T) |
Hamming code | (255,247) | 1 |
(127,120) | 1 | |
(63,57) | 1 | |
(31,26) | 1 | |
(15,11) | 1 | |
(7,4) | 1 | |
Extended Hamming code | (256,247) | 1 |
(128,120) | 1 | |
(64,57) | 1 | |
(32,26) | 1 | |
(16,11) | 1 | |
(8,4) | 1 | |
BCH code | (255,239) | 2 |
(127,113) | 2 | |
(63,51) | 2 | |
(31,21) | 2 | |
(15,7) | 2 | |
Extended BCH code | (256,239) | 2 |
(128,113) | 2 | |
(64,51) | 2 | |
(32,21) | 2 | |
(16,7) | 2 | |
Parity check code | (256,255) | - |
(128,127) | - | |
(64,63) | - | |
(32,31) | - | |
(16,15) | - | |
(8,7) | - | |
(4,3) | - |
Turbo Product Code Construction
Turbo product codes (TPC) are a form of concatenated codes used as forward error-correcting (FEC) codes. Two or more component block codes, such as systematic linear block codes, are used to construct TPCs. This encoder implements 2-D product code encoding, as described in [1], using two Linear Block Codes.
The TPC encoder accepts either full-length or shortened messages.
Construction of Full-Length Message Product Codes
Full-length input messages are encoded using specified 2-D TPC code pairs. Row-wise encoding uses the (NC,KC) code pair and column-wise encoding uses the (NR,KR) code pair. The input vector length must be KR · KC. The input message bits vector is arranged into a KR-by-KC matrix.
Row-wise encoding uses an (NC,KC) systematic linear block encoder with KC bits per row. The row-wise encoding results in a KR-by-NC matrix that includes parity bits added to each row.
Next, column-wise encoding uses an (NR,KR) systematic linear block encoder on each of the NC columns. Applying this 2-D TPC encoding to the initial KR-by-KC matrix results in an NR-by-NC matrix that includes parity bits added to each row and column.
The 2-D TPC full-code matrix is reshaped into a column vector of length NR · NC and returned as the TPC-encoded output.
Construction of Shortened Message Product Codes
Shortened input messages are encoded using specified 2-D TPC code pairs. Row-wise encoding uses the (NC,KC) code pair and column-wise encoding uses an (NR,KR) code pair. The input vector length must be SR · SC. The input shortened message bits vector is arranged into an SR-by-SC matrix. The shortened message matrix prepends two dimensions by padding the beginning of the message matrix with zeros. The resulting matrix is a KR-by-KC matrix.
Row-wise encoding uses an (NC,KC) systematic linear block encoder with KC bits per row. The row-wise encoding results in a KR-by-NC matrix that includes parity bits added to each row.
Next, the column-wise encoding uses an (NR,KR) systematic linear block encoder on each of the NC columns.
Applying this 2-D TPC encoding to the initial KR-by-KC matrix and excluding the zero-padded bits from the output results in an (NR–KR+SR)-by-(NC–KC+SC) matrix. This matrix includes parity bits added to each row and column.
The 2-D TPC shortened-code matrix is reshaped into a column vector of length (NR–KR+SR) · (NC–KC+SC) and returned as the TPC-encoded output.
References
[1] Pyndiah, R. M. "Near-Optimum Decoding of Product Codes: Block Turbo Codes." IEEE Transactions on Communications. Volume 46, Number 8, August 1998, pp. 1003–1010.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
TPC parameters
N
,K
, andS
must be constant values. If the value used for each of these parameters does not change, then you can assign them by expression or variable.
Version History
Introduced in R2018a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)