TurboEncoder#

class sionna.phy.fec.turbo.TurboEncoder(gen_poly: Tuple[str, ...] | None = None, constraint_length: int = 3, rate: float = 0.3333333333333333, terminate: bool = False, interleaver_type: str = '3GPP', precision: str | None = None, device: str | None = None, **kwargs)[source]#

Bases: sionna.phy.block.Block

Performs encoding of information bits to a Turbo code codeword.

Implements the standard Turbo code framework [Berrou]: Two identical rate-1/2 convolutional encoders ConvEncoder are combined to produce a rate-1/3 Turbo code. Further, puncturing to attain a rate-1/2 Turbo code is supported.

Parameters:
  • gen_poly (Tuple[str, ...] | None) – Tuple of strings with each string being a 0,1 sequence. If None, constraint_length must be provided.

  • constraint_length (int) – Valid values are between 3 and 6 inclusive. Only required if gen_poly is None.

  • rate (float) – Valid values are 1/3 and 1/2. Note that rate here denotes the design rate of the Turbo code. If terminate is True, a small rate-loss occurs.

  • terminate (bool) – Underlying convolutional encoders are terminated to all zero state if True. If terminated, the true rate of the code is slightly lower than rate.

  • interleaver_type (str) – Determines the choice of the interleaver to interleave the message bits before input to the second convolutional encoder. Valid values are “3GPP” or “random”. If “3GPP”, the Turbo code interleaver from the 3GPP LTE standard [3GPPTS36212] is used. If “random”, a random interleaver is used.

  • precision (str | None) – Precision used for internal calculations and outputs. If None, precision is used.

  • device (str | None) – Device for computation (e.g., ‘cpu’, ‘cuda:0’). If None, device is used.

Inputs:

inputs – […, k], torch.float. Tensor of information bits where k is the information length.

Outputs:

cw – […, k/rate], torch.float. Tensor where rate is provided as input parameter. The output is the encoded codeword for the input information tensor. When terminate is True, the effective rate of the Turbo code is slightly less than rate.

Notes

Various notations are used in literature to represent the generator polynomials for convolutional codes. For simplicity TurboEncoder only accepts the binary format, i.e., 10011, for the gen_poly argument which corresponds to the polynomial \(1 + D^3 + D^4\).

Note that Turbo codes require the underlying convolutional encoders to be recursive systematic encoders. Only then the channel output from the systematic part of the first encoder can be used to decode the second encoder.

Also note that constraint_length and memory are two different terms often used to denote the strength of the convolutional code. In this sub-package we use constraint_length. For example, the polynomial 10011 has a constraint_length of 5, however its memory is only 4.

When terminate is True, the true rate of the Turbo code is slightly lower than rate. It can be computed as \(\frac{k}{\frac{k}{r}+\frac{4\mu}{3r}}\) where r denotes rate and \(\mu\) is the constraint_length - 1. For example, in 3GPP, constraint_length = 4, terminate = True, for rate = 1/3, true rate is equal to \(\frac{k}{3k+12}\).

Examples

import torch
from sionna.phy.fec.turbo import TurboEncoder

encoder = TurboEncoder(rate=1/3, constraint_length=4, terminate=True)
u = torch.randint(0, 2, (10, 40), dtype=torch.float32)
c = encoder(u)
print(c.shape)
# torch.Size([10, 132])

Attributes

property gen_poly: Tuple[str, ...]#

Generator polynomial used by the encoder.

property constraint_length: int#

Constraint length of the encoder.

property coderate: float#

Rate of the code used in the encoder.

property trellis: sionna.phy.fec.conv.utils.Trellis#

Trellis object used during encoding.

property terminate: bool#

Indicates if the convolutional encoders are terminated.

property punct_pattern: torch.Tensor | None#

Puncturing pattern for the Turbo codeword.

property k: int | None#

Number of information bits per codeword.

property n: int | None#

Number of codeword bits.

property internal_interleaver: sionna.phy.fec.interleaving.Turbo3GPPInterleaver | sionna.phy.fec.interleaving.RandomInterleaver#

Internal interleaver used for the second encoder.

Methods

build(input_shape: tuple) None[source]#

Build block and check dimensions.

Parameters:

input_shape (tuple) – Shape of input tensor (…, k).