Main Content

GPS HDL Reference Applications Overview

Wireless HDL Toolbox™ contains examples that implement global positioning system (GPS) receiver algorithms in Simulink®. The following are the list of available examples:

  • GPS HDL Acquisition and Tracking Using C/A Code: This example performs acquisition and tracking on a GPS baseband waveform using Simulink blocks. Acquisition computes the coarse estimates of Doppler frequency offset and C/A code phase offset. It also detects the pseudorandom noise IDs (PRNIDs) of satellites that are present in the GPS waveform. Tracking fine-tunes the estimates and corrects them to recover the legacy navigation (LNAV) symbols.

  • GPS HDL Data Decode and Position Estimation: This example show how to perform bit synchronization, frame synchronization, data decoding, and position estimation on GPS LNAV symbols using Simulink blocks. The GPS navigation message parameters obtained from data decoding are used for position estimation. You can obtain the LNAV symbols by performing acquisition and tracking on a GPS baseband waveform using the GPS HDL Acquisition and Tracking Using C/A Code example.

Construct GPS Receiver Model

You can create a GPS receiver by using the GPS HDL Acquisition and Tracking Using C/A Code and GPS HDL Data Decode and Position Estimation examples. You can generate the HDL code from these examples with the exception of the position estimation functionality, which supports C/C++ code generation. The following sections provide step-by-step procedure on how to integrate these Simulink models to construct a GPS receiver model and how to generate code for these models.

Copy Files

  1. Open the GPS HDL Acquisition and Tracking Using C/A Code example and click Open Script to open its example folder. Copy the files from its example folder to a new folder and name it as GPS HDL Receiver.

  2. Open the GPS HDL Data Decode and Position Estimation example and click Open Script to open its example folder. Copy the files from its example folder to the GPS HDL Receiver folder.

Now, the GPS HDL Receiver folder contains all the files related to GPS HDL Acquisition and Tracking Using C/A Code and GPS HDL Data Decode and Position Estimation examples.

Create GPS HDL Receiver Model

  1. Open a new Simulink model and save it as gpshdlReceiver.slx in the GPS HDL Receiver folder.

  2. Open the gpshdlAcquisitionTracking model from the GPS HDL Receiver folder.

  3. Except the Diagnostic Decoder subsystem, copy the Input Configuration and Acquisition and Tracking subsystems along with the connecting input blocks from the gpshdlAcquisitionTracking model to the gpshdlReceiver model.

  4. Open the gpshdlDataDecodePositionEstimation model from the GPS HDL Receiver folder.

  5. Copy the contents from the gpshdlDataDecodePositionEstimation model to the gpshdlReceiver model.

  6. In the gpshdlReceiver model, delete the input blocks and signals connected to the Data Decode subsystem. Delete the Constant blocks connected to the coarseCodeOffsetTime and fineCodeOffsetTime input ports of the Position Estimation subsystem.

  7. Save the gpshdlReceiver model and close the gpshdlAcquisitionTracking and gpshdlDataDecodePositionEstimation models.

  8. Connect the lnavSym and valid output ports of the Acquisition and Tracking subsystem to the lnavSym and valid input ports of the Data Decode subsystem.

  9. Connect a Terminator block to each of the output ports PRNID, coarseDopplerOffset, and fineDopplerOffset of the Acquisition and Tracking subsystem.

  10. Connect a Gain block to each of the output ports coarseCodePhOffset and fineCodePhOffset of the Acquisition and Tracking subsystem. For the Gain blocks, set the Gain parameter to 1e-3/1023 and the Output data type parameter to double.

  11. Add a For Each Subsystem block. Double-click the block and remove the signal line connecting the input and output ports. Copy and paste the input port two times and the output port once to create additional input and output ports. After that, perform the following steps:

    1. Add two Unit Delay Enabled Synchronous blocks to the For Each Subsystem.

    2. Connect the first input port of the For Each Subsystem to the u port of the first unit delay block.

    3. Connect the second input port of the For Each Subsystem to the u port of the second unit delay block.

    4. Connect the third input port of the For Each Subsystem to the E ports of both the unit delay blocks.

    5. Connect the output ports y of the unit delay blocks to the output ports of the subsystem.

  12. Go to the top-level of the gpshdlReceiver model, connect the output ports of the Gain blocks to the first two input ports of the For Each Subsystem block. Connect the valid output port of the Acquisition and Tracking subsystem to the third input port of the For Each Subsystem block.

  13. Connect the outputs of the For Each Subsystem block to the coarseCodeOffsetTime and fineCodeOffsetTime input ports of the Position Estimation subsystem respectively.

  14. Connect the input reset signal of the Acquisition and Tracking subsystem to an Upsample block and set the Upsample factor, L parameter to param.modelUpSampFac.

  15. Add a Constant block and set the Constant value parameter to false(numSatDataDecode,1).

  16. Connect the Constant block output and the Upsample block output to a Logical Operator block with OR logic.

  17. Connect the Logical Operator block output to the reset input port of the Data Decode subsystem and also to the Delay block, whose output is connected to the reset input port of Prepare Outputs subsystem.

  18. Run this command in the MATLAB® command prompt to avoid storing the simulation outputs into a single variable and also ignore precision loss of parameters in the model:

    set_param('gpshdlReceiver','ReturnWorkspaceOutputs','off','ParameterPrecisionLossMsg','off')

If you complete the above mentioned steps successfully, this is how your model appears.

GPS HDL receiver model

Modify Scripts

Follow these steps to modify the scripts in the GPS HDL Receiver folder.

  1. Open the generateGPSDataDecInputFromPosition script and perform the following changes.

    1. Set the simulatedDataDuration value to 10.

    2. Set the samplingRate value to sampleRate.

    3. Add samplesPerStep = samplingRate*stepTime; in the line 16.

    4. Add receiverWaveform = zeros(samplesPerStep*numSteps,1); in the line 197.

    5. Add receiverWaveform((istep-1)*samplesPerStep + (1:samplesPerStep)) = waveform; in the line 235.

    6. Add receiverWaveform = fi(receiverWaveform,1,20,16); in the line 313.

    Note

    You can use the gpshdlReceiver model only for code generation.

  2. Open the gpshdlDataDecodePosEstInit script and modify the line 14 as model = gcs;.

Initialize GPS HDL Receiver Model

  1. From the GPS HDL Receiver folder, open the gpshdlReceiver model, double-click the Input Configuration subsystem, modify the sample rate value according to your requirement.

  2. Open and run the gpshdlAcquisitionAndTrackingUsingCACodeInit script.

  3. Open the gpshdlReceiver model, double-click the Configure Input Generation subsystem, select the input source as Receiver position, and specify the receiver position values.

  4. Open and run the gpshdlDataDecodePosEstInit script. It may take 25 minutes to run the script.

  5. Run the following commands in the MATLAB command window:

    • rxData = receiverWaveform((100*(sampleRate*1e-3)+1):end);

    • rxValid = true(length(rxData),1);

    • stopTime = simulatedDataDuration+20e-3;

  6. In the SIMULATION > SIMULATE tab, set the Stop Time parameter to stopTime and set the simulation mode to Accelerator.

  7. On the gpshdlReceiver model work area, select the shaded region as shown in the figure, and then click Create Subsystem on the AREA tab. Name the subsystem as HDL DUT.

  8. Run the hdlsetup('gpshdlReceiver') command in the MATLAB command prompt to set up the model for HDL code generation.

Because the Acquisition and Tracking subsystem runs at a high sample rate of 196.608 Msps and the Data Decode subsystem runs at a very low sample rate of 50 samples-per-second, the model takes longer time to simulate. So, it is suggested to use the gpshdlReceiver model only for code generation.

To generate HDL code and HDL test bench for the gpshdlReceiver model, use makehdl and makehdltb functions with the HDL DUT subsystem. This table shows the post place and route resource utilization when synthesized for an AMD® Zynq®- 7000 ZC706 evaluation board. The maximum frequency of operation is 203.75 MHz.

ResourcesUsage
Slice LUT83,570
Slice Registers105,351
DSP48243
RAMB3688
RAMB1850

You can generate C/C++ code for the Prepare Outputs and Position Estimation subsystems. For more information on how to generate the code, see GPS HDL Data Decode and Position Estimation example.

Related Topics