GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
pcps_acquisition_fpga.h
Go to the documentation of this file.
1 /*!
2  * \file pcps_acquisition_fpga.h
3  * \brief This class implements a Parallel Code Phase Search Acquisition for the FPGA
4  *
5  *
6  * Kay Borre book: K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,
7  * "A Software-Defined GPS and Galileo Receiver. A Single-Frequency
8  * Approach", Birkhauser, 2007. pp 81-84
9  *
10  * \authors <ul>
11  * <li> Marc Majoral, 2019. mmajoral(at)cttc.es
12  * <li> Javier Arribas, 2019. jarribas(at)cttc.es
13  * </ul>
14  *
15  * -----------------------------------------------------------------------------
16  *
17  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
18  *
19  * GNSS-SDR is a software defined Global Navigation
20  * Satellite Systems receiver
21  *
22  * This file is part of GNSS-SDR.
23  *
24  * SPDX-License-Identifier: GPL-3.0-or-later
25  *
26  * -----------------------------------------------------------------------------
27  */
28 
29 #ifndef GNSS_SDR_PCPS_ACQUISITION_FPGA_H
30 #define GNSS_SDR_PCPS_ACQUISITION_FPGA_H
31 
32 
33 #include "channel_fsm.h"
34 #include "fpga_acquisition.h"
35 #include <glog/logging.h>
36 #include <cstdint> // for uint32_t
37 #include <memory> // for shared_ptr
38 #include <string> // for string
39 
40 class Gnss_Synchro;
41 
42 typedef struct
43 {
44  /* pcps acquisition configuration */
45  std::string device_name;
46  int64_t fs_in;
47  float doppler_step2;
48  uint32_t* all_fft_codes; // pointer to memory that contains all the code ffts
49  uint32_t doppler_max;
50  uint32_t select_queue_Fpga;
51  uint32_t downsampling_factor;
52  uint32_t total_block_exp;
53  uint32_t excludelimit;
54  uint32_t num_doppler_bins_step2;
55  uint32_t max_num_acqs;
56  int32_t samples_per_code;
57  int32_t code_length;
58  bool make_2_steps;
59  bool repeat_satellite;
61 
63 
64 using pcps_acquisition_fpga_sptr = std::shared_ptr<pcps_acquisition_fpga>;
65 
66 pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_);
67 
68 /*!
69  * \brief This class implements a Parallel Code Phase Search Acquisition that uses the FPGA.
70  *
71  * Check \ref Navitec2012 "An Open Source Galileo E1 Software Receiver",
72  * Algorithm 1, for a pseudocode description of this implementation.
73  */
75 {
76 public:
77  /*!
78  * \brief Destructor
79  */
80  ~pcps_acquisition_fpga() = default;
81 
82  /*!
83  * \brief Set acquisition/tracking common Gnss_Synchro object pointer
84  * to exchange synchronization data between acquisition and tracking blocks.
85  * \param p_gnss_synchro Satellite information shared by the processing blocks.
86  */
87  inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
88  {
89  d_gnss_synchro = p_gnss_synchro;
90  }
91 
92  /*!
93  * \brief Returns the maximum peak of grid search.
94  */
95  inline uint32_t mag() const
96  {
97  return d_mag;
98  }
99 
100  /*!
101  * \brief Initializes acquisition algorithm.
102  */
103  void init();
104 
105  /*!
106  * \brief Sets local code for PCPS acquisition algorithm.
107  */
108  void set_local_code();
109 
110  /*!
111  * \brief If set to 1, ensures that acquisition starts at the
112  * first available sample.
113  * \param state - int=1 forces start of acquisition
114  */
115  void set_state(int32_t state);
116 
117  /*!
118  * \brief Starts acquisition algorithm, turning from standby mode to
119  * active mode
120  * \param active - bool that activates/deactivates the block.
121  */
122  void set_active(bool active);
123 
124  /*!
125  * \brief Set acquisition channel unique ID
126  * \param channel - receiver channel.
127  */
128  inline void set_channel(uint32_t channel)
129  {
130  d_channel = channel;
131  }
132 
133  /*!
134  * \brief Set channel fsm associated to this acquisition instance
135  */
136  inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm)
137  {
138  d_channel_fsm = channel_fsm;
139  }
140 
141  /*!
142  * \brief Set statistics threshold of PCPS algorithm.
143  * \param threshold - Threshold for signal detection (check \ref Navitec2012,
144  * Algorithm 1, for a definition of this threshold).
145  */
146  inline void set_threshold(float threshold)
147  {
148  d_threshold = threshold;
149  }
150 
151  /*!
152  * \brief Set maximum Doppler grid search
153  * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
154  */
155  inline void set_doppler_max(uint32_t doppler_max)
156  {
157  d_doppler_max = doppler_max;
158  d_acquisition_fpga->set_doppler_max(doppler_max);
159  }
160 
161  /*!
162  * \brief Set Doppler steps for the grid search
163  * \param doppler_step - Frequency bin of the search grid [Hz].
164  */
165  inline void set_doppler_step(uint32_t doppler_step)
166  {
167  d_doppler_step = doppler_step;
168  d_acquisition_fpga->set_doppler_step(doppler_step);
169  }
170 
171  /*!
172  * \brief Set Doppler center frequency for the grid search. It will refresh the Doppler grid.
173  * \param doppler_center - Frequency center of the search grid [Hz].
174  */
175  inline void set_doppler_center(int32_t doppler_center)
176  {
177  if (doppler_center != d_doppler_center)
178  {
179  DLOG(INFO) << " Doppler assistance for Channel: " << d_channel << " => Doppler: " << doppler_center << "[Hz]";
180  d_doppler_center = doppler_center;
181  }
182  }
183 
184  /*!
185  * \brief This function triggers a HW reset of the FPGA PL.
186  */
187  void reset_acquisition();
188 
189 private:
190  friend pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_);
191  explicit pcps_acquisition_fpga(pcpsconf_fpga_t conf_);
192 
193  void send_negative_acquisition();
194  void send_positive_acquisition();
195  void acquisition_core(uint32_t num_doppler_bins, uint32_t doppler_step, int32_t doppler_min);
196  float first_vs_second_peak_statistic(uint32_t& indext, int32_t& doppler, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step);
197 
198  std::shared_ptr<Fpga_Acquisition> d_acquisition_fpga;
199  std::weak_ptr<ChannelFsm> d_channel_fsm;
200 
201  pcpsconf_fpga_t d_acq_parameters;
202 
203  Gnss_Synchro* d_gnss_synchro;
204 
205  uint64_t d_sample_counter;
206 
207  float d_threshold;
208  float d_mag;
209  float d_input_power;
210  float d_test_statistics;
211  float d_doppler_step2;
212  float d_doppler_center_step_two;
213 
214  int32_t d_doppler_center;
215  int32_t d_state;
216 
217  uint32_t d_doppler_index;
218  uint32_t d_channel;
219  uint32_t d_doppler_step;
220  uint32_t d_doppler_max;
221  uint32_t d_fft_size;
222  uint32_t d_num_doppler_bins;
223  uint32_t d_downsampling_factor;
224  uint32_t d_select_queue_Fpga;
225  uint32_t d_total_block_exp;
226  uint32_t d_num_doppler_bins_step2;
227  uint32_t d_max_num_acqs;
228 
229  bool d_active;
230  bool d_make_2_steps;
231 };
232 
233 #endif // GNSS_SDR_PCPS_ACQUISITION_FPGA_H
void reset_acquisition()
This function triggers a HW reset of the FPGA PL.
void set_threshold(float threshold)
Set statistics threshold of PCPS algorithm.
void set_doppler_center(int32_t doppler_center)
Set Doppler center frequency for the grid search. It will refresh the Doppler grid.
Highly optimized FPGA vector correlator class.
void set_local_code()
Sets local code for PCPS acquisition algorithm.
void set_channel(uint32_t channel)
Set acquisition channel unique ID.
Interface of the State Machine for channel.
void set_doppler_step(uint32_t doppler_step)
Set Doppler steps for the grid search.
void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro)
Set acquisition/tracking common Gnss_Synchro object pointer to exchange synchronization data between ...
void set_doppler_max(uint32_t doppler_max)
Set maximum Doppler grid search.
This is the class that contains the information that is shared by the processing blocks.
Definition: gnss_synchro.h:33
void set_state(int32_t state)
If set to 1, ensures that acquisition starts at the first available sample.
This class implements a Parallel Code Phase Search Acquisition that uses the FPGA.
void set_active(bool active)
Starts acquisition algorithm, turning from standby mode to active mode.
~pcps_acquisition_fpga()=default
Destructor.
void init()
Initializes acquisition algorithm.
void set_channel_fsm(std::weak_ptr< ChannelFsm > channel_fsm)
Set channel fsm associated to this acquisition instance.
uint32_t mag() const
Returns the maximum peak of grid search.