LTE HDL Cell Search
This example shows how to design an LTE cell search and selection system optimized for HDL code generation and hardware implementation.
Introduction
Cell search and selection is the first step taken by User Equipment (UE) in attempting to gain access to an LTE network. The cell search and selection procedure involves detecting candidate eNodeB signals and then selecting one to synchronize to. This includes determining the chosen eNodeB's physical layer cell identity (cell ID) and duplex mode. Additionally, the UE acquires frequency and timing synchronization during this process. Once this procedure has been completed, the UE can demodulate the OFDM signal transmitted by the cell and recover its Master Information Block (MIB). A MIB Recovery model with HDL code generation capability, which reuses the cell search and selection functionality shown here, is presented in the LTE HDL MIB Recovery.
The functionality in the present example is based on the cell search functionality of the LTE Toolbox Cell Search, MIB and SIB1 Recovery (LTE Toolbox). However, the algorithms have been optimized for HDL code generation. LTE Toolbox was used extensively in the development of the present example. The HDL model described here performs the following functions:
Frequency recovery
Primary and secondary synchronization signal detection
OFDM demodulation
The frequency recovery algorithm within the HDL model can only correct offsets fewer than +-7.5kHz. Large frequency offset recovery greater than +-7.5kHz is possible by driving the input and monitoring the outputs with an external controller. A demonstration of large frequency offset correction can be found in the LTE MIB Recovery and Cell Scanner Using Analog Devices AD9361/AD9364 (SoC Blockset) example.
Once the model has completed the cell search and selection procedure, it outputs the cell ID, duplex mode and unequalized resource grid of the cell. This functionality is shown below. The model supports downlink signals with 15 kHz subcarrier spacing and normal cyclic prefix length. Frequency Division Duplex (FDD) and Time Division Duplex (TDD) modes are both supported. The duplex mode is automatically detected.
The LTE standard provides two physical signals to aid the cell search process. These are the Primary Synchronization Signal (PSS) and the Secondary Synchronization Signal (SSS). Refer to Appendix A for more information on LTE downlink synchronization signals.
Example Structure
The model consists of 5 files:
ltehdlCellSearch.slx
: This is the top level of the model, and acts as a test bench forltehdlDownlinkSyncDemod.slx
.ltehdlDownlinkSyncDemod.slx
: Model reference which implements the cell search, synchronization, and OFDM demodulation functionality.ltehdlCellSearch_init.m
: MATLAB® script for generating stimulus.ltehdlCellSearch_analyze.m
: MATLAB script for analyzing output and displaying plots at the end of the simulation.ltehdlCellSearchTools.m
: MATLAB class containing helper methods for analyzing and plotting results.
Note: ltehdlDownlinkSyncDemod.slx
does not appear in the example working folder as it is shared with other examples. The file is on the MATLAB path and can be opened by entering ltehdlDownlinkSyncDemod
at the MATLAB command line.
Model Architecture
The structure of the cell search and selection subsystem is shown below. The input is complex 16-bit data sampled at 30.72 Msps. The signal is passed to two signal processing data paths; one at 1.92 Msps and one at 30.72 Msps. Frequency recovery and PSS detection are performed on the 1.92 Msps data path. This sampling rate is used for two reasons. First, the cell bandwidth is not known at this stage therefore the smallest LTE bandwidth of 1.4 MHz is assumed for frequency recovery. This approach works irrespective of the actual cell bandwidth. Second, the PSS and SSS only occupy the six central resource blocks (1.4 MHz). Therefore, detection can be performed effectively at 1.92 Msps and resource sharing techniques can be used to optimize the hardware implementation.
The following steps describe the receiver operation.
The frequency estimation block estimates the frequency offset over a 10 ms period.
The frequency correction blocks are then activated on both the 1.92 Msps and 30.72 Msps sample streams.
PSS detection begins immediately after the frequency estimation stage has been completed.
SSS detection begins when PSS detection detects a valid PSS signal. If a valid SSS is found, this means that a valid cell has been detected and the duplex mode is now known.
The cell ID and frame start position are computed.
On the next frame boundary, the receiver starts to extract OFDM symbols from the 30.72 Msps sample stream. Each symbol is passed through a 2048-point FFT to perform OFDM demodulation.
Appendix B provides more details of the cell search and selection algorithm used in this example.
Cell Search Simulink Model
The top level of ltehdlCellSearch.slx
is shown below. This model references ltehdlDownlinkSyncDemod.slx
. ltehdlCellSearch_init.m
is called by the InitFcn
callback and ltehdlCellSearch_analyze.m
is called by the StopFcn
callback. The model uses a Stop sink to terminate the simulation when either (i) the subframeNum output is 5 or (ii) cellSearchDone is asserted true
and no cell is detected. HDL code can be generated for the Cell Search HDL subsystem.
The Cell Search HDL subsystem is primarily a wrapper for the ltehdlDownlinkSyncDemod model. It contains a Model block (Downlink Sync Demod) which references ltehdlDownlinkSyncDemod.slx
, and a Diagnostics To Workspace subsystem, which logs all of the diagnostic outputs. The diagnostic outputs are used by ltehdlCellSearch_analyze.m
to generate plots showing the internal operation.
Downlink Synchronization and Demodulation Model Reference
The ltehdlDownlinkSyncDemod model reference implements all of the cell search, synchronization and OFDM demodulation functionality. Appendix B details the cell search and selection algorithm implemented by this model. The top level of ltehdlDownlinkSyncDemod closely matches the architecture which was presented earlier.
Model Inputs:
dataIn: Complex signed 16-bit data carrying the baseband input signal.
validIn: Boolean, indicating whether dataIn is valid.
start: Boolean. Assert this input
true
for one cycle at any time to initiate a cell search. This is referred to as a start command.
Model Outputs:
NCellID: 9-bit cell ID of the detected eNodeB.
TDDMode: Boolean, indicating the duplex mode of the detected cell:
false
for FDD,true
for TDD.timingOffset: 19-bit timing offset. Indicates the number of samples from the first sample to enter the receiver to the first sample of the first full frame, from 0 to 307199.
freqEst: 14-bit signed frequency offset estimate. Multiply this output by 15e3 / 2^14 in order to convert to Hz as shown in the LTEHDLCellSearch model.
cellDetected: Boolean, indicating that a cell has been found.
cellSearchDone: Boolean, indicating that the cell search has completed. If a cell is found, cellDetected and cellSearchDone will be asserted true at the same time. If no cell is found, cellDetected will remain
false
and cellSearchDone will be assertedtrue
within 100 ms of the start command being issued. The time taken for cellSearchDone to be asserted depends on how many attempts are taken to detect PSS and SSS. See Appendix B for more details.subframeNum: 4-bit unsigned integer. Indicates which subframe is currently being passed out of the gridData port, from 0 to 9.
gridData: 16-bit data carrying the demodulated resource grid.
gridValid: Boolean, indicating whether gridData is valid.
diagnostics: Bus signal, carrying various diagnostic outputs.
ltehdlDownlinkSyncDemod uses two Wireless HDL Toolbox™ example functions during initialization: ltehdlDefineReceiverBuses
and ltehdlDownlinkSyncDemodConstants
. ltehdlDefineReceiverBuses
is shared with other Wireless HDL Toolbox examples, and defines a set of Simulink buses. This function is called in the InitFcn
of ltehdlDownlinkSyncDemod. Only the detectorDiagnosticsBus
output of the function is used here. The bus object is stored in the Base Workspace, making it available to both the ltehdlDownlinkSyncDemod and ltehdlCellSearch models.
[~,~,~,~,detectorDiagnosticsBus] = ltehdlDefineReceiverBuses();
The model relies on precomputed constants and lookup tables stored in a structure called cellDetectorConfig
. This structure is generated by the ltehdlDownlinkSyncDemodConstants
function and is only used inside the ltehdlDownlinkSyncDemod model reference. Therefore, it is defined in the Model Workspace rather than the Base Workspace. Use the Model Explorer to view the Model Workspace, which contains the following initialization code.
cellDetectorConfig = ltehdlDownlinkSyncDemodConstants(30.72e6);
The internal structure of ltehdlDownlinkSyncDemod is shown.
The Decimation Filters subsystem resamples the input data from 30.72 Msps to 1.92 Msps. It consists of CIC decimation, CIC gain compensation, CIC droop compensation, and transient removal. The filter chain is designed to have a group delay which is equal to an integer number of samples at 1.92 Msps. The Transient Removal block removes the initial transient due to this group delay from the sample stream. This is important because the frame timing offset is measured on the 1.92 Msps stream and then used to recover timing on the 30.72 Msps stream. Removing the initial transient from the decimation filter chain simplifies the logic which transfers the timing information.
The FrequencyEstimation subsystem uses the cyclic prefix to estimate the frequency offset of the incoming signal. The CyclicPrefixCorrelator continually measures the autocorrelation of the incoming signal with a lag of 128 samples across an 8 sample time window. It improves the measurement using a 7-tap OFDM-symbol spaced averaging filter. The result is converted to magnitude and phase by the Rect2Polar subsystem. Every 10ms, the AngleAtMaximum subsystem selects the strongest correlation peak, records its phase angle, and translates it into a frequency estimate. This algorithm works well for both FDD and TDD modes, including configurations where only a small portion of each frame is allocated to the downlink. Appendix B provides more information on how the cyclic prefix can be used to estimate the frequency offset.
The Sync Signal Search subsystem implements PSS and SSS detection. Timing is crucial in this part of the design, because the SSS Searcher uses the frame timing information from the PSS Searcher to identify SSS search locations. The PSS Searcher provides a validOut signal which is used by the Stream Synchronizer block to delay the input stream and compensate for the PSS Searcher pipeline latency. Synchronizing the input stream to the PSS Searcher outputs simplifies the design of the SSS Searcher.
The PSS Searcher is made up of two subsystems: the Correlators and the Max Peak Searcher. Together, these subsystems implement the PSS search algorithm described in Appendix B.
The Correlators subsystem contains a matched filter for each of the three PSS sequences, and a set of subsystems for determining the threshold. A lower limit is applied to the threshold to prevent small signals triggering false alarms. The PSS correlators and the threshold generation logic have different pipeline delays, therefore, a stream synchronizer is used to re-align their outputs.
Once a cell search is underway, the SSS Searcher continually stores samples in a circular buffer. Once PSS is detected, it continues to load samples into the buffer until the SSS search location has been reached and stored. The SSS search location is computed from the PSS timing information provided by the PSSEndTimingOffset signal. Next, the FDD location samples are read from the buffer, passed through a 128-point FFT, and the Max Likelihood SSS subsystem computes the correlation metrics and threshold. The same operation is then applied to the TDD location samples. The Max Likelihood SSS subsystem chooses the maximum correlation metric which exceeded the threshold and determines the duplex mode and frame timing. Finally, the frame timing offset is computed.
Initialization and Analysis Scripts
Initialization Script
ltehdlCellSearch_init.m
is called in the InitFcn
callback of ltehdlCellSearch.slx
. Stimulus can either be loaded from a file containing a captured off-the-air waveform, or generated with LTE Toolbox.
% ltehdlCellSearch model initialization script % Generates workspace variables needed by the ltehdlCellSearch model. SamplingRate = 30.72e6; simParams.Ts = 1/SamplingRate; % Choose to load a captured off-the-air waveform from a file, % or generate a test waveform with LTE Toolbox. loadfromfile = true; if loadfromfile % Load captured off-the-air waveform. load('eNodeBWaveform.mat'); dataIn = resample(rxWaveform,SamplingRate,fs); else % Generate a test waveform with LTE Toolbox. dataIn = hGenerateDLRXWaveform(); end % Scale signal level to be in the range -1 to +1. dataIn = 0.95 * dataIn / max(abs(dataIn)); % Start 1 subframe into the waveform (chosen arbitrarily). startIn = false(length(dataIn),1); startIn(1e-3*SamplingRate) = true; % Configure PSS and SSS attempts PSSAttempts = 2; SSSAttempts = 4; % Determine stop time. simParams.stopTime = (length(dataIn)-1)/SamplingRate;
Analysis Script
ltehdlCellSearch_analyze.m
is called in the StopFcn
callback of ltehdlCellSearch.slx
. This script relies heavily on ltehdlCellSearchTools.m
to analyze the model output and display the plots.
% ltehdlCellSearch model analysis script % Post-processes model outputs and generates plots. % Check if any simulation output exists to analyze. if exist('out','var') && ~isempty(out.PSSDetected) % Post-process the model output to extract key cell parameters, % diganostics and signals. [signals, report] = ltehdlCellSearchTools.processOutput(dataIn,startIn,out); % Plot results ltehdlCellSearchTools.figure('Input waveform and search stages'); clf; ltehdlCellSearchTools.plotSearchStates(signals,report); ltehdlCellSearchTools.figure('Frequency estimation'); clf; ltehdlCellSearchTools.plotFrequencyEstimate(signals,report); ltehdlCellSearchTools.figure('PSS search'); clf; ltehdlCellSearchTools.plotPSSCorrelation(signals,report); ltehdlCellSearchTools.figure('SSS search'); ltehdlCellSearchTools.plotSSSCorrelation(signals,report); end
Analysis Tools Class
This class contains helper functions for analyzing and plotting model output. Refer to ltehdlCellSearchTools.m
for more information.
Simulation Output and Analysis
To execute the simulation, use the run button in the ltehdlCellSearch model. Simulink will automatically call ltehdlCellSearch_init and ltehdlCellSearch_analyze via the InitFcn and StopFcn callbacks respectively. Note that it will take a while to build the ltehdlDownlinkSyncDemod model reference on the first run. The simulation generates two main types of output: (i) Display blocks at the top level of the ltehdlCellSearch block diagram show key detection parameters, and (ii) four plots are generated at the end of the simulation.
The NCellID, TDDMode, timingOffset, freqEst, cellDetected, and cellSearchDone outputs all have associated Display blocks. Their values are shown below at the end of a simulation which used the captured off-the-air waveform (eNodeBWaveform.mat
) as stimulus.
The Input waveform and search stages plot shows:
The magnitude of the input waveform vs time.
The time window during which frequency estimation occurs.
The PSS search window for each attempt (one in this case) and the location of the detected PSS.
The SSS search windows for TDD and FDD for each attempt (one in this case), and the location of the detected SSS.
The Frequency estimation plot shows the output of the frequency estimator vs time. At the end of the 10 ms frequency estimation time window, the frequency estimate is loaded into a register and used to correct the frequency offset. This value is also shown on the plot.
The cell ID is made up of two components, NCellID1
and NCellID2
, where NCellID1
is the SSS sequence number, and NCellID2
is the PSS sequence number (See Appendix A). The PSS search plot shows all three PSS correlator outputs, and the PSS threshold. PSS was detected approximately 17 ms into the waveform on PSS #1, therefore NCellID2 = 1
.
The SSS search plot shows the correlation metrics for the successful SSS detection attempt, and the SSS threshold. As previously discussed, the SSS detection algorithm determines the duplex mode and half frame position, as well as the cell ID. As a result, 4*168 = 672 correlation metrics are computed during each attempt. The correlation metrics are shown in the following order along the x-axis:
FDD1: metrics at the FDD location for SSS sequences corresponding to 1st half frame
FDD2: metrics at the FDD location for SSS sequences corresponding to 2st half frame
TDD1: metrics at the TDD location for SSS sequences corresponding to 1st half frame
TDD2: metrics at the TDD location for SSS sequences corresponding to 2st half frame
SSS was detected in the FDD location for SSS sequence corresponding to the 1st half frame. The SSS sequence number is 25 therefore NCellID1 = 25
. The final cell ID is therefore:
NCellID = 3*NCellID1 + NCellID2 = 76.
HDL Code Generation and Verification
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 testbench for the Cell Search HDL subsystem. Note that testbench generation can take a while due to the length of the tests vectors that are generated.
The Cell Search HDL subsystem was synthesized on a Xilinx® Zynq®-7000 ZC706 evaluation board. The post place and route resource utilization results are shown in the table below. The design met timing with a clock frequency of 200 MHz.
Resource Usage _______________ _____ Slice Registers 26274 Slice LUTs 15740 RAMB18 25 RAMB36 9 DSP48 88
Appendix A - LTE Downlink Synchronization Signals
LTE provides two physical signals to aid the cell search and synchronization process. These are the Primary Synchronization Signal (PSS) and the Secondary Synchronization Signal (SSS).
The cell ID of the eNodeB is encoded in the PSS and SSS. The duplex mode, cyclic prefix length, and frame timing can be determined from their positions within the received signal. The PSS and SSS are transmitted twice every frame. There are 3 possible PSS sequences, and the eNodeB transmits the same PSS every half frame. For each PSS, there are 168 possible SSS sequences in the first half of the frame and 168 different possible SSS sequences in the second half of the frame. This means that once a SSS has been detected, the receiver knows if it is in the first or second half of a frame. The PSS and SSS sequences depend on the cell ID, therefore, there are 3 * 168 = 504 possible cell IDs. The cell ID is
NCellID = 3*NCellID1 + NCellID2
where NCellID2 is the PSS sequence number from 0 to 2, and NCellID1 is the SSS sequence number from 0 to 167. Each instance of the PSS occupies the central 62 subcarriers of one OFDM symbol, as does each instance of the SSS. For normal cyclic prefix mode the locations of the PSS and SSS signals are follows:
FDD Mode: PSS is in symbol 6 of subframe 0, SSS is in symbol 5 of subframe 0
TDD Mode: PSS is in symbol 2 of subframe 1, SSS is in symbol 13 of subframe 0
There are 14 symbols in each subframe, numbered from 0 to 13. Therefore, in FDD mode, the PSS is transmitted one OFDM symbol after the SSS, whereas in TDD mode the PSS is transmitted three OFDM symbols after the SSS. This difference in relative timing allows the receiver to discriminate between the two duplex modes. The positions of PSS and SSS within radio frames in FDD and TDD mode are illustrated below.
For more details see Synchronization Signals (PSS and SSS) (LTE Toolbox).
Appendix B - Cell Search and Selection Algorithm
This section describes the algorithm used by the model to detect eNodeB signals. The algorithm is designed to cope with real world conditions such as frequency offsets, noise and interference, and variation in the SNR of the PSS and SSS over time. To detect eNodeB in the presence of such conditions, the example uses three techniques:
Frequency recovery is applied prior to PSS and SSS detection.
Dynamic thresholds are used to validate the PSS and SSS correlation metrics and minimize the probability of false alarm.
Multiple attempts are made to detect the PSS and SSS; for example, if none of the correlation metrics for a specific instance of the SSS exceed the threshold, the detector will wait half a frame and try again, up to a predefined number of attempts.
Frequency Recovery
Frequency recovery is performed by utilizing the time domain structure of the received signal. In LTE (as with other OFDM based systems), each symbol consists of a useful part and a Cyclic Prefix (CP). The CP is generated by copying a small slice from the end of the symbol and prepending it to the start of the symbol. This can be exploited in a receiver by multiplying the received signal with the complex conjugate of a delayed version of itself, and then integrating across the CP duration, where the delay is the duration of the useful part. In effect, the received signal is cross-correlated with a delayed version of itself. The magnitude of the integrator output has peaks at symbol boundaries. The phase angle of the signal at these peaks is related to the frequency offset. This approach is used in the present example, and combined with additional averaging, to estimate the frequency offset. The algorithm can detect frequency offsets from -7.5 kHz to +7.5 kHz.
PSS Detection
PSS detection is performed by continuously cross-correlating the received signal with all three possible PSS sequences in the time domain. In addition, the energy of the signal within the span of the correlators is computed on each time step and then scaled to generate a threshold. The PSS detection algorithm aims to pick the strongest cell by picking the maximum PSS correlation metric within a 10 ms time window. The following pseudocode describes the search algorithm:
initialize position of first 10 ms search window
for k = 1 to 4 (number of PSS attempts)
find correlation levels which exceed the threshold if any correlation levels exceed the threshold find the max correlation level of those which exceed the threshold PSS detected: break loop and start SSS search else PSS not detected: move search window to next 10ms period end end
SSS Detection
Once PSS is located, the detector can narrow down the position of the SSS to two possible locations; one for FDD and one for TDD. The SSS correlation metrics are computed in the frequency domain, by evaluating the dot product of the sequence. The following algorithm is used to search for and select an SSS sequence.
initialize SSS search window
for k = 1 to 8 (number of SSS attempts)
for each duplex mode in [FDD, TDD] extract 128 point search window for current duplex mode compute FFT and extract SSS subcarriers compute correlation metrics for SSS sequences corresponding to 1st half frame compute correlation metrics for SSS sequences corresponding to 2nd half frame compute signal energy-based threshold end
discard correlation metrics which do not exceed the threshold if any metrics exceeded the threshold pick maximum correlation metric from surviving metrics SSS detected: break loop and proceed to next processing stage else SSS not detected: move SSS search window later by half a frame end
end
Cell Search Illustration
The cell search algorithm is shown below for a scenario where PSS and SSS each take 2 attempts to detect valid signals. The figure also shows the frequency recovery stage. Initially, the receiver has no knowledge of the received signal frame timing. In the Simulink model (and on hardware), a start input is used to trigger the detection process. The receiver begins by measuring the frequency offset, which takes 10 ms. Next, the first 10 ms PSS search takes place. In this case, no PSS is detected, therefore a second PSS search is initiated. This time PSS is detected. The first SSS search takes place just short of 10 ms after the location of the detected PSS, avoiding the need to buffer significant amounts of data, and making the algorithm hardware friendly. As shown, SSS also takes two attempts in this case. From the location of the detected SSS, the receiver knows the duplex model (FDD in this case) and the frame timing.
References
1. 3GPP TS 36.214 "Physical layer"