TransportBlockNR#

class sionna.phy.nr.utils.TransportBlockNR(*args: Any, precision: Literal['single', 'double'] | None = None, device: str | None = None, **kwargs: Any)[source]#

Bases: sionna.phy.utils.misc.TransportBlock

Computes the number and size (measured in number of bits) of code blocks within a 5G-NR compliant transport block, given the modulation order, coderate and the total number of coded bits of a transport block. Used in PHYAbstraction. Inherits from TransportBlock and wraps calculate_tb_size().

Inputs:
  • modulation_order – […], torch.int32. Modulation order, i.e., number of bits per symbol, associated with the input MCS index.

  • target_rate – […], torch.float32. Target coderate.

  • num_coded_bits – […], torch.int32. Total number of coded bits across all codewords.

Outputs:
  • cb_size – […], torch.int32. Code block (CB) size, i.e., the number of information bits per code block.

  • num_cb – […], torch.int32. Number of code blocks that the transport block is segmented into.

Parameters:
  • args (Any)

  • precision (Literal['single', 'double'] | None)

  • device (str | None)

  • kwargs (Any)

Examples

from sionna.phy.nr.utils import TransportBlockNR
import torch

tb = TransportBlockNR()
# Scalar input
cb_size, num_cb = tb(modulation_order=4, target_coderate=0.5,
                     num_coded_bits=4800)
print(f"CB size: {cb_size}, Num CBs: {num_cb}")

# Tensor input
mod_orders = torch.tensor([4, 6, 4])
rates = torch.tensor([0.5, 0.5, 0.75])
coded_bits = torch.tensor([4800, 7200, 3600])
cb_sizes, num_cbs = tb(mod_orders, rates, coded_bits)