Code Block Segmentation

Codeblock segmentation allows the physical layer to process large transport blocks to make the best use of the capabilities of the encoder and decoders. To make the best use of the structure of the LDPC codes the inputs shall be passed in a certain format with the bound on the upper limit of the inputs that LDPC codec can process. In case transport block sizes exceed the upper limit, it is broken into multiple smaller sub-blocks called codeblocks which are individually processed by LDPC encoder/decoder and ratemater/dematcher at transmitter and receiver respectively. The implementations are discussed in details in upcoming sub-sections.

Codeblock Segmentation: Transmitter

The codeblock segmentation breaks the large transport block into small codeblock which are processed individually a defined in Section 5.3.2 of [3GPPTS38212_LDPC]. The example demonstrate a way to use the CodeBlockSegmentation module.

coderate = 0.650390625 #Code Rate
#crcTBlock ---> Transport Block with CRC bits attached

cbSegment   = CodeBlockSegmentation(coderate) # Object for processing the code blocks
codeblocks  = cbSegment(crcTBlock) # Attach the segment the TB and attach the CRC to TB based on 38.212

The API for codeblock segmentation is as follows.

class toolkit5G.ChannelCoder.LDPC.CodeBlockSegmentation(codeRate)[source]

Implements code block segmentation for the Low Density Parity Check coding. The transport block is segmented into multiple code-blocking which are individually channel coded and rate-matched for efficiency and scale. The details are provide in section 5.2.2 of [3GPPTS38212_LDPC].

Parameters:

codeRate (float) – Target Code Rate. It takes any value between 0 and 1. The codeRate for 5G is extracted from mciIndex and computed using ComputeTransportBlockSize.

Input:

inputBits ([…,B] where B (=A+L) is the size of processed transport block.) – Processed transport Block. Processed transport block contains transport block bits (A) and 24 (L) or 16 (L) bit CRC attachment.

Output:

[\(\dots, \text{N}_\text{cb}, \text{K}\)], np.float32 – Returns \(\text{N}_\text{cb}\) code-blocks each of size \(\text{K}\) where \(\text{K}\) contains K’-L’ information bits, L’ CRC bits and K-K’ zeros.

Raises:
  • ValueError – “[Error-CodeBlockSegregation]: inputBits should either be an array of int ot float”

  • ValueError – “[Error:CodeBlockSegmentation]: ‘Kbar’ can not be larger than ‘K’!”

  • ValueError – “[Error-CodeBlockSegmentation]: ‘codeRate’ should either be an float!”

  • ValueError – “[Error-CodeBlockSegmentation]: ‘codeRate’ should be in (0,1]!”

  • ValueError – “[Error-CodeBlockSegmentation]: ‘Inputsize’ should either be an int!”

  • ValueError – “[Error-CodeBlockSegmentation]: ‘Inputsize’ should be non-zero +ve number!”

property B

Int type. Defines the Input Bit Sequence Length.

property C

Total number of code blocks for LPDC codec

property K

Defines the size of each code block.

property Kb

Int type. Defines the maximum code-block size.

property Kbar

Int type. Defines the number of information bits + CRC attached, denotes by K’ in section 5.2.2 of [3GPPTS38212_LDPC].

property L

Int type. Defines the number of CRC bits attached to each codeblock.

property Zc

Int type. Defines the minimum lifting size to be used for LDPC encoding/decoding.

property baseGraph

Str type. This function returns base graph selection based on the Transport Block size and Code rate with reference to 3GPP TS 38.212 Section 5.2.2.

property codeRate

Float type. Target Code Rate. It takes any value between 0 and 1. The codeRate for 5G is extracted from mciIndex and computed using ComputeTransportBlockSize.

Code Block Aggregation: Receiver

It performs opposite of code-block segmentation at the receiver to reconstruct the transport block to pass it for transport block processing at receiver before forwarding to MAC layer. Example is understand the usage is shown below.

coderate = 0.650390625 #Code Rate
#tbLen ---> Transport Block size
#decBits ---> LDPC Decoded Block

cbAggregate = CodeBlockAggregation(coderate, tbLen) #Object that performs Code Block Aggregation
rTBwithCRC  = cbAggregate(decBits) #Output after Code Block Aggregation

The details of the API of codeblock aggregation is shown below:

class toolkit5G.ChannelCoder.LDPC.CodeBlockAggregation(codeRate, tbsize)[source]

This class aggregates all the code blocks segmented (opposite of code block segmentation) to process for forward error correction.

Parameters:
  • codeRate (float) – Target Code Rate. It takes any value between 0 and 1. The codeRate for 5G is extracted from mciIndex and computed using ComputeTransportBlockSize.

  • tbSize (int) – Transport Block Size. It can be computed using ComputeTransportBlockSize.

Input:

inputBits ([\(\dots, \text{N}_\text{cb}, \text{K}\)], np.float32) – code-blocks, where \(\text{N}_\text{cb}\) defines the number of code blocks and \(\text{K}\) defines the length of LDPC encoded code-block.

Output:

[ \(\dots, \text{N}_\text{cb} \times \text{K'}\)] – returns the transport block having a size \(\text{N}_\text{cb} \times \text{K'}\) where \(\text{K'}\): includes code block CRC and few 0s. The detailed relation between \(\text{K'}\) and \(\text{K}\) is defined in section 5.2.2 of [3GPPTS38212_LDPC].

Raises:
  • ValueError – “[Error-CodeBlockAggregation]: ‘inputBits’ must be an Numpy array of numbers!”

  • ValueError – “[Error-CodeBlockSegmentation]: ‘codeRate’ should either be an float!”

  • ValueError – “[Error-CodeBlockSegmentation]: ‘codeRate’ should be in (0,1]!”

  • ValueError – “[Error-CodeBlockAggregation]: ‘tbSize’ should either be an int!”

  • ValueError – “[Error-CodeBlockAggregation]: ‘tbSize’ should be non-zero +ve number!”

property C

Defines the number of codeblock. Details of computation of C is provided in section 5.2.2 of [3GPPTS38212_LDPC].

property Kbar

Integer type, defines the size of each code-block K’ as detailed in section 5.2.2 of [3GPPTS38212_LDPC].

property Kcb

Defines the maximum code-block size (\(\text{K}_\text{cb}\)). Details of computation of Kcb is provided in section 5.2.2 of [3GPPTS38212_LDPC].

property baseGraph

str type, defines the base graph used for LDPC coding as detailed in section 5.2.2 of [3GPPTS38212_LDPC].

property codeRate

float type, defines target code rate providing a measure of the redundancy which is added by the Physical layer to transport block.

property crcType

Defines the CRC type for code-block error detection.

property tbSize

int type, defines transport-block size. Transport Block is a packet of data which is passed between the MAC and Physical layers.