Broadcast channel (BCH) decoding
also returns the decoded and unscrambled BCH transport block
additional input arguments are the number of candidate synchronization signal / physical
broadcast channel (SS/PBCH) blocks,
lssb, and the physical layer cell
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
Decode Scrambled BCH Transport Block
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
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 = uint32 0
ans = logical 1
ans = logical 1
ans = 1x2 logical array 1 1
softbits — Approximate log-likelihood ratio (LLR) soft bits
864-by-1 real-valued column vector
Approximate log-likelihood ratio (LLR) soft bits, specified as an 864-by-1 real-valued column vector.
L — Polar decoding list length
power of 2
Polar decoding list length, specified as a power of 2.
lssb — Number of candidate SS/PBCH blocks in a half frame
Number of candidate SS/PBCH blocks in a half frame, specified as
ncellid — Physical layer cell identity number
Physical layer cell identity number, specified as an integer from 0 to 1007.
scrblk — Decoded scrambled BCH transport block
32-by-1 binary column vector
Decoded scrambled BCH transport block, returned as a 32-by-1 binary column vector.
errFlag — Error flag
Error flag to indicate whether
scrblk contains an error,
1, then an error has
trblk — Decoded and unscrambled BCH transport block
24-by-1 binary column vector
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 . The
BCCH-BCH-Message contains the master
information block (MIB), as defined in TS 38.331 Section 6.2.2.
lsbofsfn — LSBs of the system frame number
4-by-1 column vector
The four LSBs of the system frame number, returned as a 4-by-1 column vector.
hrf — Half frame bit in SS/PBCH block transmissions
Half frame bit in SS/PBCH block transmissions, returned as
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 .
msbidxoffset — MSBs of index offset
scalar | 3-by-1 column vector
MSBs of index offset, returned as a scalar or 3-by-1 column vector.
msbidxoffsetis the decoded MSB of the subcarrier index, returned as a scalar.
64, the entries of
msbidxoffsetare the three decoded MSBs of the SSB index, returned as a 3-by-1 column vector.
 3GPP TS 38.212. “NR; Multiplexing and channel coding.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.
 3GPP TS 38.331. “NR; Radio Resource Control (RRC) protocol specification.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.
 3GPP TS 38.214. “NR; Physical layer procedures for data.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
The input argument
L must be less than or equal to 64.
Version HistoryIntroduced in R2018b
R2023b: C/C++ code generation updates
For C/C++ code generation, the limitation that the input argument
be a compile-time constant has been removed, however,
L must be less
than or equal to 64.
R2020a: Polar decoding metric update
In releases R2019b and before, polar decoding uses the exact form of the expression for internal metric evaluation. Starting in release R2020a, because
the exact form leads to numerical instability for high SNR ranges, polar decoding
approximates as 0 for and as for . This approximation affects the results of the
nrBCHDecode function, resulting in a marginal degradation of
the BLER performance in a link-level simulation.