# nrBCHDecode

## Description

example

scrblk = nrBCHDecode(softbits,L) decodes the log-likelihood ratios (LLRs) softbits in accordance with TS 38.212, Section 7.1 [1]. The function returns the decoded scrambled BCH transport block scrblk. The input argument L is the list length used for polar decoding.

[scrblk,errFlag] = nrBCHDecode(softbits,L) also returns an error flag, errFlag, to indicate whether scrblk contains an error after decoding.

[scrblk,errFlag,trblk,lsbofsfn,hrf,msbidxoffset] = nrBCHDecode(softbits,L,lssb,ncellid) also returns the decoded and unscrambled BCH transport block trblk. The additional input arguments are the number of candidate synchronization signal / physical broadcast channel (SS/PBCH) blocks, lssb, and the physical layer cell identity number, ncellid. The function also returns these information elements:

• lsbofsfn, the four least significant bits (LSBs) of the system frame number

• hrf, the half frame bit

• msbidxoffset, the most significant bits (MSBs) of the index offset

## Examples

collapse all

Generate a random sequence of binary values corresponding to a BCH transport block of 24 bits.

trblk = randi([0 1],24,1,'int8');

Specify the physical layer cell identity number as 321, the system frame number as 10, and the second half frame.

nid = 321;
sfn = 10;
hrf = 1;

Specify the number of candidate SS/PBCH blocks as 8. When you specify the number of candidate SS/PBCH blocks as 4 or 8, you can specify the subcarrier offset kssb as an input argument to the BCH encoder.

lssb = 8;
kssb = 18;

Encode the BCH transport block using the specified arguments.

bch = nrBCH(trblk,sfn,hrf,lssb,kssb,nid);

Decode the encoded transport block and recover information by using a polar decoding list length of 8 bits.

listLen = 8;
[~,errFlag,rxtrblk,rxSFN4lsb,rxHRF,rxKssb] = nrBCHDecode( ...
double(1-2*bch),listLen,lssb,nid);

Verify that the decoding has no errors.

errFlag
errFlag = uint32
0
isequal(trblk,rxtrblk)
ans = logical
1

isequal(bi2de(rxSFN4lsb','left-msb'),mod(sfn,16))
ans = logical
1

[isequal(hrf,rxHRF) isequal(de2bi(floor(kssb/16),1),rxKssb)]
ans = 1x2 logical array

1   1

## Input Arguments

collapse all

Approximate log-likelihood ratio (LLR) soft bits, specified as an 864-by-1 real-valued column vector.

Data Types: single | double

Polar decoding list length, specified as a power of 2.

Data Types: double

Number of candidate SS/PBCH blocks in a half frame, specified as 4, 8, or 64.

Data Types: double

Physical layer cell identity number, specified as an integer from 0 to 1007.

Data Types: double

## Output Arguments

collapse all

Decoded scrambled BCH transport block, returned as a 32-by-1 binary column vector.

Data Types: int8

Error flag to indicate whether scrblk contains an error, returned as 0 or 1. If errFlag is 1, then an error has occurred.

Data Types: uint32

Decoded and unscrambled BCH transport block, returned as a 24-by-1 binary column vector. The output trblk is the BCCH-BCH-Message, as defined in TS 38.331 Section 6.2.1 [2]. The BCCH-BCH-Message contains the master information block (MIB), as defined in TS 38.331 Section 6.2.2.

Data Types: logical

The four LSBs of the system frame number, returned as a 4-by-1 column vector.

Data Types: logical

Half frame bit in SS/PBCH block transmissions, returned as 0 indicating the first half of a frame or 1 indicating the second half of a frame. For more information, see TS 38.214 Section 4.1 [3].

Data Types: logical

MSBs of index offset, returned as a scalar or 3-by-1 column vector.

• If lssb is 4 or 8, msbidxoffset is the decoded MSB of the subcarrier index, returned as a scalar.

• If lssb is 64, the entries of msbidxoffset are the three decoded MSBs of the SSB index, returned as a 3-by-1 column vector.

Data Types: logical

## Compatibility Considerations

expand all

Behavior changed in R2020a

## References

[1] 3GPP TS 38.212. “NR; Multiplexing and channel coding.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

[2] 3GPP TS 38.331. “NR; Radio Resource Control (RRC) protocol specification.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

[3] 3GPP TS 38.214. “NR; Physical layer procedures for data.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.