Scrambling

The scrambler is used in 5G to randomize the bits to remove the long consecutive occurrence of 1’s and 0’s. A scrambler generates the random sequence which is xor-ed with information bit bit-wise. The scrambling is performed for two purposes:

  • Randomize the bit sequence or alter the probability distribution of the information bits.

  • Reduces impact of inter-cell interference by decorrelating the interference across neighbouring cells.

The scrambling is carried out for all the uplink abd downlink physical channel. For each channel, the seed used to generate the scrambling sequence is different. The seed is computed using parameters relevant to a particular physical chain. The details of the scrambling used in 5G is provided in table-1.

Table-1: Scrambling and Scrambling parameters in 5G

Physical chain

Parameters

Comments

PBCH

\(L_{max}\), SFN, SSB-Index

Aka \(1^{nd}\) Scrambling

PBCH

Cell-ID, SSB-Index

Aka \(2^{nd}\) Scrambling

PDCCH

scambling-ID, RNTI

NA

PDCCH

RNTI

Aka RNTI masking

PSCH

scambling-ID, codeword index, RNTI

PRACH

The receiver performs the inverse process of the scrambling called de-scrambling. Descrambling undo the affect of scrambling to recover exact transmission bits. The details about the scrambling, descrambling and RNTI making is provided in upcoming section.

Table of Contents

Scrambler

This modules provide interface for implementing the scrambler for PBCH, PDCCH and PDSCH. The implementation details of the Scramblers for PDSCH, PDCCH and PBCH are provided in Section 7.3.1.1, 7.3.2.3 and 7.3.3.1 of [3GPPTS38211_Scr].

Important

  • Scrambling just randomize the bit pattern. It doesn’t change the length of the input sequence

The scrambled can be used as follows: Scrambling for PBCH:

## Bits to be scrambled
bits    = np.random.randint(2, size = 32)

cellID  = 471 # Physical cell ID
Lmax    = 8   # Maximum number of candidate SS/PBCH blocks in a half frame

# Scrambler Object for PBCH
pbchScr = Scrambler("PBCH", cellID, Lmax)
# Scrambling the input Bits using the object
scrBits = pbchScr(bits)

Scrambling for PDCCH:

numBatch= 8    # Number of batches of input bits
# bits for scrambling
bits    = np.random.randint(2, size = (numBatch, 32))
rnti    = 1051  # RNTI value
nID     = 18548 # Scrambling ID
# Scrambler Object for PDCCH
pbchScr = Scrambler("PDCCH", rnti, nID)
## Scrambling the bits using object
scrBits = pbchScr(bits)

Scrambling for PUCCH:

numBatch = 8      # Number of batches of input bits
# bits for scrambling
bits     = np.random.randint(2, size = (numBatch, 32))
nID      = 47     # Scrambling ID
rnti     = 35967  # RNTI value
# Scrambler Object for PUCCH
pucchScr = Scrambler("PUCCH", rnti, nID)
## Scrambling the bits using object
scrBits  = pucchScr(bits)

Scrambling for PDSCH:

numBatch= 8     # Number of batches
numBSs  = 3     # Number of BSs
# bits for scrambling
bits    = np.random.randint(2, size = (numBatch, numBSs, 512))
rnti    = 1151  # RNTI value
cbIndex = 0     # Codeblock Index
nID     = 39742 # Scrambling ID
# Scrambler Object for PDCCH
pbchScr = Scrambler("PDSCH", rnti, cbIndex, nID)
scrBits = pbchScr(bits) # Scrambling the bits using object

The details about the input-output interface of the scrambling is provided below.

class toolkit5G.Scrambler.Scrambler(purpose, *args)[source]

Scrambles the input bits passed to the call method. The bits are scrambled using another set of bits randomly generated using a seed. This seed is calculated using the parameters passed as input the constructor. The first variable purpose defines the physical channel for whom scrambling is performed and *args accepts variable inputs with different understanding based on the purpose.

Parameters:
  • purpose (str) – Defines the physical channel for which the scrambling is being performed. It can take 6 values currently {“PBCH-1”, “PDCCH”, “PDSCH”, “PBCH-2”, “PSBCH”, “PSCCH”}.

  • *args – Its a Variable length argument list which accepts values based on the parameter purpose.

    If purpose == “PBCH-1”:
    • arg[0] is N_cell_ID (int) - physical cell ID \(N_{ID}^{cell} \in \{0,1,...,1007\}\)

    • arg[1] is Lmax (int) - maximum number of candidate SS/PBCH blocks in a half frame (\(L_{max}\)), \(\in \{4, 8, 64\}\).

    If purpose == “PBCH-2”:
    • arg[0] is N_cell_ID (int) - physical cell ID \(N_{ID}^{cell} \in \{0,1,...,1007\}\)

    • arg[1] is Lmax (int) - maximum number of candidate SS/PBCH blocks in a half frame (\(L_{max}\)), :math:`in {4, 8, 64}.

    • arg[2] is ssbIndex (int or Numpy array, np.int) - It is the index pointing towards the SS/PBCH Block and must be lesser than (\(L_{max}\))

    If purpose == “PDCCH”:
    • arg[0] is rnti (int or NumPy array, np.int) - It defines the radio network temporary identifier (RNTI) \(\in \{1,2,..,65519\}\).

    • arg[1] is id (int) - It is defined by pdcch-DMRS-ScramblingID \(\in \{0,1,2,..,65535\}\).

    If purpose == “PSCCH”:
    • No arguments required

    If purpose == “PDSCH”:
    • arg[0] is rnti (int or NumPy array, np.int) - It defines the radio network temporary identifier (RNTI) \(\in \{1,2,..,65519\}\).

    • arg[1] is q (int or NumPy array, np.int) - It defines codeword index \(\in \{0,1\}\).

    • arg[2] is nID (int or NumPy array, np.int) - It defines dataScramblingIdentityPDSCH(2), \(\text{n}_{\text{ID}} \in \{0,1,2,..,65535\}\).

    If purpose == “PSBCH”:

    -arg[0] is N_cell_ID (int) - Physical-layer sidelink synchronization identity. \(N_{ID}^{cell} \in \{0,1,...,671\}\).

Important

The array parameters passed to constructor must have equal lengths.

Input:

[…, length], np.int8 – Input sequence

Output:

[…, length], np.int8 – scrambled sequence.

Note

For PBCH, the length must be 32.

Raises:
  • ValueError – [Error-Scrambler]: Invalid choice for purpose!n Valid inputs are “”PBCH-1””, “”PDCCH””, “”PBCH-2””, “”PSBCH””, “”PSCCH”” and, “”PDSCH””

  • ValueError – [Error-Scrambler]: inBits must be an NumPy integer array!

  • ValueError – [Error-Scrambler]: Number of MIB bits must be 32 only!

  • ValueError – [Error-Scrambler]: rnti in PD(S|C)CH scramber must be an integer/array!

  • ValueError – [Error-Scrambler]: rnti in PD(S|C)CH scramber must be +ve integer/array!

  • ValueError – [Error-Scrambler]: q ‘(codeword-Index)’ in PD(S|C)CH scramber must be an integer/array!

  • ValueError – [Error-Scrambler]: q ‘(codeword-Index)’ in PD(S|C)CH scramber must be +ve integer/array!

  • ValueError – [Error-Scrambler]: q ‘(codeword-Index)’ in PD(S|C)CH scramber must be have size same as ‘rnti’!

  • ValueError – [Error-Scrambler]: nID in PD(S|C)CH scramber must be an integer/array!

  • ValueError – [Error-Scrambler]: nID in PD(S|C)CH scramber must be +ve integer/array!

  • ValueError – [Error-Scrambler]: nID in PD(S|C)CH scramber must be have size same as ‘rnti’!

  • ValueError – [Error-Scrambler]: rnti in pdcch scramber must be +ve integer!

  • ValueError – [Error-Scrambler]: id in pdcch scramber must be +ve integer!

  • ValueError – [Error-Scrambler]: Lmax in pdcch scramber must be +ve integer!

  • ValueError – [Error-Scrambler]: ssbIndex in scrambler must be lesser than (\(L_{max}\))!

  • ValueError – [Error-Scrambler]: A ‘size of payload’ in pdcch scramber must be +ve integer!

property Lmax

Defines the maximum number of candidate SS/PBCH blocks in a half frame (\(L_{max}\)), \(\in \{4, 8, 64\}\).

property c_init

Defines the seed used for generating the random variables for scrambling.

property id

Defines the pdcch-DMRS-ScramblingID \(\in \{0,1,2,..,65535\}\).

property mu

\({\nu}\) is internally calculated for scrambling PBCH-2.

property nID

Defines dataScramblingIdentityPDSCH(2), \(\text{n}_{\text{ID}} \in \{0,1,2,..,65535\}\).

property purpose

Defines the physical channel for which the scrambling is being performed. It can take 4 values currently {“PBCH”, “PDCCH”, “PDSCH”}.

property q

Defines codeword index \(\in \{0,1\}\).

property rnti

Defines the radio network temporary identifier (RNTI) \(\in \{1,2,..,65519\}\).

property ssbIndex

Defines the maximum number of candidate SS/PBCH blocks in a half frame (\(L_{max}\)), \(\in \{4, 8, 64\}\).

References:
[3GPPTS38211_Scr]

3GPP TS 38.211 “Physical channels and modulation (Release 17)”, V17.1.0 (2022-03).