Main Content

GPS HDL Acquisition and Tracking Using C/A Code

This example shows how to acquire and track multiple Global Positioning System (GPS) satellite signals from a GPS baseband waveform using Simulink® blocks that are optimized for HDL code generation and hardware implementation. You use the L1 Coarse/Acquisition (C/A) code in the input waveform to perform signal acquisition and track the satellites. In acquisition, you detect the satellite signals in the waveform and estimate the coarse Doppler and C/A code phase offsets for the detected satellites. In tracking, you fine-tune the estimates and correct them to recover the legacy navigation (LNAV) symbols. The LNAV symbols can be used for GPS position estimation.

Model Overview

The model that you use in this example mainly consists of acquisition and tracking modules. The input to the model is a GPS baseband waveform with a sample rate of 32.768 Msps. This signal contains multiple satellite waveforms with Doppler offsets, code phase offsets, and additive white gaussian noise (AWGN) noise in it. The model upsamples the GPS waveform by a factor of six and increases the clock from 32.768 MHz to 196.6 MHz to achieve faster acquisition.

The Acquisition block decimates the GPS waveform from 32.768 Msps to 4.096 Msps and operates at this lower sampling rate. This block detects the satellites and generates coarse estimates for them.

The Tracking block uses the GPS waveform at 32.768 Msps, the pseudorandom noise identifier (PRNID) of the detected satellites, and the coarse estimates to track the satellites. Atleast four satellites are required for GPS position estimation, so tracking does not start until the acquisition process detects four satellites. The Tracking block contains eight instances of tracking logic to simultaneously track eight satellites. The Tracking block uses phase-locked loop, frequency-locked loop, and delay-locked loop to recover the pi/2-BPSK modulated LNAV symbols of each detected satellite. This figure shows an overview of the example model.

File Structure

This example uses one Simulink model, two functions and two scripts.

  • gpshdlAcquisitionTracking — Model to acquire signals and track satellites.

  • gpshdlAcquisitionAndTrackingUsingCACodeInit — Generates all the parameters and inputs required to run the gpshdlAcquisitionTracking model. The model calls this script in the InitFcn callback.

  • gpshdlAcquisitionAndTrackingUsingCACodeParameters — Generates the parameters required to run the model. The model calls this function in the gpshdlAcquisitionAndTrackingUsingCACodeInit script.

  • gpshdlGenerateRxInput — Generates the input GPS waveform for the receiver. The model calls this function in the gpshdlAcquisitionAndTrackingUsingCACodeInit script.

  • gpshdlAcquisitionTrackingValidate — Validates the outputs of the model and plots them for visualization. The model calls this function in the StopFcn callback.

Model Interface

This figure shows the structure of the gpshdlAcquisitionTracking model.

Model Inputs

  • dataIn — Input data, specified as 18-bit complex data.

  • validIn — Control signal to validate the dataIn signal, specified as a Boolean scalar.

  • reset — Control signal to reset the receiver. The receiver restarts from acquisition.

Model Outputs:

The output ports are vectors of length 8 because the example tracks eight satellites simultaneously.

  • lnavSym — Legacy navigation symbols in the input waveform, specified as 16-bit complex data.

  • validOut — Control signal to validate all the output ports, specified as a Boolean signal.

  • PRNID — PRNIDs of detected satellites, specified as a 6-bit unsigned integer.

  • coarseDopplerOffset — Estimated coarse Doppler offset of the detected satellites, specified as a 16-bit integer.

  • fineDopplerOffset — Estimated fine Doppler offset of the detected satellites, specified as 25-bit real data.

  • coarseCodePhOffset — Estimated coarse C/A code phase offset of the detected satellites, specified as 20-bit real data.

  • fineCodePhOffset — Estimated fine C/A code phase offset of the detected satellites, specified as 20-bit real data.

Input Configuration

Double-click the Input Configuration subsystem to configure the transmitter parameters and channel impairments.

  • Number of LNAV data bits — Number of LNAV data bits to generate transmitter waveform. Use a minimum of eight bits to ensure successful tracking convergence.

  • Number of satellites — Number of satellites to include in the transmitter waveform, specified as an integer in the range [1,8].

  • Satellite PRNIDs — PRNIDs of satellites. This value must be a column vector of size equal to number of satellites. Each PRNID must be an integer in the range [1,32].

  • SNR (in dB) — Signal-to-noise ratio (SNR) of individual satellites in the transmitter waveform, in dB, specified as a column vector of size equal to the number of satellites. The minimum SNR value must be -20 dB.

  • Peak Doppler offset — Maximum Doppler offset to introduce in the satellite waveform, in Hz, specified as a column vector of size equal to the number of satellites. Each entry of this vector must be in the range [–10000, 10000].

  • Doppler rate — Rate of change of the Doppler offset, specified in Hz/sec, specified as a column vector of size equal to the number of satellites. Each entry of this vector must be no greater than 1000.

  • C/A code phase offset — C/A code delay to introduce in the waveform, specified as a column vector of size equal to the number of satellites. Each entry of this vector must be in the range (–1023, 1023).

Model Structure

This figure shows the Acquisition and Tracking subsystem. This subsystem consists of the Acquisition, Time Synchronization, and Tracking subsystems.

Acquisition Subsystem

The Acquisition subsystem accepts the GPS waveform at a sampling rate of 32.768 Msps, decimates it to 4.096 Msps, and stores one millisecond duration of the decimated waveform. The subsystem selects coarse Doppler frequencies sequentially from -10 kHz to 10 kHz in steps of 1 kHz, generates local carrier waveforms at these frequencies, compensates for these frequencies in the decimated waveform, and outputs carrier-wiped-off waveform. The subsystem converts the carrier-wiped-off waveform into the frequency domain using a 4096-point fast Fourier transform (FFT). The subsystem fetches the frequency-domain C/A code from a look-up table (LUT) and correlates it with the waveform to find the correlation peak. When the peak is greater than a dynamic threshold, the subsystem detects the satellite with the C/A code is detected and the corresponding Doppler frequency and C/A code phase are the coarse estimates of the satellite. The subsystem performs this frequency-domain correlation for four satellites in parallel and for eight sequential searches to finish searching all 32 GPS satellites. The subsystem then sorts and selects the eight detected satellites with the strongest correlation peaks. The subsystem also generates a 1 ms epoch signal, which asserts, for every 1 ms, to use that signal for time synchronization.

The Acquisition subsystem contains these main subsystems:

  • Control Acquisition — Generates control signals to start acquisition and selects the satellite PRNIDs to search.

  • Decimation Decimates the input waveform from 32.768 Msps to 4.096 Msps using Cascaded Integrator Comb (CIC) and Finite Impulse Response (FIR) decimation.

  • RAM Read and Write — Writes one millisecond of decimated waveform to the RAM and reads the waveform multiple times from the RAM until acquisition finishes.

  • Carrier Wipeoff — Generates the local waveform at coarse Doppler frequencies using a numerically controlled oscillator (NCO) and compensates for the Doppler frequencies in the decimated waveform to output carrier-wiped-off waveform.

  • Correlation — Performs frequency-domain correlation of the carrier-wiped-off waveform with four satellite C/A codes simulatenously. This subsystem also finds correlation peaks, generates a threshold, and compares the peaks with the threshold to detect satellites.

  • Sort and Prepare Outputs — Sorts the PRNIDs, coarse Doppler frequencies, and coarse code phase offset values of the detected satellites in decreasing order of their correlation peaks and outputs the eight satellites with the strongest peaks .

Time Synchronization Subsystem

The Time Synchronization subsystem accepts the GPS waveform, the detected satellite PRNIDs, coarse Doppler frequencies, coarse code phase offsets, and the 1 ms epoch signal from the Acquisition subsystem. The Time Syncrhonization subsystem synchronizes the input GPS waveform after the Acquisition subsystem finishes detecting the satellites and when the incoming 1 ms epoch signal asserts.

Tracking Subsystem

The Tracking subsystem tracks the satellites detected through acquisition. The subsystem accepts the time-synchronized waveform at 32.768 Msps, the detected satellite PRNIDs, coarse Doppler offsets, and code phase offsets. The subsystem uses the coarse Doppler estimate and phase estimate to generate a local carrier using an NCO, removes the Doppler offset from the waveform, and returns a carrier-wiped-off waveform. The subsystem uses the detected PRNID and the coarse code phase offset to fetch replica C/A code from an LUT. The subsystem generates early, prompt, and late versions of this C/A code to correlate with the carrier-wiped-off waveform. The subsystem integrates these correlated outputs for every 1 millisecond (predetection integration time) and returns integrated samples after every millisecond. The integrated prompt outputs are the LNAV symbols of the receiver. The subsystem uses the integrated early and late outputs to estimate delay error and the integrated prompt output to estimate frequency and phase errors. The subsystem filters these errors using loop filters and feeds the filtered values to the NCO and C/A code LUT to aid local carrier generation and replica C/A code generation. This tracking logic applies to a single satellite. Similarly, the Tracking subsystem generates eight instances of this tracking logic and tracks eight satellites simulatenously.

The Tracking subsystem contains the Tracking Core subsystem that carries out the tracking logic. The Tracking Core subsystem contains these main subsystems:

  • NCO — Accepts the coarse Doppler offset and filtered fine Doppler offset. The subsystem generates a local carrier to compensate for the Doppler offset in the input waveform.

  • CA Code Replica — Accepts the detected satellite PRNID, coarse code phase offset, and filtered fine code phase offset to generate replica C/A code. This subsystem generates early, prompt, and late versions of the C/A code, each separated by a half C/A chip duration.

  • Code Wipeoff — Multiplies the carrier-wiped-off waveform with the generated early, prompt, and late C/A codes to give out code-wiped-off waveforms.

  • Integrate and Dump — Integrates the early, prompt, and late code-wiped-off waveforms every 1 millisecond and outputs the integrated values.

  • Discriminators and Loop Filters — Uses the integrated prompt value to estimate the frequency and phase errors and uses the integrated early and late values to estimate the delay error. The first- and second-order loop filters filter the generated errors to provide fine estimates.

Run Model

Open the gpshdlAcquisitionTracking model and double-click the Input Configuration subsystem to the change transmitter configuration and channel impairments. Run the model.

Note: It may take around 25 minutes to complete the simulation.

### Building the rapid accelerator target for model: gpshdlAcquisitionTracking
### Successfully built the rapid accelerator target for model: gpshdlAcquisitionTracking

Build Summary

Top model rapid accelerator targets built:

Model                      Action                        Rebuild Reason                                    
gpshdlAcquisitionTracking  Code generated and compiled.  Code generation information file does not exist.  

1 of 1 models built (0 models already up to date)
Build duration: 0h 4m 34.936s
Warning: In rapid accelerator mode, when the simulation is started from the
command line, visualization blocks are not updated. If the simulation is
started from the toolstrip, visualization blocks are updated. 
    Input PRNID    Detected PRNID
    ___________    ______________

        11               11      
        18               18      
        22               22      
        23               23      

    Input code phase offset    Estimated code phase offset
    _______________________    ___________________________

            300.34                       300.19           
            312.88                       312.72           
            587.21                       587.07           
            425.89                       425.72           

    Input doppler offset    Estimated doppler offset
    ____________________    ________________________

            3289                     3253.8         
            1568                     1534.7         
            5856                     5892.2         
            7796                     7836.1         

Generate HDL Code

To generate the HDL code, you must have an HDL Coder™ license. Use makehdl and makehdltb functions to generate HDL code and a HDL test bench for the Acquisition and Tracking subsystem.

The resulting HDL code is synthesized for a Xilinx® Zynq®-7000 ZC706 evaluation board. This table shows the post place and route resource utilization. The maximum frequency of operation is 200 MHz.

       Resources       Usage
    _______________    _____

    Slice LUT          65695
    Slice Registers    71376
    RAMB36             176  
    RAMB18             52   
    DSP48              269  


This example uses these helper files:


[1]. Kaplan, Elliot D., and C. Hegarty, eds., _Understanding GPS/GNSS: Principles and Applications. Third edition. GNSS Technology and Applications Series. Boston; London; Artech House, 2017.

[2]. IS-GPS-200, Rev: L. "NAVSTAR GPS Space Segment/Navigation User Segment Interfaces." GPS Enterprise Space & Missile Systems Center (SMC) - LAAFB.

[3]. Ward, P.W. "GPS Receiver Search Techniques." In Proceedings of Position, Location and Navigation Symposium - PLANS '96, 604 - 11. Atlanta, GA, USA: IEEE, 1996.