lte hdl cell search -凯发k8网页登录
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 (communications toolbox support package for xilinx zynq-based radio) 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 (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"