# ltePSBCHPRBS

PSBCH pseudorandom binary scrambling sequence

## Syntax

``[seq,cinit] = ltePSBCHPRBS(ue,n)``
``[seq,cinit] = ltePSBCHPRBS(ue,n,mapping)``
``[subseq,cinit] = ltePSBCHPRBS(ue,pn)``
``[subseq,cinit] = ltePSBCHPRBS(ue,pn,mapping)``

## Description

example

````[seq,cinit] = ltePSBCHPRBS(ue,n)` returns a column vector containing the first `n` outputs of the PSBCH pseudorandom binary scrambling sequence (PRBS) for the specified UE settings structure. It also returns an initialization value `cinit` for the PRBS generator.The scrambling sequence generated should be applied to the coded PSBCH data carried by the associated subframe. The PRBS generator is initialized with cinit = `ue`.`NSLID`.```

example

````[seq,cinit] = ltePSBCHPRBS(ue,n,mapping)` specifies the format of the returned sequence, `seq`, through the `mapping` input.```
````[subseq,cinit] = ltePSBCHPRBS(ue,pn)` returns a subsequence of a full PRBS sequence, specified by `pn`.```
````[subseq,cinit] = ltePSBCHPRBS(ue,pn,mapping)` specifies the format of the returned subsequence, `subseq`, through the `mapping` input.```

## Examples

collapse all

Scramble a PSBCH codeword by generating the PSBCH pseudorandom binary sequence (PRBS) and applying an exclusive OR operation on the two sequences.

Create a UE configuration structure and SL-BCH codeword. Generate the required length of the PRBS and scramble the PSBCH codeword with the PRBS sequence using `xor`.

```ue = struct('NSLID',2); codeword = lteSLBCH(ue,ones(40,1)); psbchPrbs = ltePSBCHPRBS(ue,length(codeword)); scrambled = xor(psbchPrbs,codeword);```

Scramble PSBCH Codeword

• Create a UE configuration structure and SL-BCH codeword.

• Generate the required length of the PRBS and scramble the PSBCH codeword with the PRBS sequence using `xor`.

• Modulate the logical scrambled data.

```ue = struct('NSLID',2); codeword = lteSLBCH(ue,ones(40,1)); psbchPrbs = ltePSBCHPRBS(ue,length(codeword)); scrambled = xor(psbchPrbs,codeword); txsym = lteSymbolModulate(scrambled,'QPSK');```

Descramble Recovered Codeword

• Generate the PSBCH PRBS in signed form.

• Descramble a vector of noisy demodulated symbols representing a sequence of soft bits. To do so, perform a pointwise multiplication between the PRBS sequence and the recovered data.

• Compare the transmitted codeword to the recovered codeword.

```rxsym = awgn(double(txsym),30,'measured'); softdata = lteSymbolDemodulate(rxsym,'QPSK'); scramblingSeq = ltePSBCHPRBS(ue,length(softdata),'signed'); descrambled = softdata.*scramblingSeq; isequal(codeword,descrambled > 0)```
```ans = logical 1 ```

The transmitted codeword matches the hard decision on the descrambled data.

## Input Arguments

collapse all

User equipment settings, specified as a parameter structure containing this field:

Physical layer sidelink synchronization identity, specified as an integer from 0 to 355. (${N}_{\text{ID}}^{\text{SL}}$)

Data Types: `double`

Data Types: `struct`

Number of elements in returned sequence, `seq`, specified as a nonnegative integer.

Data Types: `double`

Range of elements in returned subsequence, `subseq`, specified as a row vector of `[p n]`. The subsequence returns `n` values of the PRBS generator, starting at position `p` (0-based).

Data Types: `double`

Output sequence formatting, specified as `'binary'` or `'signed'`.

• `'binary'` maps `true` to 1 and `false` to 0.

• `'signed'` maps `true` to –1 and `false` to 1.

Data Types: `char` | `string`

## Output Arguments

collapse all

PSBCH pseudorandom scrambling sequence, returned as a logical column vector or a numeric column vector. `seq` contains the first `n` outputs of the physical sidelink broadcast channel (PSBCH) scrambling sequence. If you set `mapping` to `'signed'`, the output data type is `double`. Otherwise, the output data type is `logical`.

Data Types: `logical` | `double`

PSBCH pseudorandom scrambling subsequence, returned as a logical column vector or a numeric column vector. `subseq` contains the values of the PRBS generator specified by `pn`. If you set `mapping` to `'signed'`, the output data type is `double`. Otherwise, the output data type is `logical`.

Data Types: `logical` | `double`

Initialization value for PRBS generator, returned as a numeric scalar.

Data Types: `uint32`