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
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
.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
Open a new Simulink model and save it as
gpshdlReceiver.slx
in theGPS HDL Receiver
folder.Open the
gpshdlAcquisitionTracking
model from theGPS HDL Receiver
folder.Except the
Diagnostic Decoder
subsystem, copy theInput Configuration
andAcquisition and Tracking
subsystems along with the connecting input blocks from thegpshdlAcquisitionTracking
model to thegpshdlReceiver
model.Open the
gpshdlDataDecodePositionEstimation
model from theGPS HDL Receiver
folder.Copy the contents from the
gpshdlDataDecodePositionEstimation
model to thegpshdlReceiver
model.In the
gpshdlReceiver
model, delete the input blocks and signals connected to theData Decode
subsystem. Delete the Constant blocks connected to the coarseCodeOffsetTime and fineCodeOffsetTime input ports of thePosition Estimation
subsystem.Save the
gpshdlReceiver
model and close thegpshdlAcquisitionTracking
andgpshdlDataDecodePositionEstimation
models.Connect the lnavSym and valid output ports of the
Acquisition and Tracking
subsystem to the lnavSym and valid input ports of theData Decode
subsystem.Connect a Terminator block to each of the output ports PRNID, coarseDopplerOffset, and fineDopplerOffset of the
Acquisition and Tracking
subsystem.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 to1e-3/1023
and the Output data type parameter todouble
.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:
Add two Unit Delay Enabled Synchronous blocks to the For Each Subsystem.
Connect the first input port of the For Each Subsystem to the u port of the first unit delay block.
Connect the second input port of the For Each Subsystem to the u port of the second unit delay block.
Connect the third input port of the For Each Subsystem to the E ports of both the unit delay blocks.
Connect the output ports y of the unit delay blocks to the output ports of the subsystem.
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 theAcquisition and Tracking
subsystem to the third input port of the For Each Subsystem block.Connect the outputs of the For Each Subsystem block to the coarseCodeOffsetTime and fineCodeOffsetTime input ports of the
Position Estimation
subsystem respectively.Connect the input reset signal of the
Acquisition and Tracking
subsystem to an Upsample block and set the Upsample factor, L parameter toparam.modelUpSampFac
.Add a Constant block and set the Constant value parameter to
false(numSatDataDecode,1)
.Connect the Constant block output and the Upsample block output to a Logical Operator block with OR logic.
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 ofPrepare Outputs
subsystem.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.
Modify Scripts
Follow these steps to modify the scripts in the GPS HDL
Receiver
folder.
Open the
generateGPSDataDecInputFromPosition
script and perform the following changes.Set the
simulatedDataDuration
value to10
.Set the
samplingRate
value tosampleRate
.Add
samplesPerStep
=samplingRate
*stepTime;
in the line 16.Add
receiverWaveform = zeros(samplesPerStep*numSteps,1);
in the line 197.Add
receiverWaveform((istep-1)*samplesPerStep + (1:samplesPerStep)) = waveform;
in the line 235.Add
receiverWaveform = fi(receiverWaveform,1,20,16);
in the line 313.
Note
You can use the
gpshdlReceiver
model only for code generation.Open the
gpshdlDataDecodePosEstInit
script and modify the line 14 asmodel = gcs;
.
Initialize GPS HDL Receiver Model
From the GPS HDL Receiver folder, open the
gpshdlReceiver
model, double-click theInput Configuration
subsystem, modify the sample rate value according to your requirement.Open and run the
gpshdlAcquisitionAndTrackingUsingCACodeInit
script.Open the
gpshdlReceiver
model, double-click theConfigure Input Generation
subsystem, select the input source asReceiver position
, and specify the receiver position values.Open and run the
gpshdlDataDecodePosEstInit
script. It may take 25 minutes to run the script.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;
In the SIMULATION > SIMULATE tab, set the Stop Time parameter to
stopTime
and set the simulation mode toAccelerator
.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 asHDL DUT
.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.
Resources | Usage |
---|---|
Slice LUT | 83,570 |
Slice Registers | 105,351 |
DSP48 | 243 |
RAMB36 | 88 |
RAMB18 | 50 |
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.