main content

nr hdl cell search -凯发k8网页登录

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

a block diagram of the ssb detector is shown in 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 the (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, search and demodulation, 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 the nrhdlssbdetection model in search mode.

  • runssbdetectionmodeldemod.m: script for running and verifying the nrhdlssbdetection model in demodulation mode.

  • nrhdlexamples: package containing the matlab reference code and utility functions for verifying the implementation models.

nr hdl cell search model

this figure shows the nrhdlssbdetection model. 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 the runssbdetectionmodelsearch and runssbdetectionmodeldemod scripts to run the model and post-process the outputs.

ssb detection subsystem

the ssb detection subsystem references the nrhdlddcfr1core and nrhdlssbdetectionfr1core models. 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 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: 2-bit unsigned value specifying the subcarrier spacing. set this signal to 0 to select 15khz, or 1 to select 30khz.

  • mode: 2-bit unsigned value specifying the operation mode. set this signal to 0 for search mode, 1 for single demodulation mode and 2 for repeat demodulation 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 demodulation mode.

  • ncellid2: 2-bit unsigned value specifying the pss (0, 1, or 2) of the ssb to be demodulated. this parameter applies only for demodulation mode.

  • timeout: 3-bit unsigned value specifying the time out count for repeat demodulation mode. when the ssb detector fails to detect timeout 1 ssbs in a row it terminates.

  • stopdemod: 1-bit control signal that stops the repeat demodulation mode operation when asserted.

  • 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 canceled 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 demodulation mode.

  • ssscorrelation: 32-bit unsigned value that is the sss correlation strength. this signal is returned only in demodulation mode.

  • sssthreshold: 32-bit unsigned value that is the sss threshold. this value is returned only in demodulation 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 demodulation mode, this signal also validates ncellid, ssscorrelation, and sssthreshold. in demodulation 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 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 demodulation 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 demodulation 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: demodulation mode -- waiting for specified pss timing offset.

  • 5: demodulation mode -- operation complete, pss not found.

  • 6: demodulation mode -- found specified pss. demodulating the resource grid and looking for sss.

  • 7: demodulation mode -- operation complete, no sss found. returned demodulated resource grid.

  • 8: demodulation mode -- operation complete, found sss. returned demodulated resource grid.

ddc model

this diagram shows the top level of the nrhdlddcfr1core model. the input signal (datain) is 16-bit signed complex-valued data sampled at 61.44 msps. the ddc performs two operations for ssbs. first, the input scaling subsystem scales the input by a factor of 0.875, providing headroom for the subsequent processing stages. second, the ssb ddc subsystem applies the given ssb frequency offset to the data stream, and then filters and decimates the samples by eight using a chain of halfband filters. the ssbdata output is sampled at 7.68 msps and is used for ssb detection. this sample rate is the minimum bandwidth required to compute a power of 2 fft for the scs 30 ssb. the grid ddc subsystem applies the given grid frequency offset, and then filters and decimates the samples by two. the griddata output is sampled at 30.72 msps. the grid ddc, and the griddata output are used in the example, where the ddc drives both the ssb and sib1 processing steps.

ssb detection model

this diagram shows the top level of the nrhdlssbdetectionfr1core model. 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 subsystem on the left is responsible for changing the sampling rate. the rate can change only when a new operation is triggered by the startprocessing 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. therefore the timing reference wraps around every 20ms - the assumed ssb periodicity for cell search as defined by the 5g nr standard. 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. the timing reference is relative to the first valid sample at the input and runs continuously. when a new operation is triggered by the start input, the timing reference is not restarted. instead, the start time is recorded at the input timing reference. the other timing references wait until reaching the start time before changing their increment, when a new subcarrier spacing and corresponding sampling rate applies. this architecture enables the receiver to keep track of time consistently, even when a sampling rate change occurs. due to hardware latency, the other timing references lag behind the input timing reference. the timing update process relies on this latency.

the nrhdlssbdetectionfr1core model 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.

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

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

cell search operations

the design operates in one of two modes - search or demodulation. performing these operations sequentially allows a controller to perform a full cell search.

1. search mode

in search mode, the ssb detector searches for ssbs at the specified subcarrier spacing and frequency offset by correlating against each pss sequence. the operation outputs a list of the detected ssbs, defined by a timing offset and pss sequence id. the correlation metrics and frequency offset for each ssb are reported. after a successful search operation the ssb detector automatically tracks the strongest detected pss to maintain timing lock until a demodulation operation begins, and records the total timing slip. the input timing offset supplied for the demodulation operation is combined with this total timing slip to calculate the final timing occasion. this calculation improves the robustness of the design in the presence of a sample rate offset, or a delay between completion of a search step and the start of a demodulation step.

2. demodulation mode

in demodulation mode, the detector demodulates the ssb specified by the timingoffset and ncellid2 inputs. this involves searching for its pss, ofdm-demodulating the resource grid, and searching for the sss within the appropriate resource elements. demodulation mode requires the results of a successful search operation. the specified ssb is selected from the list of ssbs detected.

there are two demodulation modes: single demodulation mode and repeat demodulation mode. in single demodulation mode, the operation terminates after one demodulation attempt. in repeat demodulation mode, the operation is performed every 20ms, the assumed periodicity of ssb transmission for cell search purposes. a set of results are reported after each attempt. the repeated demodulation enables the monitoring and measurement of a single ssb over multiple transmission occasions. the repeat mode runs until the timeout count is reached or the stop demodulation input is asserted. the timeout count increments when the ssb timing offset is reached and no pss correlation is detected, and resets to zero when a correlation is detected within a timing window. in the presence of a sample rate offset the ssb timing offset drifts between each demodulation attempt. the repeat demodulation operation tracks this drift and shifts the expected timing offset in integer increments automatically. the drift offset is in units of whole samples measured at the ssb rate for the selected scs. the tracking operates on a window of five samples centered around the expected timing occasion. if the timing slip over the 20ms period is greater than two samples at the ssb rate then the peak will move outside the window and the tracking may fail. additionally, the frequency offset measured on each repetition is applied to the ddc to correct any drift in the frequency of the ssb. these corrections allow the receiver to track and repeatedly demodulate an ssb over an extended period of time.

simulation setup

the block diagram shows the simulation setup of this example, which is implemented in the runssbdetectionmodelsearch and runssbdetectionmodeldemod scripts. 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.

the test bench options section of the runssbdetectionmodelsearch script includes these variables to configure the simulation:

  • simulationcase: specifies the configuration of the generated waveform. the table shows the set of simulation cases.

    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  
      "simcase 2"       "case b"                 15                       100              6               3              4  
      "simcase 3"       "case a"                 30                         4             20               2              8  
      "simcase 4"       "case a"                 15                        84              7               0              4  
  • numsubframes: specifies the number of 1 ms subframes generated as input stimulus.

  • repeatdemoden: specifies single or repeat demodulation mode.

  • sampleslip: specifies the sample slip per 20ms applied to the generated waveform.

search mode simulation

use the runssbdetectionmodelsearch script to run a search mode simulation and verify the results. 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.
### successfully updated the model reference simulation target for: nrhdlddcfr1core
### successfully updated the model reference simulation target for: nrhdlssbdetectionfr1core
build summary
simulation targets built:
model                     action                        rebuild reason                              
====================================================================================================
nrhdlddcfr1core           code generated and compiled.  model or library dsphdlfiltering2 changed.  
nrhdlssbdetectionfr1core  code generated and compiled.  model or library dsphdlfiltering2 changed.  
2 of 2 models built (0 models already up to date)
build duration: 0h 5m 8.1663s
....................
ssbs found by matlab reference:
    ncellid2    timingoffset    psscorrelation    pssenergy    frequencyoffset
    ________    ____________    ______________    _________    _______________
       0               4440         1.8359         2.0509           5075      
       0              17592         1.4592         1.6278           4996      
       0              35160         3.6815         4.1055           5010      
       0              48312         2.9024         3.2448           5028      
       0              65880         11.579         12.927           4951      
       0              79032         4.6086         5.1405           5000      
       0              96600         2.3174         2.5819           5020      
       0         1.0975e 05         1.6359         1.8231           4992      
ssbs found by simulink model:
    ncellid2    timingoffset    psscorrelation    pssenergy    frequencyoffset
    ________    ____________    ______________    _________    _______________
       0               4440         1.8366         2.0515           5075      
       0              17592         1.4596         1.6283           4995      
       0              35160         3.6819         4.1064           5010      
       0              48312         2.9024         3.2456           5028      
       0              65880         11.582         12.929           4951      
       0              79032         4.6101         5.1414           5000      
       0              96600         2.3175         2.5826           5020      
       0         1.0975e 05         1.6363         1.8237           4992      
relative mean-squared error between matlab and simulink in search mode:
            name             relativemsedb
    _____________________    _____________
    {'pss correlation 0'}       -70.963   
    {'pss correlation 1'}       -63.516   
    {'pss correlation 2'}       -63.379   
    {'pss threshold'    }       -76.436   

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 the start input triggers the search operation. if no pss symbols are found after 20 ms, the detector sets the status output to 2 - indicating that the search has failed. 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. the simulation only runs for 5 ms however if it is extended to run for more than 20 ms, then the status output is eventually set to 3 - indicating that the search has succeeded.

demodulation mode simulation

after running runssbdetectionmodelsearch, use the runssbdetectionmodeldemod script to run a single demodulation mode simulation and verify the results. the script displays its progress in the matlab command window. ssb 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.951 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.2367s
..........
relative mean-squared error between matlab and simulink in demod mode:
            name             relativemsedb
    _____________________    _____________
    {'pss correlation 0'}       -69.983   
    {'pss threshold'    }       -69.037   
    {'sss correlation'  }       -69.892   
    {'rx resource grid' }       -70.102   
------------- displaying results for ssb demod a -------------
ssb demodulated at: 1.0723 ms
ss block report: from matlab
           ncellid2: 0
       timingoffset: 65880
     psscorrelation: 12.6758
          pssenergy: 12.9087
           ncellid1: 83
     ssscorrelation: 12.8492
          sssenergy: 13.0144
            ncellid: 249
    frequencyoffset: 0
ss block report: from simulink
           ncellid2: 0
       timingoffset: 65880
     psscorrelation: 12.6786
          pssenergy: 12.9130
           ncellid1: 83
     ssscorrelation: 12.8519
          sssenergy: 13.0188
            ncellid: 249
    frequencyoffset: 0
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 the status output to 4 while it waits for the specified timing offset and searches for the specified pss.

  2. pss is found. the detector sets the status output to 6 - the detector is now searching for the sss within the resource grid. the four demodulated ofdm symbols are output, indicated by asserting gridvalid.

  3. 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 operation is complete and sss and cell id are ready.

if the pss is not found at the specified timing offset, the detector sets the status output to 5 and stops searching. if the detector is unable to determine the sss, then it sets the status output to 7. in this example, the detector recovers the specified ssb - the ssb with the strongest pss from the initial search.

further exploration

this section shows how to run a simulation in repeat demodulation mode by modifying the options described in the simulation setup section.

increase the length of the generated waveform to contain a second ssb transmission. generating a waveform with 25 subframes provides enough input data to perform two ssb demods in repeat mode. increase the value further to perform more demodulations.

   numsubframes = 25;

enable the repeat demodulation mode to perform multiple ssb demodulations.

   repeatdemoden = 1;

apply a sample rate offset to the waveform. the sample slip is specified in units of input samples per 20ms. the design is robust to sample slips of up to two samples per 20ms at the ssb rate. the ratio between the ssb rate and the input rate is 16 for scs 15, and 8 for scs 30. therefore, the sample slip can be -32 to 32 for scs 15 and -16 to 16 for scs 30.

   sampleslip = 8;

run the runssbdetectionmodelsearch followed by the runssbdetectionmodeldemod scripts to perform the simulation.

with this input configuration the receiver demodulates two ssbs in demodulation mode. the pss correlation plot shows the peaks of both ssb demodulation occasions, labelled a and b. results are displayed for both demodulations in the command window.

hdl code generation and implementation results

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 nrhdlssbdetection/ssb 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    34819
    slice luts         20861
    ramb18                12
    ramb36                 0
    dsp48                209

related topics

    网站地图