GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
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#include <utility> // for std::move, std::pair
28#include <vector> // for std::vector
29
30/** \addtogroup Acquisition
31 * \{ */
32/** \addtogroup acquisition_libs
33 * \{ */
34
35
36/*!
37 * \brief Class that implements carrier wipe-off and correlators.
38 */
40{
41public:
42 /*!
43 * \brief Constructor
44 */
46 std::string device_name,
47 uint32_t select_queue,
48 std::vector<std::pair<uint32_t, uint32_t>> &downsampling_filter_specs,
49 uint32_t &max_FFT_size);
50
51 /*!
52 * \brief Destructor
53 */
54 ~Fpga_Acquisition() = default;
55
56 /*!
57 * \brief Initialize acquisition parameters
58 */
59 // void init(uint32_t samples_per_code, uint32_t code_length, int64_t resampled_fs, uint32_t *all_fft_codes);
60 void init(uint32_t nsamples, uint32_t d_fft_size,
61 int64_t resampled_fs, uint32_t downsampling_filter_num, uint32_t excludelimit, uint32_t *all_fft_codes);
62
63 /*!
64 * \brief Select the code with the chosen PRN
65 */
66 bool set_local_code(uint32_t PRN);
67
68 /*!
69 * \brief Configure the doppler sweep parameters in the FPGA
70 */
71 void set_doppler_sweep(uint32_t num_sweeps, uint32_t doppler_step, int32_t doppler_min);
72
73 /*!
74 * \brief Run the acquisition process in the FPGA
75 */
77
78 /*!
79 * \brief Read the results of the acquisition process
80 */
82 uint32_t *max_index,
83 float *firstpeak,
84 float *secondpeak,
85 uint64_t *initial_sample,
86 float *power_sum,
87 uint32_t *doppler_index,
88 uint32_t *total_blk_exp);
89
90 /*!
91 * \brief Reset the FPGA PL.
92 */
94
95 /*!
96 * \brief stop the acquisition and the FPGA modules.
97 */
99
100 /*!
101 * \brief Set the block exponent of the FFT in the FPGA.
102 */
103 void set_block_exp(uint32_t total_block_exp);
104
105 /*!
106 * \brief Write the PRN code in the FPGA
107 */
109
110 /*!
111 * \brief Write the acquisition parameters into the FPGA
112 */
114
115 /*!
116 * \brief Open the device driver
117 */
119
120 /*!
121 * \brief Close the device driver
122 */
124
125private:
126 // FPGA IP Core version
127 static const uint32_t FPGA_ACQ_IP_VERSION_1 = 0x0001; // FPGA IP core version
128
129 // FPGA register addresses
130
131 // write-only registers
132 static const uint32_t FREQ_BAND_DOWNSAMPLE_REG_ADDR = 0; // Select frequency band and downsampling filter
133 static const uint32_t FFT_LENGTH_REG_ADDR = 1; // Length of the FFT
134 static const uint32_t CORR_NSAMPLES_REG_ADDR = 2; // Correlation length
135 static const uint32_t DOPPLER_MIN_REG_ADDR = 3; // Doppler min
136 static const uint32_t DOPPLER_STEP_REG_ADDR = 4; // Doppler step
137 static const uint32_t NUM_DOPPLER_SEARCH_STEPS_REG_ADDR = 5; // Number of Doppler search steps
138 static const uint32_t PROG_MEM_ADDR = 6; // Access to the memory storing the PRN code of the target satellite.
139 static const uint32_t LOG2_FFT_LENGTH_REG_ADDR = 7; // Log2(FFT_LENGTH)
140 static const uint32_t ACQ_COMMAND_FLAGS_REG_ADDR = 8; // Flags that reset, start, and stop the acquisition process.
141 static const uint32_t CLEAR_MEM_REG_ADDR = 9; // Flag that resets the write address of the PRN code memory.
142 static const uint32_t MAX_FFT_SCALING_FACTOR_REG_ADDR = 11; // Reference FFT scaling factor
143 static const uint32_t EXCL_LIM_REG_ADDR = 12; // Exclude Limit value for the second FFT peak search process
144
145 // read-write registers
146 static const uint32_t TEST_REG_ADDR = 15;
147
148 // read-only registers
149 static const uint32_t RESULT_VALID_REG_ADDR = 0; // Flag that indicates a valid result
150 static const uint32_t SAMPLESTAMP_LSW_REG_ADDR = 1; // Sample stamp LSW
151 static const uint32_t SAMPLESTAMP_MSW_REG_ADDR = 2; // Sample stamp MSW
152 static const uint32_t MAG_SQ_FIRST_PEAK_REG_ADDR = 3; // magnitude squared of the first peak
153 static const uint32_t MAG_SQ_SECOND_PEAK_REG_ADDR = 4; // magnitude squared of the second peak
154 static const uint32_t ACQ_DELAY_SAMPLES_REG_ADDR = 5; // acquisition delay in samples
155 static const uint32_t DOPPLER_INDEX_REG_ADDR = 7; // Doppler index
156 static const uint32_t FFT_SCALING_FACTOR_REG_ADDR = 8; // Scaling factor applied by the FFT
157 static const uint32_t MAX_FFT_SIZE_REG_ADDR = 9; // Maximum FFT size supported by the FPGA
158 static const uint32_t DOWNSAMPLING_FILTER_DEC_FACTORS_REG_ADDR = 10; // Available decimation factors
159 static const uint32_t DOWNSAMPLING_FILTER_LATENCIES_REG_ADDR = 11; // Available downsampling filter latencies
160 static const uint32_t FPGA_IP_CORE_VERSION_REG_ADDR = 14; // FPGA acquisition IP core version
161
162 // FPGA register parameters
163 static const uint32_t FPGA_PAGE_SIZE = 0x1000; // default page size for the multicorrelator memory map
164 static const uint32_t LAUNCH_ACQUISITION = 1; // command to launch the acquisition process
165 static const uint32_t RESET_ACQUISITION = 2; // command to reset the acquisition and the FPGA Modules
166 static const uint32_t STOP_ACQUISITION = 4; // command to stop the acquisition and the FPGA modules
167 static const uint32_t TEST_REG_SANITY_CHECK = 0x55AA; // value to check the presence of the test register (to detect the hw)
168 static const uint32_t LOCAL_CODE_CLEAR_MEM = 0x10000000; // command to clear the internal memory of the multicorrelator
169 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
170 static const uint32_t POW_2_2 = 4; // 2^2 (used for the conversion of floating point numbers to integers)
171 static const uint32_t POW_2_31 = 2147483648; // 2^31 (used for the conversion of floating point numbers to integers)
172 static const uint32_t MAX_FILTERS_AVAILABLE = 2; // maximum number of downsampling filters available in the FPGA by default
173 static const uint32_t DEFAULT_MAX_FFT_SIZE = 32768; // default maximum FFT size supported by the FPGA
174 static const uint32_t ACQ_BUFF_0 = 0; // FPGA Acquisition IP buffer containing L1/E1 frequency band samples by default.
175 static const uint32_t ACQ_BUFF_1 = 0; // FPGA Acquisition IP buffer containing L2 or L5/E5a frequency band samples by default.
176
177 // bit manipulation
178 static const uint32_t RSHIFT_4_BITS = 0x4;
179 static const uint32_t RSHIFT_8_BITS = 0x8;
180 static const uint32_t BIT_MASK_4 = 0xF;
181 static const uint32_t BIT_MASK_8 = 0xFF;
182
183 // Downsampling default constants
184 const uint32_t DEFAULT_DOWNSAMPLING_FILTER_DELAY = 40; // default downsampling filter delay (for FPGA Acquisition IP core versions earlier than FPGA_ACQ_IP_VERSION_1)
185 const uint32_t DEFAULT_DOWNSAMPLING_FACTOR = 4; // default downsampling factor (for FPGA Acquisition IP core versions earlier than FPGA_ACQ_IP_VERSION_1)
186
187 // private methods
188 void fpga_acquisition_test_register(void);
189 void read_ipcore_info(std::vector<std::pair<uint32_t, uint32_t>> &downsampling_filter_specs, uint32_t &max_FFT_size);
190
191 std::vector<std::pair<uint32_t, uint32_t>> d_downsampling_filter_specs;
192 std::string d_device_name; // HW device name
193 int64_t d_resampled_fs; // sampling frequency
194 volatile uint32_t *d_map_base; // driver memory map
195 uint32_t *d_all_fft_codes; // memory that contains all the code ffts
196 int32_t d_fd; // driver descriptor
197 uint32_t d_fft_size; // number of samples including padding
198 uint32_t d_excludelimit;
199 uint32_t d_nsamples; // number of samples not including padding
200 uint32_t d_filter_num; // Selected downsampling filter
201 uint32_t d_downsampling_factor; // downsampling_factor
202 uint32_t d_downsampling_filter_delay; // Impulse response delay of the downsampling filter
203 uint32_t d_select_queue; // queue selection
204 uint32_t d_PRN; // PRN
205 uint32_t d_IP_core_version; // FPGA acquisition IP core version
206};
207
208
209/** \} */
210/** \} */
211#endif // GNSS_SDR_FPGA_ACQUISITION_H
void stop_acquisition()
stop the acquisition and the FPGA modules.
~Fpga_Acquisition()=default
Destructor.
void close_device()
Close the device driver.
void write_local_code(void)
Write the PRN code in the FPGA.
void reset_acquisition()
Reset the FPGA PL.
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 init(uint32_t nsamples, uint32_t d_fft_size, int64_t resampled_fs, uint32_t downsampling_filter_num, uint32_t excludelimit, uint32_t *all_fft_codes)
Initialize acquisition parameters.
Fpga_Acquisition(std::string device_name, uint32_t select_queue, std::vector< std::pair< uint32_t, uint32_t > > &downsampling_filter_specs, uint32_t &max_FFT_size)
Constructor.
bool set_local_code(uint32_t PRN)
Select the code with the chosen PRN.
void open_device()
Open the device driver.
void set_block_exp(uint32_t total_block_exp)
Set the block exponent of the FFT in the FPGA.
void run_acquisition()
Run the acquisition process in the FPGA.
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.