Interleaving

The term interleaving describes the channel process of exchanging the bit positions during coding. This is usually being done in order to distribute the bit errors resulting from a wrong symbol decision during waveform demodulation over the communication data frame. Therefore, most interleaving coding operations do not introduce redundancy to the interleaved blocks, i.e. the code rate is \(R = 1\).

class BlockInterleaver(block_size, interleave_blocks)[source]

Bases: Encoder, Serializable

An encoding operation interleaving bits in a block-wise fashion.

During encoding, the block interleaver divides a block of \(K_n\) bit_block_size() bits into \(\tilde{M}\) interleave_blocks() of length \(\tilde{K}\). Let

\[\mathbf{x} = \left[ x_1, x_2, \dots, x_{K_n} \right]^\intercal \in \left\lbrace 0, 1 \right\rbrace^{K_n}\]

be the vector of input bits and

\[\mathbf{y} = \left[ y_1, y_2, \dots, y_{K_n} \right]^\intercal \in \left\lbrace 0, 1 \right\rbrace^{K_n}\]

be the vector of interleaved output bits, then

\[y_k = x_{(k \cdot \tilde{M}) \mod{K_n}}\]

describes the block interleaving scheme.

Parameters:
  • block_size (int) – The input / output number of bits the interleaver requires / generates.

  • interleave_blocks (int) – The number of sections being interleaved.

Raises:

ValueError – If block_size is not dividable into interleave_blocks.

decode(encoded_bits)[source]

Decodes a single block of bits.

Bit decoding routine during data reception, decoding a block of \(L_n\) code bits into a block of \(K_n\) data bits.

Parameters:

encoded_bits (numpy.ndarray) – A numpy vector of \(L_n\) code bits, representing a single code block to be decoded.

Returns:

A numpy vector of \(K_n\) bits, representing a single data block.

Return type:

np.ndarray

Raises:

ValueError – If the length of encoded_bits does not equal code_block_size().

encode(bits)[source]

Encodes a single block of bits.

Bit encoding routine during data transmission, encoding a block of \(K_n\) input bits into a block of \(L_n\) code bits.

Parameters:

bits (numpy.ndarray) – A numpy vector of \(K_n\) bits, representing a single bit block to be encoded.

Returns:

A numpy vector of \(L_n\) bits, representing a single code block.

Return type:

np.ndarray

Raises:

ValueError – If the length of bits does not equal bit_block_size().

property bit_block_size: int

Data bit block size of a single coding operation.

In other words, the number of input bits within a single code block during transmit encoding, or the number of output bits during receive decoding. Referred to as \(K_n\) within the respective equations.

Returns: Number of bits \(K_n\).

property block_size: int

The configured block size.

Returns:

The number of bits per block.

Return type:

int

property code_block_size: int

Code bit block size of a single coding operation.

In other words, the number of input bits within a single code block during receive decoding, or the number of output bits during transmit encoding. Referred to as \(L_n\) within the respective equations.

Returns: Number of bits \(L_n\).

property interleave_blocks: int

The number of sub-blocks in which which the input block is divided.

Returns:

The number of interleaved sections \(\tilde{M}\).

Return type:

int

Raises:

ValueError – If the number of interleaved sections is less than one.

property rate: float

Code rate achieved by this coding step.

Defined as the relation

\[R_n = \frac{K_n}{L_n}\]

between the bit_block_size() \(K_n\) and code_block_size() \(L_n\).

Returns:

The code rate \(R_n\)

Return type:

float

yaml_tag: Optional[str] = 'BlockInterleaver'

YAML serialization tag.