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