2017-05-05 14:14:27 +00:00
|
|
|
/*!
|
2018-04-27 18:00:50 +00:00
|
|
|
* \file fpga_acquisition.h
|
2019-03-06 12:49:14 +00:00
|
|
|
* \brief Highly optimized FPGA vector correlator class
|
2017-05-05 14:14:27 +00:00
|
|
|
* \authors <ul>
|
2019-02-26 17:28:14 +00:00
|
|
|
* <li> Marc Majoral, 2019. mmajoral(at)cttc.cat
|
2017-05-05 14:14:27 +00:00
|
|
|
* </ul>
|
|
|
|
*
|
2019-03-06 12:49:14 +00:00
|
|
|
* Class that controls and executes a highly optimized acquisition HW
|
2018-04-27 18:00:50 +00:00
|
|
|
* accelerator in the FPGA
|
2017-05-05 14:14:27 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2019-02-26 17:28:14 +00:00
|
|
|
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
2017-05-05 14:14:27 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2017-05-05 14:14:27 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2020-02-08 09:10:46 +00:00
|
|
|
#ifndef GNSS_SDR_FPGA_ACQUISITION_H
|
|
|
|
#define GNSS_SDR_FPGA_ACQUISITION_H
|
2017-05-05 14:14:27 +00:00
|
|
|
|
2018-08-11 09:42:07 +00:00
|
|
|
#include <cstdint>
|
2019-03-06 12:49:14 +00:00
|
|
|
#include <string>
|
2017-05-05 14:14:27 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Class that implements carrier wipe-off and correlators.
|
|
|
|
*/
|
2019-02-28 20:45:30 +00:00
|
|
|
class Fpga_Acquisition
|
2017-05-05 14:14:27 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-07-24 09:26:16 +00:00
|
|
|
/*!
|
2019-10-05 01:16:31 +00:00
|
|
|
* \brief Constructor
|
|
|
|
*/
|
2019-07-02 15:48:00 +00:00
|
|
|
Fpga_Acquisition(
|
|
|
|
std::string device_name,
|
2018-08-11 09:42:07 +00:00
|
|
|
uint32_t nsamples,
|
|
|
|
uint32_t doppler_max,
|
|
|
|
uint32_t nsamples_total,
|
|
|
|
int64_t fs_in,
|
|
|
|
uint32_t select_queue,
|
2019-03-26 11:26:08 +00:00
|
|
|
uint32_t *all_fft_codes,
|
2019-02-27 16:27:31 +00:00
|
|
|
uint32_t excludelimit);
|
2018-08-11 09:42:07 +00:00
|
|
|
|
2019-07-23 17:05:43 +00:00
|
|
|
/*!
|
|
|
|
* \brief Destructor
|
|
|
|
*/
|
2019-07-21 17:32:52 +00:00
|
|
|
~Fpga_Acquisition() = default;
|
2019-07-02 15:48:00 +00:00
|
|
|
|
2019-07-23 17:05:43 +00:00
|
|
|
/*!
|
|
|
|
* \brief Select the code with the chosen PRN
|
|
|
|
*/
|
2018-08-11 09:42:07 +00:00
|
|
|
bool set_local_code(uint32_t PRN);
|
2019-07-02 15:48:00 +00:00
|
|
|
|
2019-07-23 17:05:43 +00:00
|
|
|
/*!
|
|
|
|
* \brief Configure the doppler sweep parameters in the FPGA
|
|
|
|
*/
|
2019-03-01 19:37:14 +00:00
|
|
|
void set_doppler_sweep(uint32_t num_sweeps, uint32_t doppler_step, int32_t doppler_min);
|
2019-07-02 15:48:00 +00:00
|
|
|
|
2019-07-23 17:05:43 +00:00
|
|
|
/*!
|
|
|
|
* \brief Run the acquisition process in the FPGA
|
|
|
|
*/
|
2019-08-14 00:14:29 +00:00
|
|
|
void run_acquisition();
|
2019-02-28 19:49:35 +00:00
|
|
|
|
2019-07-23 17:05:43 +00:00
|
|
|
/*!
|
|
|
|
* \brief Read the results of the acquisition process
|
|
|
|
*/
|
2019-07-02 15:48:00 +00:00
|
|
|
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);
|
2018-10-31 17:48:08 +00:00
|
|
|
|
2017-05-18 15:10:28 +00:00
|
|
|
/*!
|
|
|
|
* \brief Set maximum Doppler grid search
|
|
|
|
* \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
|
|
|
|
*/
|
2018-08-11 09:42:07 +00:00
|
|
|
void set_doppler_max(uint32_t doppler_max)
|
2017-05-18 15:10:28 +00:00
|
|
|
{
|
|
|
|
d_doppler_max = doppler_max;
|
|
|
|
}
|
2018-04-27 18:00:50 +00:00
|
|
|
|
2017-05-18 15:10:28 +00:00
|
|
|
/*!
|
|
|
|
* \brief Set Doppler steps for the grid search
|
|
|
|
* \param doppler_step - Frequency bin of the search grid [Hz].
|
|
|
|
*/
|
2018-08-11 09:42:07 +00:00
|
|
|
void set_doppler_step(uint32_t doppler_step)
|
2017-05-18 15:10:28 +00:00
|
|
|
{
|
|
|
|
d_doppler_step = doppler_step;
|
|
|
|
}
|
|
|
|
|
2018-09-12 14:02:23 +00:00
|
|
|
/*!
|
2019-02-26 17:28:14 +00:00
|
|
|
* \brief Reset the FPGA PL.
|
2018-09-12 14:02:23 +00:00
|
|
|
*/
|
2019-08-14 00:14:29 +00:00
|
|
|
void reset_acquisition();
|
2018-09-12 14:02:23 +00:00
|
|
|
|
2018-09-18 09:36:12 +00:00
|
|
|
/*!
|
2019-07-23 17:05:43 +00:00
|
|
|
* \brief Read the scaling factor that has been used by the FFT-IFFT
|
2018-09-18 09:36:12 +00:00
|
|
|
*/
|
|
|
|
void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor);
|
|
|
|
|
2019-07-23 17:05:43 +00:00
|
|
|
/*!
|
|
|
|
* \brief Set the block exponent of the FFT in the FPGA.
|
|
|
|
*/
|
2018-10-31 17:48:08 +00:00
|
|
|
void set_block_exp(uint32_t total_block_exp);
|
|
|
|
|
2019-07-23 17:05:43 +00:00
|
|
|
/*!
|
|
|
|
* \brief Write the PRN code in the FPGA
|
|
|
|
*/
|
2018-10-31 17:48:08 +00:00
|
|
|
void write_local_code(void);
|
|
|
|
|
2019-07-23 17:05:43 +00:00
|
|
|
/*!
|
|
|
|
* \brief Write the acquisition parameters into the FPGA
|
|
|
|
*/
|
2018-10-31 17:48:08 +00:00
|
|
|
void configure_acquisition(void);
|
|
|
|
|
2019-07-23 17:05:43 +00:00
|
|
|
/*!
|
|
|
|
* \brief Open the device driver
|
|
|
|
*/
|
2018-12-05 10:23:30 +00:00
|
|
|
void open_device();
|
2018-10-31 17:48:08 +00:00
|
|
|
|
2019-07-23 17:05:43 +00:00
|
|
|
/*!
|
|
|
|
* \brief Close the device driver
|
|
|
|
*/
|
2019-07-02 15:48:00 +00:00
|
|
|
void close_device();
|
|
|
|
|
2017-05-05 14:14:27 +00:00
|
|
|
private:
|
2019-07-23 13:20:59 +00:00
|
|
|
// FPGA register parameters
|
2019-07-26 11:22:11 +00:00
|
|
|
static const uint32_t PAGE_SIZE_DEFAULT = 0x10000; // default page size for the multicorrelator memory map
|
2019-07-23 13:20:59 +00:00
|
|
|
static const uint32_t RESET_ACQUISITION = 2; // command to reset the multicorrelator
|
|
|
|
static const uint32_t LAUNCH_ACQUISITION = 1; // command to launch the multicorrelator
|
|
|
|
static const uint32_t TEST_REG_SANITY_CHECK = 0x55AA; // value to check the presence of the test register (to detect the hw)
|
|
|
|
static const uint32_t LOCAL_CODE_CLEAR_MEM = 0x10000000; // command to clear the internal memory of the multicorrelator
|
|
|
|
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
|
|
|
|
static const uint32_t POW_2_2 = 4; // 2^2 (used for the conversion of floating point numbers to integers)
|
|
|
|
static const uint32_t POW_2_31 = 2147483648; // 2^31 (used for the conversion of floating point numbers to integers)
|
|
|
|
|
|
|
|
static const uint32_t SELECT_LSBits = 0x0000FFFF; // Select the 10 LSbits out of a 20-bit word
|
|
|
|
static const uint32_t SELECT_MSBbits = 0xFFFF0000; // Select the 10 MSbits out of a 20-bit word
|
|
|
|
static const uint32_t SELECT_ALL_CODE_BITS = 0xFFFFFFFF; // Select a 20 bit word
|
|
|
|
static const uint32_t SHL_CODE_BITS = 65536; // shift left by 10 bits
|
|
|
|
|
2018-08-11 09:42:07 +00:00
|
|
|
int64_t d_fs_in;
|
2017-05-18 15:10:28 +00:00
|
|
|
// data related to the hardware module and the driver
|
2018-08-11 09:42:07 +00:00
|
|
|
int32_t d_fd; // driver descriptor
|
|
|
|
volatile uint32_t *d_map_base; // driver memory map
|
2019-04-04 17:55:02 +00:00
|
|
|
uint32_t *d_all_fft_codes; // memory that contains all the code ffts
|
2019-07-09 09:52:53 +00:00
|
|
|
uint32_t d_vector_length; // number of samples including padding and number of ms
|
2018-10-31 17:48:08 +00:00
|
|
|
uint32_t d_excludelimit;
|
2019-02-27 16:27:31 +00:00
|
|
|
uint32_t d_nsamples_total; // number of samples including padding
|
|
|
|
uint32_t d_nsamples; // number of samples not including padding
|
|
|
|
uint32_t d_select_queue; // queue selection
|
|
|
|
std::string d_device_name; // HW device name
|
|
|
|
uint32_t d_doppler_max; // max doppler
|
|
|
|
uint32_t d_doppler_step; // doppler step
|
|
|
|
uint32_t d_PRN; // PRN
|
2017-05-05 14:14:27 +00:00
|
|
|
// FPGA private functions
|
2018-11-30 10:07:01 +00:00
|
|
|
void fpga_acquisition_test_register(void);
|
2018-10-31 17:48:08 +00:00
|
|
|
void read_result_valid(uint32_t *result_valid);
|
2017-05-05 14:14:27 +00:00
|
|
|
};
|
|
|
|
|
2020-02-08 09:10:46 +00:00
|
|
|
#endif // GNSS_SDR_FPGA_ACQUISITION_H
|