This example shows the design of a 5G NR synchronization signal block (SSB) decoding and master information block (MIB) recovery model optimized for HDL code generation and hardware implementation.
The Simulink models described in this example are HDL optimized implementations of SSB decoding and MIB recovery for 5G. This example is one of a related set which show the workflow for designing and deploying a 5G NR cell search and MIB recovery algorithm to hardware. The figure shows the complete set of examples and the current example within the workflow. For more details on the overall algorithm and workflow, see the NR HDL Cell Search and MIB Recovery MATLAB Reference example. The 5G NR MIB Recovery Using Analog Devices AD9361/AD9364 (Communications Toolbox Support Package for Xilinx Zynq-Based Radio) example shows how to deploy the algorithm to an SoC. For a general description of how MATLAB and Simulink can be used together to develop deployable models, see Wireless Communications Design for FPGAs and ASICs.
MIB recovery requires SSB detection, demodulation and SSB decoding. This example focuses on the SSB decoding aspect of MIB recovery, and SSB detection and decoding are described in NR HDL Cell Search. The SSB decoding described in this example is designed to be used with either MATLAB or Simulink SSB detection implementations. This example introduces the SSB decoding model, using MATLAB reference to generate the input to the SSB decoding model and to verify the behavior of the model. The example then shows a Simulink model integrating the SSB detection and SSB decoding parts of the receiver to recover MIB from a baseband waveform.
After an SSB has been detected and demodulated, the SSB needs to be decoded to extract the MIB contents. SSB decoding requires demodulation reference signal (DMRS) search, channel estimation and phase equalization, and broadcast channel (BCH) decoding steps as shown in the figure below.
This example uses these files.
Simulink models
nrhdlSSBDecoding
: This Simulink model uses the nrhdlSSBDecodingCore
model reference to simulate the behaviour of the SSB decoding part of the MIB recovery process.
nrhdlMIBRecovery
: This Simulink model combines the processing of the SSB detector and the SSB decoder into an integrated model illustrating the complete MIB recovery process. This model uses the nrhdlSSBDetectionCore
and nrhdlSSBDecodingCore
model references.
nrhdlSSBDecodingCore
: This model reference implements the SSB decoding algorithm.
nrhdlSSBDetectionCore
: This model reference implements the SSB detection algorithm.
MATLAB functions and scripts
nrhdlexamples.runSSBDecodingModel
: This script uses the MATLAB reference to implement the cell search and SSB detection algorithms, then runs the nrhdlSSBDecoding
Simulink model by calling the nrhdlexampes.ssbDecodeSimulink
function. The model is verified using 5G Toolbox functions and the MATLAB reference.
nrhdlexamples.runMIBRecoveryModel
: This script used the MATLAB reference to implement the cell search algorithm, then runs the nrhdlMIBRecovery
Simulink model. The script verifies the operation of the model using 5G toolbox and the MATLAB reference code.
nrhdlexamples.ssbDecodeSimulink
: This function runs the nrhdlSSBDecoding
Simulink model to decode the SSB. It has the same input and output arguments as the nrhdlexamples.ssbDecode
function from the MATLAB reference.
This example also uses a number of helper functions from the nrhdlexamples
package. The Simulink models and the nrhdlexamples
package are on the MATLAB path. To open one of the models, enter its name at the MATLAB command prompt. To open a function or script from the nrhdlexamples
package, use the edit command.
This figure shows the nrhdlSSBDecoding
model. The top level of the model reads the signals from the MATLAB base workspace, passes them to the SSB Decoding subsystem, and writes the outputs back to the workspace. The ParseMIB subsystem takes the pbchPayload and interprets the bit fields to produce the MIB parameter outputs. To run the model, call the nrhdlexamples.runSSBDecodingModel
script in MATLAB.
The SSB Decoding subsystem contains an instance of the nrhdlSSBDecodingCore
model reference. This section describes the inputs and outputs of that model.
Inputs
data: 16-bit signed complex-valued signal carrying the 4 OFDM symbols of the SSB.
dataValid: 1-bit control signal to validate data.
NCellID: 10-bit unsigned number which provides cell ID number for the detected SSB.
startProcessing: 1-bit control signal which indicates when all data has been written and that cellID and Lmax are valid.
Lmax: 2-bit unsigned number which indicates the maximum number of SSBs in a burst. A value of 0 indicates 4 SSBs and a value of 1 indicates 8 SSBs.
Reset: 1-bit control signal to reset the processing.
Outputs
Status: 3-bit unsigned value indicating the progress of the current operation. See below for more information on the possible values of this signal.
Ibar_SSB: 3-bit unsigned value that is the index calculated by the DMRS search process.
ssbIndex: 3-bit unsigned value that is the index of the SSB, calculated using ibar_ssb and Lmax.
pbchPayload: 32-bit unsigned value that contains the MIB and additional PBCH timing data.
Diagnostics: Bus containing diagnostic signals.
Status Signal States
0
: idle
1
: performing DMRS search
2
: performing PBCH decoding
3
: performing rate recovery
4
: performing polar decoding
5
: CRC error (end state)
6
: CRC pass, MIB detected (end state)
This diagram shows the top level of the nrhdlSSBDecodingCore
model. The input data is 4 OFDM symbols for the synchronization signal block (SSB), with the data scaled within the range +/-1. The model starts processing when all of the SSB data has been input to the model and startProcessing is asserted. The startProcessing signal indicates when all of the SSB data has been written, the NCellID and Lmax inputs are valid, and processing of the SSB can begin.
The pbch processing subsystem performs DMRS search, channel estimation and equalization, QPSK symbol demodulation, and descrambling. The output from the pbch processing subsystem is passed to the bch processing subsystem which performs rate recovery, polar decoding, and CRC decoding. The prepOutputs subsystem uses the control signal to produce the status output, and creates the diagnostics bus using signals from intermediate points in the processing.
The pbch processing subsystem performs DMRS search, channel estimation and equalization, and QPSK demodulation and descrambling. Incoming data is stored in a RAM buffer where it is held until startProcessing is asserted, indicating that all required information is available to start the DMRS search process. The DMRS search reads the DMRS symbols from the RAM and correlates with the 8 possible DMRS sequences, selecting the strongest correlation value to determine ibar_SSB. Once the DMRS search has been completed ibar_SSB is used to generate the reference DMRS required for channel estimation. The reference DMRS passed to the channel est + eq subsystem along with the received PBCH symbols and associated DMRS.
The channel est + eq subsystem performs channel estimation using the received data and the reference DMRS. The channel estimate performs linear interpolation between DMRS locations within an OFDM symbol, but does not perform averaging between symbols in case of any residual carrier frequency offset. Phase equalization of the PBCH symbols is then performed, before QPSK demodulation and descrambling are performed, using ibar_SSB and Lmax to calculate the descrambling sequence.
The BCH processing performs rate recovery, polar decoding and CRC decoding of the BCH. The rate recovery subsystem includes signal scaling and wordlength reduction to prepare the data for polar decoding. The scaled, rate recovered, soft bits are then passed to the NR Polar Decoder block, which also performs CRC decoding. The err output port from the NR Polar Decoder block indicates if decoding was successful or encountered any errors. The extract payload subsystem performs descrambling and deinterleaving of the payload bits.
This block diagram shows the simulation setup implemented by the nrhdlexamples.runSSBDecodingModel
script. The script uses 5G Toolbox functions to generate a test waveform. The test waveform is then processed using the MATLAB reference code for the SSB detector to search for, then demodulate, the strongest SSB in the waveform. This provides the SSB data input for the SSB decoding stage. The SSB data is passed to both MATLAB and Simulink implementations, and the outputs are compared to verify the operation of the Simulink model.
Call the nrhdlexamples.runSSBDecodingModel
function to perform the SSB decode simulation setup as described above. This function calls the MATLAB reference code followed by the Simulink model using the functions nrhdlexamples.SSBDecoding
and nrhdlexamples.SSBDecodingSimulink
.
The signals from the diagnostics bus can be used to compare and verify intermediate signals from the Simulink simulation with the MATLAB equivalent. The plot of the correlation strengths from the DMRS search process is shown below, with the MATLAB and Simulink signals producing the same result.
The equalized QPSK symbols representing the PBCH are also plotted by the script, and the output is shown below. This plot shows that the Simulink model matches the MATLAB reference.
The script also displays the final result of the decoding process in the command prompt, with both the simulation and MATLAB reference results shown for comparison.
The nrhdlMIBRecovery
model connects the two reference models for SSB Decoding and SSB detection (nrhdlSSBDecodingCore
and nrhdlSSBDetectionCore
) to create a complete MIB recovery implementation. This model can be used to recover MIB from baseband 5G waveforms. The script nrhdlexamples.runMIBRecoveryModel
can be used to run this model and compare against the MATLAB reference. To reduce the processing time required the cell search part of the algorithm is performed in MATLAB then, once the strongest SSB has been determined, the Simulink model is used to re-acquire, demodulate, and decode the SSB.
The status signal from the detector is used to start the SSB decoder when it has reached state 8, indicating that demodulation is complete, SSS has been found and the demodulated grid has been output. When the SSB decoder has the demodulated grid and received the startProcessing signal it will decode the SSB, outputting the PBCH payload which is then parsed to extract the MIB data.
To generate the HDL code for this example, you must have an HDL Coder™ license. Use the makehdl
and makehdltb
commands to generate HDL code and an HDL test bench for nrhdlSSBDecoding/SSB Decoding
or nrhdlMIBRecovery/MIB Recovery
subsystems. The resulting HDL code was synthesized for a Xilinx® Zynq®-7000 ZC706 evaluation board. The table shows the post place and route resource utilization results. The design meets timing with a clock frequency of 150 MHz.
Resource utilization for nrhdlSSBDecoding model:
Resource Usage _______________ _____ Slice Registers 8896 Slice LUTs 11229 RAMB18 4 RAMB36 5 DSP48 38
Resource utilization for nrhdlMIBRecovery model:
Resource Usage _______________ _____ Slice Registers 87760 Slice LUTs 47747 RAMB18 14 RAMB36 5 DSP48 247