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.BlockPerforms encoding of information bits to a Turbo code codeword.
Implements the standard Turbo code framework [Berrou]: Two identical rate-1/2 convolutional encoders
ConvEncoderare 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_lengthmust be provided.constraint_length (int) – Valid values are between 3 and 6 inclusive. Only required if
gen_polyis None.rate (float) – Valid values are 1/3 and 1/2. Note that
ratehere denotes the design rate of the Turbo code. Ifterminateis 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,
precisionis used.device (str | None) – Device for computation (e.g., ‘cpu’, ‘cuda:0’). If None,
deviceis 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
terminateis True, the effective rate of the Turbo code is slightly less thanrate.
Notes
Various notations are used in literature to represent the generator polynomials for convolutional codes. For simplicity
TurboEncoderonly accepts the binary format, i.e., 10011, for thegen_polyargument 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_lengthandmemoryare two different terms often used to denote the strength of the convolutional code. In this sub-package we useconstraint_length. For example, the polynomial 10011 has aconstraint_lengthof 5, however itsmemoryis only 4.When
terminateis True, the true rate of the Turbo code is slightly lower thanrate. It can be computed as \(\frac{k}{\frac{k}{r}+\frac{4\mu}{3r}}\) where r denotesrateand \(\mu\) is theconstraint_length- 1. For example, in 3GPP,constraint_length= 4,terminate= True, forrate= 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 trellis: sionna.phy.fec.conv.utils.Trellis#
Trellis object used during encoding.
- property punct_pattern: torch.Tensor | None#
Puncturing pattern for the Turbo codeword.
- property internal_interleaver: sionna.phy.fec.interleaving.Turbo3GPPInterleaver | sionna.phy.fec.interleaving.RandomInterleaver#
Internal interleaver used for the second encoder.
Methods