TB5GScrambler#
- class sionna.phy.fec.scrambling.TB5GScrambler(n_rnti: int | Sequence[int] = 1, n_id: int | Sequence[int] = 1, binary: bool = True, channel_type: str = 'PUSCH', codeword_index: int = 0, *, precision: str | None = None, device: str | None = None, **kwargs)[source]#
Bases:
sionna.phy.block.Block5G NR Scrambler for PUSCH and PDSCH channel.
Implements the pseudo-random bit scrambling as defined in [3GPPTS38211] Sec. 6.3.1.1 for the “PUSCH” channel and in Sec. 7.3.1.1 for the “PDSCH” channel.
Only for the “PDSCH” channel, the scrambler can be configured for two codeword transmission mode. Hereby,
codeword_indexcorresponds to the index of the codeword to be scrambled.If
n_rntiis a list of ints, the scrambler assumes that the second last axis containslen(n_rnti)elements. This allows independent scrambling for multiple independent streams.- Parameters:
n_rnti (int | Sequence[int]) – RNTI identifier provided by higher layer. Defaults to 1 and must be in range [0, 65535]. If a list is provided, every list element defines a scrambling sequence for multiple independent streams.
n_id (int | Sequence[int]) – Scrambling ID related to cell id and provided by higher layer. Defaults to 1 and must be in range [0, 1023]. If a list is provided, every list element defines a scrambling sequence for multiple independent streams.
binary (bool) – Indicates whether bit-sequence should be flipped (i.e., binary operations are performed) or the signs should be flipped (i.e., soft-value/LLR domain-based).
channel_type (str) – Can be either
'PUSCH'or'PDSCH'.codeword_index (int) – Scrambler can be configured for two codeword transmission.
codeword_indexcan be either 0 or 1.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:
x – torch.Tensor. Tensor of arbitrary shape. If
n_rntiandn_idare a list, it is assumed thatxhas shape[..., num_streams, n]wherenum_streams = len(n_rnti).binary – None | bool. Overrules the init parameter
binaryif explicitly given. Indicates whether bit-sequence should be flipped (i.e., binary operations are performed) or the signs should be flipped (i.e., soft-value/LLR domain-based).
- Outputs:
x_out – torch.Tensor. Tensor of same shape as
x.
Notes
The parameters radio network temporary identifier (RNTI)
n_rntiand the datascrambling IDn_idare usually provided by the higher layer protocols.For inverse scrambling, the same scrambler can be reused (as the values are flipped again, i.e., result in the original state).
Examples
import torch from sionna.phy.fec.scrambling import TB5GScrambler scrambler = TB5GScrambler(n_rnti=1, n_id=1) bits = torch.randint(0, 2, (10, 100), dtype=torch.float32) scrambled = scrambler(bits) unscrambled = scrambler(scrambled) # Re-use for descrambling assert torch.allclose(bits, unscrambled)
Attributes