calculate_tb_size#
- sionna.phy.nr.utils.calculate_tb_size(modulation_order: int | torch.Tensor, target_coderate: float | torch.Tensor, target_tb_size: int | float | torch.Tensor | None = None, num_coded_bits: int | torch.Tensor | None = None, num_prbs: int | torch.Tensor | None = None, num_ofdm_symbols: int | torch.Tensor | None = None, num_dmrs_per_prb: int | torch.Tensor | None = None, num_layers: int | torch.Tensor = 1, num_ov: int | torch.Tensor = 0, tb_scaling: float | torch.Tensor = 1.0, return_cw_length: bool = True, verbose: bool = False, device: str | None = None) Tuple[source]#
Calculates the transport block (TB) size for given system parameters.
This function follows the procedure defined in TS 38.214 Sec. 5.1.3.2 and Sec. 6.1.4.2 [3GPPTS38214].
- Parameters:
modulation_order (int | torch.Tensor) – Modulation order, i.e., number of bits per QAM symbol.
target_coderate (float | torch.Tensor) – Target coderate.
target_tb_size (int | float | torch.Tensor | None) – Target transport block size, i.e., number of information bits that can be encoded into a slot for the given slot configuration.
num_coded_bits (int | torch.Tensor | None) – Number of coded bits that can be fit into a given slot. If provided,
num_prbs,num_ofdm_symbolsandnum_dmrs_per_prbare ignored.num_prbs (int | torch.Tensor | None) – Total number of allocated PRBs per OFDM symbol, where 1 PRB equals 12 subcarriers. Must not exceed 275.
num_ofdm_symbols (int | torch.Tensor | None) – Number of OFDM symbols allocated for transmission. Cannot be larger than 14.
num_dmrs_per_prb (int | torch.Tensor | None) – Number of DMRS (i.e., pilot) symbols per PRB that are not used for data transmission, across all
num_ofdm_symbolsOFDM symbols.num_layers (int | torch.Tensor) – Number of MIMO layers.
num_ov (int | torch.Tensor) – Number of unused resource elements due to additional overhead as specified by higher layer.
tb_scaling (float | torch.Tensor) – TB scaling factor for PDSCH as defined in TS 38.214 Tab. 5.1.3.2-2.
return_cw_length (bool) – If True, the function returns
tb_size,cb_size,num_cb,tb_crc_length,cb_crc_length,cw_length. Otherwise, it does not returncw_lengthto reduce computation time.verbose (bool) – If True, additional information is printed.
device (str | None) – Device for computation. If None,
deviceis used.
- Outputs:
tb_size – […], torch.int32. Transport block (TB) size, i.e., how many information bits can be encoded into a slot for the given slot configuration.
cb_size – […], torch.int32. Code block (CB) size, i.e., the number of information bits per codeword, including the TB/CB CRC parity bits.
num_cb – […], torch.int32. Number of CBs that the TB is segmented into.
tb_crc_length – […], torch.int32. Length of the TB CRC.
cb_crc_length – […], torch.int32. Length of each CB CRC.
cw_length – […, N], torch.int32. Codeword length of each of the
num_cbscodewords after LDPC encoding and rate-matching. Note that zeros are appended along the last axis to obtain a dense tensor. The total number of coded bits,num_coded_bits, is the sum ofcw_lengthacross its last axis. Only returned ifreturn_cw_lengthis True.
Examples
from sionna.phy.nr.utils import calculate_tb_size tb_size, cb_size, num_cb, tb_crc, cb_crc, cw_len = calculate_tb_size( modulation_order=4, target_coderate=0.5, num_coded_bits=4800, num_layers=1 ) print(f"TB size: {tb_size}, CB size: {cb_size}, Num CBs: {num_cb}")