1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-12-16 21:38:06 +00:00

Add base class for FPGA-based acquisition adapters

Update changelog
This commit is contained in:
Carles Fernandez
2025-10-25 16:56:54 +02:00
parent 7e66db864e
commit 7fc4209428
16 changed files with 509 additions and 1869 deletions

View File

@@ -33,6 +33,9 @@ All notable changes to GNSS-SDR will be documented in this file.
implementations, greatly improving maintainability, simplifying the addition
of new signals, and eliminating a lot of duplicated code. Awesome contribution
by @MathieuFavreau.
- Added a base class for the main acquisition adapters, improving
maintainability and extensibility. Another excellent contribution by
@MathieuFavreau.
- Refactored the internal handling of multi-signal configurations in the PVT
block for improved maintainability and extensibility. Another excellent
contribution by @MathieuFavreau.

View File

@@ -55,6 +55,7 @@ set(ACQ_ADAPTER_HEADERS
if(ENABLE_FPGA)
set(ACQ_ADAPTER_SOURCES ${ACQ_ADAPTER_SOURCES}
base_pcps_acquisition_fpga.cc
gps_l1_ca_pcps_acquisition_fpga.cc
gps_l2_m_pcps_acquisition_fpga.cc
galileo_e1_pcps_ambiguous_acquisition_fpga.cc
@@ -63,6 +64,7 @@ if(ENABLE_FPGA)
gps_l5i_pcps_acquisition_fpga.cc
)
set(ACQ_ADAPTER_HEADERS ${ACQ_ADAPTER_HEADERS}
base_pcps_acquisition_fpga.h
gps_l1_ca_pcps_acquisition_fpga.h
gps_l2_m_pcps_acquisition_fpga.h
galileo_e1_pcps_ambiguous_acquisition_fpga.h

View File

@@ -0,0 +1,252 @@
/*!
* \file base_pcps_acquisition_fpga.cc
* \brief Shared implementation for FPGA-based PCPS acquisition adapters
* \authors Carles Fernandez, 2025. carles.fernandez(at)cttc.cat
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "base_pcps_acquisition_fpga.h"
#include "configuration_interface.h"
#include "gnss_sdr_flags.h"
#include <vector>
#if USE_GLOG_AND_GFLAGS
#include <glog/logging.h>
#else
#include <absl/log/log.h>
#endif
BasePcpsAcquisitionFpga::BasePcpsAcquisitionFpga(
const ConfigurationInterface* configuration,
std::string role,
double code_rate_cps,
double code_length_chips,
uint32_t opt_acq_fs_sps,
uint32_t default_fpga_blk_exp,
uint32_t acq_buff,
unsigned int in_streams,
unsigned int out_streams)
: doppler_center_(0),
doppler_max_(0),
doppler_step_(0),
role_(std::move(role)),
gnss_synchro_(nullptr),
channel_(0),
in_streams_(in_streams),
out_streams_(out_streams)
{
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
}
if (out_streams_ > 0)
{
LOG(ERROR) << "This implementation does not provide an output stream";
}
// set acquisition parameters
acq_parameters_.SetFromConfiguration(configuration, role_, default_fpga_blk_exp, code_rate_cps, code_length_chips);
// Query the capabilities of the instantiated FPGA Acquisition IP Core
std::vector<std::pair<uint32_t, uint32_t>> downsampling_filter_specs;
uint32_t max_FFT_size;
acquisition_fpga_ = pcps_make_acquisition_fpga(&acq_parameters_, acq_buff, downsampling_filter_specs, max_FFT_size);
// Configure the automatic resampler according to the capabilities of the instantiated FPGA Acquisition IP Core.
// When the FPGA is in use, the acquisition resampler operates only in the L1/E1 frequency band.
if (acq_buff == 0)
{
bool acq_configuration_valid = acq_parameters_.ConfigureAutomaticResampler(downsampling_filter_specs, max_FFT_size, opt_acq_fs_sps);
if (!acq_configuration_valid)
{
std::cout << "The FPGA acquisition IP does not support the required sampling frequency of " << acq_parameters_.fs_in << " SPS for the L1/E1 band. Please update the sampling frequency in the configuration file." << std::endl;
exit(0);
}
}
else
{
bool acq_configuration_valid = acq_parameters_.Is_acq_config_valid(max_FFT_size);
if (!acq_configuration_valid)
{
std::cout << "The FPGA acquisition IP does not support the required sampling frequency of " << acq_parameters_.fs_in << " SPS for the L2/L5 band. Please update the sampling frequency in the configuration file." << std::endl;
exit(0);
}
}
DLOG(INFO) << "role " << role_;
#if USE_GLOG_AND_GFLAGS
if (FLAGS_doppler_max != 0)
{
acq_parameters_.doppler_max = FLAGS_doppler_max;
}
#else
if (absl::GetFlag(FLAGS_doppler_max) != 0)
{
acq_parameters_.doppler_max = absl::GetFlag(FLAGS_doppler_max);
}
#endif
doppler_max_ = acq_parameters_.doppler_max;
doppler_step_ = static_cast<unsigned int>(acq_parameters_.doppler_step);
}
void BasePcpsAcquisitionFpga::connect(gr::top_block_sptr top_block)
{
if (top_block)
{
// FPGA acquisition blocks usually dont connect to GNU Radio flowgraphs
}
}
void BasePcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block)
{
if (top_block)
{
// No connections to remove
}
}
gr::basic_block_sptr BasePcpsAcquisitionFpga::get_left_block()
{
return nullptr;
}
gr::basic_block_sptr BasePcpsAcquisitionFpga::get_right_block()
{
return nullptr;
}
void BasePcpsAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro)
{
gnss_synchro_ = gnss_synchro;
if (acquisition_fpga_)
{
acquisition_fpga_->set_gnss_synchro(gnss_synchro_);
}
}
void BasePcpsAcquisitionFpga::set_channel(unsigned int channel)
{
channel_ = channel;
if (acquisition_fpga_)
{
acquisition_fpga_->set_channel(channel_);
}
}
void BasePcpsAcquisitionFpga::set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm)
{
channel_fsm_ = std::move(channel_fsm);
if (acquisition_fpga_)
{
acquisition_fpga_->set_channel_fsm(channel_fsm_);
}
}
void BasePcpsAcquisitionFpga::set_threshold(float threshold)
{
if (acquisition_fpga_)
{
acquisition_fpga_->set_threshold(threshold);
}
}
void BasePcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max)
{
doppler_max_ = doppler_max;
if (acquisition_fpga_)
{
acquisition_fpga_->set_doppler_max(doppler_max_);
}
}
void BasePcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step)
{
doppler_step_ = doppler_step;
if (acquisition_fpga_)
{
acquisition_fpga_->set_doppler_step(doppler_step_);
}
}
void BasePcpsAcquisitionFpga::set_doppler_center(int doppler_center)
{
doppler_center_ = doppler_center;
if (acquisition_fpga_)
{
acquisition_fpga_->set_doppler_center(doppler_center_);
}
}
void BasePcpsAcquisitionFpga::set_state(int state)
{
if (acquisition_fpga_)
{
acquisition_fpga_->set_state(state);
}
}
void BasePcpsAcquisitionFpga::reset()
{
if (acquisition_fpga_)
{
acquisition_fpga_->set_active(true);
}
}
void BasePcpsAcquisitionFpga::stop_acquisition()
{
if (acquisition_fpga_)
{
acquisition_fpga_->stop_acquisition();
}
}
void BasePcpsAcquisitionFpga::init()
{
if (acquisition_fpga_)
{
acquisition_fpga_->init();
}
}
signed int BasePcpsAcquisitionFpga::mag()
{
if (acquisition_fpga_)
{
return acquisition_fpga_->mag();
}
return 0;
}
void BasePcpsAcquisitionFpga::set_local_code()
{
acquisition_fpga_->set_local_code();
}

View File

@@ -0,0 +1,116 @@
/*!
* \file base_pcps_acquisition_fpga.h
* \brief Shared implementation for FPGA-based PCPS acquisition adapters
* \authors Carles Fernandez, 2025. carles.fernandez(at)cttc.cat
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_BASE_PCPS_ACQUISITION_FPGA_H
#define GNSS_SDR_BASE_PCPS_ACQUISITION_FPGA_H
#include "acq_conf_fpga.h"
#include "channel_fsm.h"
#include "gnss_synchro.h"
#include "pcps_acquisition_fpga.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
/** \addtogroup Acquisition
* Classes for GNSS signal acquisition
* \{ */
/** \addtogroup Acq_adapters acquisition_adapters
* Wrap GNU Radio acquisition blocks with an AcquisitionInterface
* \{ */
class ConfigurationInterface;
/*!
* \brief Base class providing shared logic for FPGA-based GPS PCPS acquisition adapters.
*/
class BasePcpsAcquisitionFpga : public AcquisitionInterface
{
public:
BasePcpsAcquisitionFpga(const ConfigurationInterface* configuration,
std::string role,
double code_rate_cps,
double code_length_chips,
uint32_t opt_acq_fs_sps,
uint32_t default_fpga_blk_exp,
uint32_t acq_buff,
unsigned int in_streams,
unsigned int out_streams);
~BasePcpsAcquisitionFpga() override = default;
inline std::string role() override final { return role_; }
inline size_t item_size() override { return sizeof(int16_t); }
// Common AcquisitionInterface overrides
void connect(gr::top_block_sptr top_block) override;
void disconnect(gr::top_block_sptr top_block) override;
gr::basic_block_sptr get_left_block() override;
gr::basic_block_sptr get_right_block() override;
signed int mag() override;
void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override;
void set_channel(unsigned int channel) override;
void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override;
void set_threshold(float threshold) override;
void set_doppler_max(unsigned int doppler_max) override;
void set_doppler_step(unsigned int doppler_step) override;
void set_doppler_center(int doppler_center) override;
void set_state(int state) override;
void reset() override;
void stop_acquisition() override;
void init() override;
void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {}
void set_local_code() override;
protected:
// Members subclasses can use
static const uint32_t QUANT_BITS_LOCAL_CODE = 16;
static const uint32_t SELECT_LSBITS = 0x0000FFFF; // Select the 10 LSbits out of a 20-bit word
static const uint32_t SELECT_MSBITS = 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
static const uint32_t ACQ_BUFF_0 = 0; // FPGA Acquisition IP buffer containing L1/E1 frequency band samples by default.
static const uint32_t ACQ_BUFF_1 = 1; // FPGA Acquisition IP buffer containing L2 or L5/E5 frequency band samples by default.
// Members subclasses must set
pcps_acquisition_fpga_sptr acquisition_fpga_;
volk_gnsssdr::vector<uint32_t> d_all_fft_codes_;
Acq_Conf_Fpga acq_parameters_;
int32_t doppler_center_;
uint32_t doppler_max_;
uint32_t doppler_step_;
private:
// Managed entirely by the base class
std::weak_ptr<ChannelFsm> channel_fsm_;
std::string role_;
Gnss_Synchro* gnss_synchro_;
uint32_t channel_;
unsigned int in_streams_;
unsigned int out_streams_;
};
/** \} */
/** \} */
#endif // GNSS_SDR_BASE_PCPS_ACQUISITION_FPGA_H

View File

@@ -20,12 +20,12 @@
#include "configuration_interface.h"
#include "galileo_e1_signal_replica.h"
#include "gnss_sdr_fft.h"
#include "gnss_sdr_flags.h"
#include <gnuradio/fft/fft.h> // for fft_complex
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <algorithm> // for copy_n
#include <array> // for array
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
@@ -40,65 +40,26 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga(
const std::string& role,
unsigned int in_streams,
unsigned int out_streams)
: gnss_synchro_(nullptr),
role_(role),
doppler_center_(0),
channel_(0),
doppler_step_(0),
in_streams_(in_streams),
out_streams_(out_streams),
acquire_pilot_(configuration->property(role + ".acquire_pilot", false))
: BasePcpsAcquisitionFpga(configuration,
role,
GALILEO_E1_CODE_CHIP_RATE_CPS,
GALILEO_E1_B_CODE_LENGTH_CHIPS,
GALILEO_E1_OPT_ACQ_FS_SPS,
DEFAULT_FPGA_BLK_EXP,
ACQ_BUFF_0,
in_streams,
out_streams)
{
// Set acquisition parameters
acq_parameters_.SetFromConfiguration(configuration, role_, DEFAULT_FPGA_BLK_EXP, GALILEO_E1_CODE_CHIP_RATE_CPS, GALILEO_E1_B_CODE_LENGTH_CHIPS);
// Query the capabilities of the instantiated FPGA Acquisition IP Core
std::vector<std::pair<uint32_t, uint32_t>> downsampling_filter_specs;
uint32_t max_FFT_size;
acquisition_fpga_ = pcps_make_acquisition_fpga(&acq_parameters_, ACQ_BUFF_0, downsampling_filter_specs, max_FFT_size);
// Configure the automatic resampler according to the capabilities of the instantiated FPGA Acquisition IP Core.
// When the FPGA is in use, the acquisition resampler operates only in the L1/E1 frequency band.
bool acq_configuration_valid = acq_parameters_.ConfigureAutomaticResampler(downsampling_filter_specs, max_FFT_size, GALILEO_E1_OPT_ACQ_FS_SPS);
if (!acq_configuration_valid)
{
std::cout << "The FPGA acquisition IP does not support the required sampling frequency of " << acq_parameters_.fs_in << " SPS for the L1/E1 band. Please update the sampling frequency in the configuration file." << std::endl;
exit(0);
}
DLOG(INFO) << "role " << role;
acquire_pilot_ = configuration->property(role + ".acquire_pilot", false);
generate_galileo_e1_prn_codes();
#if USE_GLOG_AND_GFLAGS
if (FLAGS_doppler_max != 0)
{
acq_parameters_.doppler_max = FLAGS_doppler_max;
}
#else
if (absl::GetFlag(FLAGS_doppler_max) != 0)
{
acq_parameters_.doppler_max = absl::GetFlag(FLAGS_doppler_max);
}
#endif
doppler_max_ = acq_parameters_.doppler_max;
doppler_step_ = static_cast<unsigned int>(acq_parameters_.doppler_step);
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
}
if (out_streams_ > 0)
{
LOG(ERROR) << "This implementation does not provide an output stream";
}
DLOG(INFO) << "Initialized FPGA acquisition adapter for role " << role;
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::generate_galileo_e1_prn_codes()
{
uint32_t code_length = acq_parameters_.code_length;
uint32_t nsamples_total = acq_parameters_.fft_size;
const uint32_t code_length = acq_parameters_.code_length;
const uint32_t nsamples_total = acq_parameters_.fft_size;
// 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)
@@ -112,7 +73,7 @@ void GalileoE1PcpsAmbiguousAcquisitionFpga::generate_galileo_e1_prn_codes()
int32_t tmp2;
int32_t local_code;
int32_t fft_data;
for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++)
for (uint32_t prn = 1; prn <= GALILEO_E1_NUMBER_OF_CODES; prn++)
{
bool cboc = false; // cboc is set to 0 when using the FPGA
@@ -121,13 +82,13 @@ void GalileoE1PcpsAmbiguousAcquisitionFpga::generate_galileo_e1_prn_codes()
// set local signal generator to Galileo E1 pilot component (1C)
std::array<char, 3> pilot_signal = {{'1', 'C', '\0'}};
galileo_e1_code_gen_complex_sampled(code, pilot_signal,
cboc, PRN, acq_parameters_.resampled_fs, 0, false);
cboc, prn, acq_parameters_.resampled_fs, 0, false);
}
else
{
std::array<char, 3> data_signal = {{'1', 'B', '\0'}};
galileo_e1_code_gen_complex_sampled(code, data_signal,
cboc, PRN, acq_parameters_.resampled_fs, 0, false);
cboc, prn, acq_parameters_.resampled_fs, 0, false);
}
if (acq_parameters_.enable_zero_padding)
@@ -138,7 +99,6 @@ void GalileoE1PcpsAmbiguousAcquisitionFpga::generate_galileo_e1_prn_codes()
std::fill(code.begin() + (acq_parameters_.enable_zero_padding ? 2 * code_length : code_length), code.end(), std::complex<float>(0.0, 0.0));
}
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_code.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
@@ -164,112 +124,9 @@ void GalileoE1PcpsAmbiguousAcquisitionFpga::generate_galileo_e1_prn_codes()
tmp2 = static_cast<int32_t>(floor(fft_code[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;
d_all_fft_codes_[i + (nsamples_total * (prn - 1))] = fft_data;
}
}
acq_parameters_.all_fft_codes = d_all_fft_codes_.data();
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::stop_acquisition()
{
// stop the acquisition and the other FPGA modules.
acquisition_fpga_->stop_acquisition();
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::set_threshold(float threshold)
{
DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold;
acquisition_fpga_->set_threshold(threshold);
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::set_doppler_max(unsigned int doppler_max)
{
doppler_max_ = doppler_max;
acquisition_fpga_->set_doppler_max(doppler_max_);
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::set_doppler_step(unsigned int doppler_step)
{
doppler_step_ = doppler_step;
acquisition_fpga_->set_doppler_step(doppler_step_);
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::set_doppler_center(int doppler_center)
{
doppler_center_ = doppler_center;
acquisition_fpga_->set_doppler_center(doppler_center_);
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro)
{
gnss_synchro_ = gnss_synchro;
acquisition_fpga_->set_gnss_synchro(gnss_synchro_);
}
signed int GalileoE1PcpsAmbiguousAcquisitionFpga::mag()
{
return acquisition_fpga_->mag();
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::init()
{
acquisition_fpga_->init();
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::set_local_code()
{
acquisition_fpga_->set_local_code();
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::reset()
{
// This command starts the acquisition process
acquisition_fpga_->set_active(true);
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::set_state(int state)
{
acquisition_fpga_->set_state(state);
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::connect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
// Nothing to connect
}
void GalileoE1PcpsAmbiguousAcquisitionFpga::disconnect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
// Nothing to disconnect
}
gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisitionFpga::get_left_block()
{
return nullptr;
}
gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisitionFpga::get_right_block()
{
return nullptr;
}

View File

@@ -18,15 +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_fpga.h"
#include "channel_fsm.h"
#include "gnss_synchro.h"
#include "pcps_acquisition_fpga.h"
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base_pcps_acquisition_fpga.h"
/** \addtogroup Acquisition
* \{ */
@@ -40,7 +32,7 @@ class ConfigurationInterface;
* \brief This class adapts a PCPS acquisition block off-loaded on an FPGA
* to an AcquisitionInterface for Galileo E1 Signals
*/
class GalileoE1PcpsAmbiguousAcquisitionFpga : public AcquisitionInterface
class GalileoE1PcpsAmbiguousAcquisitionFpga : public BasePcpsAcquisitionFpga
{
public:
/*!
@@ -52,19 +44,6 @@ public:
unsigned int in_streams,
unsigned int out_streams);
/*!
* \brief Destructor
*/
~GalileoE1PcpsAmbiguousAcquisitionFpga() = default;
/*!
* \brief Role
*/
inline std::string role() override
{
return role_;
}
/*!
* \brief Returns "Galileo_E1_PCPS_Ambiguous_Acquisition_FPGA"
*/
@@ -73,137 +52,9 @@ public:
return "Galileo_E1_PCPS_Ambiguous_Acquisition_FPGA";
}
/*!
* \brief Returns size of lv_16sc_t
*/
size_t item_size() override
{
return sizeof(int16_t);
}
/*!
* \brief Connect
*/
void connect(gr::top_block_sptr top_block) override;
/*!
* \brief Disconnect
*/
void disconnect(gr::top_block_sptr top_block) override;
/*!
* \brief Get left block
*/
gr::basic_block_sptr get_left_block() override;
/*!
* \brief Get right block
*/
gr::basic_block_sptr get_right_block() override;
/*!
* \brief Set acquisition/tracking common Gnss_Synchro object pointer
* to efficiently exchange synchronization data between acquisition and
* tracking blocks
*/
void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override;
/*!
* \brief Set acquisition channel unique ID
*/
inline void set_channel(unsigned int channel) override
{
channel_ = channel;
acquisition_fpga_->set_channel(channel_);
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = std::move(channel_fsm);
acquisition_fpga_->set_channel_fsm(channel_fsm_);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
void set_threshold(float threshold) override;
/*!
* \brief Set maximum Doppler off grid search
*/
void set_doppler_max(unsigned int doppler_max) override;
/*!
* \brief Set Doppler steps for the grid search
*/
void set_doppler_step(unsigned int doppler_step) override;
/*!
* \brief Set Doppler center for the grid search
*/
void set_doppler_center(int doppler_center) override;
/*!
* \brief Initializes acquisition algorithm.
*/
void init() override;
/*!
* \brief Sets local code for Galileo E1 PCPS acquisition algorithm.
*/
void set_local_code() override;
/*!
* \brief Returns the maximum peak of grid search
*/
signed int mag() override;
/*!
* \brief Restart acquisition algorithm
*/
void reset() override;
/*!
* \brief If state = 1, it forces the block to start acquiring from the first sample
*/
void set_state(int state) override;
/*!
* \brief Stop running acquisition
*/
void stop_acquisition() override;
/*!
* \brief Set resampler latency
*/
void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {};
private:
static const uint32_t ACQ_BUFF_0 = 0; // FPGA Acquisition IP buffer containing L1/E1 frequency band samples by default.
static const uint32_t DEFAULT_FPGA_BLK_EXP = 13; // default block exponent
static const uint32_t QUANT_BITS_LOCAL_CODE = 16;
static const uint32_t SELECT_LSBITS = 0x0000FFFF; // Select the 10 LSbits out of a 20-bit word
static const uint32_t SELECT_MSBITS = 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
void generate_galileo_e1_prn_codes();
pcps_acquisition_fpga_sptr acquisition_fpga_;
volk_gnsssdr::vector<uint32_t> d_all_fft_codes_; // memory that contains all the code ffts
std::weak_ptr<ChannelFsm> channel_fsm_;
Gnss_Synchro* gnss_synchro_;
Acq_Conf_Fpga acq_parameters_;
std::string role_;
int32_t doppler_center_;
uint32_t channel_;
uint32_t doppler_max_;
uint32_t doppler_step_;
unsigned int in_streams_;
unsigned int out_streams_;
bool acquire_pilot_;
};

View File

@@ -20,11 +20,10 @@
#include "configuration_interface.h"
#include "galileo_e5_signal_replica.h"
#include "gnss_sdr_fft.h"
#include "gnss_sdr_flags.h"
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <algorithm> // for copy_n
#include <array> // for array
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
@@ -39,65 +38,27 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(
const std::string& role,
unsigned int in_streams,
unsigned int out_streams)
: gnss_synchro_(nullptr),
role_(role),
doppler_center_(0),
channel_(0),
in_streams_(in_streams),
out_streams_(out_streams),
acq_pilot_(configuration->property(role + ".acquire_pilot", false)),
acq_iq_(configuration->property(role + ".acquire_iq", false))
: BasePcpsAcquisitionFpga(configuration,
role,
GALILEO_E5A_CODE_CHIP_RATE_CPS,
GALILEO_E5A_CODE_LENGTH_CHIPS,
0.0,
DEFAULT_FPGA_BLK_EXP,
ACQ_BUFF_1,
in_streams,
out_streams)
{
// Set acquisition parameters
acq_parameters_.SetFromConfiguration(configuration, role_, DEFAULT_FPGA_BLK_EXP, GALILEO_E5A_CODE_CHIP_RATE_CPS, GALILEO_E5A_CODE_LENGTH_CHIPS);
// Query the capabilities of the instantiated FPGA Acquisition IP Core. When the FPGA is in use, the acquisition resampler operates only in the L1/E1 frequency band.
std::vector<std::pair<uint32_t, uint32_t>> downsampling_filter_specs;
uint32_t max_FFT_size;
acquisition_fpga_ = pcps_make_acquisition_fpga(&acq_parameters_, ACQ_BUFF_1, downsampling_filter_specs, max_FFT_size);
// When the FPGA is in use, the acquisition resampler operates only in the L1/E1 frequency band.
// Check whether the acquisition configuration is supported by the FPGA.
bool acq_configuration_valid = acq_parameters_.Is_acq_config_valid(max_FFT_size);
if (!acq_configuration_valid)
{
std::cout << "The FPGA acquisition IP does not support the required sampling frequency of " << acq_parameters_.fs_in << " SPS for the L5/E5a band. Please update the sampling frequency in the configuration file." << std::endl;
exit(0);
}
DLOG(INFO) << "role " << role;
acq_pilot_ = configuration->property(role + ".acquire_pilot", false);
acq_iq_ = configuration->property(role + ".acquire_iq", false);
generate_galileo_e5a_prn_codes();
#if USE_GLOG_AND_GFLAGS
if (FLAGS_doppler_max != 0)
{
acq_parameters_.doppler_max = FLAGS_doppler_max;
}
#else
if (absl::GetFlag(FLAGS_doppler_max) != 0)
{
acq_parameters_.doppler_max = absl::GetFlag(FLAGS_doppler_max);
}
#endif
doppler_max_ = acq_parameters_.doppler_max;
doppler_step_ = static_cast<unsigned int>(acq_parameters_.doppler_step);
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
}
if (out_streams_ > 0)
{
LOG(ERROR) << "This implementation does not provide an output stream";
}
DLOG(INFO) << "Initialized FPGA acquisition adapter for role " << role;
}
void GalileoE5aPcpsAcquisitionFpga::generate_galileo_e5a_prn_codes()
{
uint32_t code_length = acq_parameters_.code_length;
uint32_t nsamples_total = acq_parameters_.fft_size;
const uint32_t code_length = acq_parameters_.code_length;
const uint32_t nsamples_total = acq_parameters_.fft_size;
// 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)
@@ -117,7 +78,7 @@ void GalileoE5aPcpsAcquisitionFpga::generate_galileo_e5a_prn_codes()
int32_t local_code;
int32_t fft_data;
for (uint32_t PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++)
for (uint32_t prn = 1; prn <= GALILEO_E5A_NUMBER_OF_CODES; prn++)
{
std::array<char, 3> signal_;
signal_[0] = '5';
@@ -136,7 +97,7 @@ void GalileoE5aPcpsAcquisitionFpga::generate_galileo_e5a_prn_codes()
signal_[1] = 'I';
}
galileo_e5_a_code_gen_complex_sampled(code, PRN, signal_, acq_parameters_.fs_in, 0);
galileo_e5_a_code_gen_complex_sampled(code, prn, signal_, acq_parameters_.fs_in, 0);
if (acq_parameters_.enable_zero_padding)
{
@@ -146,7 +107,6 @@ void GalileoE5aPcpsAcquisitionFpga::generate_galileo_e5a_prn_codes()
std::fill(code.begin() + (acq_parameters_.enable_zero_padding ? 2 * code_length : code_length), code.end(), std::complex<float>(0.0, 0.0));
}
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_code.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
@@ -171,111 +131,9 @@ void GalileoE5aPcpsAcquisitionFpga::generate_galileo_e5a_prn_codes()
tmp2 = static_cast<int32_t>(floor(fft_code[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;
d_all_fft_codes_[i + (nsamples_total * (prn - 1))] = fft_data;
}
}
acq_parameters_.all_fft_codes = d_all_fft_codes_.data();
}
void GalileoE5aPcpsAcquisitionFpga::stop_acquisition()
{
// stop the acquisition and the other FPGA modules.
acquisition_fpga_->stop_acquisition();
}
void GalileoE5aPcpsAcquisitionFpga::set_threshold(float threshold)
{
DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold;
acquisition_fpga_->set_threshold(threshold);
}
void GalileoE5aPcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max)
{
doppler_max_ = doppler_max;
acquisition_fpga_->set_doppler_max(doppler_max_);
}
void GalileoE5aPcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step)
{
doppler_step_ = doppler_step;
acquisition_fpga_->set_doppler_step(doppler_step_);
}
void GalileoE5aPcpsAcquisitionFpga::set_doppler_center(int doppler_center)
{
doppler_center_ = doppler_center;
acquisition_fpga_->set_doppler_center(doppler_center_);
}
void GalileoE5aPcpsAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro)
{
gnss_synchro_ = gnss_synchro;
acquisition_fpga_->set_gnss_synchro(gnss_synchro_);
}
signed int GalileoE5aPcpsAcquisitionFpga::mag()
{
return acquisition_fpga_->mag();
}
void GalileoE5aPcpsAcquisitionFpga::init()
{
acquisition_fpga_->init();
}
void GalileoE5aPcpsAcquisitionFpga::set_local_code()
{
acquisition_fpga_->set_local_code();
}
void GalileoE5aPcpsAcquisitionFpga::reset()
{
acquisition_fpga_->set_active(true);
}
void GalileoE5aPcpsAcquisitionFpga::set_state(int state)
{
acquisition_fpga_->set_state(state);
}
void GalileoE5aPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
// Nothing to connect
}
void GalileoE5aPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
// Nothing to disconnect
}
gr::basic_block_sptr GalileoE5aPcpsAcquisitionFpga::get_left_block()
{
return nullptr;
}
gr::basic_block_sptr GalileoE5aPcpsAcquisitionFpga::get_right_block()
{
return nullptr;
}

View File

@@ -18,14 +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"
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <memory>
#include <string>
#include <utility>
#include "base_pcps_acquisition_fpga.h"
/** \addtogroup Acquisition
* \{ */
@@ -40,7 +33,7 @@ class ConfigurationInterface;
* \brief This class adapts a PCPS acquisition block off-loaded on an FPGA
* to an AcquisitionInterface for Galileo E5a signals
*/
class GalileoE5aPcpsAcquisitionFpga : public AcquisitionInterface
class GalileoE5aPcpsAcquisitionFpga : public BasePcpsAcquisitionFpga
{
public:
/*!
@@ -52,19 +45,6 @@ public:
unsigned int in_streams,
unsigned int out_streams);
/*!
* \brief Destructor
*/
~GalileoE5aPcpsAcquisitionFpga() = default;
/*!
* \brief Role
*/
inline std::string role() override
{
return role_;
}
/*!
* \brief Returns "Galileo_E5a_Pcps_Acquisition_FPGA"
*/
@@ -73,144 +53,9 @@ public:
return "Galileo_E5a_Pcps_Acquisition_FPGA";
}
/*!
* \brief Returns size of lv_16sc_t
*/
inline size_t item_size() override
{
return sizeof(int16_t);
}
/*!
* \brief Connect
*/
void connect(gr::top_block_sptr top_block) override;
/*!
* \brief Disconnect
*/
void disconnect(gr::top_block_sptr top_block) override;
/*!
* \brief Get left block
*/
gr::basic_block_sptr get_left_block() override;
/*!
* \brief Get right block
*/
gr::basic_block_sptr get_right_block() override;
/*!
* \brief Set acquisition/tracking common Gnss_Synchro object pointer
* to efficiently exchange synchronization data between acquisition and
* tracking blocks
*/
void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override;
/*!
* \brief Set acquisition channel unique ID
*/
inline void set_channel(unsigned int channel) override
{
channel_ = channel;
acquisition_fpga_->set_channel(channel_);
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = std::move(channel_fsm);
acquisition_fpga_->set_channel_fsm(channel_fsm_);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
void set_threshold(float threshold) override;
/*!
* \brief Set maximum Doppler off grid search
*/
void set_doppler_max(unsigned int doppler_max) override;
/*!
* \brief Set Doppler steps for the grid search
*/
void set_doppler_step(unsigned int doppler_step) override;
/*!
* \brief Set Doppler center for the grid search
*/
void set_doppler_center(int doppler_center) override;
/*!
* \brief Initializes acquisition algorithm.
*/
void init() override;
/*!
* \brief Sets local Galileo E5a code for PCPS acquisition algorithm.
*/
void set_local_code() override;
/*!
* \brief Returns the maximum peak of grid search
*/
signed int mag() override;
/*!
* \brief Restart acquisition algorithm
*/
void reset() override;
/*!
* \brief If set to 1, ensures that acquisition starts at the
* first available sample.
* \param state - int=1 forces start of acquisition
*/
void set_state(int state) override;
/*!
* \brief This function is only used in the unit tests
*/
void set_single_doppler_flag(unsigned int single_doppler_flag);
/*!
* \brief Stop running acquisition
*/
void stop_acquisition() override;
/*!
* \brief Set resampler latency
*/
void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {};
private:
static const uint32_t ACQ_BUFF_1 = 1; // FPGA Acquisition IP buffer containing L2 or L5/E5 frequency band samples by default.
static const uint32_t DEFAULT_FPGA_BLK_EXP = 13; // default block exponent
static const uint32_t QUANT_BITS_LOCAL_CODE = 16;
static const uint32_t SELECT_LSBITS = 0x0000FFFF; // Select the 10 LSbits out of a 20-bit word
static const uint32_t SELECT_MSBITS = 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
void generate_galileo_e5a_prn_codes();
pcps_acquisition_fpga_sptr acquisition_fpga_;
std::weak_ptr<ChannelFsm> channel_fsm_;
volk_gnsssdr::vector<uint32_t> d_all_fft_codes_; // memory that contains all the code ffts
Gnss_Synchro* gnss_synchro_;
Acq_Conf_Fpga acq_parameters_;
std::string role_;
int32_t doppler_center_;
uint32_t channel_;
uint32_t doppler_max_;
uint32_t doppler_step_;
unsigned int in_streams_;
unsigned int out_streams_;
bool acq_pilot_;
bool acq_iq_;
};

View File

@@ -21,12 +21,11 @@
#include "configuration_interface.h"
#include "galileo_e5_signal_replica.h"
#include "gnss_sdr_fft.h"
#include "gnss_sdr_flags.h"
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <algorithm> // for copy_n
#include <array> // for array
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#if USE_GLOG_AND_GFLAGS
#include <glog/logging.h>
@@ -34,70 +33,32 @@
#include <absl/log/log.h>
#endif
GalileoE5bPcpsAcquisitionFpga::GalileoE5bPcpsAcquisitionFpga(const ConfigurationInterface* configuration,
GalileoE5bPcpsAcquisitionFpga::GalileoE5bPcpsAcquisitionFpga(
const ConfigurationInterface* configuration,
const std::string& role,
unsigned int in_streams,
unsigned int out_streams)
: gnss_synchro_(nullptr),
role_(role),
doppler_center_(0),
channel_(0),
doppler_step_(0),
in_streams_(in_streams),
out_streams_(out_streams),
acq_pilot_(configuration->property(role + ".acquire_pilot", false)),
acq_iq_(configuration->property(role + ".acquire_iq", false))
: BasePcpsAcquisitionFpga(configuration,
role,
GALILEO_E5B_CODE_CHIP_RATE_CPS,
GALILEO_E5B_CODE_LENGTH_CHIPS,
0.0,
DEFAULT_FPGA_BLK_EXP,
ACQ_BUFF_1,
in_streams,
out_streams)
{
// Set acquisition parameters
acq_parameters_.SetFromConfiguration(configuration, role_, DEFAULT_FPGA_BLK_EXP, GALILEO_E5B_CODE_CHIP_RATE_CPS, GALILEO_E5B_CODE_LENGTH_CHIPS);
// Query the capabilities of the instantiated FPGA Acquisition IP Core. When the FPGA is in use, the acquisition resampler operates only in the L1/E1 frequency band.
std::vector<std::pair<uint32_t, uint32_t>> downsampling_filter_specs;
uint32_t max_FFT_size;
acquisition_fpga_ = pcps_make_acquisition_fpga(&acq_parameters_, ACQ_BUFF_1, downsampling_filter_specs, max_FFT_size);
// When the FPGA is in use, the acquisition resampler operates only in the L1/E1 frequency band.
// Check whether the acquisition configuration is supported by the FPGA.
bool acq_configuration_valid = acq_parameters_.Is_acq_config_valid(max_FFT_size);
if (!acq_configuration_valid)
{
std::cout << "The FPGA acquisition IP does not support the required sampling frequency of " << acq_parameters_.fs_in << " SPS for the E5b band. Please update the sampling frequency in the configuration file." << std::endl;
exit(0);
}
DLOG(INFO) << "role " << role;
acq_pilot_ = configuration->property(role + ".acquire_pilot", false);
acq_iq_ = configuration->property(role + ".acquire_iq", false);
generate_galileo_e5b_prn_codes();
#if USE_GLOG_AND_GFLAGS
if (FLAGS_doppler_max != 0)
{
acq_parameters_.doppler_max = FLAGS_doppler_max;
}
#else
if (absl::GetFlag(FLAGS_doppler_max) != 0)
{
acq_parameters_.doppler_max = absl::GetFlag(FLAGS_doppler_max);
}
#endif
doppler_max_ = acq_parameters_.doppler_max;
doppler_step_ = static_cast<unsigned int>(acq_parameters_.doppler_step);
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
}
if (out_streams_ > 0)
{
LOG(ERROR) << "This implementation does not provide an output stream";
}
DLOG(INFO) << "Initialized FPGA acquisition adapter for role " << role;
}
void GalileoE5bPcpsAcquisitionFpga::generate_galileo_e5b_prn_codes()
{
uint32_t code_length = acq_parameters_.code_length;
uint32_t nsamples_total = acq_parameters_.fft_size;
const uint32_t code_length = acq_parameters_.code_length;
const uint32_t nsamples_total = acq_parameters_.fft_size;
// 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)
@@ -117,7 +78,7 @@ void GalileoE5bPcpsAcquisitionFpga::generate_galileo_e5b_prn_codes()
int32_t local_code;
int32_t fft_data;
for (uint32_t PRN = 1; PRN <= GALILEO_E5B_NUMBER_OF_CODES; PRN++)
for (uint32_t prn = 1; prn <= GALILEO_E5B_NUMBER_OF_CODES; prn++)
{
std::array<char, 3> signal_;
signal_[0] = '7';
@@ -136,7 +97,7 @@ void GalileoE5bPcpsAcquisitionFpga::generate_galileo_e5b_prn_codes()
signal_[1] = 'I';
}
galileo_e5_b_code_gen_complex_sampled(code, PRN, signal_, acq_parameters_.fs_in, 0);
galileo_e5_b_code_gen_complex_sampled(code, prn, signal_, acq_parameters_.fs_in, 0);
if (acq_parameters_.enable_zero_padding)
{
@@ -146,7 +107,6 @@ void GalileoE5bPcpsAcquisitionFpga::generate_galileo_e5b_prn_codes()
std::fill(code.begin() + (acq_parameters_.enable_zero_padding ? 2 * code_length : code_length), code.end(), std::complex<float>(0.0, 0.0));
}
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_code.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
@@ -171,112 +131,9 @@ void GalileoE5bPcpsAcquisitionFpga::generate_galileo_e5b_prn_codes()
tmp2 = static_cast<int32_t>(floor(fft_code[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;
d_all_fft_codes_[i + (nsamples_total * (prn - 1))] = fft_data;
}
}
acq_parameters_.all_fft_codes = d_all_fft_codes_.data();
}
void GalileoE5bPcpsAcquisitionFpga::stop_acquisition()
{
// this command causes the SW to reset the HW.
acquisition_fpga_->reset_acquisition();
}
void GalileoE5bPcpsAcquisitionFpga::set_threshold(float threshold)
{
DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold;
acquisition_fpga_->set_threshold(threshold);
}
void GalileoE5bPcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max)
{
doppler_max_ = doppler_max;
acquisition_fpga_->set_doppler_max(doppler_max_);
}
void GalileoE5bPcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step)
{
doppler_step_ = doppler_step;
acquisition_fpga_->set_doppler_step(doppler_step_);
}
void GalileoE5bPcpsAcquisitionFpga::set_doppler_center(int doppler_center)
{
doppler_center_ = doppler_center;
acquisition_fpga_->set_doppler_center(doppler_center_);
}
void GalileoE5bPcpsAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro)
{
gnss_synchro_ = gnss_synchro;
acquisition_fpga_->set_gnss_synchro(gnss_synchro_);
}
signed int GalileoE5bPcpsAcquisitionFpga::mag()
{
return acquisition_fpga_->mag();
}
void GalileoE5bPcpsAcquisitionFpga::init()
{
acquisition_fpga_->init();
}
void GalileoE5bPcpsAcquisitionFpga::set_local_code()
{
acquisition_fpga_->set_local_code();
}
void GalileoE5bPcpsAcquisitionFpga::reset()
{
acquisition_fpga_->set_active(true);
}
void GalileoE5bPcpsAcquisitionFpga::set_state(int state)
{
acquisition_fpga_->set_state(state);
}
void GalileoE5bPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block)
{
if (top_block)
{
/* top_block is not null */
};
// Nothing to connect
}
void GalileoE5bPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block)
{
if (top_block)
{
/* top_block is not null */
};
// Nothing to disconnect
}
gr::basic_block_sptr GalileoE5bPcpsAcquisitionFpga::get_left_block()
{
return nullptr;
}
gr::basic_block_sptr GalileoE5bPcpsAcquisitionFpga::get_right_block()
{
return nullptr;
}

View File

@@ -19,14 +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"
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <memory>
#include <string>
#include <utility>
#include "base_pcps_acquisition_fpga.h"
/** \addtogroup Acquisition
* \{ */
@@ -40,7 +33,7 @@ class ConfigurationInterface;
* \brief This class adapts a PCPS acquisition block off-loaded on an FPGA
* to an AcquisitionInterface for Galileo E5b signals
*/
class GalileoE5bPcpsAcquisitionFpga : public AcquisitionInterface
class GalileoE5bPcpsAcquisitionFpga : public BasePcpsAcquisitionFpga
{
public:
/*!
@@ -51,19 +44,6 @@ public:
unsigned int in_streams,
unsigned int out_streams);
/*!
* \brief Destructor
*/
~GalileoE5bPcpsAcquisitionFpga() = default;
/*!
* \brief Role
*/
inline std::string role() override
{
return role_;
}
/*!
* \brief Returns "Galileo_E5b_Pcps_Acquisition_FPGA"
*/
@@ -72,145 +52,9 @@ public:
return "Galileo_E5b_PCPS_Acquisition_FPGA";
}
/*!
* \brief Returns size of lv_16sc_t
*/
inline size_t item_size() override
{
return sizeof(int16_t);
}
/*!
* \brief Connect
*/
void connect(gr::top_block_sptr top_block) override;
/*!
* \brief Disconnect
*/
void disconnect(gr::top_block_sptr top_block) override;
/*!
* \brief Get left block
*/
gr::basic_block_sptr get_left_block() override;
/*!
* \brief Get right block
*/
gr::basic_block_sptr get_right_block() override;
/*!
* \brief Set acquisition/tracking common Gnss_Synchro object pointer
* to efficiently exchange synchronization data between acquisition and
* tracking blocks
*/
void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override;
/*!
* \brief Set acquisition channel unique ID
*/
inline void set_channel(unsigned int channel) override
{
channel_ = channel;
acquisition_fpga_->set_channel(channel_);
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = std::move(channel_fsm);
acquisition_fpga_->set_channel_fsm(channel_fsm_);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
void set_threshold(float threshold) override;
/*!
* \brief Set maximum Doppler off grid search
*/
void set_doppler_max(unsigned int doppler_max) override;
/*!
* \brief Set Doppler steps for the grid search
*/
void set_doppler_step(unsigned int doppler_step) override;
/*!
* \brief Set Doppler center for the grid search
*/
void set_doppler_center(int doppler_center) override;
/*!
* \brief Initializes acquisition algorithm.
*/
void init() override;
/*!
* \brief Sets local Galileo E5b code for PCPS acquisition algorithm.
*/
void set_local_code() override;
/*!
* \brief Returns the maximum peak of grid search
*/
signed int mag() override;
/*!
* \brief Restart acquisition algorithm
*/
void reset() override;
/*!
* \brief If set to 1, ensures that acquisition starts at the
* first available sample.
* \param state - int=1 forces start of acquisition
*/
void set_state(int state) override;
/*!
* \brief This function is only used in the unit tests
*/
void set_single_doppler_flag(unsigned int single_doppler_flag);
/*!
* \brief Stop running acquisition
*/
void stop_acquisition() override;
/*!
* \brief Set resampler latency
*/
void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {};
private:
static const uint32_t ACQ_BUFF_1 = 1; // FPGA Acquisition IP buffer containing L2 or L5/E5 frequency band samples by default.
static const uint32_t DEFAULT_FPGA_BLK_EXP = 13; // default block exponent
static const uint32_t QUANT_BITS_LOCAL_CODE = 16;
static const uint32_t SELECT_LSBITS = 0x0000FFFF; // Select the 10 LSbits out of a 20-bit word
static const uint32_t SELECT_MSBITS = 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
void generate_galileo_e5b_prn_codes();
pcps_acquisition_fpga_sptr acquisition_fpga_;
volk_gnsssdr::vector<uint32_t> d_all_fft_codes_; // memory that contains all the code ffts
std::weak_ptr<ChannelFsm> channel_fsm_;
Gnss_Synchro* gnss_synchro_;
Acq_Conf_Fpga acq_parameters_;
std::string role_;
int32_t doppler_center_;
uint32_t channel_;
uint32_t doppler_max_;
uint32_t doppler_step_;
unsigned int in_streams_;
unsigned int out_streams_;
bool acq_pilot_;
bool acq_iq_;
};

View File

@@ -22,13 +22,11 @@
#include "GPS_L1_CA.h"
#include "configuration_interface.h"
#include "gnss_sdr_fft.h"
#include "gnss_sdr_flags.h"
#include "gps_sdr_signal_replica.h"
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#if USE_GLOG_AND_GFLAGS
#include <glog/logging.h>
@@ -40,64 +38,27 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
const ConfigurationInterface* configuration,
const std::string& role,
unsigned int in_streams,
unsigned int out_streams) : gnss_synchro_(nullptr),
role_(role),
doppler_center_(0),
channel_(0),
doppler_step_(0),
in_streams_(in_streams),
out_streams_(out_streams)
unsigned int out_streams)
: BasePcpsAcquisitionFpga(configuration,
role,
GPS_L1_CA_CODE_RATE_CPS,
GPS_L1_CA_CODE_LENGTH_CHIPS,
GPS_L1_CA_OPT_ACQ_FS_SPS,
DEFAULT_FPGA_BLK_EXP,
ACQ_BUFF_0,
in_streams,
out_streams)
{
// set acquisition parameters
acq_parameters_.SetFromConfiguration(configuration, role_, DEFAULT_FPGA_BLK_EXP, GPS_L1_CA_CODE_RATE_CPS, GPS_L1_CA_CODE_LENGTH_CHIPS);
// Query the capabilities of the instantiated FPGA Acquisition IP Core
std::vector<std::pair<uint32_t, uint32_t>> downsampling_filter_specs;
uint32_t max_FFT_size;
acquisition_fpga_ = pcps_make_acquisition_fpga(&acq_parameters_, ACQ_BUFF_0, downsampling_filter_specs, max_FFT_size);
// Configure the automatic resampler according to the capabilities of the instantiated FPGA Acquisition IP Core.
// When the FPGA is in use, the acquisition resampler operates only in the L1/E1 frequency band.
bool acq_configuration_valid = acq_parameters_.ConfigureAutomaticResampler(downsampling_filter_specs, max_FFT_size, GPS_L1_CA_OPT_ACQ_FS_SPS);
if (!acq_configuration_valid)
{
std::cout << "The FPGA acquisition IP does not support the required sampling frequency of " << acq_parameters_.fs_in << " SPS for the L1/E1 band. Please update the sampling frequency in the configuration file." << std::endl;
exit(0);
}
DLOG(INFO) << "role " << role;
generate_gps_l1_ca_prn_codes();
#if USE_GLOG_AND_GFLAGS
if (FLAGS_doppler_max != 0)
{
acq_parameters_.doppler_max = FLAGS_doppler_max;
}
#else
if (absl::GetFlag(FLAGS_doppler_max) != 0)
{
acq_parameters_.doppler_max = absl::GetFlag(FLAGS_doppler_max);
}
#endif
doppler_max_ = acq_parameters_.doppler_max;
doppler_step_ = static_cast<unsigned int>(acq_parameters_.doppler_step);
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
}
if (out_streams_ > 0)
{
LOG(ERROR) << "This implementation does not provide an output stream";
}
DLOG(INFO) << "Initialized FPGA acquisition adapter for role " << role;
}
void GpsL1CaPcpsAcquisitionFpga::generate_gps_l1_ca_prn_codes()
{
uint32_t code_length = acq_parameters_.code_length;
uint32_t nsamples_total = acq_parameters_.fft_size;
const uint32_t NUM_PRNs = 32;
const uint32_t code_length = acq_parameters_.code_length;
const uint32_t nsamples_total = acq_parameters_.fft_size;
// 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)
@@ -112,9 +73,9 @@ void GpsL1CaPcpsAcquisitionFpga::generate_gps_l1_ca_prn_codes()
int32_t local_code;
int32_t fft_data;
// temporary maxima search
for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++)
for (uint32_t prn = 1; prn <= NUM_PRNs; prn++)
{
gps_l1_ca_code_gen_complex_sampled(code, PRN, acq_parameters_.resampled_fs, 0); // generate PRN code
gps_l1_ca_code_gen_complex_sampled(code, prn, acq_parameters_.resampled_fs, 0); // generate PRN code
if (acq_parameters_.enable_zero_padding)
{
@@ -148,112 +109,9 @@ void GpsL1CaPcpsAcquisitionFpga::generate_gps_l1_ca_prn_codes()
tmp2 = static_cast<int32_t>(floor(fft_code[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;
d_all_fft_codes_[i + (nsamples_total * (prn - 1))] = fft_data;
}
}
acq_parameters_.all_fft_codes = d_all_fft_codes_.data();
}
void GpsL1CaPcpsAcquisitionFpga::stop_acquisition()
{
// stop the acquisition and the other FPGA modules.
acquisition_fpga_->stop_acquisition();
}
void GpsL1CaPcpsAcquisitionFpga::set_threshold(float threshold)
{
DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold;
acquisition_fpga_->set_threshold(threshold);
}
void GpsL1CaPcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max)
{
doppler_max_ = doppler_max;
acquisition_fpga_->set_doppler_max(doppler_max_);
}
void GpsL1CaPcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step)
{
doppler_step_ = doppler_step;
acquisition_fpga_->set_doppler_step(doppler_step_);
}
void GpsL1CaPcpsAcquisitionFpga::set_doppler_center(int doppler_center)
{
doppler_center_ = doppler_center;
acquisition_fpga_->set_doppler_center(doppler_center_);
}
void GpsL1CaPcpsAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro)
{
gnss_synchro_ = gnss_synchro;
acquisition_fpga_->set_gnss_synchro(gnss_synchro_);
}
signed int GpsL1CaPcpsAcquisitionFpga::mag()
{
return acquisition_fpga_->mag();
}
void GpsL1CaPcpsAcquisitionFpga::init()
{
acquisition_fpga_->init();
}
void GpsL1CaPcpsAcquisitionFpga::set_local_code()
{
acquisition_fpga_->set_local_code();
}
void GpsL1CaPcpsAcquisitionFpga::reset()
{
// this function starts the acquisition process
acquisition_fpga_->set_active(true);
}
void GpsL1CaPcpsAcquisitionFpga::set_state(int state)
{
acquisition_fpga_->set_state(state);
}
void GpsL1CaPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
// Nothing to connect
}
void GpsL1CaPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
// Nothing to disconnect
}
gr::basic_block_sptr GpsL1CaPcpsAcquisitionFpga::get_left_block()
{
return nullptr;
}
gr::basic_block_sptr GpsL1CaPcpsAcquisitionFpga::get_right_block()
{
return nullptr;
}

View File

@@ -21,14 +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"
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <memory>
#include <string>
#include <utility>
#include "base_pcps_acquisition_fpga.h"
/** \addtogroup Acquisition
* \{ */
@@ -42,7 +35,7 @@ class ConfigurationInterface;
* \brief This class adapts a PCPS acquisition block off-loaded on an FPGA
* to an AcquisitionInterface for GPS L1 C/A signals
*/
class GpsL1CaPcpsAcquisitionFpga : public AcquisitionInterface
class GpsL1CaPcpsAcquisitionFpga : public BasePcpsAcquisitionFpga
{
public:
/*!
@@ -53,19 +46,6 @@ public:
unsigned int in_streams,
unsigned int out_streams);
/*!
* \brief Destructor
*/
~GpsL1CaPcpsAcquisitionFpga() = default;
/*!
* \brief Role
*/
inline std::string role() override
{
return role_;
}
/*!
* \brief Returns "GPS_L1_CA_PCPS_Acquisition_FPGA"
*/
@@ -74,140 +54,9 @@ public:
return "GPS_L1_CA_PCPS_Acquisition_FPGA";
}
/*!
* \brief Returns size of lv_16sc_t
*/
inline size_t item_size() override
{
return sizeof(int16_t);
}
/*!
* \brief Connect
*/
void connect(gr::top_block_sptr top_block) override;
/*!
* \brief Disconnect
*/
void disconnect(gr::top_block_sptr top_block) override;
/*!
* \brief Get left block
*/
gr::basic_block_sptr get_left_block() override;
/*!
* \brief Get right block
*/
gr::basic_block_sptr get_right_block() override;
/*!
* \brief Set acquisition/tracking common Gnss_Synchro object pointer
* to efficiently exchange synchronization data between acquisition and
* tracking blocks
*/
void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override;
/*!
* \brief Set acquisition channel unique ID
*/
inline void set_channel(unsigned int channel) override
{
channel_ = channel;
acquisition_fpga_->set_channel(channel_);
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = std::move(channel_fsm);
acquisition_fpga_->set_channel_fsm(channel_fsm_);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
std::string item_type_;
void set_threshold(float threshold) override;
/*!
* \brief Set maximum Doppler off grid search
*/
void set_doppler_max(unsigned int doppler_max) override;
/*!
* \brief Set Doppler steps for the grid search
*/
void set_doppler_step(unsigned int doppler_step) override;
/*!
* \brief Set Doppler center for the grid search
*/
void set_doppler_center(int doppler_center) override;
/*!
* \brief Initializes acquisition algorithm.
*/
void init() override;
/*!
* \brief Sets local code for GPS L1/CA PCPS acquisition algorithm.
*/
void set_local_code() override;
/*!
* \brief Returns the maximum peak of grid search
*/
signed int mag() override;
/*!
* \brief Restart acquisition algorithm
*/
void reset() override;
/*!
* \brief If state = 1, it forces the block to start acquiring from the first sample
*/
void set_state(int state) override;
/*!
* \brief Stop running acquisition
*/
void stop_acquisition() override;
/*!
* \brief Set Resampler Latency
*/
void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {};
private:
static const uint32_t ACQ_BUFF_0 = 0; // FPGA Acquisition IP buffer containing L1/E1 frequency band samples by default.
static const uint32_t DEFAULT_FPGA_BLK_EXP = 10; // default block exponent
static const uint32_t NUM_PRNs = 32;
static const uint32_t QUANT_BITS_LOCAL_CODE = 16;
static const uint32_t SELECT_LSBITS = 0x0000FFFF; // Select the 10 LSbits out of a 20-bit word
static const uint32_t SELECT_MSBITS = 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
void generate_gps_l1_ca_prn_codes();
pcps_acquisition_fpga_sptr acquisition_fpga_;
std::weak_ptr<ChannelFsm> channel_fsm_;
volk_gnsssdr::vector<uint32_t> d_all_fft_codes_; // memory that contains all the code ffts
Gnss_Synchro* gnss_synchro_;
Acq_Conf_Fpga acq_parameters_;
std::string role_;
int32_t doppler_center_;
uint32_t channel_;
uint32_t doppler_max_;
uint32_t doppler_step_;
unsigned int in_streams_;
unsigned int out_streams_;
};

View File

@@ -21,10 +21,8 @@
#include "GPS_L2C.h"
#include "configuration_interface.h"
#include "gnss_sdr_fft.h"
#include "gnss_sdr_flags.h"
#include "gps_l2c_signal_replica.h"
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
@@ -40,64 +38,27 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga(
const ConfigurationInterface* configuration,
const std::string& role,
unsigned int in_streams,
unsigned int out_streams) : gnss_synchro_(nullptr),
role_(role),
threshold_(0),
channel_(0),
doppler_step_(0),
in_streams_(in_streams),
out_streams_(out_streams)
unsigned int out_streams)
: BasePcpsAcquisitionFpga(configuration,
role,
GPS_L2_M_CODE_RATE_CPS,
GPS_L2_M_CODE_LENGTH_CHIPS,
0.0,
DEFAULT_FPGA_BLK_EXP,
ACQ_BUFF_1,
in_streams,
out_streams)
{
// Set acquisition parameters
acq_parameters_.SetFromConfiguration(configuration, role_, DEFAULT_FPGA_BLK_EXP, GPS_L2_M_CODE_RATE_CPS, GPS_L2_M_CODE_LENGTH_CHIPS);
// Query the capabilities of the instantiated FPGA Acquisition IP Core. When the FPGA is in use, the acquisition resampler operates only in the L1/E1 frequency band.
std::vector<std::pair<uint32_t, uint32_t>> downsampling_filter_specs;
uint32_t max_FFT_size;
acquisition_fpga_ = pcps_make_acquisition_fpga(&acq_parameters_, ACQ_BUFF_1, downsampling_filter_specs, max_FFT_size);
// When the FPGA is in use, the acquisition resampler operates only in the L1/E1 frequency band.
// Check whether the acquisition configuration is supported by the FPGA.
bool acq_configuration_valid = acq_parameters_.Is_acq_config_valid(max_FFT_size);
if (!acq_configuration_valid)
{
std::cout << "The FPGA acquisition IP does not support the required sampling frequency of " << acq_parameters_.fs_in << " SPS for the L2 band. Please update the sampling frequency in the configuration file." << std::endl;
exit(0);
}
DLOG(INFO) << "role " << role;
generate_gps_l2c_m_prn_codes();
#if USE_GLOG_AND_GFLAGS
if (FLAGS_doppler_max != 0)
{
acq_parameters_.doppler_max = FLAGS_doppler_max;
}
#else
if (absl::GetFlag(FLAGS_doppler_max) != 0)
{
acq_parameters_.doppler_max = absl::GetFlag(FLAGS_doppler_max);
}
#endif
doppler_max_ = acq_parameters_.doppler_max;
doppler_step_ = static_cast<unsigned int>(acq_parameters_.doppler_step);
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
}
if (out_streams_ > 0)
{
LOG(ERROR) << "This implementation does not provide an output stream";
}
DLOG(INFO) << "Initialized FPGA acquisition adapter for role " << role;
}
void GpsL2MPcpsAcquisitionFpga::generate_gps_l2c_m_prn_codes()
{
uint32_t code_length = acq_parameters_.code_length;
uint32_t nsamples_total = acq_parameters_.fft_size;
const uint32_t code_length = acq_parameters_.code_length;
const uint32_t nsamples_total = acq_parameters_.fft_size;
const uint32_t NUM_PRNs = 32;
// 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)
@@ -113,9 +74,9 @@ void GpsL2MPcpsAcquisitionFpga::generate_gps_l2c_m_prn_codes()
int32_t local_code;
int32_t fft_data;
for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++)
for (uint32_t prn = 1; prn <= NUM_PRNs; prn++)
{
gps_l2c_m_code_gen_complex_sampled(code, PRN, acq_parameters_.fs_in);
gps_l2c_m_code_gen_complex_sampled(code, prn, acq_parameters_.fs_in);
if (acq_parameters_.enable_zero_padding)
{
@@ -148,109 +109,9 @@ void GpsL2MPcpsAcquisitionFpga::generate_gps_l2c_m_prn_codes()
tmp2 = static_cast<int32_t>(floor(fft_codes[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;
d_all_fft_codes_[i + (nsamples_total * (prn - 1))] = fft_data;
}
}
acq_parameters_.all_fft_codes = d_all_fft_codes_.data();
}
void GpsL2MPcpsAcquisitionFpga::stop_acquisition()
{
// stop the acquisition and the other FPGA modules.
acquisition_fpga_->stop_acquisition();
}
void GpsL2MPcpsAcquisitionFpga::set_threshold(float threshold)
{
threshold_ = threshold;
DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_;
acquisition_fpga_->set_threshold(threshold_);
}
void GpsL2MPcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max)
{
doppler_max_ = doppler_max;
acquisition_fpga_->set_doppler_max(doppler_max_);
}
// Be aware that Doppler step should be set to 2/(3T) Hz, where T is the coherent integration time (GPS L2 period is 0.02s)
// Doppler bin minimum size= 33 Hz
void GpsL2MPcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step)
{
doppler_step_ = doppler_step;
acquisition_fpga_->set_doppler_step(doppler_step_);
}
void GpsL2MPcpsAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro)
{
gnss_synchro_ = gnss_synchro;
acquisition_fpga_->set_gnss_synchro(gnss_synchro_);
}
signed int GpsL2MPcpsAcquisitionFpga::mag()
{
return acquisition_fpga_->mag();
}
void GpsL2MPcpsAcquisitionFpga::init()
{
acquisition_fpga_->init();
}
void GpsL2MPcpsAcquisitionFpga::set_local_code()
{
acquisition_fpga_->set_local_code();
}
void GpsL2MPcpsAcquisitionFpga::reset()
{
acquisition_fpga_->set_active(true);
}
void GpsL2MPcpsAcquisitionFpga::set_state(int state)
{
acquisition_fpga_->set_state(state);
}
void GpsL2MPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
// Nothing to connect
}
void GpsL2MPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
// Nothing to disconnect
}
gr::basic_block_sptr GpsL2MPcpsAcquisitionFpga::get_left_block()
{
return nullptr;
}
gr::basic_block_sptr GpsL2MPcpsAcquisitionFpga::get_right_block()
{
return nullptr;
}

View File

@@ -20,16 +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 "gnss_synchro.h"
#include "pcps_acquisition_fpga.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <cstddef> // for size_t
#include <memory> // for weak_ptr
#include <string> // for string
#include <utility>
#include "base_pcps_acquisition_fpga.h"
/** \addtogroup Acquisition
* \{ */
@@ -43,7 +34,7 @@ class ConfigurationInterface;
* \brief This class adapts a PCPS acquisition block off-loaded on an FPGA
* to an AcquisitionInterface for GPS L2 M signals
*/
class GpsL2MPcpsAcquisitionFpga : public AcquisitionInterface
class GpsL2MPcpsAcquisitionFpga : public BasePcpsAcquisitionFpga
{
public:
GpsL2MPcpsAcquisitionFpga(
@@ -52,13 +43,6 @@ public:
unsigned int in_streams,
unsigned int out_streams);
~GpsL2MPcpsAcquisitionFpga() = default;
inline std::string role() override
{
return role_;
}
/*!
* \brief Returns "GPS_L2_M_PCPS_Acquisition_FPGA"
*/
@@ -67,112 +51,9 @@ public:
return "GPS_L2_M_PCPS_Acquisition_FPGA";
}
inline size_t item_size() override
{
return sizeof(float);
}
void connect(gr::top_block_sptr top_block) override;
void disconnect(gr::top_block_sptr top_block) override;
gr::basic_block_sptr get_left_block() override;
gr::basic_block_sptr get_right_block() override;
/*!
* \brief Set acquisition/tracking common Gnss_Synchro object pointer
* to efficiently exchange synchronization data between acquisition and
* tracking blocks
*/
void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override;
/*!
* \brief Set acquisition channel unique ID
*/
inline void set_channel(unsigned int channel) override
{
channel_ = channel;
acquisition_fpga_->set_channel(channel_);
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = std::move(channel_fsm);
acquisition_fpga_->set_channel_fsm(channel_fsm_);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
void set_threshold(float threshold) override;
/*!
* \brief Set maximum Doppler off grid search
*/
void set_doppler_max(unsigned int doppler_max) override;
/*!
* \brief Set Doppler steps for the grid search
*/
void set_doppler_step(unsigned int doppler_step) override;
/*!
* \brief Initializes acquisition algorithm.
*/
void init() override;
/*!
* \brief Sets local code for GPS L2/M PCPS acquisition algorithm.
*/
void set_local_code() override;
/*!
* \brief Returns the maximum peak of grid search
*/
signed int mag() override;
/*!
* \brief Restart acquisition algorithm
*/
void reset() override;
/*!
* \brief If state = 1, it forces the block to start acquiring from the first sample
*/
void set_state(int state) override;
/*!
* \brief Stop running acquisition
*/
void stop_acquisition() override;
void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {};
private:
static const uint32_t ACQ_BUFF_1 = 1; // FPGA Acquisition IP buffer containing L2 or L5/E5 frequency band samples by default.
static const uint32_t DEFAULT_FPGA_BLK_EXP = 13; // default block exponent
static const uint32_t NUM_PRNs = 32;
static const uint32_t QUANT_BITS_LOCAL_CODE = 16;
static const uint32_t SELECT_LSBITS = 0x0000FFFF; // Select the 10 LSbits out of a 20-bit word
static const uint32_t SELECT_MSBITS = 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
void generate_gps_l2c_m_prn_codes();
pcps_acquisition_fpga_sptr acquisition_fpga_;
volk_gnsssdr::vector<uint32_t> d_all_fft_codes_; // memory that contains all the code ffts
std::weak_ptr<ChannelFsm> channel_fsm_;
Gnss_Synchro* gnss_synchro_;
Acq_Conf_Fpga acq_parameters_;
std::string role_;
float threshold_;
unsigned int channel_;
unsigned int doppler_max_;
unsigned int doppler_step_;
unsigned int in_streams_;
unsigned int out_streams_;
};

View File

@@ -22,10 +22,8 @@
#include "GPS_L5.h"
#include "configuration_interface.h"
#include "gnss_sdr_fft.h"
#include "gnss_sdr_flags.h"
#include "gps_l5_signal_replica.h"
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
@@ -41,64 +39,27 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga(
const ConfigurationInterface* configuration,
const std::string& role,
unsigned int in_streams,
unsigned int out_streams) : gnss_synchro_(nullptr),
role_(role),
doppler_center_(0),
channel_(0),
doppler_step_(0),
in_streams_(in_streams),
out_streams_(out_streams)
unsigned int out_streams)
: BasePcpsAcquisitionFpga(configuration,
role,
GPS_L5I_CODE_RATE_CPS,
GPS_L5I_CODE_LENGTH_CHIPS,
0.0,
DEFAULT_FPGA_BLK_EXP,
ACQ_BUFF_1,
in_streams,
out_streams)
{
// Set acquisition parameters
acq_parameters_.SetFromConfiguration(configuration, role_, DEFAULT_FPGA_BLK_EXP, GPS_L5I_CODE_RATE_CPS, GPS_L5I_CODE_LENGTH_CHIPS);
// Query the capabilities of the instantiated FPGA Acquisition IP Core. When the FPGA is in use, the acquisition resampler operates only in the L1/E1 frequency band.
std::vector<std::pair<uint32_t, uint32_t>> downsampling_filter_specs;
uint32_t max_FFT_size;
acquisition_fpga_ = pcps_make_acquisition_fpga(&acq_parameters_, ACQ_BUFF_1, downsampling_filter_specs, max_FFT_size);
// When the FPGA is in use, the acquisition resampler operates only in the L1/E1 frequency band.
// Check whether the acquisition configuration is supported by the FPGA.
bool acq_configuration_valid = acq_parameters_.Is_acq_config_valid(max_FFT_size);
if (!acq_configuration_valid)
{
std::cout << "The FPGA acquisition IP does not support the required sampling frequency of " << acq_parameters_.fs_in << " SPS for the L5/E5a band. Please update the sampling frequency in the configuration file." << std::endl;
exit(0);
}
DLOG(INFO) << "role " << role;
generate_gps_l5i_prn_codes();
#if USE_GLOG_AND_GFLAGS
if (FLAGS_doppler_max != 0)
{
acq_parameters_.doppler_max = FLAGS_doppler_max;
}
#else
if (absl::GetFlag(FLAGS_doppler_max) != 0)
{
acq_parameters_.doppler_max = absl::GetFlag(FLAGS_doppler_max);
}
#endif
doppler_max_ = acq_parameters_.doppler_max;
doppler_step_ = static_cast<unsigned int>(acq_parameters_.doppler_step);
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
}
if (out_streams_ > 0)
{
LOG(ERROR) << "This implementation does not provide an output stream";
}
DLOG(INFO) << "Initialized FPGA acquisition adapter for role " << role;
}
void GpsL5iPcpsAcquisitionFpga::generate_gps_l5i_prn_codes()
{
uint32_t code_length = acq_parameters_.code_length;
uint32_t nsamples_total = acq_parameters_.fft_size;
const uint32_t code_length = acq_parameters_.code_length;
const uint32_t nsamples_total = acq_parameters_.fft_size;
const uint32_t NUM_PRNs = 32;
// 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)
@@ -113,9 +74,9 @@ void GpsL5iPcpsAcquisitionFpga::generate_gps_l5i_prn_codes()
int32_t local_code;
int32_t fft_data;
for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++)
for (uint32_t prn = 1; prn <= NUM_PRNs; prn++)
{
gps_l5i_code_gen_complex_sampled(code, PRN, acq_parameters_.fs_in);
gps_l5i_code_gen_complex_sampled(code, prn, acq_parameters_.fs_in);
if (acq_parameters_.enable_zero_padding)
{
@@ -149,113 +110,9 @@ void GpsL5iPcpsAcquisitionFpga::generate_gps_l5i_prn_codes()
tmp2 = static_cast<int32_t>(floor(fft_codes[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;
d_all_fft_codes_[i + (nsamples_total * (prn - 1))] = fft_data;
}
}
acq_parameters_.all_fft_codes = d_all_fft_codes_.data();
}
void GpsL5iPcpsAcquisitionFpga::stop_acquisition()
{
// stop the acquisition and the other FPGA modules.
acquisition_fpga_->stop_acquisition();
}
void GpsL5iPcpsAcquisitionFpga::set_threshold(float threshold)
{
DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold;
acquisition_fpga_->set_threshold(threshold);
}
void GpsL5iPcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max)
{
doppler_max_ = doppler_max;
acquisition_fpga_->set_doppler_max(doppler_max_);
}
// Be aware that Doppler step should be set to 2/(3T) Hz, where T is the coherent integration time (GPS L2 period is 0.02s)
// Doppler bin minimum size= 33 Hz
void GpsL5iPcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step)
{
doppler_step_ = doppler_step;
acquisition_fpga_->set_doppler_step(doppler_step_);
}
void GpsL5iPcpsAcquisitionFpga::set_doppler_center(int doppler_center)
{
doppler_center_ = doppler_center;
acquisition_fpga_->set_doppler_center(doppler_center_);
}
void GpsL5iPcpsAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro)
{
gnss_synchro_ = gnss_synchro;
acquisition_fpga_->set_gnss_synchro(gnss_synchro_);
}
signed int GpsL5iPcpsAcquisitionFpga::mag()
{
return acquisition_fpga_->mag();
}
void GpsL5iPcpsAcquisitionFpga::init()
{
acquisition_fpga_->init();
}
void GpsL5iPcpsAcquisitionFpga::set_local_code()
{
acquisition_fpga_->set_local_code();
}
void GpsL5iPcpsAcquisitionFpga::reset()
{
acquisition_fpga_->set_active(true);
}
void GpsL5iPcpsAcquisitionFpga::set_state(int state)
{
acquisition_fpga_->set_state(state);
}
void GpsL5iPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
// Nothing to connect
}
void GpsL5iPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
// Nothing to disconnect
}
gr::basic_block_sptr GpsL5iPcpsAcquisitionFpga::get_left_block()
{
return nullptr;
}
gr::basic_block_sptr GpsL5iPcpsAcquisitionFpga::get_right_block()
{
return nullptr;
}

View File

@@ -21,15 +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"
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base_pcps_acquisition_fpga.h"
/** \addtogroup Acquisition
* \{ */
@@ -43,7 +35,7 @@ class ConfigurationInterface;
* \brief This class adapts a PCPS acquisition block off-loaded on an FPGA
* to an AcquisitionInterface for GPS L5i signals
*/
class GpsL5iPcpsAcquisitionFpga : public AcquisitionInterface
class GpsL5iPcpsAcquisitionFpga : public BasePcpsAcquisitionFpga
{
public:
/*!
@@ -55,19 +47,6 @@ public:
unsigned int in_streams,
unsigned int out_streams);
/*!
* \brief Destructor
*/
~GpsL5iPcpsAcquisitionFpga() = default;
/*!
* \brief Role
*/
inline std::string role() override
{
return role_;
}
/*!
* \brief Returns "GPS_L5i_PCPS_Acquisition_FPGA"
*/
@@ -76,139 +55,9 @@ public:
return "GPS_L5i_PCPS_Acquisition_FPGA";
}
/*!
* \brief Returns size of lv_16sc_t
*/
inline size_t item_size() override
{
return sizeof(int16_t);
}
/*!
* \brief Connect
*/
void connect(gr::top_block_sptr top_block) override;
/*!
* \brief Disconnect
*/
void disconnect(gr::top_block_sptr top_block) override;
/*!
* \brief Get left block
*/
gr::basic_block_sptr get_left_block() override;
/*!
* \brief Get right block
*/
gr::basic_block_sptr get_right_block() override;
/*!
* \brief Set acquisition/tracking common Gnss_Synchro object pointer
* to efficiently exchange synchronization data between acquisition and
* tracking blocks
*/
void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override;
/*!
* \brief Set acquisition channel unique ID
*/
inline void set_channel(unsigned int channel) override
{
channel_ = channel;
acquisition_fpga_->set_channel(channel_);
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = std::move(channel_fsm);
acquisition_fpga_->set_channel_fsm(channel_fsm_);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
void set_threshold(float threshold) override;
/*!
* \brief Set maximum Doppler off grid search
*/
void set_doppler_max(unsigned int doppler_max) override;
/*!
* \brief Set Doppler steps for the grid search
*/
void set_doppler_step(unsigned int doppler_step) override;
/*!
* \brief Set Doppler center for the grid search
*/
void set_doppler_center(int doppler_center) override;
/*!
* \brief Initializes acquisition algorithm.
*/
void init() override;
/*!
* \brief Sets local code for GPS L5 PCPS acquisition algorithm.
*/
void set_local_code() override;
/*!
* \brief Returns the maximum peak of grid search
*/
signed int mag() override;
/*!
* \brief Restart acquisition algorithm
*/
void reset() override;
/*!
* \brief If state = 1, it forces the block to start acquiring from the first sample
*/
void set_state(int state) override;
/*!
* \brief Stop running acquisition
*/
void stop_acquisition() override;
/*!
* \brief Set resampler latency
*/
void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {};
private:
static const uint32_t ACQ_BUFF_1 = 1; // FPGA Acquisition IP buffer containing L2 or L5/E5 frequency band samples by default.
static const uint32_t DEFAULT_FPGA_BLK_EXP = 13; // default block exponent
static const uint32_t NUM_PRNs = 32;
static const uint32_t QUANT_BITS_LOCAL_CODE = 16;
static const uint32_t SELECT_LSBITS = 0x0000FFFF; // Select the 10 LSbits out of a 20-bit word
static const uint32_t SELECT_MSBITS = 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
void generate_gps_l5i_prn_codes();
float calculate_threshold(float pfa);
pcps_acquisition_fpga_sptr acquisition_fpga_;
std::weak_ptr<ChannelFsm> channel_fsm_;
volk_gnsssdr::vector<uint32_t> d_all_fft_codes_; // memory that contains all the code ffts
Gnss_Synchro* gnss_synchro_;
Acq_Conf_Fpga acq_parameters_;
std::string role_;
int32_t doppler_center_;
uint32_t channel_;
uint32_t doppler_max_;
uint32_t doppler_step_;
unsigned int in_streams_;
unsigned int out_streams_;
};