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