This example shows the design of a 5G NR cell search subsystem optimized for HDL code generation and hardware implementation.
The model shown in this example detects and demodulates 5G NR synchronization signal blocks (SSBs). It is an HDL optimized implementation of the PSS search, OFDM demodulation, and SSS search steps shown in the NR Synchronization Procedures (5G Toolbox) example. The model also includes a digital down converter (DDC) for correcting frequency offsets in the received signal. This figure shows a block diagram of the algorithm. The SS Block Detector searches for SSBs in time at a given frequency offset and subcarrier spacing. It is designed to be used as part of a larger cell search system that implements carrier frequency offset recovery and subcarrier spacing detection. A controller must be used co-ordinate the overall cell search as shown in the 5G NR Cell Search Using Analog Devices AD9361/AD9364 (Communications Toolbox Support Package for Xilinx Zynq-Based Radio) example.
The NR HDL Cell Search MATLAB Reference example describes the SS block detector and the overall cell search algorithm. The MATLAB reference is created during development of the cell search reference application to evaluate hardware-friendly algorithms and verify the SS block detection HDL implementation. This example describes the Simulink HDL implementation of the SS block detector, shows how to use the detector, and how to verify the detector by using 5G Toolbox™ functions and the MATLAB reference code.
This example uses these files.
nrhdlexamples.runCellSearchModel
: This script runs the nrhdlCellSearch
model by calling the nrhdlexamples.ssBlockDetectSimulink
function and verifies the model by using 5G Toolbox functions and the NR HDL Cell Search MATLAB Reference.
nrhdlexamples.ssBlockDetectSimulink
: This function runs the Simulink model and has the same input and output arguments as the nrhdlexamples.ssBlockDetect
function from the MATLAB reference.
nrhdlCellSearch
: This top-level Simulink model is a lightweight wrapper that instantiates the nrhdlSSBlockDetection
model reference.
nrhdlSSBlockDetection
: This model reference implements the SS block detection algorithm.
This example also uses 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.
nrhdlCellSearch
To open a function or script from the nrhdlexamples
package, use the edit command.
edit nrhdlexamples.runCellSearchModel
This figure shows the nrhdlCellSearch
model. The top level of the model reads signals from the MATLAB base workspace, passes them to the SS Block Detection subsystem, and writes the outputs back to the workspace. To run the model, call the nrhdlexamples.runCellSearchModel
script in MATLAB.
The SS Block Detection subsystem contains a Model block that references the nrhdlSSBlockDetection
model. This section describes the inputs and outputs of that model.
Inputs
dataIn: 14-bit signed complex-valued signal, sampled at 61.44 Msps.
validIn: 1-bit control signal to validate dataIn.
frequencyOffset: 32-bit signed value specifying the frequency offset to be corrected. This signal is connected to an NCO with a 32-bit accumulator. Use this equation to convert the value to Hz: frequencyOffset_Hz = frequencyOffset * 61.44e6 / 2^32;
subcarrierSpacing: 1-bit unsigned value specifying the subcarrier spacing. Set this signal to 0 to select 15kHz, or 1 to select 30kHz.
mode: 1-bit unsigned value specifying the operation mode. Set this signal to 0 for search mode, or 1 for demod mode.
timingOffset: 21-bit unsigned value specifying the timing offset of the start of the SSB to be demodulated. Specify the timing offset in samples at 61.44 Msps, from 0 to 1228799. This parameter applies only for demod mode.
NCellID2: 2-bit unsigned value specifying the PSS (0, 1, or 2) of the SSB to be demodulated. This parameter applies only for demod mode.
start: 1-bit control signal used to start a search or demodulation operation. To start an operation, set frequencyOffset, subcarrierSpacing, mode, timingOffset, and NCellID2 to the desired values and set start to 1 (true) for one or more cycles. If an operation is already in progress, that operation is cancelled when start is set to 1 (true). The new operation begins when start is returned to 0 (false).
Outputs
status: 4-bit unsigned value that indicates the progress of the current operation. See the next section for the possible values of this signal.
pssNCellID2: 2-bit unsigned value that is the PSS (0, 1 or 2) of the detected SSB.
pssTimingOffset: 21-bit unsigned value that is the timing offset of the detected SSB. The timing offset is in samples at 61.44 Msp from 0 to 1228799.
pssFrequencyOffset: 32-bit signed value that is the frequency offset of the detected SSB. This signal has the same units as the frequencyOffset input.
pssCorrelation: 32-bit unsigned value that is the strength of the PSS correlation.
pssThreshold: 32-bit unsigned value that is the threshold value when PSS was detected.
NCellID: 10-bit unsigned value that is the cell ID of the demodulated SSB. This value is returned only in demod mode.
sssCorrelation: 32-bit unsigned value that is the SSS correlation strength. This signal is returned only in demod mode.
sssThreshold: 32-bit unsigned value that is the SSS threshold. This value is returned only in demod mode.
reportValid: 1-bit control signal. In search mode, this signal validates pssNCellID2, pssTimingOffset, pssFrequencyOffset, pssCorrelation, and pssThreshold for each PSS that is detected. In demod mode, this signal also validates NCellID, sssCorrelation, and sssThreshold. In demod mode, sssCorrelation and sssThreshold are only valid if the specified SSB was found using its PSS, and NCellID is only valid if the SSS was detected.
gridData: 16-bit signed complex-values that are the resource grid data. The receiver only returns the 2nd, 3rd, and 4th symbols of the SSB resource grid. Values are returned one resource element at a time. The resource grid is only returned in demod mode.
gridValid: 1-bit control signal that validates the gridData output. Data is only returned if the specified SSB was found using its PSS. This signal is returned only in demod mode.
diagnostics: Bus containing diagnostic signals.
Status Signal States
0
Idle.
1
Search mode -- Searching for PSS.
2
Search mode -- Operation complete, no PSS found.
3
Search mode -- Operation complete, found one or more PSSs.
4
Demod mode -- Waiting for specified PSS timing offset.
5
Demod mode -- Operation complete, PSS not found.
6
Demod mode -- Found specified PSS. Demodulating the resource grid and looking for SSS.
7
Demod mode -- Operation complete, no SSS found. Returned demodulated resource grid.
8
Demod mode -- Operation complete, found SSS. Returned demodulated resource grid.
This diagram shows the top level of the nrhdlSSBlockDetection
model. The input signal (dataIn) is 14-bit signed complex-valued data sampled at 61.44 Msps. The Input Scaling subsystem increases the word length to 16 bits by sign-extending the values by one bit and adding one LSB. This increase provides headroom and extra accuracy for subsequent processing stages. The DDC corrects the frequency offset and decimates the samples by eight (to 7.68 Msps) by using halfband filters. The output of the DDC is the input to the SS Block Core subsystem. The Detection Status block keeps track of progress and generates the status output.
The SS Block Core subsystem performs SS block detection and demodulation. Its internal sampling rate varies depending on the subcarrier spacing (SCS). The subsystem uses 7.68 Msps for SCS30 and 3.84 Msps for SCS15. The subcarrier spacing selection logic on the left is responsible for changing the sampling rate. The rate can change only when a new operation is triggered by the start input.
The receiver has an internal timing reference system that keeps track of time by using counters at key points in the datapath. Time is measured in samples at 61.44 Msps modulo 1228800. Since the actual sampling rate is either 7.84 Msps or 3.84 Msps, the timing reference counters increment by either 8 or 16, respectively, for each sample. When a new operation is triggered by the start input, the Start Controller records the start time and passes the time to the other timing references in the model. This signal tells the other timing references when a new subcarrier spacing and corresponding sampling rate applies. The other timing references wait until the start time before changing their increment. This design is possible only because hardware latency means the other timing references lag behind the Start Controller. This architecture enables the receiver to keep track of time consistently, even when a sampling rate change occurs.
The SS Block Core subsystem contains these main subsystems.
Subcarrier Spacing Selection: Converts the input to two synchronized sample streams, one at 7.68 Msps and one at 3.84 Msps, and selects which stream to pass to subsequent processing stages according to the subcarrier spacing.
PSS Detection: Searches for PSS symbols in the received signal. The next section describes this subsystem in more detail.
Cyclic Prefix Correlation: Computes cyclic prefix (CP) correlation values. Each result is averaged across the last four OFDM symbols.
CP Correlation to Frequency: Converts CP correlation values to fine frequency offset estimates.
PSS and CP Alignment: Matches a CP-based frequency estimate with each PSS symbol detection instance. This alignment is necessary because the frequency estimate for a given PSS detection instance is available only at the end of the corresponding SSB.
PSS Info Serialization: If PSS is detected on more than one PSS correlator output at the same timing offset, this block serializes the results so that they are returned from the detector one at a time.
OFDM Data Synchronization: Synchronizes the OFDM demodulator input with the output of the PSS detector. This synchronization enables the PSS detector to trigger the OFDM demodulation process at the correct time.
OFDM Demodulation: OFDM-demodulates symbols 1, 2, and 3 of the specified SSB.
SSS Detection: Extracts the SSS resource elements from the OFDM demodulator output and correlates them with all 336 possible sequences to determine the cell ID.
Create report: Aligns all of the parameters corresponding to one SS block detection, so that they are all valid at the same time.
This block diagram shows the simulation setup implemented by the nrhdlexamples.runCellSearchModel
function. The function uses 5G Toolbox functions to generate a test waveform that has these parameters.
SSB pattern is case B
Subcarrier spacing is 30
NCellID is 249
Active SSBs within the burst is 8
Frequency offset is 10 kHz
Channel is modeled with AWGN
The function passes the test waveform to the MATLAB and Simulink implementations of the SS block detector in search mode and then in demodulation mode. Key diagnostic signals from each detector are compared in terms of their relative mean-squared error (MSE) and the final outputs are compared. The function calls 5G Toolbox functions to decode the BCH, recover the MIB, and measure the EVM of the resource grid returned by the Simulink implementation.
To run the simulation, call the nrhdlexamples.runCellSearchModel
function. This diagram shows the actions performed by the script.
The simulation starts by generating a test waveform as previously described. The plot shows the combined resource grid of all eight SSBs in the transmitted waveform.
In search mode, the detector looks for PSS symbols within a 20 ms time window, which begins after a pulse on the start input triggers the search operation. If no PSS symbols are found after 20 ms, the detector sets the status output to 2
. In this example, the detector finds all eight SSBs. The status output is set to 1
during the search, and a report is returned for each SSB by asserting the reportValid signal. View these signals by opening the Simulink Logic Analyzer tool after the search mode simulation is complete. The simulation runs for 5 ms. If the simulation ran for more than 20 ms, then the status output is eventually set to 3
.
The script generates a plot that shows the PSS correlation outputs and the PSS detection threshold. Tables are displayed at the command line showing the parameters of each SSB. The final table shows the MSE between the MATLAB and Simulink implementations for each correlator output and for the detection threshold. These results show that the MATLAB and Simulink implementations match very closely. The small differences between the two implementations are due to quantization errors. These errors occur because the MATLAB reference uses floating-point data types, and the Simulink model uses fixed-point data types.
In demodulation mode, the detector recovers the specified SSB by searching for its PSS, OFDM-demodulating the resource grid, and searching for the SSS within the appropriate resource elements. If the PSS is not found within 20 ms, the detector sets the status output to 5
and stops searching.
In this example, the detector recovers the specified SSB. The test bench in the nrhdlexamples.runCellSearchModel
function chooses the SSB with the strongest PSS from the initial search. The frequency offset measurement from this SSB is used as a frequency offset estimate and passed back into the detector. The Simulink Logic Analyzer tool shows the detector output as it progresses through these steps.
The detector sets status output to 4
while it waits for the specified timing offset and looks for the PSS.
PSS is found. The detector sets the status output to 6
and returns three demodulated OFDM symbols by asserting gridValid. The detector searches for the SSS within the resource grid.
After the SSS is determined, the detector asserts reportValid to indicate that all of the PSS and SSS parameters, including NCellID, are valid. The status output changes to 8
, to indicate that the SSS and cell ID are ready.
If the detector is unable to determine the SSS, then it sets the status output to 7
.
These plots show the PSS and SSS correlation signals for both detector implementations. The PSS correlation levels are stronger in demod mode than in search mode because the frequency offset is corrected. The final reports are displayed at the command line, showing that both detectors returned similar parameters and determined the cell ID is 249. The table shows the relative MSE for the PSS and SSS correlation signals and the resource grid.
The plot shows the demodulated resource grids returned by MATLAB and Simulink. The demodulator returns only symbols 1, 2 and 3 of the grid.
As a final verification step, the script decodes the BCH from the Simulink output by calling 5G Toolbox functions. The command line output displays the EVM measurement, shows that the CRC check passed, and confirms that the MIB content matches that of the transmitted waveform.
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 the nrhdlCellSearch/SS Block Detection
subsystem. 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 230 MHz.
Resource Usage _______________ _____ Slice Registers 83300 Slice LUTs 47560 RAMB18 7 RAMB36 1 DSP48 206