GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
fpga_acquisition.h
Go to the documentation of this file.
1 /*!
2  * \file fpga_acquisition.h
3  * \brief Highly optimized FPGA vector correlator class
4  * \authors <ul>
5  * <li> Marc Majoral, 2019. mmajoral(at)cttc.cat
6  * </ul>
7  *
8  * Class that controls and executes a highly optimized acquisition HW
9  * accelerator in the FPGA
10  *
11  * -----------------------------------------------------------------------------
12  *
13  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
14  * This file is part of GNSS-SDR.
15  *
16  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
17  * SPDX-License-Identifier: GPL-3.0-or-later
18  *
19  * -----------------------------------------------------------------------------
20  */
21 
22 #ifndef GNSS_SDR_FPGA_ACQUISITION_H
23 #define GNSS_SDR_FPGA_ACQUISITION_H
24 
25 #include <cstdint>
26 #include <string>
27 
28 /** \addtogroup Acquisition
29  * \{ */
30 /** \addtogroup acquisition_libs
31  * \{ */
32 
33 
34 /*!
35  * \brief Class that implements carrier wipe-off and correlators.
36  */
38 {
39 public:
40  /*!
41  * \brief Constructor
42  */
44  std::string device_name,
45  uint32_t nsamples,
46  uint32_t doppler_max,
47  uint32_t nsamples_total,
48  int64_t fs_in,
49  uint32_t select_queue,
50  uint32_t *all_fft_codes,
51  uint32_t excludelimit);
52 
53  /*!
54  * \brief Destructor
55  */
56  ~Fpga_Acquisition() = default;
57 
58  /*!
59  * \brief Select the code with the chosen PRN
60  */
61  bool set_local_code(uint32_t PRN);
62 
63  /*!
64  * \brief Configure the doppler sweep parameters in the FPGA
65  */
66  void set_doppler_sweep(uint32_t num_sweeps, uint32_t doppler_step, int32_t doppler_min);
67 
68  /*!
69  * \brief Run the acquisition process in the FPGA
70  */
71  void run_acquisition();
72 
73  /*!
74  * \brief Read the results of the acquisition process
75  */
77  uint32_t *max_index,
78  float *firstpeak,
79  float *secondpeak,
80  uint64_t *initial_sample,
81  float *power_sum,
82  uint32_t *doppler_index,
83  uint32_t *total_blk_exp);
84 
85  /*!
86  * \brief Set maximum Doppler grid search
87  * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
88  */
89  void set_doppler_max(uint32_t doppler_max)
90  {
91  d_doppler_max = doppler_max;
92  }
93 
94  /*!
95  * \brief Set Doppler steps for the grid search
96  * \param doppler_step - Frequency bin of the search grid [Hz].
97  */
98  void set_doppler_step(uint32_t doppler_step)
99  {
100  d_doppler_step = doppler_step;
101  }
102 
103  /*!
104  * \brief Reset the FPGA PL.
105  */
106  void reset_acquisition();
107 
108  /*!
109  * \brief stop the acquisition and the FPGA modules.
110  */
111  void stop_acquisition();
112 
113  /*!
114  * \brief Read the scaling factor that has been used by the FFT-IFFT
115  */
116  void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor);
117 
118  /*!
119  * \brief Set the block exponent of the FFT in the FPGA.
120  */
121  void set_block_exp(uint32_t total_block_exp);
122 
123  /*!
124  * \brief Write the PRN code in the FPGA
125  */
126  void write_local_code(void);
127 
128  /*!
129  * \brief Write the acquisition parameters into the FPGA
130  */
131  void configure_acquisition(void);
132 
133  /*!
134  * \brief Open the device driver
135  */
136  void open_device();
137 
138  /*!
139  * \brief Close the device driver
140  */
141  void close_device();
142 
143 private:
144  // FPGA register parameters
145  static const uint32_t FPGA_PAGE_SIZE = 0x1000; // default page size for the multicorrelator memory map
146  static const uint32_t LAUNCH_ACQUISITION = 1; // command to launch the acquisition process
147  static const uint32_t RESET_ACQUISITION = 2; // command to reset the acquisition and the FPGA Modules
148  static const uint32_t STOP_ACQUISITION = 4; // command to stop the acquisition and the FPGA modules
149  static const uint32_t TEST_REG_SANITY_CHECK = 0x55AA; // value to check the presence of the test register (to detect the hw)
150  static const uint32_t LOCAL_CODE_CLEAR_MEM = 0x10000000; // command to clear the internal memory of the multicorrelator
151  static const uint32_t MEM_LOCAL_CODE_WR_ENABLE = 0x0C000000; // command to enable the ENA and WR pins of the internal memory of the multicorrelator
152  static const uint32_t POW_2_2 = 4; // 2^2 (used for the conversion of floating point numbers to integers)
153  static const uint32_t POW_2_31 = 2147483648; // 2^31 (used for the conversion of floating point numbers to integers)
154 
155  static const uint32_t SELECT_LSBits = 0x0000FFFF; // Select the 10 LSbits out of a 20-bit word
156  static const uint32_t SELECT_MSBbits = 0xFFFF0000; // Select the 10 MSbits out of a 20-bit word
157  static const uint32_t SELECT_ALL_CODE_BITS = 0xFFFFFFFF; // Select a 20 bit word
158  static const uint32_t SHL_CODE_BITS = 65536; // shift left by 10 bits
159 
160  // FPGA private functions
161  void fpga_acquisition_test_register(void);
162  void read_result_valid(uint32_t *result_valid);
163 
164  std::string d_device_name; // HW device name
165 
166  int64_t d_fs_in;
167  // data related to the hardware module and the driver
168  int32_t d_fd; // driver descriptor
169  volatile uint32_t *d_map_base; // driver memory map
170  uint32_t *d_all_fft_codes; // memory that contains all the code ffts
171  uint32_t d_vector_length; // number of samples including padding and number of ms
172  uint32_t d_excludelimit;
173  uint32_t d_nsamples_total; // number of samples including padding
174  uint32_t d_nsamples; // number of samples not including padding
175  uint32_t d_select_queue; // queue selection
176  uint32_t d_doppler_max; // max doppler
177  uint32_t d_doppler_step; // doppler step
178  uint32_t d_PRN; // PRN
179 };
180 
181 
182 /** \} */
183 /** \} */
184 #endif // GNSS_SDR_FPGA_ACQUISITION_H
void set_doppler_step(uint32_t doppler_step)
Set Doppler steps for the grid search.
void close_device()
Close the device driver.
Class that implements carrier wipe-off and correlators.
~Fpga_Acquisition()=default
Destructor.
void reset_acquisition()
Reset the FPGA PL.
void set_block_exp(uint32_t total_block_exp)
Set the block exponent of the FFT in the FPGA.
void stop_acquisition()
stop the acquisition and the FPGA modules.
Fpga_Acquisition(std::string device_name, uint32_t nsamples, uint32_t doppler_max, uint32_t nsamples_total, int64_t fs_in, uint32_t select_queue, uint32_t *all_fft_codes, uint32_t excludelimit)
Constructor.
void open_device()
Open the device driver.
bool set_local_code(uint32_t PRN)
Select the code with the chosen PRN.
void run_acquisition()
Run the acquisition process in the FPGA.
void read_acquisition_results(uint32_t *max_index, float *firstpeak, float *secondpeak, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index, uint32_t *total_blk_exp)
Read the results of the acquisition process.
void configure_acquisition(void)
Write the acquisition parameters into the FPGA.
void set_doppler_sweep(uint32_t num_sweeps, uint32_t doppler_step, int32_t doppler_min)
Configure the doppler sweep parameters in the FPGA.
void set_doppler_max(uint32_t doppler_max)
Set maximum Doppler grid search.
void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor)
Read the scaling factor that has been used by the FFT-IFFT.
void write_local_code(void)
Write the PRN code in the FPGA.