From 4fa5648aa438dba1e994a4aa3de77f1b17c86210 Mon Sep 17 00:00:00 2001 From: mmajoral Date: Thu, 3 May 2018 10:38:21 +0200 Subject: [PATCH 1/2] Currently creating a generic tracking class for the FPGA in the same way as it is done in the SW. --- .../gps_l1_ca_pcps_acquisition_fpga.cc | 3 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 2 +- .../gnuradio_blocks/pcps_acquisition_fpga.h | 4 +- .../gps_l1_ca_dll_pll_tracking_fpga.cc | 139 +++++++++++------- .../gps_l1_ca_dll_pll_tracking_fpga.h | 9 +- .../tracking/gnuradio_blocks/CMakeLists.txt | 2 +- ...ga_sc.cc => dll_pll_veml_tracking_fpga.cc} | 126 +++++++++++----- ...fpga_sc.h => dll_pll_veml_tracking_fpga.h} | 122 +++++++++------ src/algorithms/tracking/libs/CMakeLists.txt | 2 +- ...relator_8sc.cc => fpga_multicorrelator.cc} | 24 +-- ...orrelator_8sc.h => fpga_multicorrelator.h} | 4 +- .../gps_l1_ca_dll_pll_tracking_test_fpga.cc | 2 +- 12 files changed, 285 insertions(+), 154 deletions(-) rename src/algorithms/tracking/gnuradio_blocks/{gps_l1_ca_dll_pll_tracking_fpga_sc.cc => dll_pll_veml_tracking_fpga.cc} (87%) rename src/algorithms/tracking/gnuradio_blocks/{gps_l1_ca_dll_pll_tracking_fpga_sc.h => dll_pll_veml_tracking_fpga.h} (57%) rename src/algorithms/tracking/libs/{fpga_multicorrelator_8sc.cc => fpga_multicorrelator.cc} (95%) rename src/algorithms/tracking/libs/{fpga_multicorrelator_8sc.h => fpga_multicorrelator.h} (97%) 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 455fac062..adbcfe05a 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 @@ -132,12 +132,13 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( delete fft_if; delete[] fft_codes_padded; - acquisition_fpga_ = pcps_make_acquisition(acq_parameters); + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; channel_ = 0; doppler_step_ = 0; gnss_synchro_ = 0; + } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 6a337925e..5bc5b2b3d 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -45,7 +45,7 @@ using google::LogMessage; -pcps_acquisition_fpga_sptr pcps_make_acquisition(pcpsconf_fpga_t conf_) +pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_) { return pcps_acquisition_fpga_sptr(new pcps_acquisition_fpga(conf_)); } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index 3014a278a..9edb69685 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -81,7 +81,7 @@ class pcps_acquisition_fpga; typedef boost::shared_ptr pcps_acquisition_fpga_sptr; pcps_acquisition_fpga_sptr -pcps_make_acquisition(pcpsconf_fpga_t conf_); +pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_); /*! * \brief This class implements a Parallel Code Phase Search Acquisition that uses the FPGA. @@ -94,7 +94,7 @@ class pcps_acquisition_fpga : public gr::block private: friend pcps_acquisition_fpga_sptr - pcps_make_acquisition(pcpsconf_fpga_t conf_); + pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_); pcps_acquisition_fpga(pcpsconf_fpga_t conf_); diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc index 336e93eb8..8658a5a0b 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc @@ -1,8 +1,9 @@ /*! * \file gps_l1_ca_dll_pll_tracking.cc * \brief Implementation of an adapter of a DLL+PLL tracking loop block - * for GPS L1 C/A to a TrackingInterface - * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com + * for GPS L1 C/A to a TrackingInterface that uses the FPGA + * \author Marc Majoral, 2018, mmajoral(at)cttc.es + * Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Javier Arribas, 2011. jarribas(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: @@ -36,11 +37,19 @@ */ -#include "gps_l1_ca_dll_pll_tracking_fpga.h" -#include -#include "GPS_L1_CA.h" -#include "configuration_interface.h" +//#include + +#include +#include "gps_sdr_signal_processing.h" +#include "gps_l1_ca_dll_pll_tracking_fpga.h" +#include "configuration_interface.h" +#include "GPS_L1_CA.h" +#include "gnss_sdr_flags.h" +#include "display.h" + + +#define NUM_PRNs 32 using google::LogMessage; @@ -49,59 +58,88 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { + dllpllconf_fpga_t trk_param_fpga; DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## - int fs_in; - int vector_length; - int f_if; - bool dump; - std::string dump_filename; - std::string item_type; - //std::string default_item_type = "gr_complex"; - std::string default_item_type = "cshort"; - float pll_bw_hz; - float dll_bw_hz; - float early_late_space_chips; - item_type = configuration->property(role + ".item_type", default_item_type); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - std::string device_name; - unsigned int device_base; - std::string default_device_name = "/dev/uio"; - device_name = configuration->property(role + ".devicename", default_device_name); - device_base = configuration->property(role + ".device_base", 1); - fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - f_if = configuration->property(role + ".if", 0); - dump = configuration->property(role + ".dump", false); - pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); + int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + trk_param_fpga.fs_in = fs_in; + bool dump = configuration->property(role + ".dump", false); + trk_param_fpga.dump = dump; + float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); + if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + trk_param_fpga.pll_bw_hz = pll_bw_hz; + float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); + trk_param_fpga.pll_bw_narrow_hz = pll_bw_narrow_hz; + float dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); + trk_param_fpga.dll_bw_narrow_hz = dll_bw_narrow_hz; + float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); + if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + trk_param_fpga.dll_bw_hz = dll_bw_hz; + float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); + trk_param_fpga.early_late_space_chips = early_late_space_chips; + float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.5); + trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; std::string default_dump_filename = "./track_ch"; - dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); //unused! - vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); - if (item_type.compare("cshort") == 0) + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + trk_param_fpga.dump_filename = dump_filename; + int vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); + trk_param_fpga.vector_length = vector_length; + int symbols_extended_correlator = configuration->property(role + ".extend_correlation_symbols", 1); + if (symbols_extended_correlator < 1) { - item_size_ = sizeof(lv_16sc_t); - tracking_fpga_sc = gps_l1_ca_dll_pll_make_tracking_fpga_sc( - f_if, fs_in, vector_length, dump, dump_filename, pll_bw_hz, - dll_bw_hz, early_late_space_chips, device_name, - device_base); - DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() - << ")"; + symbols_extended_correlator = 1; + std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be bigger than 1. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << std::endl; } - else + else if (symbols_extended_correlator > 20) { + symbols_extended_correlator = 20; + std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be lower than 21. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << std::endl; + } + trk_param_fpga.extend_correlation_symbols = symbols_extended_correlator; + bool track_pilot = configuration->property(role + ".track_pilot", false); + if (track_pilot) + { + std::cout << TEXT_RED << "WARNING: GPS L1 C/A does not have pilot signal. Data tracking has been enabled" << TEXT_RESET << std::endl; + } + if ((symbols_extended_correlator > 1) and (pll_bw_narrow_hz > pll_bw_hz or dll_bw_narrow_hz > dll_bw_hz)) + { + std::cout << TEXT_RED << "WARNING: GPS L1 C/A. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << std::endl; + } + trk_param_fpga.very_early_late_space_chips = 0.0; + trk_param_fpga.very_early_late_space_narrow_chips = 0.0; + trk_param_fpga.track_pilot = false; + trk_param_fpga.system = 'G'; + char sig_[3] = "1C"; + std::memcpy(trk_param_fpga.signal, sig_, 3); - item_size_ = sizeof(lv_16sc_t); - // LOG(WARNING) << item_type_ << " unknown tracking item type"; - LOG(WARNING) << item_type - << " the tracking item type for the FPGA tracking test has to be cshort"; - } + // FPGA configuration parameters + std::string default_device_name = "/dev/uio"; + std::string device_name = configuration->property(role + ".devicename", default_device_name); + trk_param_fpga.device_name = device_name; + unsigned int device_base = configuration->property(role + ".device_base", 1); + trk_param_fpga.device_base = device_base; + + //################# PRE-COMPUTE ALL THE CODES ################# + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS*NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); + for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) + { + gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); + } + trk_param_fpga.ca_codes = d_ca_codes; + trk_param_fpga.code_length = GPS_L1_CA_CODE_LENGTH_CHIPS; + + //################# MAKE TRACKING GNURadio object ################### + tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); channel_ = 0; DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; + } GpsL1CaDllPllTrackingFpga::~GpsL1CaDllPllTrackingFpga() -{} +{ + delete[] d_ca_codes; +} void GpsL1CaDllPllTrackingFpga::start_tracking() { @@ -125,14 +163,14 @@ void GpsL1CaDllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) void GpsL1CaDllPllTrackingFpga::connect(gr::top_block_sptr top_block) { if(top_block) { /* top_block is not null */}; - //nothing to connect, now the tracking uses gr_sync_decimator + //nothing to connect } void GpsL1CaDllPllTrackingFpga::disconnect(gr::top_block_sptr top_block) { if(top_block) { /* top_block is not null */}; - //nothing to disconnect, now the tracking uses gr_sync_decimator + //nothing to disconnect } @@ -148,8 +186,3 @@ gr::basic_block_sptr GpsL1CaDllPllTrackingFpga::get_right_block() } -void GpsL1CaDllPllTrackingFpga::reset(void) -{ - // tracking_fpga_sc->reset(); - -} diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h index f45e3f802..1da65cda8 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h @@ -40,7 +40,7 @@ #include #include "tracking_interface.h" -#include "gps_l1_ca_dll_pll_tracking_fpga_sc.h" +#include "dll_pll_veml_tracking_fpga.h" class ConfigurationInterface; @@ -92,16 +92,17 @@ public: void start_tracking() override; - void reset(void); + //void reset(void); private: - //gps_l1_ca_dll_pll_tracking_cc_sptr tracking_; - gps_l1_ca_dll_pll_tracking_fpga_sc_sptr tracking_fpga_sc; + //gps_l1_ca_dll_pll_tracking_cc_sptr tracking_; + dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; size_t item_size_; unsigned int channel_; std::string role_; unsigned int in_streams_; unsigned int out_streams_; + int* d_ca_codes; }; #endif // GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_H_ diff --git a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt index 4cb869a79..2010ef817 100644 --- a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt @@ -23,7 +23,7 @@ if(ENABLE_CUDA) endif(ENABLE_CUDA) if(ENABLE_FPGA) - set(OPT_TRACKING_BLOCKS ${OPT_TRACKING_BLOCKS} gps_l1_ca_dll_pll_tracking_fpga_sc.cc) + set(OPT_TRACKING_BLOCKS ${OPT_TRACKING_BLOCKS} dll_pll_veml_tracking_fpga.cc) endif(ENABLE_FPGA) set(TRACKING_GR_BLOCKS_SOURCES diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_fpga_sc.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc similarity index 87% rename from src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_fpga_sc.cc rename to src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 069b426db..22c6cad45 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_fpga_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -34,7 +34,7 @@ * ------------------------------------------------------------------------- */ -#include "gps_l1_ca_dll_pll_tracking_fpga_sc.h" +#include "dll_pll_veml_tracking_fpga.h" #include #include #include @@ -61,43 +61,96 @@ using google::LogMessage; -gps_l1_ca_dll_pll_tracking_fpga_sc_sptr -gps_l1_ca_dll_pll_make_tracking_fpga_sc( - long if_freq, - long fs_in, - unsigned int vector_length, - bool dump, - std::string dump_filename, - float pll_bw_hz, - float dll_bw_hz, - float early_late_space_chips, - std::string device_name, - unsigned int device_base) +//dll_pll_veml_tracking_fpga_sptr +//dll_pll_veml_make_tracking_fpga( +// long if_freq, +// long fs_in, +// unsigned int vector_length, +// bool dump, +// std::string dump_filename, +// float pll_bw_hz, +// float dll_bw_hz, +// float early_late_space_chips, +// std::string device_name, +// unsigned int device_base, +// int* ca_codes, +// unsigned int code_length) +//{ +// return dll_pll_veml_tracking_fpga_sptr(new dll_pll_veml_tracking_fpga(if_freq, +// fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, early_late_space_chips, device_name, device_base, ca_codes, code_length)); +// +//// return dll_pll_veml_tracking_fpga_sptr(new dll_pll_veml_tracking_fpga(conf_)); +//} + + + + +dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(dllpllconf_fpga_t conf_) { - return gps_l1_ca_dll_pll_tracking_fpga_sc_sptr(new Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc(if_freq, - fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, early_late_space_chips, device_name, device_base)); + + return dll_pll_veml_tracking_fpga_sptr(new dll_pll_veml_tracking_fpga(conf_)); + //return dll_pll_veml_tracking_fpga_sptr(new dll_pll_veml_tracking_fpga(//0, //conf_.f_if, // if_freq is removed ... why ???????????? + // conf_.fs_in, conf_.vector_length, conf_.dump, conf_.dump_filename, conf_.pll_bw_hz, conf_.dll_bw_hz, + // conf_.early_late_space_chips, conf_.device_name, conf_.device_base, conf_.ca_codes, conf_.code_length)); + } -Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc( - long if_freq, - long fs_in, - unsigned int vector_length, - bool dump, - std::string dump_filename, - float pll_bw_hz, - float dll_bw_hz, - float early_late_space_chips, - std::string device_name, - unsigned int device_base) : - gr::block("Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc", gr::io_signature::make(0, 0, sizeof(lv_16sc_t)), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) + + +//dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga( +// //long if_freq, +// long fs_in, +// unsigned int vector_length, +// bool dump, +// std::string dump_filename, +// float pll_bw_hz, +// float dll_bw_hz, +// float early_late_space_chips, +// std::string device_name, +// unsigned int device_base, +// int* ca_codes, +// unsigned int code_length) : +// gr::block("dll_pll_veml_tracking_fpga", gr::io_signature::make(0, 0, sizeof(lv_16sc_t)), +// gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +//{ + +dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) : + gr::block("dll_pll_veml_tracking_fpga", gr::io_signature::make(0, 0, sizeof(lv_16sc_t)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { + + trk_parameters = conf_; + // Telemetry bit synchronization message port input this->message_port_register_out(pmt::mp("events")); + + + long fs_in = trk_parameters.fs_in; + unsigned int vector_length = trk_parameters.vector_length; + bool dump = trk_parameters.dump; + std::string dump_filename = trk_parameters.dump_filename; + float pll_bw_hz = trk_parameters.pll_bw_hz; + float dll_bw_hz = trk_parameters.dll_bw_hz; + float early_late_space_chips = trk_parameters.early_late_space_chips; + std::string device_name = trk_parameters.device_name; + unsigned int device_base = trk_parameters.device_base; + int* ca_codes = trk_parameters.ca_codes; + unsigned int code_length = trk_parameters.code_length; + + + + + + + + + + + // initialize internal vars d_dump = dump; - d_if_freq = if_freq; + //d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; d_dump_filename = dump_filename; @@ -132,7 +185,7 @@ Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc( d_local_code_shift_chips[2] = d_early_late_spc_chips; // create multicorrelator class - multicorrelator_fpga_8sc = std::make_shared (d_n_correlator_taps, device_name, device_base); + multicorrelator_fpga_8sc = std::make_shared (d_n_correlator_taps, device_name, device_base, ca_codes, code_length); //--- Perform initializations ------------------------------ // define initial code frequency basis of NCO @@ -174,9 +227,10 @@ Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc( set_relative_rate(1.0 / static_cast(d_vector_length)); multicorrelator_fpga_8sc->set_output_vectors(d_correlator_outs); + } -void Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::start_tracking() +void dll_pll_veml_tracking_fpga::start_tracking() { /* * correct the code phase according to the delay between acq and trk @@ -252,7 +306,7 @@ void Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::start_tracking() << " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples; } -Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::~Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc() +dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() { if (d_dump_file.is_open()) { @@ -278,7 +332,7 @@ Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::~Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc() } } -int Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), +int dll_pll_veml_tracking_fpga::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -513,7 +567,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::general_work (int noutput_items __attrib -void Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::set_channel(unsigned int channel) +void dll_pll_veml_tracking_fpga::set_channel(unsigned int channel) { d_channel = channel; multicorrelator_fpga_8sc->set_channel(d_channel); @@ -541,12 +595,12 @@ void Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::set_channel(unsigned int channel) } -void Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) +void dll_pll_veml_tracking_fpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { d_acquisition_gnss_synchro = p_gnss_synchro; } -void Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc::reset(void) +void dll_pll_veml_tracking_fpga::reset(void) { multicorrelator_fpga_8sc->unlock_channel(); } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_fpga_sc.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h similarity index 57% rename from src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_fpga_sc.h rename to src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h index 161d87530..cd505f0cb 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_fpga_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h @@ -35,8 +35,8 @@ * ------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_SC_H -#define GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_SC_H +#ifndef GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H +#define GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H #include #include @@ -45,34 +45,63 @@ #include "gnss_synchro.h" #include "tracking_2nd_DLL_filter.h" #include "tracking_2nd_PLL_filter.h" -#include "fpga_multicorrelator_8sc.h" +#include "fpga_multicorrelator.h" -class Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc; +typedef struct +{ + /* DLL/PLL tracking configuration */ + double fs_in; + unsigned int vector_length; + bool dump; + std::string dump_filename; + float pll_bw_hz; + float dll_bw_hz; + float pll_bw_narrow_hz; + float dll_bw_narrow_hz; + float early_late_space_chips; + float very_early_late_space_chips; + float early_late_space_narrow_chips; + float very_early_late_space_narrow_chips; + int extend_correlation_symbols; + bool track_pilot; + char system; + char signal[3]; + std::string device_name; + unsigned int device_base; + unsigned int code_length; + int* ca_codes; + //int f_if; +} dllpllconf_fpga_t; -typedef boost::shared_ptr - gps_l1_ca_dll_pll_tracking_fpga_sc_sptr; +class dll_pll_veml_tracking_fpga; -gps_l1_ca_dll_pll_tracking_fpga_sc_sptr -gps_l1_ca_dll_pll_make_tracking_fpga_sc(long if_freq, - long fs_in, unsigned - int vector_length, - bool dump, - std::string dump_filename, - float pll_bw_hz, - float dll_bw_hz, - float early_late_space_chips, - std::string device_name, - unsigned int device_base); +typedef boost::shared_ptr +dll_pll_veml_tracking_fpga_sptr; +//dll_pll_veml_tracking_fpga_sptr +//dll_pll_veml_make_tracking_fpga(long if_freq, +// long fs_in, unsigned +// int vector_length, +// bool dump, +// std::string dump_filename, +// float pll_bw_hz, +// float dll_bw_hz, +// float early_late_space_chips, +// std::string device_name, +// unsigned int device_base, +// int* ca_codes, +// unsigned int code_length); + +dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(dllpllconf_fpga_t conf_); /*! * \brief This class implements a DLL + PLL tracking loop block */ -class Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc: public gr::block +class dll_pll_veml_tracking_fpga: public gr::block { public: - ~Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc(); + ~dll_pll_veml_tracking_fpga(); void set_channel(unsigned int channel); void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); @@ -84,28 +113,37 @@ public: void reset(void); private: - friend gps_l1_ca_dll_pll_tracking_fpga_sc_sptr - gps_l1_ca_dll_pll_make_tracking_fpga_sc(long if_freq, - long fs_in, unsigned - int vector_length, - bool dump, - std::string dump_filename, - float pll_bw_hz, - float dll_bw_hz, - float early_late_space_chips, - std::string device_name, - unsigned int device_base); +// friend dll_pll_veml_tracking_fpga_sptr +// dll_pll_veml_make_tracking_fpga(long if_freq, +// long fs_in, unsigned +// int vector_length, +// bool dump, +// std::string dump_filename, +// float pll_bw_hz, +// float dll_bw_hz, +// float early_late_space_chips, +// std::string device_name, +// unsigned int device_base, +// int* ca_codes, +// unsigned int code_length); + friend dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(dllpllconf_fpga_t conf_); - Gps_L1_Ca_Dll_Pll_Tracking_fpga_sc(long if_freq, - long fs_in, unsigned - int vector_length, - bool dump, - std::string dump_filename, - float pll_bw_hz, - float dll_bw_hz, - float early_late_space_chips, - std::string device_name, - unsigned int device_base); + dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_); +// dll_pll_veml_tracking_fpga(//long if_freq, +// long fs_in, unsigned +// int vector_length, +// bool dump, +// std::string dump_filename, +// float pll_bw_hz, +// float dll_bw_hz, +// float early_late_space_chips, +// std::string device_name, +// unsigned int device_base, +// int* ca_codes, +// unsigned int code_length); + + + dllpllconf_fpga_t trk_parameters; // tracking configuration vars unsigned int d_vector_length; @@ -114,7 +152,7 @@ private: Gnss_Synchro* d_acquisition_gnss_synchro; unsigned int d_channel; - long d_if_freq; + //long d_if_freq; long d_fs_in; double d_early_late_spc_chips; @@ -184,4 +222,4 @@ private: }; -#endif //GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_SC_H +#endif //GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H diff --git a/src/algorithms/tracking/libs/CMakeLists.txt b/src/algorithms/tracking/libs/CMakeLists.txt index 88c4eb2a5..4e2a93efd 100644 --- a/src/algorithms/tracking/libs/CMakeLists.txt +++ b/src/algorithms/tracking/libs/CMakeLists.txt @@ -46,7 +46,7 @@ set(TRACKING_LIB_SOURCES ) if(ENABLE_FPGA) - SET(TRACKING_LIB_SOURCES ${TRACKING_LIB_SOURCES} fpga_multicorrelator_8sc.cc) + SET(TRACKING_LIB_SOURCES ${TRACKING_LIB_SOURCES} fpga_multicorrelator.cc) endif(ENABLE_FPGA) include_directories( diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc similarity index 95% rename from src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc rename to src/algorithms/tracking/libs/fpga_multicorrelator.cc index 9c9e6af0b..281bf2bc2 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -34,7 +34,7 @@ * ------------------------------------------------------------------------- */ -#include "fpga_multicorrelator_8sc.h" +#include "fpga_multicorrelator.h" #include @@ -65,9 +65,9 @@ #include // constants -#include "GPS_L1_CA.h" +#include "GPS_L1_CA.h" -#include "gps_sdr_signal_processing.h" +//#include "gps_sdr_signal_processing.h" #define NUM_PRNs 32 #define PAGE_SIZE 0x10000 @@ -144,7 +144,7 @@ void fpga_multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler( } fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int n_correlators, - std::string device_name, unsigned int device_base) + std::string device_name, unsigned int device_base, int *ca_codes, unsigned int code_length) { d_n_correlators = n_correlators; d_device_name = device_name; @@ -170,14 +170,16 @@ fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int n_correlators, d_phase_step_rad_int = 0; d_initial_sample_counter = 0; d_channel = 0; - d_correlator_length_samples = 0; + d_correlator_length_samples = 0, + d_code_length = code_length; // pre-compute all the codes - d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS*NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); - for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) - { - gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); - } +// d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS*NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); +// for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) +// { +// gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); +// } + d_ca_codes = ca_codes; DLOG(INFO) << "TRACKING FPGA CLASS CREATED"; } @@ -278,7 +280,7 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int PRN) for (k = 0; k < d_code_length_chips; k++) { //if (d_local_code_in[k] == 1) - if (d_ca_codes[((int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)) + k] == 1) + if (d_ca_codes[((int(d_code_length)) * (PRN - 1)) + k] == 1) { code_chip = 1; } diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.h b/src/algorithms/tracking/libs/fpga_multicorrelator.h similarity index 97% rename from src/algorithms/tracking/libs/fpga_multicorrelator_8sc.h rename to src/algorithms/tracking/libs/fpga_multicorrelator.h index 9bf44536e..5012651d4 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.h +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.h @@ -49,7 +49,7 @@ class fpga_multicorrelator_8sc { public: fpga_multicorrelator_8sc(int n_correlators, std::string device_name, - unsigned int device_base); + unsigned int device_base, int *ca_codes, unsigned int code_length); ~fpga_multicorrelator_8sc(); //bool set_output_vectors(gr_complex* corr_out); void set_output_vectors(gr_complex* corr_out); @@ -110,6 +110,8 @@ private: int* d_ca_codes; + unsigned int d_code_length; // nominal number of chips + // private functions unsigned fpga_acquisition_test_register(unsigned writeval); void fpga_configure_tracking_gps_local_code(int PRN); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc index 91c611d2d..896c2a6c0 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc @@ -534,7 +534,7 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga) { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait - tracking->reset();// unlock the channel + //tracking->reset();// unlock the channel end = std::chrono::system_clock::now(); elapsed_seconds = end - start; }) << "Failure running the top_block."; From 7754fc66a68b3d3280ea22d549ffa947183c6fa5 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 9 May 2018 13:09:26 +0200 Subject: [PATCH 2/2] Code cleaning --- .../gps_l1_ca_pcps_acquisition_fpga.cc | 18 +-- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 20 ++- .../gps_l1_ca_dll_pll_tracking_fpga.cc | 130 +++--------------- .../gps_l1_ca_dll_pll_tracking_fpga.h | 16 +-- .../dll_pll_veml_tracking_fpga.cc | 93 +++++-------- .../dll_pll_veml_tracking_fpga.h | 11 +- 6 files changed, 88 insertions(+), 200 deletions(-) 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 2e5fecee9..4b7aae6d0 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 @@ -34,16 +34,15 @@ * ------------------------------------------------------------------------- */ +#include "gps_l1_ca_pcps_acquisition_fpga.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" -#include "gps_l1_ca_pcps_acquisition_fpga.h" -#include "gps_sdr_signal_processing.h" #include "GPS_L1_CA.h" +#include "gps_sdr_signal_processing.h" #include #include #include - #define NUM_PRNs 32 using google::LogMessage; @@ -123,8 +122,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( } } - //acq_parameters - + // acq_parameters acq_parameters.all_fft_codes = d_all_fft_codes_; // temporary buffers that we can delete @@ -138,7 +136,6 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( channel_ = 0; doppler_step_ = 0; gnss_synchro_ = 0; - } @@ -212,15 +209,20 @@ void GpsL1CaPcpsAcquisitionFpga::set_state(int state) acquisition_fpga_->set_state(state); } + void GpsL1CaPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { - // nothing to connect + if (top_block) + { // nothing to disconnect + } } void GpsL1CaPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block) { - // nothing to disconnect + if (top_block) + { // nothing to disconnect + } } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 5bc5b2b3d..8a5d3ea99 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -38,10 +38,10 @@ * ------------------------------------------------------------------------- */ - +#include "pcps_acquisition_fpga.h" #include #include -#include "pcps_acquisition_fpga.h" + using google::LogMessage; @@ -52,8 +52,8 @@ pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_) pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) : gr::block("pcps_acquisition_fpga", - gr::io_signature::make(0, 0, 0), - gr::io_signature::make(0, 0, 0)) + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)) { this->message_port_register_out(pmt::mp("events")); @@ -71,10 +71,8 @@ pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) : gr::block( d_channel = 0; d_gnss_synchro = 0; - acquisition_fpga = std::make_shared - (acq_parameters.device_name, d_fft_size, acq_parameters.doppler_max, acq_parameters.samples_per_ms, - acq_parameters.fs_in, acq_parameters.freq, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes); - + acquisition_fpga = std::make_shared(acq_parameters.device_name, d_fft_size, acq_parameters.doppler_max, acq_parameters.samples_per_ms, + acq_parameters.fs_in, acq_parameters.freq, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes); } @@ -196,9 +194,9 @@ void pcps_acquisition_fpga::set_active(bool active) int doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * doppler_index; acquisition_fpga->set_phase_step(doppler_index); - acquisition_fpga->run_acquisition(); // runs acquisition and waits until it is finished + acquisition_fpga->run_acquisition(); // runs acquisition and waits until it is finished acquisition_fpga->read_acquisition_results(&indext, &magt, - &initial_sample, &d_input_power); + &initial_sample, &d_input_power); d_sample_counter = initial_sample; if (d_mag < magt) @@ -213,7 +211,7 @@ void pcps_acquisition_fpga::set_active(bool active) d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - d_test_statistics = (d_mag / d_input_power); //* correction_factor; + d_test_statistics = (d_mag / d_input_power); //* correction_factor; } // In the case of the FPGA the option of dumping the results of the acquisition to a file is not available diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc index df4f193eb..111de94c5 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc @@ -36,17 +36,13 @@ * ------------------------------------------------------------------------- */ - - -//#include - -#include -#include "gps_sdr_signal_processing.h" #include "gps_l1_ca_dll_pll_tracking_fpga.h" #include "configuration_interface.h" -#include "GPS_L1_CA.h" -#include "gnss_sdr_flags.h" #include "display.h" +#include "gnss_sdr_flags.h" +#include "GPS_L1_CA.h" +#include "gps_sdr_signal_processing.h" +#include #define NUM_PRNs 32 @@ -54,16 +50,13 @@ using google::LogMessage; GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( - ConfigurationInterface* configuration, std::string role, - unsigned int in_streams, unsigned int out_streams) : - role_(role), in_streams_(in_streams), out_streams_(out_streams) + ConfigurationInterface* configuration, std::string role, + unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { dllpllconf_fpga_t trk_param_fpga; DLOG(INFO) << "role " << role; - + //################# CONFIGURATION PARAMETERS ######################## - //std::string default_item_type = "gr_complex"; - //std::string item_type = configuration->property(role + ".item_type", default_item_type); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); trk_param_fpga.fs_in = fs_in; @@ -136,11 +129,11 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( trk_param_fpga.device_base = device_base; //################# PRE-COMPUTE ALL THE CODES ################# - d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS*NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS * NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) - { - gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); - } + { + gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); + } trk_param_fpga.ca_codes = d_ca_codes; trk_param_fpga.code_length = GPS_L1_CA_CODE_LENGTH_CHIPS; @@ -148,104 +141,21 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); channel_ = 0; DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; - - - - - - - - /* - - - //################# CONFIGURATION PARAMETERS ######################## - int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - trk_param_fpga.fs_in = fs_in; - bool dump = configuration->property(role + ".dump", false); - trk_param_fpga.dump = dump; - float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); - trk_param_fpga.pll_bw_hz = pll_bw_hz; - float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); - trk_param_fpga.pll_bw_narrow_hz = pll_bw_narrow_hz; - float dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); - trk_param_fpga.dll_bw_narrow_hz = dll_bw_narrow_hz; - float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); - trk_param_fpga.dll_bw_hz = dll_bw_hz; - float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); - trk_param_fpga.early_late_space_chips = early_late_space_chips; - float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.5); - trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; - std::string default_dump_filename = "./track_ch"; - std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); - trk_param_fpga.dump_filename = dump_filename; - int vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); - trk_param_fpga.vector_length = vector_length; - int symbols_extended_correlator = configuration->property(role + ".extend_correlation_symbols", 1); - if (symbols_extended_correlator < 1) - { - symbols_extended_correlator = 1; - std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be bigger than 1. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << std::endl; - } - else if (symbols_extended_correlator > 20) - { - symbols_extended_correlator = 20; - std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be lower than 21. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << std::endl; - } - trk_param_fpga.extend_correlation_symbols = symbols_extended_correlator; - bool track_pilot = configuration->property(role + ".track_pilot", false); - if (track_pilot) - { - std::cout << TEXT_RED << "WARNING: GPS L1 C/A does not have pilot signal. Data tracking has been enabled" << TEXT_RESET << std::endl; - } - if ((symbols_extended_correlator > 1) and (pll_bw_narrow_hz > pll_bw_hz or dll_bw_narrow_hz > dll_bw_hz)) - { - std::cout << TEXT_RED << "WARNING: GPS L1 C/A. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << std::endl; - } - trk_param_fpga.very_early_late_space_chips = 0.0; - trk_param_fpga.very_early_late_space_narrow_chips = 0.0; - trk_param_fpga.track_pilot = false; - trk_param_fpga.system = 'G'; - char sig_[3] = "1C"; - std::memcpy(trk_param_fpga.signal, sig_, 3); - - // FPGA configuration parameters - std::string default_device_name = "/dev/uio"; - std::string device_name = configuration->property(role + ".devicename", default_device_name); - trk_param_fpga.device_name = device_name; - unsigned int device_base = configuration->property(role + ".device_base", 1); - trk_param_fpga.device_base = device_base; - - //################# PRE-COMPUTE ALL THE CODES ################# - d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS*NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); - for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) - { - gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); - } - trk_param_fpga.ca_codes = d_ca_codes; - trk_param_fpga.code_length = GPS_L1_CA_CODE_LENGTH_CHIPS; - - //################# MAKE TRACKING GNURadio object ################### - tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); - channel_ = 0; - DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; - - */ - } + GpsL1CaDllPllTrackingFpga::~GpsL1CaDllPllTrackingFpga() { delete[] d_ca_codes; } + void GpsL1CaDllPllTrackingFpga::start_tracking() { tracking_fpga_sc->start_tracking(); } + /* * Set tracking channel unique ID */ @@ -255,21 +165,27 @@ void GpsL1CaDllPllTrackingFpga::set_channel(unsigned int channel) tracking_fpga_sc->set_channel(channel); } + void GpsL1CaDllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { tracking_fpga_sc->set_gnss_synchro(p_gnss_synchro); } + void GpsL1CaDllPllTrackingFpga::connect(gr::top_block_sptr top_block) { - if(top_block) { /* top_block is not null */}; + if (top_block) + { /* top_block is not null */ + }; //nothing to connect } void GpsL1CaDllPllTrackingFpga::disconnect(gr::top_block_sptr top_block) { - if(top_block) { /* top_block is not null */}; + if (top_block) + { /* top_block is not null */ + }; //nothing to disconnect } @@ -284,5 +200,3 @@ gr::basic_block_sptr GpsL1CaDllPllTrackingFpga::get_right_block() { return tracking_fpga_sc; } - - diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h index b7798be81..4c5a171d2 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h @@ -39,10 +39,9 @@ #ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_H_ #define GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_H_ -#include #include "tracking_interface.h" #include "dll_pll_veml_tracking_fpga.h" - +#include class ConfigurationInterface; @@ -53,9 +52,9 @@ class GpsL1CaDllPllTrackingFpga : public TrackingInterface { public: GpsL1CaDllPllTrackingFpga(ConfigurationInterface* configuration, - std::string role, - unsigned int in_streams, - unsigned int out_streams); + std::string role, + unsigned int in_streams, + unsigned int out_streams); virtual ~GpsL1CaDllPllTrackingFpga(); @@ -93,11 +92,8 @@ public: void start_tracking() override; - //void reset(void); - private: - //gps_l1_ca_dll_pll_tracking_cc_sptr tracking_; - dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; + dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; size_t item_size_; unsigned int channel_; std::string role_; @@ -106,4 +102,4 @@ private: int* d_ca_codes; }; -#endif // GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_H_ +#endif // GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_H_ diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 2a75713c4..fe856cded 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -64,9 +64,8 @@ dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(dllpllconf_fpga_ } -dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) : - gr::block("dll_pll_veml_tracking_fpga", gr::io_signature::make(0, 0, sizeof(lv_16sc_t)), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) : gr::block("dll_pll_veml_tracking_fpga", gr::io_signature::make(0, 0, sizeof(lv_16sc_t)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { trk_parameters = conf_; // Telemetry bit synchronization message port input @@ -133,21 +132,20 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) d_correlation_length_ms = 1; d_code_samples_per_chip = 1; d_code_length_chips = static_cast(GPS_L5i_CODE_LENGTH_CHIPS); - // GPS L5 does not have pilot secondary code d_secondary = true; - interchange_iq = false; if (trk_parameters.track_pilot) { d_secondary_code_length = static_cast(GPS_L5q_NH_CODE_LENGTH); d_secondary_code_string = const_cast(&GPS_L5q_NH_CODE_STR); signal_pretty_name = signal_pretty_name + "Q"; - //interchange_iq = true; + interchange_iq = true; } else { d_secondary_code_length = static_cast(GPS_L5i_NH_CODE_LENGTH); d_secondary_code_string = const_cast(&GPS_L5i_NH_CODE_STR); signal_pretty_name = signal_pretty_name + "I"; + interchange_iq = false; } } else @@ -201,18 +199,18 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) d_code_samples_per_chip = 1; d_code_length_chips = static_cast(Galileo_E5a_CODE_LENGTH_CHIPS); d_secondary = true; - interchange_iq = false; if (trk_parameters.track_pilot) { d_secondary_code_length = static_cast(Galileo_E5a_Q_SECONDARY_CODE_LENGTH); signal_pretty_name = signal_pretty_name + "Q"; - // interchange_iq = true; + interchange_iq = true; } else { d_secondary_code_length = static_cast(Galileo_E5a_I_SECONDARY_CODE_LENGTH); d_secondary_code_string = const_cast(&Galileo_E5a_I_SECONDARY_CODE); signal_pretty_name = signal_pretty_name + "I"; + interchange_iq = false; } } else @@ -248,7 +246,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) K_blk_samples = 0.0; // Initialize tracking ========================================== - d_code_loop_filter = Tracking_2nd_DLL_filter(static_cast(d_code_period)); d_carrier_loop_filter = Tracking_2nd_PLL_filter(static_cast(d_code_period)); d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_hz); @@ -333,7 +330,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) d_current_prn_length_samples = static_cast(trk_parameters.vector_length); d_next_prn_length_samples = d_current_prn_length_samples; - d_correlation_length_samples = static_cast(trk_parameters.vector_length); // this one is only for initialisation and does not change its value (MM) + d_correlation_length_samples = static_cast(trk_parameters.vector_length); // this one is only for initialisation and does not change its value (MM) // CN0 estimation and lock detector buffers d_cn0_estimation_counter = 0; @@ -364,9 +361,9 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(dllpllconf_fpga_t conf_) // create multicorrelator class std::string device_name = trk_parameters.device_name; unsigned int device_base = trk_parameters.device_base; - int* ca_codes = trk_parameters.ca_codes; + int *ca_codes = trk_parameters.ca_codes; unsigned int code_length = trk_parameters.code_length; - multicorrelator_fpga = std::make_shared (d_n_correlator_taps, device_name, device_base, ca_codes, code_length); + multicorrelator_fpga = std::make_shared(d_n_correlator_taps, device_name, device_base, ca_codes, code_length); multicorrelator_fpga->set_output_vectors(d_correlator_outs); d_pull_in = 0; @@ -381,7 +378,7 @@ void dll_pll_veml_tracking_fpga::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - double acq_trk_diff_seconds = 0; // when using the FPGA we don't use the global sample counter + double acq_trk_diff_seconds = 0; // when using the FPGA we don't use the global sample counter // Doppler effect Fd = (C / (C + Vr)) * F double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; // new chip and prn sequence periods based on acq Doppler @@ -509,7 +506,6 @@ void dll_pll_veml_tracking_fpga::start_tracking() d_pull_in = 1; // enable tracking pull-in and d_state at the end to avoid general work from starting pull-in before the start tracking function is finished d_state = 1; - } dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() @@ -1136,14 +1132,21 @@ void dll_pll_veml_tracking_fpga::set_channel(unsigned int channel) } } -void dll_pll_veml_tracking_fpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) + +void dll_pll_veml_tracking_fpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) { d_acquisition_gnss_synchro = p_gnss_synchro; } -int dll_pll_veml_tracking_fpga::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), - gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) +void dll_pll_veml_tracking_fpga::reset(void) +{ + multicorrelator_fpga->unlock_channel(); +} + + +int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { // Block input data and block output stream pointers Gnss_Synchro **out = reinterpret_cast(&output_items[0]); @@ -1160,22 +1163,21 @@ int dll_pll_veml_tracking_fpga::general_work (int noutput_items __attribute__((u { for (int n = 0; n < d_n_correlator_taps; n++) { - d_correlator_outs[n] = gr_complex(0,0); + d_correlator_outs[n] = gr_complex(0, 0); } - current_synchro_data.Tracking_sample_counter =d_sample_counter + d_current_prn_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; current_synchro_data.System = {'G'}; current_synchro_data.correlation_length_ms = 1; break; - } case 1: // Standby - Consume samples at full throttle, do nothing { d_pull_in = 0; multicorrelator_fpga->lock_channel(); unsigned counter_value = multicorrelator_fpga->read_sample_counter(); - unsigned num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples - current_synchro_data.Acq_delay_samples)/d_correlation_length_samples); - unsigned absolute_samples_offset = current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples + num_frames*d_correlation_length_samples; + unsigned num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples - current_synchro_data.Acq_delay_samples) / d_correlation_length_samples); + unsigned absolute_samples_offset = current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples + num_frames * d_correlation_length_samples; multicorrelator_fpga->set_initial_sample(absolute_samples_offset); d_sample_counter = absolute_samples_offset; current_synchro_data.Tracking_sample_counter = absolute_samples_offset; @@ -1188,14 +1190,14 @@ int dll_pll_veml_tracking_fpga::general_work (int noutput_items __attribute__((u case 2: { d_sample_counter = d_sample_counter_next; - d_sample_counter_next = d_sample_counter + d_current_prn_length_samples; + d_sample_counter_next = d_sample_counter + d_current_prn_length_samples; // ################# CARRIER WIPEOFF AND CORRELATORS ############################## // perform carrier wipe-off and compute Early, Prompt and Late correlation multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( - d_rem_carr_phase_rad, d_carrier_phase_step_rad, - d_rem_code_phase_chips, d_code_phase_step_chips, - d_current_prn_length_samples); + d_rem_carr_phase_rad, d_carrier_phase_step_rad, + d_rem_code_phase_chips, d_code_phase_step_chips, + d_current_prn_length_samples); // Save single correlation step variables if (d_veml) @@ -1317,11 +1319,9 @@ int dll_pll_veml_tracking_fpga::general_work (int noutput_items __attribute__((u } else { - d_state = 4; } } - } break; @@ -1330,15 +1330,15 @@ int dll_pll_veml_tracking_fpga::general_work (int noutput_items __attribute__((u case 3: { d_sample_counter = d_sample_counter_next; - d_sample_counter_next = d_sample_counter + d_current_prn_length_samples; + d_sample_counter_next = d_sample_counter + d_current_prn_length_samples; // Fill the acquisition data current_synchro_data = *d_acquisition_gnss_synchro; // perform a correlation step multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( - d_rem_carr_phase_rad, d_carrier_phase_step_rad, - d_rem_code_phase_chips, d_code_phase_step_chips, - d_current_prn_length_samples); + d_rem_carr_phase_rad, d_carrier_phase_step_rad, + d_rem_code_phase_chips, d_code_phase_step_chips, + d_current_prn_length_samples); update_tracking_vars(); save_correlation_results(); @@ -1390,14 +1390,14 @@ int dll_pll_veml_tracking_fpga::general_work (int noutput_items __attribute__((u case 4: // narrow tracking { d_sample_counter = d_sample_counter_next; - d_sample_counter_next = d_sample_counter + d_current_prn_length_samples; + d_sample_counter_next = d_sample_counter + d_current_prn_length_samples; // perform a correlation step //do_correlation_step(in); multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( - d_rem_carr_phase_rad, d_carrier_phase_step_rad, - d_rem_code_phase_chips, d_code_phase_step_chips, - d_current_prn_length_samples); + d_rem_carr_phase_rad, d_carrier_phase_step_rad, + d_rem_code_phase_chips, d_code_phase_step_chips, + d_current_prn_length_samples); save_correlation_results(); @@ -1472,24 +1472,3 @@ int dll_pll_veml_tracking_fpga::general_work (int noutput_items __attribute__((u } return 0; } - -void dll_pll_veml_tracking_fpga::reset(void) -{ - multicorrelator_fpga->unlock_channel(); -} - - - - - - - - - - - - - - - - diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h index 750d24a42..0d8b93f1e 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h @@ -39,15 +39,15 @@ #ifndef GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H #define GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H +#include "fpga_multicorrelator.h" #include "gnss_synchro.h" #include "tracking_2nd_DLL_filter.h" #include "tracking_2nd_PLL_filter.h" -#include "fpga_multicorrelator.h" #include #include #include #include -#include "fpga_multicorrelator.h" + typedef struct { @@ -75,13 +75,13 @@ typedef struct std::string device_name; unsigned int device_base; unsigned int code_length; - int* ca_codes; + int *ca_codes; } dllpllconf_fpga_t; class dll_pll_veml_tracking_fpga; typedef boost::shared_ptr -dll_pll_veml_tracking_fpga_sptr; + dll_pll_veml_tracking_fpga_sptr; dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(dllpllconf_fpga_t conf_); @@ -221,7 +221,6 @@ private: int d_next_prn_length_samples; unsigned long int d_sample_counter_next; unsigned int d_pull_in = 0; - }; -#endif //GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H +#endif //GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H