2013-10-01 20:32:04 +00:00
|
|
|
/*!
|
|
|
|
* \file pcps_opencl_acquisition_cc.h
|
|
|
|
* \brief This class implements a Parallel Code Phase Search Acquisition
|
|
|
|
* using OpenCL to offload some functions to the GPU.
|
|
|
|
*
|
|
|
|
* Acquisition strategy (Kay Borre book + CFAR threshold).
|
|
|
|
* <ol>
|
|
|
|
* <li> Compute the input signal power estimation
|
|
|
|
* <li> Doppler serial search loop
|
|
|
|
* <li> Perform the FFT-based circular convolution (parallel time search)
|
|
|
|
* <li> Record the maximum peak and the associated synchronization parameters
|
|
|
|
* <li> Compute the test statistics and compare to the threshold
|
2016-05-09 14:44:54 +00:00
|
|
|
* <li> Declare positive or negative acquisition using a message port
|
2013-10-01 20:32:04 +00:00
|
|
|
* </ol>
|
|
|
|
*
|
|
|
|
* Kay Borre book: K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,
|
|
|
|
* "A Software-Defined GPS and Galileo Receiver. A Single-Frequency
|
|
|
|
* Approach", Birkha user, 2007. pp 81-84
|
|
|
|
*
|
|
|
|
* \authors <ul>
|
|
|
|
* <li> Javier Arribas, 2011. jarribas(at)cttc.es
|
|
|
|
* <li> Luis Esteve, 2012. luis(at)epsilon-formacion.com
|
|
|
|
* <li> Marc Molina, 2013. marc.molina.pena@gmail.com
|
|
|
|
* </ul>
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2018-05-13 20:49:11 +00:00
|
|
|
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
2013-10-01 20:32:04 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2015-01-08 18:49:59 +00:00
|
|
|
* (at your option) any later version.
|
2013-10-01 20:32:04 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-05-13 20:49:11 +00:00
|
|
|
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
2013-10-01 20:32:04 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GNSS_SDR_PCPS_OPENCL_ACQUISITION_CC_H_
|
|
|
|
#define GNSS_SDR_PCPS_OPENCL_ACQUISITION_CC_H_
|
|
|
|
|
2019-06-24 11:39:34 +00:00
|
|
|
#define CL_SILENCE_DEPRECATION
|
2019-03-20 14:13:17 +00:00
|
|
|
#include "channel_fsm.h"
|
2018-04-29 11:26:21 +00:00
|
|
|
#include "gnss_synchro.h"
|
2019-06-24 11:39:34 +00:00
|
|
|
#include "opencl/cl.hpp"
|
2018-04-29 11:26:21 +00:00
|
|
|
#include "opencl/fft_internal.h"
|
2013-10-01 20:32:04 +00:00
|
|
|
#include <gnuradio/block.h>
|
|
|
|
#include <gnuradio/fft/fft.h>
|
2018-12-09 21:00:09 +00:00
|
|
|
#include <gnuradio/gr_complex.h>
|
2018-12-11 01:22:33 +00:00
|
|
|
#include <cstdint>
|
2018-04-29 11:26:21 +00:00
|
|
|
#include <fstream>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2013-10-01 20:32:04 +00:00
|
|
|
|
|
|
|
class pcps_opencl_acquisition_cc;
|
|
|
|
|
|
|
|
typedef boost::shared_ptr<pcps_opencl_acquisition_cc> pcps_opencl_acquisition_cc_sptr;
|
|
|
|
|
|
|
|
pcps_opencl_acquisition_cc_sptr
|
2018-12-11 01:22:33 +00:00
|
|
|
pcps_make_opencl_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells,
|
|
|
|
uint32_t doppler_max, int64_t fs_in,
|
2018-03-03 01:03:39 +00:00
|
|
|
int samples_per_ms, int samples_per_code,
|
|
|
|
bool bit_transition_flag,
|
|
|
|
bool dump,
|
|
|
|
std::string dump_filename);
|
2013-10-01 20:32:04 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief This class implements a Parallel Code Phase Search Acquisition.
|
|
|
|
*
|
|
|
|
* Check \ref Navitec2012 "An Open Source Galileo E1 Software Receiver",
|
|
|
|
* Algorithm 1, for a pseudocode description of this implementation.
|
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
class pcps_opencl_acquisition_cc : public gr::block
|
2013-10-01 20:32:04 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend pcps_opencl_acquisition_cc_sptr
|
2018-12-11 01:22:33 +00:00
|
|
|
pcps_make_opencl_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells,
|
|
|
|
uint32_t doppler_max, int64_t fs_in,
|
2018-03-03 01:03:39 +00:00
|
|
|
int samples_per_ms, int samples_per_code,
|
|
|
|
bool bit_transition_flag,
|
|
|
|
bool dump,
|
|
|
|
std::string dump_filename);
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-12-11 01:22:33 +00:00
|
|
|
pcps_opencl_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells,
|
|
|
|
uint32_t doppler_max, int64_t fs_in,
|
2018-03-03 01:03:39 +00:00
|
|
|
int samples_per_ms, int samples_per_code,
|
|
|
|
bool bit_transition_flag,
|
|
|
|
bool dump,
|
|
|
|
std::string dump_filename);
|
2013-10-01 20:32:04 +00:00
|
|
|
|
|
|
|
void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift,
|
2018-03-03 01:03:39 +00:00
|
|
|
int doppler_offset);
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-12-11 00:56:25 +00:00
|
|
|
int init_opencl_environment(const std::string& kernel_filename);
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-12-11 01:22:33 +00:00
|
|
|
int64_t d_fs_in;
|
2013-11-29 08:38:22 +00:00
|
|
|
int d_samples_per_ms;
|
2013-10-01 20:32:04 +00:00
|
|
|
int d_samples_per_code;
|
2018-12-11 01:22:33 +00:00
|
|
|
uint32_t d_doppler_resolution;
|
2013-11-29 08:38:22 +00:00
|
|
|
float d_threshold;
|
2013-10-01 20:32:04 +00:00
|
|
|
std::string d_satellite_str;
|
2018-12-11 01:22:33 +00:00
|
|
|
uint32_t d_doppler_max;
|
|
|
|
uint32_t d_doppler_step;
|
|
|
|
uint32_t d_sampled_ms;
|
|
|
|
uint32_t d_max_dwells;
|
|
|
|
uint32_t d_well_count;
|
|
|
|
uint32_t d_fft_size;
|
|
|
|
uint32_t d_fft_size_pow2;
|
2013-10-01 20:32:04 +00:00
|
|
|
int* d_max_doppler_indexs;
|
2018-08-10 18:34:03 +00:00
|
|
|
uint64_t d_sample_counter;
|
2013-10-01 20:32:04 +00:00
|
|
|
gr_complex** d_grid_doppler_wipeoffs;
|
2018-12-11 01:22:33 +00:00
|
|
|
uint32_t d_num_doppler_bins;
|
2013-11-29 08:38:22 +00:00
|
|
|
gr_complex* d_fft_codes;
|
|
|
|
gr::fft::fft_complex* d_fft_if;
|
|
|
|
gr::fft::fft_complex* d_ifft;
|
2018-03-03 01:03:39 +00:00
|
|
|
Gnss_Synchro* d_gnss_synchro;
|
2018-12-11 01:22:33 +00:00
|
|
|
uint32_t d_code_phase;
|
2013-11-29 08:38:22 +00:00
|
|
|
float d_doppler_freq;
|
|
|
|
float d_mag;
|
2013-10-01 20:32:04 +00:00
|
|
|
float* d_magnitude;
|
2013-11-29 08:38:22 +00:00
|
|
|
float d_input_power;
|
|
|
|
float d_test_statistics;
|
2013-10-01 20:32:04 +00:00
|
|
|
bool d_bit_transition_flag;
|
2013-11-29 08:38:22 +00:00
|
|
|
std::ofstream d_dump_file;
|
|
|
|
bool d_active;
|
2013-10-01 20:32:04 +00:00
|
|
|
int d_state;
|
|
|
|
bool d_core_working;
|
|
|
|
bool d_dump;
|
2018-12-11 01:22:33 +00:00
|
|
|
uint32_t d_channel;
|
2013-11-29 08:38:22 +00:00
|
|
|
std::string d_dump_filename;
|
2013-10-01 20:32:04 +00:00
|
|
|
gr_complex* d_zero_vector;
|
|
|
|
gr_complex** d_in_buffer;
|
2018-08-10 18:34:03 +00:00
|
|
|
std::vector<uint64_t> d_sample_counter_buffer;
|
2018-12-11 01:22:33 +00:00
|
|
|
uint32_t d_in_dwell_count;
|
2013-10-01 20:32:04 +00:00
|
|
|
|
|
|
|
cl::Platform d_cl_platform;
|
|
|
|
cl::Device d_cl_device;
|
|
|
|
cl::Context d_cl_context;
|
|
|
|
cl::Program d_cl_program;
|
|
|
|
cl::Buffer* d_cl_buffer_in;
|
|
|
|
cl::Buffer* d_cl_buffer_fft_codes;
|
|
|
|
cl::Buffer* d_cl_buffer_1;
|
|
|
|
cl::Buffer* d_cl_buffer_2;
|
|
|
|
cl::Buffer* d_cl_buffer_magnitude;
|
|
|
|
cl::Buffer** d_cl_buffer_grid_doppler_wipeoffs;
|
|
|
|
cl::CommandQueue* d_cl_queue;
|
|
|
|
clFFT_Plan d_cl_fft_plan;
|
|
|
|
cl_int d_cl_fft_batch_size;
|
2019-04-09 15:39:48 +00:00
|
|
|
std::weak_ptr<ChannelFsm> d_channel_fsm;
|
2013-10-01 20:32:04 +00:00
|
|
|
int d_opencl;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
* \brief Default destructor.
|
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
~pcps_opencl_acquisition_cc();
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2013-11-29 08:38:22 +00:00
|
|
|
* \brief Set acquisition/tracking common Gnss_Synchro object pointer
|
|
|
|
* to exchange synchronization data between acquisition and tracking blocks.
|
|
|
|
* \param p_gnss_synchro Satellite information shared by the processing blocks.
|
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
|
|
|
|
{
|
|
|
|
d_gnss_synchro = p_gnss_synchro;
|
|
|
|
}
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2013-11-29 08:38:22 +00:00
|
|
|
* \brief Returns the maximum peak of grid search.
|
|
|
|
*/
|
2018-12-11 01:22:33 +00:00
|
|
|
inline uint32_t mag() const
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
|
|
|
return d_mag;
|
|
|
|
}
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2013-11-29 08:38:22 +00:00
|
|
|
* \brief Initializes acquisition algorithm.
|
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
void init();
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2013-11-29 08:38:22 +00:00
|
|
|
* \brief Sets local code for PCPS acquisition algorithm.
|
|
|
|
* \param code - Pointer to the PRN code.
|
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
void set_local_code(std::complex<float>* code);
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2013-11-29 08:38:22 +00:00
|
|
|
* \brief Starts acquisition algorithm, turning from standby mode to
|
|
|
|
* active mode
|
|
|
|
* \param active - bool that activates/deactivates the block.
|
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
inline void set_active(bool active)
|
|
|
|
{
|
|
|
|
d_active = active;
|
|
|
|
}
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2015-02-10 18:30:15 +00:00
|
|
|
* \brief If set to 1, ensures that acquisition starts at the
|
|
|
|
* first available sample.
|
|
|
|
* \param state - int=1 forces start of acquisition
|
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
void set_state(int state);
|
2015-02-10 18:30:15 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2013-11-29 08:38:22 +00:00
|
|
|
* \brief Set acquisition channel unique ID
|
|
|
|
* \param channel - receiver channel.
|
|
|
|
*/
|
2018-12-11 01:22:33 +00:00
|
|
|
inline void set_channel(uint32_t channel)
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
|
|
|
d_channel = channel;
|
|
|
|
}
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2019-03-20 14:13:17 +00:00
|
|
|
/*!
|
|
|
|
* \brief Set channel fsm associated to this acquisition instance
|
|
|
|
*/
|
2019-04-09 15:39:48 +00:00
|
|
|
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm)
|
2019-03-20 14:13:17 +00:00
|
|
|
{
|
|
|
|
d_channel_fsm = channel_fsm;
|
|
|
|
}
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2013-11-29 08:38:22 +00:00
|
|
|
* \brief Set statistics threshold of PCPS algorithm.
|
|
|
|
* \param threshold - Threshold for signal detection (check \ref Navitec2012,
|
|
|
|
* Algorithm 1, for a definition of this threshold).
|
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
inline void set_threshold(float threshold)
|
|
|
|
{
|
|
|
|
d_threshold = threshold;
|
|
|
|
}
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2013-11-29 08:38:22 +00:00
|
|
|
* \brief Set maximum Doppler grid search
|
|
|
|
* \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
|
|
|
|
*/
|
2018-12-11 01:22:33 +00:00
|
|
|
inline void set_doppler_max(uint32_t doppler_max)
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
|
|
|
d_doppler_max = doppler_max;
|
|
|
|
}
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2013-11-29 08:38:22 +00:00
|
|
|
* \brief Set Doppler steps for the grid search
|
|
|
|
* \param doppler_step - Frequency bin of the search grid [Hz].
|
|
|
|
*/
|
2018-12-11 01:22:33 +00:00
|
|
|
inline void set_doppler_step(uint32_t doppler_step)
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
|
|
|
d_doppler_step = doppler_step;
|
|
|
|
}
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2019-06-24 12:33:08 +00:00
|
|
|
inline bool opencl_ready() const
|
|
|
|
{
|
|
|
|
bool ready = false;
|
|
|
|
if (d_opencl == 0)
|
|
|
|
{
|
|
|
|
ready = true;
|
|
|
|
}
|
|
|
|
return ready;
|
|
|
|
}
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2013-11-29 08:38:22 +00:00
|
|
|
* \brief Parallel Code Phase Search Acquisition signal processing.
|
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
int general_work(int noutput_items, gr_vector_int& ninput_items,
|
|
|
|
gr_vector_const_void_star& input_items,
|
|
|
|
gr_vector_void_star& output_items);
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
void acquisition_core_volk();
|
2013-10-01 20:32:04 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
void acquisition_core_opencl();
|
2013-10-01 20:32:04 +00:00
|
|
|
};
|
|
|
|
|
2013-11-29 08:38:22 +00:00
|
|
|
#endif
|