From 39d5608cd6442108756ac3d5ce5a4e06d0dba55c Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Tue, 12 Jul 2022 12:40:56 +0200 Subject: [PATCH] replace FPGA acq configuration struct by a class --- .../acquisition/adapters/CMakeLists.txt | 3 +- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 67 +++-------------- ...lileo_e1_pcps_ambiguous_acquisition_fpga.h | 12 ++- .../galileo_e5a_pcps_acquisition_fpga.cc | 61 +++------------ .../galileo_e5a_pcps_acquisition_fpga.h | 13 ++-- .../galileo_e5b_pcps_acquisition_fpga.cc | 63 +++------------- .../galileo_e5b_pcps_acquisition_fpga.h | 14 ++-- .../gps_l1_ca_pcps_acquisition_fpga.cc | 57 +++----------- .../gps_l1_ca_pcps_acquisition_fpga.h | 13 +++- .../gps_l2_m_pcps_acquisition_fpga.cc | 54 +++---------- .../adapters/gps_l2_m_pcps_acquisition_fpga.h | 11 ++- .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 61 +++------------ .../adapters/gps_l5i_pcps_acquisition_fpga.h | 12 ++- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 10 +-- .../gnuradio_blocks/pcps_acquisition_fpga.h | 32 ++------ .../acquisition/libs/CMakeLists.txt | 12 ++- .../acquisition/libs/acq_conf_fpga.cc | 75 +++++++++++++++++++ .../acquisition/libs/acq_conf_fpga.h | 69 +++++++++++++++++ 18 files changed, 282 insertions(+), 357 deletions(-) create mode 100644 src/algorithms/acquisition/libs/acq_conf_fpga.cc create mode 100644 src/algorithms/acquisition/libs/acq_conf_fpga.h diff --git a/src/algorithms/acquisition/adapters/CMakeLists.txt b/src/algorithms/acquisition/adapters/CMakeLists.txt index 010027d8d..d0251383e 100644 --- a/src/algorithms/acquisition/adapters/CMakeLists.txt +++ b/src/algorithms/acquisition/adapters/CMakeLists.txt @@ -1,7 +1,7 @@ # GNSS-SDR is a Global Navigation Satellite System software-defined receiver. # This file is part of GNSS-SDR. # -# SPDX-FileCopyrightText: 2010-2020 C. Fernandez-Prades cfernandez(at)cttc.es +# SPDX-FileCopyrightText: 2010-2022 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause @@ -123,7 +123,6 @@ if(ENABLE_FPGA) target_link_libraries(acquisition_adapters PRIVATE algorithms_libs - core_libs Volk::volk ) endif() diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 9e3deb0fe..629179924 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -9,7 +9,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -21,7 +21,6 @@ #include "galileo_e1_signal_replica.h" #include "gnss_sdr_fft.h" #include "gnss_sdr_flags.h" -#include "uio_fpga.h" #include #include // for fft_complex #include // for gr_complex @@ -43,56 +42,21 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - pcpsconf_fpga_t acq_parameters; - - std::string default_dump_filename = "./data/acquisition.dat"; + acq_parameters_.SetFromConfiguration(configuration, role, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GALILEO_E1_CODE_CHIP_RATE_CPS, GALILEO_E1_B_CODE_LENGTH_CHIPS); DLOG(INFO) << "role " << role; - int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 4000000); - int64_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - - acq_parameters.repeat_satellite = configuration->property(role + ".repeat_satellite", false); - DLOG(INFO) << role << " satellite repeat = " << acq_parameters.repeat_satellite; - - uint32_t downsampling_factor = configuration->property(role + ".downsampling_factor", 4); - acq_parameters.downsampling_factor = downsampling_factor; - - fs_in = fs_in / downsampling_factor; - - acq_parameters.fs_in = fs_in; - - doppler_max_ = configuration->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) { - doppler_max_ = FLAGS_doppler_max; + acq_parameters_.doppler_max = FLAGS_doppler_max; } - acq_parameters.doppler_max = doppler_max_; - + doppler_max_ = acq_parameters_.doppler_max; + doppler_step_ = static_cast(acq_parameters_.doppler_step); + fs_in_ = acq_parameters_.fs_in; acquire_pilot_ = configuration->property(role + ".acquire_pilot", false); // could be true in future versions - // Find number of samples per spreading code (4 ms) - auto code_length = static_cast(std::round(static_cast(fs_in) / (GALILEO_E1_CODE_CHIP_RATE_CPS / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - acq_parameters.code_length = code_length; - - // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f(static_cast(code_length) * 2.0F)); - uint32_t nsamples_total = pow(2, nbits); - uint32_t select_queue_Fpga = configuration->property(role + ".select_queue_Fpga", 0); - acq_parameters.select_queue_Fpga = select_queue_Fpga; - - // UIO device file - std::string device_io_name; - // find the uio device file corresponding to the acquisition - if (find_uio_dev_file_name(device_io_name, acquisition_device_name, 0) < 0) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device name " << acquisition_device_name << std::endl; - throw std::exception(); - } - acq_parameters.device_name = device_io_name; - - acq_parameters.samples_per_code = nsamples_total; - acq_parameters.excludelimit = static_cast(1 + ceil((1.0 / GALILEO_E1_CODE_CHIP_RATE_CPS) * static_cast(fs_in))); + uint32_t code_length = acq_parameters_.code_length; + uint32_t nsamples_total = acq_parameters_.samples_per_code; // compute all the GALILEO E1 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) @@ -116,13 +80,13 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( // set local signal generator to Galileo E1 pilot component (1C) std::array pilot_signal = {{'1', 'C', '\0'}}; galileo_e1_code_gen_complex_sampled(code, pilot_signal, - cboc, PRN, fs_in, 0, false); + cboc, PRN, fs_in_, 0, false); } else { std::array data_signal = {{'1', 'B', '\0'}}; galileo_e1_code_gen_complex_sampled(code, data_signal, - cboc, PRN, fs_in, 0, false); + cboc, PRN, fs_in_, 0, false); } for (uint32_t s = code_length; s < 2 * code_length; s++) @@ -165,16 +129,9 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( } } - acq_parameters.all_fft_codes = d_all_fft_codes_.data(); + acq_parameters_.all_fft_codes = d_all_fft_codes_.data(); - acq_parameters.num_doppler_bins_step2 = configuration->property(role + ".second_nbins", 4); - acq_parameters.doppler_step2 = configuration->property(role + ".second_doppler_step", static_cast(125.0)); - acq_parameters.make_2_steps = configuration->property(role + ".make_two_steps", false); - acq_parameters.max_num_acqs = configuration->property(role + ".max_num_acqs", 2); - // reference for the FPGA FFT-IFFT attenuation factor - acq_parameters.total_block_exp = configuration->property(role + ".total_block_exp", 13); - - acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters_); if (in_streams_ > 1) { diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 95283fae5..e28fdd087 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -9,7 +9,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -18,7 +18,7 @@ #ifndef GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_FPGA_H #define GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_FPGA_H -#include "acq_conf.h" +#include "acq_conf_fpga.h" #include "channel_fsm.h" #include "gnss_synchro.h" #include "pcps_acquisition_fpga.h" @@ -181,7 +181,9 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: - const std::string acquisition_device_name = "acquisition_S00_AXI"; // UIO device name + static const uint32_t fpga_downsampling_factor = 4; // downampling factor in the FPGA + static const uint32_t fpga_buff_num = 0; // L1/E1 band + static const uint32_t fpga_blk_exp = 13; // default block exponent // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. @@ -195,8 +197,10 @@ private: volk_gnsssdr::vector d_all_fft_codes_; // memory that contains all the code ffts std::weak_ptr channel_fsm_; Gnss_Synchro* gnss_synchro_; - std::string dump_filename_; + const ConfigurationInterface* configuration_; + Acq_Conf_Fpga acq_parameters_; std::string role_; + int64_t fs_in_; int32_t doppler_center_; uint32_t channel_; uint32_t doppler_max_; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 8f68bc73c..444a56d7f 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -9,7 +9,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -21,7 +21,6 @@ #include "galileo_e5_signal_replica.h" #include "gnss_sdr_fft.h" #include "gnss_sdr_flags.h" -#include "uio_fpga.h" #include #include // for gr_complex #include // for volk_32fc_conjugate_32fc @@ -42,29 +41,17 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - pcpsconf_fpga_t acq_parameters; - const std::string default_dump_filename("../data/acquisition.dat"); + acq_parameters_.SetFromConfiguration(configuration, role, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GALILEO_E5A_CODE_CHIP_RATE_CPS, GALILEO_E5A_CODE_LENGTH_CHIPS); DLOG(INFO) << "Role " << role; - int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 32000000); - int64_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - - acq_parameters.repeat_satellite = configuration->property(role + ".repeat_satellite", false); - DLOG(INFO) << role << " satellite repeat = " << acq_parameters.repeat_satellite; - - uint32_t downsampling_factor = configuration->property(role + ".downsampling_factor", 1); - acq_parameters.downsampling_factor = downsampling_factor; - fs_in = fs_in / downsampling_factor; - - acq_parameters.fs_in = fs_in; - - doppler_max_ = configuration->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) { - doppler_max_ = FLAGS_doppler_max; + acq_parameters_.doppler_max = FLAGS_doppler_max; } - acq_parameters.doppler_max = doppler_max_; + doppler_max_ = acq_parameters_.doppler_max; + doppler_step_ = static_cast(acq_parameters_.doppler_step); + fs_in_ = acq_parameters_.fs_in; acq_pilot_ = configuration->property(role + ".acquire_pilot", false); acq_iq_ = configuration->property(role + ".acquire_iq", false); @@ -73,27 +60,8 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga( acq_pilot_ = false; } - auto code_length = static_cast(std::round(static_cast(fs_in) / GALILEO_E5A_CODE_CHIP_RATE_CPS * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); - acq_parameters.code_length = code_length; - - // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f(static_cast(code_length) * 2.0F)); - uint32_t nsamples_total = pow(2, nbits); - uint32_t select_queue_Fpga = configuration->property(role + ".select_queue_Fpga", 1); - acq_parameters.select_queue_Fpga = select_queue_Fpga; - - // UIO device file - std::string device_io_name; - // find the uio device file corresponding to the acquisition - if (find_uio_dev_file_name(device_io_name, acquisition_device_name, 0) < 0) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device name " << acquisition_device_name << std::endl; - throw std::exception(); - } - acq_parameters.device_name = device_io_name; - - acq_parameters.samples_per_code = nsamples_total; - acq_parameters.excludelimit = static_cast(1 + ceil((1.0 / GALILEO_E5A_CODE_CHIP_RATE_CPS) * static_cast(fs_in))); + uint32_t code_length = acq_parameters_.code_length; + uint32_t nsamples_total = acq_parameters_.samples_per_code; // compute all the GALILEO E5 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) @@ -127,7 +95,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga( signal_[1] = 'I'; } - galileo_e5_a_code_gen_complex_sampled(code, PRN, signal_, fs_in, 0); + galileo_e5_a_code_gen_complex_sampled(code, PRN, signal_, fs_in_, 0); for (uint32_t s = code_length; s < 2 * code_length; s++) { @@ -168,16 +136,9 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga( } } - acq_parameters.all_fft_codes = d_all_fft_codes_.data(); + acq_parameters_.all_fft_codes = d_all_fft_codes_.data(); - // reference for the FPGA FFT-IFFT attenuation factor - acq_parameters.total_block_exp = configuration->property(role + ".total_block_exp", 13); - - acq_parameters.num_doppler_bins_step2 = configuration->property(role + ".second_nbins", 4); - acq_parameters.doppler_step2 = configuration->property(role + ".second_doppler_step", static_cast(125.0)); - acq_parameters.make_2_steps = configuration->property(role + ".make_two_steps", false); - acq_parameters.max_num_acqs = configuration->property(role + ".max_num_acqs", 2); - acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters_); if (in_streams_ > 1) { diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index 11321bf68..9968ccd72 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -9,7 +9,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -18,7 +18,7 @@ #ifndef GNSS_SDR_GALILEO_E5A_PCPS_ACQUISITION_FPGA_H #define GNSS_SDR_GALILEO_E5A_PCPS_ACQUISITION_FPGA_H - +#include "acq_conf_fpga.h" #include "channel_fsm.h" #include "gnss_synchro.h" #include "pcps_acquisition_fpga.h" @@ -188,7 +188,9 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: - const std::string acquisition_device_name = "acquisition_S00_AXI"; // UIO device name + static const uint32_t fpga_downsampling_factor = 1; // downampling factor in the FPGA + static const uint32_t fpga_buff_num = 1; // L5/E5a band + static const uint32_t fpga_blk_exp = 13; // default block exponent // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. @@ -202,9 +204,10 @@ private: std::weak_ptr channel_fsm_; volk_gnsssdr::vector d_all_fft_codes_; // memory that contains all the code ffts Gnss_Synchro* gnss_synchro_; + const ConfigurationInterface* configuration_; + Acq_Conf_Fpga acq_parameters_; std::string role_; - std::string item_type_; - std::string dump_filename_; + int64_t fs_in_; int32_t doppler_center_; uint32_t channel_; uint32_t doppler_max_; diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc index 39ecea729..be2e26680 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc @@ -10,7 +10,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -22,7 +22,6 @@ #include "galileo_e5_signal_replica.h" #include "gnss_sdr_fft.h" #include "gnss_sdr_flags.h" -#include "uio_fpga.h" #include #include // for gr_complex #include // for volk_32fc_conjugate_32fc @@ -41,29 +40,15 @@ GalileoE5bPcpsAcquisitionFpga::GalileoE5bPcpsAcquisitionFpga(const Configuration in_streams_(in_streams), out_streams_(out_streams) { - pcpsconf_fpga_t acq_parameters; - std::string default_dump_filename = "../data/acquisition.dat"; + acq_parameters_.SetFromConfiguration(configuration, role, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GALILEO_E5B_CODE_CHIP_RATE_CPS, GALILEO_E5B_CODE_LENGTH_CHIPS); - DLOG(INFO) << "Role " << role; - - int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 32000000); - int64_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - - acq_parameters.repeat_satellite = configuration->property(role + ".repeat_satellite", false); - DLOG(INFO) << role << " satellite repeat = " << acq_parameters.repeat_satellite; - - uint32_t downsampling_factor = configuration->property(role + ".downsampling_factor", 1); - acq_parameters.downsampling_factor = downsampling_factor; - fs_in = fs_in / downsampling_factor; - - acq_parameters.fs_in = fs_in; - - doppler_max_ = configuration->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) { - doppler_max_ = FLAGS_doppler_max; + acq_parameters_.doppler_max = FLAGS_doppler_max; } - acq_parameters.doppler_max = doppler_max_; + doppler_max_ = acq_parameters_.doppler_max; + doppler_step_ = static_cast(acq_parameters_.doppler_step); + fs_in_ = acq_parameters_.fs_in; acq_pilot_ = configuration->property(role + ".acquire_pilot", false); acq_iq_ = configuration->property(role + ".acquire_iq", false); @@ -72,27 +57,8 @@ GalileoE5bPcpsAcquisitionFpga::GalileoE5bPcpsAcquisitionFpga(const Configuration acq_pilot_ = false; } - auto code_length = static_cast(std::round(static_cast(fs_in) / GALILEO_E5B_CODE_CHIP_RATE_CPS * static_cast(GALILEO_E5B_CODE_LENGTH_CHIPS))); - acq_parameters.code_length = code_length; - - // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f(static_cast(code_length) * 2.0F)); - uint32_t nsamples_total = pow(2, nbits); - uint32_t select_queue_Fpga = configuration->property(role + ".select_queue_Fpga", 1); - acq_parameters.select_queue_Fpga = select_queue_Fpga; - - // UIO device file - std::string device_io_name; - // find the uio device file corresponding to the acquisition - if (find_uio_dev_file_name(device_io_name, acquisition_device_name, 0) < 0) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device name " << acquisition_device_name << std::endl; - throw std::exception(); - } - acq_parameters.device_name = device_io_name; - - acq_parameters.samples_per_code = nsamples_total; - acq_parameters.excludelimit = static_cast(1 + ceil((1.0 / GALILEO_E5B_CODE_CHIP_RATE_CPS) * static_cast(fs_in))); + uint32_t code_length = acq_parameters_.code_length; + uint32_t nsamples_total = acq_parameters_.samples_per_code; // compute all the GALILEO E5b PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) @@ -126,7 +92,7 @@ GalileoE5bPcpsAcquisitionFpga::GalileoE5bPcpsAcquisitionFpga(const Configuration signal_[1] = 'I'; } - galileo_e5_b_code_gen_complex_sampled(code, PRN, signal_, fs_in, 0); + galileo_e5_b_code_gen_complex_sampled(code, PRN, signal_, fs_in_, 0); for (uint32_t s = code_length; s < 2 * code_length; s++) { @@ -167,16 +133,9 @@ GalileoE5bPcpsAcquisitionFpga::GalileoE5bPcpsAcquisitionFpga(const Configuration } } - acq_parameters.all_fft_codes = d_all_fft_codes_.data(); + acq_parameters_.all_fft_codes = d_all_fft_codes_.data(); - // reference for the FPGA FFT-IFFT attenuation factor - acq_parameters.total_block_exp = configuration->property(role + ".total_block_exp", 13); - - acq_parameters.num_doppler_bins_step2 = configuration->property(role + ".second_nbins", 4); - acq_parameters.doppler_step2 = configuration->property(role + ".second_doppler_step", static_cast(125.0)); - acq_parameters.make_2_steps = configuration->property(role + ".make_two_steps", false); - acq_parameters.max_num_acqs = configuration->property(role + ".max_num_acqs", 2); - acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters_); if (in_streams_ > 1) { diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h index 6563bb0aa..6e7403906 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h @@ -10,7 +10,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -19,7 +19,7 @@ #ifndef GNSS_SDR_GALILEO_E5B_PCPS_ACQUISITION_FPGA_H #define GNSS_SDR_GALILEO_E5B_PCPS_ACQUISITION_FPGA_H - +#include "acq_conf_fpga.h" #include "channel_fsm.h" #include "gnss_synchro.h" #include "pcps_acquisition_fpga.h" @@ -187,7 +187,9 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: - const std::string acquisition_device_name = "acquisition_S00_AXI"; // UIO device name + static const uint32_t fpga_downsampling_factor = 1; // downampling factor in the FPGA + static const uint32_t fpga_buff_num = 1; // E5b band + static const uint32_t fpga_blk_exp = 13; // default block exponent // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. @@ -202,10 +204,10 @@ private: std::weak_ptr channel_fsm_; Gnss_Synchro* gnss_synchro_; - - std::string item_type_; - std::string dump_filename_; + const ConfigurationInterface* configuration_; + Acq_Conf_Fpga acq_parameters_; std::string role_; + int64_t fs_in_; int32_t doppler_center_; uint32_t channel_; uint32_t doppler_max_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 617329230..5b01d13f4 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -12,7 +12,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -24,7 +24,6 @@ #include "gnss_sdr_fft.h" #include "gnss_sdr_flags.h" #include "gps_sdr_signal_replica.h" -#include "uio_fpga.h" #include #include // for gr_complex #include // for volk_32fc_conjugate_32fc @@ -44,47 +43,20 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - pcpsconf_fpga_t acq_parameters; + acq_parameters_.SetFromConfiguration(configuration, role, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GPS_L1_CA_CODE_RATE_CPS, GPS_L1_CA_CODE_LENGTH_CHIPS); DLOG(INFO) << "role " << role; - int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - int64_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - - acq_parameters.repeat_satellite = configuration->property(role + ".repeat_satellite", false); - DLOG(INFO) << role << " satellite repeat = " << acq_parameters.repeat_satellite; - - uint32_t downsampling_factor = configuration->property(role + ".downsampling_factor", 4); - acq_parameters.downsampling_factor = downsampling_factor; - fs_in = fs_in / downsampling_factor; - - acq_parameters.fs_in = fs_in; - doppler_max_ = configuration->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) { - doppler_max_ = FLAGS_doppler_max; + acq_parameters_.doppler_max = FLAGS_doppler_max; } - acq_parameters.doppler_max = doppler_max_; - auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); - acq_parameters.code_length = code_length; - // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f(static_cast(code_length) * 2.0F)); - uint32_t nsamples_total = pow(2, nbits); - uint32_t select_queue_Fpga = configuration->property(role + ".select_queue_Fpga", 0); - acq_parameters.select_queue_Fpga = select_queue_Fpga; + doppler_max_ = acq_parameters_.doppler_max; + doppler_step_ = static_cast(acq_parameters_.doppler_step); + fs_in_ = acq_parameters_.fs_in; - // UIO device file - std::string device_io_name; - // find the uio device file corresponding to the acquisition - if (find_uio_dev_file_name(device_io_name, acquisition_device_name, 0) < 0) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device name " << acquisition_device_name << std::endl; - throw std::exception(); - } - acq_parameters.device_name = device_io_name; - - acq_parameters.samples_per_code = nsamples_total; - acq_parameters.excludelimit = static_cast(1 + ceil(GPS_L1_CA_CHIP_PERIOD_S * static_cast(fs_in))); + uint32_t code_length = acq_parameters_.code_length; + uint32_t nsamples_total = acq_parameters_.samples_per_code; // compute all the GPS L1 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) @@ -101,7 +73,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( // temporary maxima search for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { - gps_l1_ca_code_gen_complex_sampled(code, PRN, fs_in, 0); // generate PRN code + gps_l1_ca_code_gen_complex_sampled(code, PRN, fs_in_, 0); // generate PRN code for (uint32_t s = code_length; s < 2 * code_length; s++) { @@ -143,16 +115,9 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( } // acq_parameters - acq_parameters.all_fft_codes = d_all_fft_codes_.data(); + acq_parameters_.all_fft_codes = d_all_fft_codes_.data(); - // reference for the FPGA FFT-IFFT attenuation factor - acq_parameters.total_block_exp = configuration->property(role + ".total_block_exp", 10); - - acq_parameters.num_doppler_bins_step2 = configuration->property(role + ".second_nbins", 4); - acq_parameters.doppler_step2 = configuration->property(role + ".second_doppler_step", static_cast(125.0)); - acq_parameters.make_2_steps = configuration->property(role + ".make_two_steps", false); - acq_parameters.max_num_acqs = configuration->property(role + ".max_num_acqs", 2); - acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters_); if (in_streams_ > 1) { diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index a69c8839f..5cb8728d6 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -12,7 +12,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -21,7 +21,7 @@ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FPGA_H #define GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FPGA_H - +#include "acq_conf_fpga.h" #include "channel_fsm.h" #include "gnss_synchro.h" #include "pcps_acquisition_fpga.h" @@ -129,6 +129,8 @@ public: /*! * \brief Set statistics threshold of PCPS algorithm */ + std::string item_type_; + void set_threshold(float threshold) override; /*! @@ -184,7 +186,9 @@ public: private: static const uint32_t NUM_PRNs = 32; - const std::string acquisition_device_name = "acquisition_S00_AXI"; // UIO device name + static const uint32_t fpga_downsampling_factor = 4; // downampling factor in the FPGA + static const uint32_t fpga_buff_num = 0; // L1/E1 band + static const uint32_t fpga_blk_exp = 10; // default block exponent // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. @@ -198,7 +202,10 @@ private: std::weak_ptr channel_fsm_; volk_gnsssdr::vector d_all_fft_codes_; // memory that contains all the code ffts Gnss_Synchro* gnss_synchro_; + const ConfigurationInterface* configuration_; + Acq_Conf_Fpga acq_parameters_; std::string role_; + int64_t fs_in_; int32_t doppler_center_; uint32_t channel_; uint32_t doppler_max_; diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc index 593fb3785..771607f88 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc @@ -11,7 +11,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -24,7 +24,6 @@ #include "gnss_sdr_flags.h" #include "gnss_synchro.h" #include "gps_l2c_signal_replica.h" -#include "uio_fpga.h" #include #include // for gr_complex #include // for volk_32fc_conjugate_32fc @@ -45,47 +44,20 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - pcpsconf_fpga_t acq_parameters; - std::string default_dump_filename = "./acquisition.mat"; + acq_parameters_.SetFromConfiguration(configuration, role, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GPS_L2_M_CODE_RATE_CPS, GPS_L2_M_CODE_LENGTH_CHIPS); LOG(INFO) << "role " << role; - int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - acq_parameters.fs_in = fs_in_; - - acq_parameters.repeat_satellite = configuration->property(role + ".repeat_satellite", false); - DLOG(INFO) << role << " satellite repeat = " << acq_parameters.repeat_satellite; - - doppler_max_ = configuration->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) { - doppler_max_ = FLAGS_doppler_max; + acq_parameters_.doppler_max = FLAGS_doppler_max; } - acq_parameters.doppler_max = doppler_max_; + doppler_max_ = acq_parameters_.doppler_max; + doppler_step_ = static_cast(acq_parameters_.doppler_step); + fs_in_ = acq_parameters_.fs_in; - auto code_length = static_cast(std::round(static_cast(fs_in_) / (GPS_L2_M_CODE_RATE_CPS / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS)))); - acq_parameters.code_length = code_length; - // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f(static_cast(code_length))); - unsigned int nsamples_total = pow(2, nbits); - unsigned int select_queue_Fpga = configuration->property(role + ".select_queue_Fpga", 0); - acq_parameters.select_queue_Fpga = select_queue_Fpga; - - // UIO device file - std::string device_io_name; - // find the uio device file corresponding to the acquisition - if (find_uio_dev_file_name(device_io_name, acquisition_device_name, 0) < 0) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device name " << acquisition_device_name << std::endl; - throw std::exception(); - } - acq_parameters.device_name = device_io_name; - - acq_parameters.samples_per_code = nsamples_total; - acq_parameters.downsampling_factor = configuration->property(role + ".downsampling_factor", 1.0); - acq_parameters.total_block_exp = configuration->property(role + ".total_block_exp", 14); - acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in_) / GPS_L2_M_CODE_RATE_CPS)); + uint32_t code_length = acq_parameters_.code_length; + uint32_t nsamples_total = acq_parameters_.samples_per_code; // compute all the GPS L2C PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) @@ -139,15 +111,9 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( } } - acq_parameters.all_fft_codes = d_all_fft_codes_.data(); + acq_parameters_.all_fft_codes = d_all_fft_codes_.data(); - acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); - - channel_ = 0; - doppler_step_ = 0; - gnss_synchro_ = nullptr; - - threshold_ = 0.0; + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters_); if (in_streams_ > 1) { diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h index 916cd3ea4..7fb6bbc9f 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h @@ -11,7 +11,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -20,6 +20,7 @@ #ifndef GNSS_SDR_GPS_L2_M_PCPS_ACQUISITION_FPGA_H #define GNSS_SDR_GPS_L2_M_PCPS_ACQUISITION_FPGA_H +#include "acq_conf_fpga.h" #include "channel_fsm.h" #include "pcps_acquisition_fpga.h" #include // for basic_block_sptr, top_block_sptr @@ -148,7 +149,9 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: - const std::string acquisition_device_name = "acquisition_S00_AXI"; // UIO device name + static const uint32_t fpga_downsampling_factor = 4; // downampling factor in the FPGA + static const uint32_t fpga_buff_num = 0; // L2 band + static const uint32_t fpga_blk_exp = 13; // default block exponent static const uint32_t NUM_PRNs = 32; static const uint32_t QUANT_BITS_LOCAL_CODE = 16; @@ -161,8 +164,8 @@ private: volk_gnsssdr::vector d_all_fft_codes_; // memory that contains all the code ffts std::weak_ptr channel_fsm_; Gnss_Synchro* gnss_synchro_; - std::string item_type_; - std::string dump_filename_; + const ConfigurationInterface* configuration_; + Acq_Conf_Fpga acq_parameters_; std::string role_; int64_t fs_in_; float threshold_; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index 682e7b1e4..269672f65 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -12,7 +12,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -24,7 +24,6 @@ #include "gnss_sdr_fft.h" #include "gnss_sdr_flags.h" #include "gps_l5_signal_replica.h" -#include "uio_fpga.h" #include #include // for gr_complex #include // for volk_32fc_conjugate_32fc @@ -45,51 +44,20 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - pcpsconf_fpga_t acq_parameters; - std::string default_dump_filename = "./data/acquisition.dat"; + acq_parameters_.SetFromConfiguration(configuration, role, fpga_downsampling_factor, fpga_buff_num, fpga_blk_exp, GPS_L5I_CODE_RATE_CPS, GPS_L5I_CODE_LENGTH_CHIPS); LOG(INFO) << "role " << role; - int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - int64_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - - acq_parameters.repeat_satellite = configuration->property(role + ".repeat_satellite", false); - DLOG(INFO) << role << " satellite repeat = " << acq_parameters.repeat_satellite; - - uint32_t downsampling_factor = configuration->property(role + ".downsampling_factor", 1); - acq_parameters.downsampling_factor = downsampling_factor; - - fs_in = fs_in / downsampling_factor; - - acq_parameters.fs_in = fs_in; - doppler_max_ = configuration->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) { - doppler_max_ = FLAGS_doppler_max; + acq_parameters_.doppler_max = FLAGS_doppler_max; } - acq_parameters.doppler_max = doppler_max_; + doppler_max_ = acq_parameters_.doppler_max; + doppler_step_ = static_cast(acq_parameters_.doppler_step); + fs_in_ = acq_parameters_.fs_in; - // -- Find number of samples per spreading code ------------------------- - auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L5I_CODE_RATE_CPS / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); - acq_parameters.code_length = code_length; - // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f(static_cast(code_length) * 2.0F)); - uint32_t nsamples_total = pow(2, nbits); - uint32_t select_queue_Fpga = configuration->property(role + ".select_queue_Fpga", 1); - acq_parameters.select_queue_Fpga = select_queue_Fpga; - - // UIO device file - std::string device_io_name; - // find the uio device file corresponding to the acquisition - if (find_uio_dev_file_name(device_io_name, acquisition_device_name, 0) < 0) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device name " << acquisition_device_name << std::endl; - throw std::exception(); - } - acq_parameters.device_name = device_io_name; - - acq_parameters.samples_per_code = nsamples_total; - acq_parameters.excludelimit = static_cast(1 + ceil((1.0 / GPS_L5I_CODE_RATE_CPS) * static_cast(fs_in))); + uint32_t code_length = acq_parameters_.code_length; + uint32_t nsamples_total = acq_parameters_.samples_per_code; // compute all the GPS L5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) @@ -106,7 +74,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { - gps_l5i_code_gen_complex_sampled(code, PRN, fs_in); + gps_l5i_code_gen_complex_sampled(code, PRN, fs_in_); for (uint32_t s = code_length; s < 2 * code_length; s++) { @@ -146,16 +114,9 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( } } - acq_parameters.all_fft_codes = d_all_fft_codes_.data(); + acq_parameters_.all_fft_codes = d_all_fft_codes_.data(); - // reference for the FPGA FFT-IFFT attenuation factor - acq_parameters.total_block_exp = configuration->property(role + ".total_block_exp", 13); - - acq_parameters.num_doppler_bins_step2 = configuration->property(role + ".second_nbins", 4); - acq_parameters.doppler_step2 = configuration->property(role + ".second_doppler_step", static_cast(125.0)); - acq_parameters.make_2_steps = configuration->property(role + ".make_two_steps", false); - acq_parameters.max_num_acqs = configuration->property(role + ".max_num_acqs", 2); - acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters_); if (in_streams_ > 1) { diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index e1c5eedb2..5a700d34f 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -12,7 +12,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -21,6 +21,7 @@ #ifndef GNSS_SDR_GPS_L5I_PCPS_ACQUISITION_FPGA_H #define GNSS_SDR_GPS_L5I_PCPS_ACQUISITION_FPGA_H +#include "acq_conf_fpga.h" #include "channel_fsm.h" #include "gnss_synchro.h" #include "pcps_acquisition_fpga.h" @@ -185,7 +186,9 @@ public: private: static const uint32_t NUM_PRNs = 32; - const std::string acquisition_device_name = "acquisition_S00_AXI"; // UIO device name + static const uint32_t fpga_downsampling_factor = 1; // downampling factor in the FPGA + static const uint32_t fpga_buff_num = 1; // L5/E5a band + static const uint32_t fpga_blk_exp = 13; // default block exponent // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. @@ -201,9 +204,10 @@ private: std::weak_ptr channel_fsm_; volk_gnsssdr::vector d_all_fft_codes_; // memory that contains all the code ffts Gnss_Synchro* gnss_synchro_; - std::string item_type_; - std::string dump_filename_; + const ConfigurationInterface* configuration_; + Acq_Conf_Fpga acq_parameters_; std::string role_; + int64_t fs_in_; int32_t doppler_center_; uint32_t channel_; uint32_t doppler_max_; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index e61d65e3e..0414a2d79 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -11,7 +11,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -27,14 +27,14 @@ #include // for move -pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_) +pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(Acq_Conf_Fpga& conf_) { - return pcps_acquisition_fpga_sptr(new pcps_acquisition_fpga(std::move(conf_))); + return pcps_acquisition_fpga_sptr(new pcps_acquisition_fpga(conf_)); } -pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) - : d_acq_parameters(std::move(conf_)), +pcps_acquisition_fpga::pcps_acquisition_fpga(Acq_Conf_Fpga& conf_) + : d_acq_parameters(conf_), d_gnss_synchro(nullptr), d_sample_counter(0ULL), d_threshold(0.0), diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index 3b3e534ee..d0c0c3849 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -17,7 +17,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -26,7 +26,7 @@ #ifndef GNSS_SDR_PCPS_ACQUISITION_FPGA_H #define GNSS_SDR_PCPS_ACQUISITION_FPGA_H - +#include "acq_conf_fpga.h" #include "channel_fsm.h" #include "fpga_acquisition.h" #include @@ -42,31 +42,11 @@ class Gnss_Synchro; -typedef struct -{ - /* pcps acquisition configuration */ - std::string device_name; - int64_t fs_in; - float doppler_step2; - uint32_t* all_fft_codes; // pointer to memory that contains all the code ffts - uint32_t doppler_max; - uint32_t select_queue_Fpga; - uint32_t downsampling_factor; - uint32_t total_block_exp; - uint32_t excludelimit; - uint32_t num_doppler_bins_step2; - uint32_t max_num_acqs; - int32_t samples_per_code; - int32_t code_length; - bool make_2_steps; - bool repeat_satellite; -} pcpsconf_fpga_t; - class pcps_acquisition_fpga; using pcps_acquisition_fpga_sptr = std::shared_ptr; -pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_); +pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(Acq_Conf_Fpga& conf_); /*! * \brief This class implements a Parallel Code Phase Search Acquisition that uses the FPGA. @@ -195,8 +175,8 @@ public: void stop_acquisition(); private: - friend pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_); - explicit pcps_acquisition_fpga(pcpsconf_fpga_t conf_); + friend pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(Acq_Conf_Fpga& conf_); + explicit pcps_acquisition_fpga(Acq_Conf_Fpga& conf_); void send_negative_acquisition(); void send_positive_acquisition(); @@ -206,7 +186,7 @@ private: std::shared_ptr d_acquisition_fpga; std::weak_ptr d_channel_fsm; - pcpsconf_fpga_t d_acq_parameters; + Acq_Conf_Fpga d_acq_parameters; Gnss_Synchro* d_gnss_synchro; diff --git a/src/algorithms/acquisition/libs/CMakeLists.txt b/src/algorithms/acquisition/libs/CMakeLists.txt index c42f59340..9d0894d62 100644 --- a/src/algorithms/acquisition/libs/CMakeLists.txt +++ b/src/algorithms/acquisition/libs/CMakeLists.txt @@ -1,7 +1,7 @@ # GNSS-SDR is a Global Navigation Satellite System software-defined receiver. # This file is part of GNSS-SDR. # -# SPDX-FileCopyrightText: 2010-2020 C. Fernandez-Prades cfernandez(at)cttc.es +# SPDX-FileCopyrightText: 2010-2022 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause @@ -9,6 +9,8 @@ set(ACQUISITION_LIB_HEADERS acq_conf.h) set(ACQUISITION_LIB_SOURCES acq_conf.cc) if(ENABLE_FPGA) + set(ACQUISITION_LIB_SOURCES ${ACQUISITION_LIB_SOURCES} acq_conf_fpga.cc) + set(ACQUISITION_LIB_HEADERS ${ACQUISITION_LIB_HEADERS} acq_conf_fpga.h) set(ACQUISITION_LIB_SOURCES ${ACQUISITION_LIB_SOURCES} fpga_acquisition.cc) set(ACQUISITION_LIB_HEADERS ${ACQUISITION_LIB_HEADERS} fpga_acquisition.h) endif() @@ -55,3 +57,11 @@ set_property(TARGET acquisition_libs APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ ) + +if(ENABLE_FPGA) + target_link_libraries(acquisition_libs + PRIVATE + core_libs + ) +endif() + diff --git a/src/algorithms/acquisition/libs/acq_conf_fpga.cc b/src/algorithms/acquisition/libs/acq_conf_fpga.cc new file mode 100644 index 000000000..93cf6dc28 --- /dev/null +++ b/src/algorithms/acquisition/libs/acq_conf_fpga.cc @@ -0,0 +1,75 @@ +/*! + * \file acq_conf_fpga.cc + * \brief Class that contains all the configuration parameters for generic + * acquisition block based on the PCPS algorithm running in the FPGA. + * \author Marc Majoral, 2022. mmajoral(at)cttc.es + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#include "acq_conf_fpga.h" +#include "item_type_helpers.h" +#include "uio_fpga.h" +#include +#include +#include + +void Acq_Conf_Fpga::SetFromConfiguration(const ConfigurationInterface *configuration, + const std::string &role, uint32_t downs_factor, uint32_t sel_queue_fpga, uint32_t blk_exp, double chip_rate, double code_length_chips) +{ + // sampling frequency + const int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", fs_in); + fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + + // max doppler + doppler_max = configuration->property(role + ".doppler_max", doppler_max); + + // downsampling factor + uint32_t downsampling_factor = configuration->property(role + ".downsampling_factor", downs_factor); + downsampling_factor = downsampling_factor; + fs_in = fs_in / downsampling_factor; + + // code length in samples + code_length = static_cast(std::round(static_cast(fs_in) / (chip_rate / code_length_chips))); + + // The FPGA can only use FFT lengths that are a power of two. + float nbits = ceilf(log2f(static_cast(code_length) * 2.0F)); + samples_per_code = pow(2, nbits); + + // repeat satellite + repeat_satellite = configuration->property(role + ".repeat_satellite", false); + + // FPGA buffer number + select_queue_Fpga = configuration->property(role + ".select_queue_Fpga", sel_queue_fpga); + + // UIO device file + std::string device_io_name; + // find the uio device file corresponding to the acquisition + if (find_uio_dev_file_name(device_io_name, acquisition_device_name, 0) < 0) + { + std::cout << "Cannot find the FPGA uio device file corresponding to device name " << acquisition_device_name << std::endl; + throw std::exception(); + } + device_name = device_io_name; + + // exclusion limit + excludelimit = static_cast(1 + ceil((1.0 / chip_rate) * static_cast(fs_in))); + + // acquisition step 2 parameters + num_doppler_bins_step2 = configuration->property(role + ".second_nbins", num_doppler_bins_step2); + doppler_step2 = configuration->property(role + ".second_doppler_step", doppler_step2); + doppler_step = configuration->property(role + ".doppler_step", doppler_step); + make_2_steps = configuration->property(role + ".make_two_steps", make_2_steps); + max_num_acqs = configuration->property(role + ".max_num_acqs", 2); + + // reference for the FPGA FFT-IFFT attenuation factor + total_block_exp = configuration->property(role + ".total_block_exp", blk_exp); +} diff --git a/src/algorithms/acquisition/libs/acq_conf_fpga.h b/src/algorithms/acquisition/libs/acq_conf_fpga.h new file mode 100644 index 000000000..5bac585f4 --- /dev/null +++ b/src/algorithms/acquisition/libs/acq_conf_fpga.h @@ -0,0 +1,69 @@ +/*! + * \file acq_conf_fpga.h + * \brief Class that contains all the configuration parameters for generic + * acquisition block based on the PCPS algorithm running in the FPGA. + * \author Marc Majoral, 2022. mmajoral(at)cttc.es + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_ACQ_CONF_FPGA_H +#define GNSS_SDR_ACQ_CONF_FPGA_H + +#include "configuration_interface.h" +#include +#include +#include + +/** \addtogroup Acquisition + * \{ */ +/** \addtogroup acquisition_libs acquisition_libs + * Library with utilities for GNSS signal acquisition + * \{ */ + + +class Acq_Conf_Fpga +{ +public: + Acq_Conf_Fpga() = default; + + void SetFromConfiguration(const ConfigurationInterface *configuration, const std::string &role, uint32_t downs_factor, uint32_t sel_queue_fpga, uint32_t blk_exp, double chip_rate, double code_length_chips); + + /* PCPS Acquisition configuration */ + std::string device_name = "uio0"; + uint32_t *all_fft_codes = NULL; // pointer to memory that contains all the code ffts + int64_t fs_in{4000000LL}; + + float doppler_step{250.0}; + float doppler_step2{125.0}; + + uint32_t num_doppler_bins_step2{4U}; + + int32_t doppler_max{5000}; + + uint32_t select_queue_Fpga{0U}; + uint32_t downsampling_factor{4U}; + uint32_t total_block_exp{13U}; + uint32_t excludelimit{5U}; + uint32_t max_num_acqs{2U}; + uint32_t samples_per_code{1U}; + uint32_t code_length{16000U}; + bool make_2_steps{false}; + bool repeat_satellite{false}; + +private: + const std::string acquisition_device_name = "acquisition_S00_AXI"; // UIO device name +}; + + +/** \} */ +/** \} */ +#endif // GNSS_SDR_ACQ_CONF_FPGA_H