Main Content

NR HDL Cell Search

This example shows the design of a 5G NR cell search subsystem optimized for HDL code generation and hardware implementation.

Introduction

The Simulink® model described in this example is an HDL-optimized implementation of a synchronization signal block (SSB) detector for 5G NR frequency range 1 (FR1). This example is one of a related set, for more information seeNR HDL Reference Applications Overview.

单边带检测器的框图所示the figure. The detector performs all of the high-speed signal processing tasks associated with the cell search algorithm therefore is well suited for FPGA or ASIC implementation. The SSB 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 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 the5G NR MIB Recovery Using Analog Devices AD9361/AD9364(Communications Toolbox Support Package for Xilinx Zynq-Based Radio)example.

The SSB detector performs primary synchronization sequence (PSS) search, orthogonal frequency division multiplexing (OFDM) demodulation, and secondary synchronization sequence (SSS) search. It also includes a digital down converter (DDC) for correcting frequency offsets in the received signal. The SSB detector has two modes of operation,searchanddemodulation, which are demonstrated in this example. In search mode, the detector searches for SSBs and returns their parameters. In demodulation mode, the detector recovers a specified SSB OFDM-demodulates its resource grid and searches for SSS within the appropriate resource elements.

File Structure

The example uses these files.

Simulink models

  • nrhdlSSBDetection.slx: This Simulink model uses the simulates the behavior of SSB detection.

  • nrhdlSSBDetectionFR1Core.slx: This model implements the SSB detection algorithm.

  • nrhdlDDCFR1Core.slx: This model implements a DDC to create sample streams for SIB1 and SSBs.

Simulink data dictionary

  • nrhdlReceiverData.sldd: This Simulink data dictionary contains bus objects that define the buses contained in the example models.

MATLAB code

  • runSSBDetectionModelSearch.m: Script for running and verifying thenrhdlSSBDetectionmodel in search mode.

  • runSSBDetectionModelDemod.m: Script for running and verifying thenrhdlSSBDetection在解调模型mode.

  • nrhdlexamples: Package containing the MATLAB reference code and utility functions for verifying the implementation models.

NR HDL Cell Search Model

This figure shows thenrhdlSSBDetectionmodel. The top level of the model reads signals from the MATLAB base workspace, passes them to the SSB Detection subsystem, and writes the outputs back to the workspace. Use therunSSBDetectionModelSearchandrunSSBDetectionModelDemodscripts to run the model and post-process the outputs.

SSB Detection Subsystem

The SSB Detection subsystem references thenrhdlDDCFR1CoreandnrhdlSSBDetectionFR1Coremodels. The DDC performs frequency offset correction and decimation, and the SSB Detector searches for and demodulates SSBs. The algorithms of the model references are described in the next sections. The output of the DDC is the input to the SSB Detection algorithm.

Inputs

  • dataIn: 14-bit signed complex-valued signal, sampled at 61.44 Msps.

  • validIn: 1-bit control signal to validatedataIn.

  • 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: 2-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, setfrequencyOffset,subcarrierSpacing,mode,timingOffset, andNCellID2to the desired values and setstartto1(true) for one or more cycles. If an operation is already in progress, that operation is canceled whenstartis set to1(true). The new operation begins whenstartis returned to0(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 thefrequencyOffsetinput.

  • 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 validatespssNCellID2,pssTimingOffset,pssFrequencyOffset,pssCorrelation, andpssThresholdfor each PSS that is detected. In demod mode, this signal also validatesNCellID,sssCorrelation, andsssThreshold. In demod mode,sssCorrelationandsssThresholdare only valid if the specified SSB was found using its PSS, andNCellIDis only valid if the SSS was detected.

  • gridData: 16-bit signed complex-values that are the resource grid data. The receiver returns all four 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 thegridDataoutput. 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 -- Initial state. Waiting for first start pulse.

  • 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:解调模式——等待指定PSS时机啊ffset.

  • 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.

DDC Model

This diagram shows the top level of thenrhdlDDCFR1Coremodel. The input signal (dataIn)是16位签署了复数数据采样61.44 Msps. The DDC performs three operations. First, theInput Scalingsubsystem scales the input by a factor of 0.875, providing headroom for the subsequent processing stages. Second, theFrequency Correctionsubsystem applies the given frequency offset to the data stream. Last, theFilter and Downsamplesubsystem filters and decimates the samples by eight (to 7.68 Msps) using a chain of halfband filters. TheFilter and Downsamplesubsystem produces two data streams. ThessbDataoutput is sampled at 7.68 Msps and is used for SSB detection. Thesib1Dataoutput is sampled at 30.72 Msps and is used for SIB1 demodulation. These sample rates were selected as they are the minimum bandwidth required to compute a power of 2 FFT for each stream. Thesib1Dataoutput is used in theNR HDL SIB1 Recoveryexample, where a single DDC is shared to drive both the SSB and SIB1 processing steps.

SSB Detection Model

This diagram shows the top level of thenrhdlSSBDetectionFR1Coremodel. The model performs SSB detection and demodulation. Its internal sampling rate varies depending on the subcarrier spacing (SCS). The model uses 7.68 Msps for 30kHz SCS and 3.84 Msps for 15kHz SCS. 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 thestartProcessinginput.

The receiver has an internal timing reference system that keeps track of time by using counters at key points in the datapath. The timing reference counts 20ms periods - the assumed SSB periodicity for cell search as defined by the 5G NR standard. Time is measured in samples at 61.44 Msps modulo 1228800 to create the 20ms period. 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 thestartinput, 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.

ThenrhdlSSBDetectionFR1Coremodel 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.

  • SSB Search: Performs PSS correlation to search for SSBs.

  • SSB Demod: Performs OFDM demodulation and SSS correlation.

  • 再保险port Creation: Aligns all of the parameters corresponding to one SSB detection, so that they are all valid at the same time.

SSB Search subsystem

  • 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.

SSB Demod subsystem

  • 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. The synchronized data is one OFDM symbol behind the PSS correlator as the peak detection occurs at the end of the first OFDM symbol to be demodulated.

  • OFDM Demodulation: OFDM-demodulates `the four symbols 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.

Simulation Setup

The block diagram shows the simulation setup of this example, which is implemented in therunSSBDetectionModelSearchandrunSSBDetectionModelDemodscripts. 5G Toolbox™ functions are used to generate a test waveform which is applied to the MATLAB and Simulink implementations of the SSB 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. Finally, the resource grid output of the Simulink model is decoded to show that the MIB contents are as expected.

Search Mode Simulation

Use therunSSBDetectionModelSearchscript to run a search mode simulation and verify the results. In search mode, the SSB detector searches for SSBs and returns their parameters. The script displays its progress in the MATLAB command window. Tables show the parameters of each SSB detected by MATLAB and Simulink. The final table shows the relative MSE between MATLAB and Simulink for each correlator output and for the detection threshold. Plots are generated showing (i) the combined resource grid of all eight SSBs in the transmitted waveform and (ii) the PSS correlation outputs and threshold. The 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.

runSSBDetectionModelSearch;
Generating test waveform. Selected Simulation case: Simulation Case SSB Pattern Subcarrier Spacing Common PDCCH Config SIB1 SNR dB Strongest SSB index Lmax _______________ ___________ _________________________ _________________ ______ ___________________ ____ "SimCase 1" "Case C" 30 164 50 4 8 Searching for SSBs using the MATLAB reference. Searching for SSBs using the Simulink model. Running nrhdlSSBDetection.slx ### Starting serial model reference simulation build ### Model reference simulation target for nrhdlDDCFR1Core is up to date. ### Model reference simulation target for nrhdlSSBDetectionFR1Core is up to date. Build Summary 0 of 2 models built (2 models already up to date) Build duration: 0h 0m 3.8694s .......... SSBs found by MATLAB reference: NCellID2 timingOffset pssCorrelation pssEnergy frequencyOffset ________ ____________ ______________ _________ _______________ 0 4416 1.8564 2.0487 5057 0 17568 1.4776 1.6272 4997 0 35136 3.7246 4.1033 5016 0 48288 2.9372 3.243 5031 0 65856 11.729 12.921 4940 0 79008 2.6242 2.8901 5003 0 96576 4.6843 5.1559 5017 0 1.0973e+05 2.3364 2.5728 4997 SSBs found by Simulink model: NCellID2 timingOffset pssCorrelation pssEnergy frequencyOffset ________ ____________ ______________ _________ _______________ 0 4416 1.857 2.0492 5057 0 17568 1.4781 1.6277 4997 0 35136 3.7249 4.1042 5016 0 48288 2.9375 3.2439 5031 0 65856 11.732 12.923 4940 0 79008 2.6249 2.8908 5003 0 96576 4.6849 5.1569 5017 0 1.0973e+05 2.3367 2.5735 4997 Relative mean-squared error between MATLAB and Simulink in search mode: name relativeMSEdB _____________________ _____________ {'PSS correlation 0'} -71.51 {'PSS correlation 1'} -63.414 {'PSS correlation 2'} -63.272 {'PSS threshold' } -76.134

Use the Simulink Logic Analyzer to view the inputs and outputs to the SSB Detection subsystem. The detector looks for PSS symbols within a 20 ms time window, which begins after a pulse on thestartinput triggers the search operation. If no PSS symbols are found after 20 ms, the detector sets thestatusoutput to 2 - indicating that the search has failed. In this example, the detector finds all eight SSBs. Thestatusoutput is set to 1 during the search, and a report is returned for each SSB by asserting thereportValidsignal. The simulation only runs for 5 ms however if it is extended to run for more than 20 ms, then thestatusoutput is eventually set to 3 - indicating that the search has succeeded.

Demodulation Mode Simulation

After runningrunSSBDetectionModelSearch, use therunSSBDetectionModelDemodscript to run a demodulation mode simulation and verify the results. 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. The script displays its progress in the MATLAB command window. SS block reports from MATLAB and Simulink show that both detectors returned similar parameters and determined the cell ID correctly as 249. Relative MSE measurements indicate that the MATLAB and Simulink implementations match very closely. As a final verification step, the script decodes the broadcast channel (BCH) from the Simulink resource grid output. The CRC check passes and the master information block (MIB) contents match the transmission. Plots are generated which show the PSS and SSS correlation results, and the resource grid output. The PSS correlation levels are stronger in the demodulation mode simulation than in search mode simulation because the frequency offset is corrected.

runSSBDetectionModelDemod;
Choosing the strongest PSS from the previous search and computing its frequency offset. Strongest PSS index (1 based): 5 Frequency offset (coarse + fine): 4.94 kHz Demodulating the strongest SSBs using the MATLAB reference. Demodulating the strongest SSBs using the Simulink model. Running nrhdlSSBDetection.slx ### Starting serial model reference simulation build ### Model reference simulation target for nrhdlDDCFR1Core is up to date. ### Model reference simulation target for nrhdlSSBDetectionFR1Core is up to date. Build Summary 0 of 2 models built (2 models already up to date) Build duration: 0h 0m 1.6156s ................... SS block report from MATLAB NCellID2: 0 timingOffset: 65856 pssCorrelation: 12.8410 pssEnergy: 12.9020 NCellID1: 83 sssCorrelation: 13.0099 sssEnergy: 13.0102 NCellID: 249 frequencyOffset: 0 SS block report from Simulink NCellID2: 0 timingOffset: 65856 pssCorrelation: 12.8441 pssEnergy: 12.9064 NCellID1: 83 sssCorrelation: 13.0123 sssEnergy: 13.0143 NCellID: 249 frequencyOffset: 0 Relative mean-squared error between MATLAB and Simulink in demod mode: name relativeMSEdB _____________________ _____________ {'PSS correlation 0'} -69.651 {'PSS threshold' } -68.8 {'SSS correlation' } -69.961 {'Rx resource grid' } -70.084 Decoding BCH from Simulink resource grid output: BCH CRC: 0 Decoded (Rx) MIB NFrame: 0 SubcarrierSpacingCommon: 30 k_SSB: 0 DMRSTypeAPosition: 3 PDCCHConfigSIB1: 164 CellBarred: 0 IntraFreqReselection: 0 Expected (Tx) MIB NFrame: 0 SubcarrierSpacingCommon: 30 k_SSB: 0 DMRSTypeAPosition: 3 PDCCHConfigSIB1: 164 CellBarred: 0 IntraFreqReselection: 0

Use the Simulink Logic Analyzer to view the detector output as it progresses through these steps.

  1. The detector sets thestatusoutput to4while it waits for the specified timing offset and searches for the specified PSS.

  2. PSS is found. The detector sets thestatusoutput to6- the detector is now searching for the SSS within the resource grid. The four demodulated OFDM symbols are output, indicated by assertinggridValid.

  3. After the SSS is determined, the detector assertsreportValidto indicate that all of the PSS and SSS parameters, includingNCellID, are valid. Thestatusoutput changes to8, to indicate that the operation is complete and SSS and cell ID are ready.

If the PSS is not found at the specified timing offset, the detector sets thestatusoutput to5and stops searching. If the detector is unable to determine the SSS, then it sets thestatusoutput to7. In this example, the detector recovers the specified SSB - the SSB with the strongest PSS from the initial search.

HDL Code Generation and Implementation Results

To generate the HDL code for this example, you must have an HDL Coder™ license. Use themakehdlandmakehdltbcommands to generate HDL code and an HDL test bench for thenrhdlSSBDetection/SSB Detectionsubsystem. 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.

再保险source Usage _______________ _____ Slice Registers 36531 Slice LUTs 20857 RAMB18 13 RAMB36 0 DSP48 218

再保险lated Examples

More About