diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 96a5a90fa..7086c62ac 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -65,7 +65,7 @@ public: } /*! - * \brief Returns "Galileo_E1_PCPS_Ambiguous_Acquisition" + * \brief Returns "Galileo_E1_PCPS_Ambiguous_Acquisition_Fpga" */ inline std::string implementation() override { diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index 9c63431f2..abe993526 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -57,6 +57,9 @@ public: return role_; } + /*! + * \brief Returns "Galileo_E5a_Pcps_Acquisition_Fpga" + */ inline std::string implementation() override { return "Galileo_E5a_Pcps_Acquisition_Fpga"; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index ce5cdfc4a..9615338bc 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -65,7 +65,7 @@ public: } /*! - * \brief Returns "GPS_L1_CA_PCPS_Acquisition" + * \brief Returns "GPS_L1_CA_PCPS_Acquisition_Fpga" */ inline std::string implementation() override { diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index 7e15f4df7..836d46cee 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -67,11 +67,11 @@ public: } /*! - * \brief Returns "GPS_L5i_PCPS_Acquisition" + * \brief Returns "GPS_L5i_PCPS_Acquisition_Fpga" */ inline std::string implementation() override { - return "GPS_L5i_PCPS_Acquisition"; + return "GPS_L5i_PCPS_Acquisition_Fpga"; } inline size_t item_size() override diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 34c2a2cf0..091092c89 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -40,8 +40,6 @@ #include #include -#include // for the usleep function only (debug) - #define AQ_DOWNSAMPLING_DELAY 40 // delay due to the downsampling filter in the acquisition using google::LogMessage; @@ -196,10 +194,6 @@ void pcps_acquisition_fpga::set_active(bool active) << ", use_CFAR_algorithm_flag: false"; uint64_t initial_sample; - float input_power_all = 0.0; - float input_power_computed = 0.0; - - float temp_d_input_power; acquisition_fpga->configure_acquisition(); acquisition_fpga->set_doppler_sweep(d_num_doppler_bins); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index f551e0778..a08cd5363 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -178,9 +178,7 @@ public: */ inline void set_threshold(float threshold) { - // printf("acq set threshold start\n"); d_threshold = threshold; - // printf("acq set threshold end\n"); } /*! @@ -189,10 +187,8 @@ public: */ inline void set_doppler_max(uint32_t doppler_max) { - // printf("acq set doppler max start\n"); acq_parameters.doppler_max = doppler_max; acquisition_fpga->set_doppler_max(doppler_max); - // printf("acq set doppler max end\n"); } /*! @@ -201,10 +197,8 @@ public: */ inline void set_doppler_step(uint32_t doppler_step) { - // printf("acq set doppler step start\n"); d_doppler_step = doppler_step; acquisition_fpga->set_doppler_step(doppler_step); - // printf("acq set doppler step end\n"); } /*! diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 18264bc58..9a14f779a 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -212,8 +212,8 @@ void fpga_acquisition::run_acquisition(void) nb = read(d_fd, &irq_count, sizeof(irq_count)); if (nb != sizeof(irq_count)) { - printf("acquisition module Read failed to retrieve 4 bytes!\n"); - printf("acquisition module Interrupt number %d\n", irq_count); + std::cout << "acquisition module Read failed to retrieve 4 bytes!" << std::endl; + std::cout << "acquisition module Interrupt number " << irq_count << std::endl; } write(d_fd, reinterpret_cast(&disable_int), sizeof(int32_t)); @@ -359,7 +359,7 @@ void fpga_acquisition::close_device() uint32_t *aux = const_cast(d_map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { - printf("Failed to unmap memory uio\n"); + std::cout << "Failed to unmap memory uio" << std::endl; } close(d_fd); } diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index d1628c787..ff599f4ff 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -102,7 +102,6 @@ public: void configure_acquisition(void); - //void configure_acquisition_debug(void); void close_device(); void open_device(); diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc index 211137535..9a5427c60 100644 --- a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc @@ -53,10 +53,7 @@ gnss_sdr_fpga_sample_counter::gnss_sdr_fpga_sample_counter( set_max_noutput_items(1); interval_ms = _interval_ms; fs = _fs; - //printf("CREATOR fs = %f\n", fs); - //printf("CREATOR interval_ms = %" PRIu32 "\n", interval_ms); samples_per_output = std::round(fs * static_cast(interval_ms) / 1e3); - //printf("CREATOR samples_per_output = %" PRIu32 "\n", samples_per_output); //todo: Load here the hardware counter register with this amount of samples. It should produce an //interrupt every samples_per_output count. //The hardware timer must keep always interrupting the PS. It must not wait for the interrupt to @@ -122,7 +119,6 @@ int gnss_sdr_fpga_sample_counter::general_work(int noutput_items __attribute__(( uint32_t counter = wait_for_interrupt_and_read_counter(); uint64_t samples_passed = 2 * static_cast(samples_per_output) - static_cast(counter); // ellapsed samples - //printf("============================================ interrupter : samples_passed = %" PRIu64 "\n", samples_passed); // Note: at this moment the sample counter is implemented as a sample counter that decreases to zero and then it is automatically // reloaded again and keeps counter. It is done in this way to minimize the logic in the FPGA and maximize the FPGA clock performance // (it takes less resources and latency in the FPGA to compare a number against a fixed value like zero than to compare it to a programmable @@ -137,10 +133,6 @@ int gnss_sdr_fpga_sample_counter::general_work(int noutput_items __attribute__(( out[0].fs = fs; if ((current_T_rx_ms % report_interval_ms) == 0) { - //printf("time to print sample_counter = %" PRIu64 "\n", sample_counter); - //printf("time to print current Tx ms : %" PRIu64 "\n", current_T_rx_ms); - //printf("time to print report_interval_ms : %" PRIu32 "\n", report_interval_ms); - //printf("time to print %f\n", (current_T_rx_ms % report_interval_ms)); current_s++; if ((current_s % 60) == 0) { @@ -217,15 +209,7 @@ uint32_t gnss_sdr_fpga_sample_counter::test_register(uint32_t writeval) void gnss_sdr_fpga_sample_counter::configure_samples_per_output(uint32_t interval) { // note : the counter is a 48-bit value in the HW. - //printf("============================================ total counter - interrupted interval : %" PRIu32 "\n", interval); - //uint64_t temp_interval; - //temp_interval = (interval & static_cast(0xFFFFFFFF)); - //printf("LSW counter - interrupted interval : %" PRIu32 "\n", static_cast(temp_interval)); - //map_base[0] = static_cast(temp_interval); map_base[0] = interval - 1; - //temp_interval = (interval >> 32) & static_cast(0xFFFFFFFF); - //printf("MSbits counter - interrupted interval : %" PRIu32 "\n", static_cast(temp_interval)); - //map_base[1] = static_cast(temp_interval); // writing the most significant bits also enables the interrupts } void gnss_sdr_fpga_sample_counter::open_device() @@ -262,13 +246,12 @@ void gnss_sdr_fpga_sample_counter::open_device() void gnss_sdr_fpga_sample_counter::close_device() { - //printf("=========================================== NOW closing device ...\n"); map_base[2] = 0; // disable the generation of the interrupt in the device auto *aux = const_cast(map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { - printf("Failed to unmap memory uio\n"); + std::cout << "Failed to unmap memory uio" << std::endl; } close(fd); } @@ -284,14 +267,11 @@ uint32_t gnss_sdr_fpga_sample_counter::wait_for_interrupt_and_read_counter() write(fd, reinterpret_cast(&reenable), sizeof(int32_t)); // wait for interrupt - //printf("============================================ interrupter : going to wait for interupt\n"); nb = read(fd, &irq_count, sizeof(irq_count)); - //printf("============================================ interrupter : interrupt received\n"); - //printf("interrupt received\n"); if (nb != sizeof(irq_count)) { - printf("acquisition module Read failed to retrieve 4 bytes!\n"); - printf("acquisition module Interrupt number %d\n", irq_count); + std::cout << "fpga sample counter module read failed to retrieve 4 bytes!" << std::endl; + std::cout << "fpga sample counter module interrupt number " << irq_count << std::endl; } // it is a rising edge interrupt, the interrupt does not need to be acknowledged diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h index 7d36d1e74..e1a606f1f 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h @@ -63,7 +63,7 @@ public: return role_; } - //! Returns "GPS_L2_M_DLL_PLL_Tracking" + //! Returns "GPS_L2_M_DLL_PLL_Tracking_Fpga" inline std::string implementation() override { return "GPS_L2_M_DLL_PLL_Tracking_Fpga"; diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc index d918ca478..ba7b52f9f 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc @@ -83,7 +83,6 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( trk_param_fpga.early_late_space_chips = early_late_space_chips; int vector_length = std::round(static_cast(fs_in) / (static_cast(GPS_L5I_CODE_RATE_HZ) / static_cast(GPS_L5I_CODE_LENGTH_CHIPS))); trk_param_fpga.vector_length = vector_length; - printf("trk vector length = %d\n", vector_length); int extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15); trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; @@ -152,7 +151,6 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * NUM_PRNs * sizeof(int), volk_gnsssdr_get_alignment())); } - //printf("start \n"); for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) { if (track_pilot) 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 0d23430a5..874ed9929 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 @@ -1,7 +1,7 @@ /*! * \file dll_pll_veml_tracking_fpga.cc * \brief Implementation of a code DLL + carrier PLL tracking block using an FPGA - * \author Marc Majoral, 2018. marc.majoral(at)cttc.es + * \author Marc Majoral, 2019. marc.majoral(at)cttc.es * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com * \author Javier Arribas, 2018. jarribas(at)cttc.es * @@ -12,7 +12,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -63,30 +63,6 @@ #include #include -//#include "GPS_L1_CA.h" -//#include "gps_sdr_signal_processing.h" -//#include "GPS_L2C.h" -//#include "GPS_L5.h" -//#include "Galileo_E1.h" -//#include "Galileo_E5a.h" -//#include "MATH_CONSTANTS.h" -//#include "control_message_factory.h" -//#include "gnss_sdr_create_directory.h" -//#include "gps_l2c_signal.h" -//#include "gps_l5_signal.h" -//#include "lock_detectors.h" -//#include "tracking_discriminators.h" -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include - using google::LogMessage; dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_) @@ -139,8 +115,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_code_chip_rate = GPS_L1_CA_CODE_RATE_HZ; d_symbols_per_bit = GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; d_correlation_length_ms = 1; - //d_code_samples_per_chip = 1; - //d_code_length_chips = static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS); // GPS L1 C/A does not have pilot component nor secondary code d_secondary = false; trk_parameters.track_pilot = false; @@ -175,10 +149,8 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_signal_carrier_freq = GPS_L2_FREQ_HZ; d_code_period = GPS_L2_M_PERIOD; d_code_chip_rate = GPS_L2_M_CODE_RATE_HZ; - //d_code_length_chips = static_cast(GPS_L2_M_CODE_LENGTH_CHIPS); d_symbols_per_bit = GPS_L2_SAMPLES_PER_SYMBOL; d_correlation_length_ms = 20; - //d_code_samples_per_chip = 1; // GPS L2 does not have pilot component nor secondary code d_secondary = false; trk_parameters.track_pilot = false; @@ -191,8 +163,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_code_chip_rate = GPS_L5I_CODE_RATE_HZ; d_symbols_per_bit = GPS_L5_SAMPLES_PER_SYMBOL; d_correlation_length_ms = 1; - //d_code_samples_per_chip = 1; - //d_code_length_chips = static_cast(GPS_L5i_CODE_LENGTH_CHIPS); d_secondary = true; if (trk_parameters.track_pilot) { @@ -218,8 +188,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - //d_code_length_chips = 0U; - //d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } } @@ -231,10 +199,8 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_signal_carrier_freq = GALILEO_E1_FREQ_HZ; d_code_period = GALILEO_E1_CODE_PERIOD; d_code_chip_rate = GALILEO_E1_CODE_CHIP_RATE_HZ; - //d_code_length_chips = static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS); d_symbols_per_bit = 1; d_correlation_length_ms = 4; - //d_code_samples_per_chip = 2; // CBOC disabled: 2 samples per chip. CBOC enabled: 12 samples per chip d_veml = true; if (trk_parameters.track_pilot) { @@ -257,8 +223,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_code_chip_rate = GALILEO_E5A_CODE_CHIP_RATE_HZ; d_symbols_per_bit = 20; d_correlation_length_ms = 1; - //d_code_samples_per_chip = 1; - //d_code_length_chips = static_cast(Galileo_E5a_CODE_LENGTH_CHIPS); if (trk_parameters.track_pilot) { @@ -271,10 +235,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & { //Do not acquire secondary code in data component. It is done in telemetry decoder d_secondary = false; -//======= -// d_secondary_code_length = static_cast(GALILEO_E5A_I_SECONDARY_CODE_LENGTH); -// d_secondary_code_string = const_cast(&GALILEO_E5A_I_SECONDARY_CODE); -//>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 signal_pretty_name = signal_pretty_name + "I"; interchange_iq = false; } @@ -288,8 +248,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - //d_code_length_chips = 0U; - //d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } } @@ -302,8 +260,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - //d_code_length_chips = 0U; - //d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } T_chip_seconds = 0.0; @@ -317,10 +273,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & 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)); - // Initialization of local code replica - // Get space for a vector with the sinboc(1,1) replica sampled 2x/chip - //d_tracking_code = static_cast(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); - // correlator outputs (scalar) if (d_veml) { // Very-Early, Early, Prompt, Late, Very-Late @@ -363,7 +315,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_prompt_data_shift = &d_local_code_shift_chips[1]; } - //multicorrelator_cpu.init(2 * trk_parameters.vector_length, d_n_correlator_taps); if (trk_parameters.extend_correlation_symbols > 1) { @@ -375,21 +326,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & trk_parameters.extend_correlation_symbols = 1; } - // Enable Data component prompt correlator (slave to Pilot prompt) if tracking uses Pilot signal - if (trk_parameters.track_pilot) - { - // Extra correlator for the data component - //correlator_data_cpu.init(2 * trk_parameters.vector_length, 1); - //correlator_data_cpu.set_high_dynamics_resampler(trk_parameters.high_dyn); - //d_data_code = static_cast(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); - } - else - { - //d_data_code = nullptr; - } - - // --- Initializations --- - //multicorrelator_cpu.set_high_dynamics_resampler(trk_parameters.high_dyn); + // --- Initializations --- // Initial code frequency basis of NCO d_code_freq_chips = d_code_chip_rate; // Residual code phase (in chips) @@ -494,8 +431,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & void dll_pll_veml_tracking_fpga::start_tracking() { - //gr::thread::scoped_lock l(d_setlock); - // correct the code phase according to the delay between acq and trk d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; @@ -510,64 +445,29 @@ void dll_pll_veml_tracking_fpga::start_tracking() d_carrier_loop_filter.initialize(); // initialize the carrier filter d_code_loop_filter.initialize(); // initialize the code filter - if (systemName == "GPS" and signal_type == "1C") - { - //gps_l1_ca_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0); - } - else if (systemName == "GPS" and signal_type == "2S") - { - //gps_l2c_m_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); - } - else if (systemName == "GPS" and signal_type == "L5") + if (systemName == "GPS" and signal_type == "L5") { if (trk_parameters.track_pilot) { - //gps_l5q_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); - //gps_l5i_code_gen_float(d_data_code, d_acquisition_gnss_synchro->PRN); d_Prompt_Data[0] = gr_complex(0.0, 0.0); - //correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code, d_prompt_data_shift); - } - else - { - //gps_l5i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); } } else if (systemName == "Galileo" and signal_type == "1B") { if (trk_parameters.track_pilot) { - //char pilot_signal[3] = "1C"; - //galileo_e1_code_gen_sinboc11_float(d_tracking_code, pilot_signal, d_acquisition_gnss_synchro->PRN); - //galileo_e1_code_gen_sinboc11_float(d_data_code, d_acquisition_gnss_synchro->Signal, d_acquisition_gnss_synchro->PRN); d_Prompt_Data[0] = gr_complex(0.0, 0.0); - //correlator_data_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_data_code, d_prompt_data_shift); - } - else - { - //galileo_e1_code_gen_sinboc11_float(d_tracking_code, d_acquisition_gnss_synchro->Signal, d_acquisition_gnss_synchro->PRN); } } else if (systemName == "Galileo" and signal_type == "5X") { - //gr_complex *aux_code = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex) * d_code_length_chips, volk_gnsssdr_get_alignment())); - //galileo_e5_a_code_gen_complex_primary(aux_code, d_acquisition_gnss_synchro->PRN, const_cast(signal_type.c_str())); if (trk_parameters.track_pilot) { d_secondary_code_string = const_cast(&GALILEO_E5A_Q_SECONDARY_CODE[d_acquisition_gnss_synchro->PRN - 1]); d_Prompt_Data[0] = gr_complex(0.0, 0.0); - //correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code, d_prompt_data_shift); } - else - { - //for (uint32_t i = 0; i < d_code_length_chips; i++) - // { - // d_tracking_code[i] = aux_code[i].real(); - // } - } - //volk_gnsssdr_free(aux_code); } - //multicorrelator_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_tracking_code, d_local_code_shift_chips); std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); d_carrier_lock_fail_counter = 0; @@ -645,15 +545,8 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() { volk_gnsssdr_free(d_local_code_shift_chips); volk_gnsssdr_free(d_correlator_outs); - //volk_gnsssdr_free(d_tracking_code); volk_gnsssdr_free(d_Prompt_Data); - if (trk_parameters.track_pilot) - { - //volk_gnsssdr_free(d_data_code); - //correlator_data_cpu.free(); - } delete[] d_Prompt_buffer; - //multicorrelator_cpu.free(); multicorrelator_fpga->free(); } catch (const std::exception &ex) @@ -763,30 +656,6 @@ void dll_pll_veml_tracking_fpga::do_correlation_step(void) { // // ################# CARRIER WIPEOFF AND CORRELATORS ############################## -// // perform carrier wipe-off and compute Early, Prompt and Late correlation -// multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, input_samples); -// multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler( -// d_rem_carr_phase_rad, -// d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, -// static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), -// static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), -// static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), -// trk_parameters.vector_length); -// -// // DATA CORRELATOR (if tracking tracks the pilot signal) -// if (trk_parameters.track_pilot) -// { -// correlator_data_cpu.set_input_output_vectors(d_Prompt_Data, input_samples); -// correlator_data_cpu.Carrier_wipeoff_multicorrelator_resampler( -// d_rem_carr_phase_rad, -// d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, -// static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), -// static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), -// static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), -// trk_parameters.vector_length); -// } -// -// multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( d_rem_carr_phase_rad, @@ -873,9 +742,7 @@ void dll_pll_veml_tracking_fpga::update_tracking_vars() // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation T_prn_samples = T_prn_seconds * trk_parameters.fs_in; K_blk_samples = T_prn_samples + d_rem_code_phase_samples; - //d_current_prn_length_samples = static_cast(round(K_blk_samples)); // round to a discrete number of samples d_next_prn_length_samples = static_cast(std::floor(K_blk_samples)); // round to a discrete number of samples - //d_current_prn_length_samples = static_cast(std::floor(K_blk_samples)); // round to a discrete number of samples //################### PLL COMMANDS ################################################# // carrier phase step (NCO phase increment per sample) [rads/sample] @@ -900,16 +767,12 @@ void dll_pll_veml_tracking_fpga::update_tracking_vars() d_carrier_phase_rate_step_rad = (tmp_cp2 - tmp_cp1) / tmp_samples; } } - //std::cout << d_carrier_phase_rate_step_rad * trk_parameters.fs_in * trk_parameters.fs_in / PI_2 << std::endl; // remnant carrier phase to prevent overflow in the code NCO d_rem_carr_phase_rad += static_cast(d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, PI_2); // carrier phase accumulator - //double a = d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); - //double b = 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples); - //std::cout << fmod(b, PI_2) / fmod(a, PI_2) << std::endl; d_acc_carrier_phase_rad -= (d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); //################### DLL COMMANDS ################################################# @@ -1372,7 +1235,6 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) { - //gr::thread::scoped_lock l(d_setlock); d_channel = channel; multicorrelator_fpga->set_channel(d_channel); LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -1389,8 +1251,6 @@ void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) { try { - //trk_parameters.dump_filename.append(boost::lexical_cast(d_channel)); - //trk_parameters.dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(dump_filename_.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << dump_filename_.c_str(); @@ -1407,14 +1267,12 @@ void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) void dll_pll_veml_tracking_fpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) { - //gr::thread::scoped_lock l(d_setlock); d_acquisition_gnss_synchro = p_gnss_synchro; } void dll_pll_veml_tracking_fpga::stop_tracking() { - //gr::thread::scoped_lock l(d_setlock); d_state = 0; } @@ -1423,8 +1281,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un { - //gr::thread::scoped_lock l(d_setlock); - //const gr_complex *in = reinterpret_cast(input_items[0]); Gnss_Synchro **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -1435,8 +1291,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un { case 0: // Standby - Consume samples at full throttle, do nothing { - //d_sample_counter += static_cast(ninput_items[0]); - //consume_each(ninput_items[0]); return 0; break; } @@ -1446,21 +1300,17 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un double acq_trk_diff_seconds; double delta_trk_to_acq_prn_start_samples; - //printf("state 1\n"); multicorrelator_fpga->lock_channel(); uint64_t counter_value = multicorrelator_fpga->read_sample_counter(); uint64_t absolute_samples_offset; if (counter_value > (d_acq_sample_stamp + d_acq_code_phase_samples)) { // Signal alignment (skip samples until the incoming signal is aligned with local replica) - //int64_t acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); acq_trk_diff_samples = static_cast(counter_value) - static_cast(d_acq_sample_stamp); acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; - //uint32_t num_frames = ceil((counter_value - d_acq_sample_stamp - d_acq_code_phase_samples) / d_correlation_length_samples); uint32_t num_frames = ceil((delta_trk_to_acq_prn_start_samples) / d_correlation_length_samples); - //absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp + num_frames * d_correlation_length_samples); absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp + num_frames * d_correlation_length_samples); } else @@ -1471,7 +1321,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) + d_acq_code_phase_samples; - //absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp); absolute_samples_offset = static_cast(delta_trk_to_acq_prn_start_samples); } multicorrelator_fpga->set_initial_sample(absolute_samples_offset); @@ -1481,11 +1330,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un d_sample_counter_next = d_sample_counter; -// // Signal alignment (skip samples until the incoming signal is aligned with local replica) -// //int64_t acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); -// int64_t acq_trk_diff_samples = static_cast(counter_value) - static_cast(d_acq_sample_stamp); -// double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; -// double delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; + // Signal alignment (skip samples until the incoming signal is aligned with local replica) // Doppler effect Fd = (C / (C + Vr)) * F double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; @@ -1497,7 +1342,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un double T_prn_mod_seconds = T_chip_mod_seconds * static_cast(d_code_length_chips); double T_prn_mod_samples = T_prn_mod_seconds * trk_parameters.fs_in; - //d_acq_code_phase_samples = T_prn_mod_samples - std::fmod(delta_trk_to_acq_prn_start_samples, T_prn_mod_samples); d_acq_code_phase_samples = absolute_samples_offset; d_current_prn_length_samples = round(T_prn_mod_samples); @@ -1511,11 +1355,11 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un DLOG(INFO) << "PULL-IN Doppler [Hz] = " << d_carrier_doppler_hz << ". PULL-IN Code Phase [samples] = " << d_acq_code_phase_samples; + // don't leave the HW module blocking the signal path before the first sample arrives + // start the first tracking process run_state_2(current_synchro_data); break; - //consume_each(samples_offset); // shift input to perform alignment with local replica - //return 0; } case 2: // Wide tracking and symbol synchronization { @@ -1524,7 +1368,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } case 3: // coherent integration (correlation time extension) { - //printf("state 3\n"); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); @@ -1581,7 +1424,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } case 4: // narrow tracking { - //printf("state 4\n"); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); // Fill the acquisition data @@ -1652,15 +1494,12 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } } } - //consume_each(d_current_prn_length_samples); - //d_sample_counter += static_cast(d_current_prn_length_samples); if (current_synchro_data.Flag_valid_symbol_output) { current_synchro_data.fs = static_cast(trk_parameters.fs_in); - // two choices for the reporting of the sample counter: - // either the sample counter position that should be (d_sample_counter_next) - //or the sample counter corresponding to the number of samples that the FPGA actually consumed. - //current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); + // two choices for the reporting of the sample counter: + // either the sample counter position that should be (d_sample_counter_next) + //or the sample counter corresponding to the number of samples that the FPGA actually consumed. current_synchro_data.Tracking_sample_counter = d_sample_counter_next; *out[0] = current_synchro_data; return 1; @@ -1670,7 +1509,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un void dll_pll_veml_tracking_fpga::run_state_2(Gnss_Synchro ¤t_synchro_data) { - //printf("state 2\n"); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); @@ -1740,7 +1578,6 @@ void dll_pll_veml_tracking_fpga::run_state_2(Gnss_Synchro ¤t_synchro_data) } if (corr_value == GPS_CA_PREAMBLE_LENGTH_SYMBOLS) { - //std::cout << "Preamble detected at tracking!" << std::endl; next_state = true; } else 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 a2fb3ed74..c0411b142 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 @@ -1,13 +1,13 @@ /*! - * \file dll_pll_veml_tracking.h - * \brief Implementation of a code DLL + carrier PLL tracking block. - * \author Marc Majoral, 2018. marc.majoral(at)cttc.es + * \file dll_pll_veml_tracking_fpga.h + * \brief Implementation of a code DLL + carrier PLL tracking block using an FPGA. + * \author Marc Majoral, 2019. marc.majoral(at)cttc.es * \author Javier Arribas, 2018. jarribas(at)cttc.es * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -80,7 +80,6 @@ private: bool cn0_and_tracking_lock_status(double coh_integration_time_s); bool acquire_secondary(); - //void do_correlation_step(const gr_complex *input_samples); void do_correlation_step(void); void run_dll_pll(); void update_tracking_vars(); diff --git a/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc b/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc index 855a336b5..36cdd264b 100644 --- a/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc +++ b/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc @@ -1,12 +1,13 @@ /*! - * \file dll_pll_conf.cc + * \file dll_pll_conf_fpga.cc * \brief Class that contains all the configuration parameters for generic - * tracking block based on a DLL and a PLL. + * tracking block based on a DLL and a PLL for the FPGA. + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat * \author Javier Arribas, 2018. jarribas(at)cttc.es * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver diff --git a/src/algorithms/tracking/libs/dll_pll_conf_fpga.h b/src/algorithms/tracking/libs/dll_pll_conf_fpga.h index 95878f592..33dd901d7 100644 --- a/src/algorithms/tracking/libs/dll_pll_conf_fpga.h +++ b/src/algorithms/tracking/libs/dll_pll_conf_fpga.h @@ -1,13 +1,15 @@ /*! - * \file dll_pll_conf.h - * \brief Class that contains all the configuration parameters for generic tracking block based on a DLL and a PLL. + * \file dll_pll_conf_fpga.h + * \brief Class that contains all the configuration parameters for generic + * tracking block based on a DLL and a PLL for the FPGA. + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat * \author Javier Arribas, 2018. jarribas(at)cttc.es * * Class that contains all the configuration parameters for generic tracking block based on a DLL and a PLL. * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 158b02c07..dee4667da 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -2,7 +2,7 @@ * \file fpga_multicorrelator_8sc.cc * \brief High optimized FPGA vector correlator class * \authors
    - *
  • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
  • Marc Majoral, 2019. mmajoral(at)cttc.cat *
  • Javier Arribas, 2015. jarribas(at)cttc.es *
* @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -36,81 +36,62 @@ #include "fpga_multicorrelator.h" #include - -// FPGA stuff #include - -// libraries used by DMA test code and GIPO test code #include #include #include #include - -// libraries used by DMA test code #include #include #include #include - -// libraries used by GPIO test code #include #include #include - -// logging #include - -// string manipulation #include #include -// constants -#include "GPS_L1_CA.h" +// FPGA register access constants +#define PAGE_SIZE 0x10000 +#define MAX_LENGTH_DEVICEIO_NAME 50 +#define CODE_RESAMPLER_NUM_BITS_PRECISION 20 +#define CODE_PHASE_STEP_CHIPS_NUM_NBITS CODE_RESAMPLER_NUM_BITS_PRECISION +#define pwrtwo(x) (1 << (x)) +#define MAX_CODE_RESAMPLER_COUNTER pwrtwo(CODE_PHASE_STEP_CHIPS_NUM_NBITS) // 2^CODE_PHASE_STEP_CHIPS_NUM_NBITS +#define PHASE_CARR_NBITS 32 +#define PHASE_CARR_NBITS_INT 1 +#define PHASE_CARR_NBITS_FRAC PHASE_CARR_NBITS - PHASE_CARR_NBITS_INT +#define LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT 0x20000000 +#define LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER 0x10000000 +#define LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY 0x0C000000 +#define TEST_REGISTER_TRACK_WRITEVAL 0x55AA + + -//#include "gps_sdr_signal_processing.h" -#define NUM_PRNs 32 -#define PAGE_SIZE 0x10000 -#define MAX_LENGTH_DEVICEIO_NAME 50 -#define CODE_RESAMPLER_NUM_BITS_PRECISION 20 -#define CODE_PHASE_STEP_CHIPS_NUM_NBITS CODE_RESAMPLER_NUM_BITS_PRECISION -#define pwrtwo(x) (1 << (x)) -#define MAX_CODE_RESAMPLER_COUNTER pwrtwo(CODE_PHASE_STEP_CHIPS_NUM_NBITS) // 2^CODE_PHASE_STEP_CHIPS_NUM_NBITS -#define PHASE_CARR_NBITS 32 -#define PHASE_CARR_NBITS_INT 1 -#define PHASE_CARR_NBITS_FRAC PHASE_CARR_NBITS - PHASE_CARR_NBITS_INT -#define LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT 0x20000000 -#define LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER 0x10000000 -#define LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY 0x0C000000 -#define TEST_REGISTER_TRACK_WRITEVAL 0x55AA uint64_t fpga_multicorrelator_8sc::read_sample_counter() { uint64_t sample_counter_tmp, sample_counter_msw_tmp; - sample_counter_tmp = d_map_base[d_SAMPLE_COUNTER_REG_ADDR_LSW]; - sample_counter_msw_tmp = d_map_base[d_SAMPLE_COUNTER_REG_ADDR_MSW]; + sample_counter_tmp = d_map_base[SAMPLE_COUNTER_REG_ADDR_LSW]; + sample_counter_msw_tmp = d_map_base[SAMPLE_COUNTER_REG_ADDR_MSW]; sample_counter_msw_tmp = sample_counter_msw_tmp << 32; sample_counter_tmp = sample_counter_tmp + sample_counter_msw_tmp; // 2^32 - //return d_map_base[d_SAMPLE_COUNTER_REG_ADDR]; return sample_counter_tmp; } void fpga_multicorrelator_8sc::set_initial_sample(uint64_t samples_offset) { d_initial_sample_counter = samples_offset; - //printf("www writing d map base %d = d_initial_sample_counter = %d\n", d_INITIAL_COUNTER_VALUE_REG_ADDR, d_initial_sample_counter); - d_map_base[d_INITIAL_COUNTER_VALUE_REG_ADDR_LSW] = (d_initial_sample_counter & 0xFFFFFFFF); - d_map_base[d_INITIAL_COUNTER_VALUE_REG_ADDR_MSW] = (d_initial_sample_counter >> 32) & 0xFFFFFFFF; + d_map_base[INITIAL_COUNTER_VALUE_REG_ADDR_LSW] = (d_initial_sample_counter & 0xFFFFFFFF); + d_map_base[INITIAL_COUNTER_VALUE_REG_ADDR_MSW] = (d_initial_sample_counter >> 32) & 0xFFFFFFFF; } -//void fpga_multicorrelator_8sc::set_local_code_and_taps(int32_t code_length_chips, -// float *shifts_chips, int32_t PRN) - void fpga_multicorrelator_8sc::set_local_code_and_taps(float *shifts_chips, float *prompt_data_shift, int32_t PRN) { d_shifts_chips = shifts_chips; d_prompt_data_shift = prompt_data_shift; - //d_code_length_chips = code_length_chips; fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(PRN); } @@ -123,7 +104,6 @@ void fpga_multicorrelator_8sc::set_output_vectors(gr_complex *corr_out, gr_compl void fpga_multicorrelator_8sc::update_local_code(float rem_code_phase_chips) { d_rem_code_phase_chips = rem_code_phase_chips; - //printf("uuuuu d_rem_code_phase_chips = %f\n", d_rem_code_phase_chips); fpga_multicorrelator_8sc::fpga_compute_code_shift_parameters(); fpga_multicorrelator_8sc::fpga_configure_code_parameters_in_fpga(); } @@ -146,13 +126,11 @@ void fpga_multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler( fpga_multicorrelator_8sc::fpga_launch_multicorrelator_fpga(); int32_t irq_count; ssize_t nb; - //printf("$$$$$ waiting for interrupt ... \n"); nb = read(d_device_descriptor, &irq_count, sizeof(irq_count)); - //printf("$$$$$ interrupt received ... \n"); if (nb != sizeof(irq_count)) { - printf("Tracking_module Read failed to retrieve 4 bytes!\n"); - printf("Tracking_module Interrupt number %d\n", irq_count); + std::cout << "Tracking_module Read failed to retrieve 4 bytes!" << std::endl; + std::cout << "Tracking_module Interrupt number " << irq_count << std::endl; } fpga_multicorrelator_8sc::read_tracking_gps_results(); } @@ -161,7 +139,6 @@ fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int32_t n_correlators, std::string device_name, uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, uint32_t multicorr_type, uint32_t code_samples_per_chip) { - //printf("tracking fpga class created\n"); d_n_correlators = n_correlators; d_device_name = std::move(device_name); d_device_base = device_base; @@ -197,103 +174,18 @@ fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int32_t n_correlators, d_initial_sample_counter = 0; d_channel = 0; d_correlator_length_samples = 0, - //d_code_length = code_length; - d_code_length_chips = code_length_chips; + d_code_length_chips = code_length_chips; d_ca_codes = ca_codes; d_data_codes = data_codes; d_multicorr_type = multicorr_type; - d_code_samples_per_chip = code_samples_per_chip; - // set up register mapping - // write-only registers - d_CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR = 0; - d_INITIAL_INDEX_REG_BASE_ADDR = 1; - // if (d_multicorr_type == 0) - // { - // // multicorrelator with 3 correlators (16 registers only) - // d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR = 4; - // d_NSAMPLES_MINUS_1_REG_ADDR = 7; - // d_CODE_LENGTH_MINUS_1_REG_ADDR = 8; - // d_REM_CARR_PHASE_RAD_REG_ADDR = 9; - // d_PHASE_STEP_RAD_REG_ADDR = 10; - // d_PROG_MEMS_ADDR = 11; - // d_DROP_SAMPLES_REG_ADDR = 12; - // d_INITIAL_COUNTER_VALUE_REG_ADDR = 13; - // d_START_FLAG_ADDR = 14; - // } - // else - // { - // other types of multicorrelators (32 registers) - d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR = 7; - d_NSAMPLES_MINUS_1_REG_ADDR = 13; - d_CODE_LENGTH_MINUS_1_REG_ADDR = 14; - d_REM_CARR_PHASE_RAD_REG_ADDR = 15; - d_PHASE_STEP_RAD_REG_ADDR = 16; - d_PROG_MEMS_ADDR = 17; - d_DROP_SAMPLES_REG_ADDR = 18; - d_INITIAL_COUNTER_VALUE_REG_ADDR_LSW = 19; - d_INITIAL_COUNTER_VALUE_REG_ADDR_MSW = 20; - d_START_FLAG_ADDR = 30; - // } - - //printf("d_n_correlators = %d\n", d_n_correlators); - //printf("d_multicorr_type = %d\n", d_multicorr_type); - // read-write registers - // if (d_multicorr_type == 0) - // { - // // multicorrelator with 3 correlators (16 registers only) - // d_TEST_REG_ADDR = 15; - // } - // else - // { - // other types of multicorrelators (32 registers) - d_TEST_REG_ADDR = 31; - // } - - // result 2's complement saturation value - // if (d_multicorr_type == 0) - // { - // // multicorrelator with 3 correlators (16 registers only) - // d_result_SAT_value = 1048576; // 21 bits 2's complement -> 2^20 - // } - // else - // { - // // other types of multicorrelators (32 registers) - // d_result_SAT_value = 4194304; // 23 bits 2's complement -> 2^22 - // } - - // read only registers - d_RESULT_REG_REAL_BASE_ADDR = 1; - // if (d_multicorr_type == 0) - // { - // // multicorrelator with 3 correlators (16 registers only) - // d_RESULT_REG_IMAG_BASE_ADDR = 4; - // d_RESULT_REG_DATA_REAL_BASE_ADDR = 0; // no pilot tracking - // d_RESULT_REG_DATA_IMAG_BASE_ADDR = 0; - // d_SAMPLE_COUNTER_REG_ADDR = 7; - // - // } - // else - // { - // other types of multicorrelators (32 registers) - d_RESULT_REG_IMAG_BASE_ADDR = 7; - //d_RESULT_REG_DATA_REAL_BASE_ADDR = 6; // no pilot tracking - //d_RESULT_REG_DATA_IMAG_BASE_ADDR = 12; - d_SAMPLE_COUNTER_REG_ADDR_LSW = 13; - d_SAMPLE_COUNTER_REG_ADDR_MSW = 14; - - // } - - //printf("d_SAMPLE_COUNTER_REG_ADDR = %d\n", d_SAMPLE_COUNTER_REG_ADDR); - //printf("mmmmmmmmmmmmm d_n_correlators = %d\n", d_n_correlators); DLOG(INFO) << "TRACKING FPGA CLASS CREATED"; } fpga_multicorrelator_8sc::~fpga_multicorrelator_8sc() { - //delete[] d_ca_codes; close_device(); } @@ -322,7 +214,6 @@ bool fpga_multicorrelator_8sc::free() void fpga_multicorrelator_8sc::set_channel(uint32_t channel) { - //printf("www trk set channel channel=%lu\n", (unsigned long) channel); char device_io_name[MAX_LENGTH_DEVICEIO_NAME]; // driver io name d_channel = channel; @@ -334,22 +225,13 @@ void fpga_multicorrelator_8sc::set_channel(uint32_t channel) mergedname = d_device_name + devicebasetemp.str(); strcpy(device_io_name, mergedname.c_str()); - //printf("ppps opening device %s\n", device_io_name); - - printf("trk device_io_name = %s\n", device_io_name); + std::cout << "trk device_io_name = " << device_io_name << std::endl; if ((d_device_descriptor = open(device_io_name, O_RDWR | O_SYNC)) == -1) { LOG(WARNING) << "Cannot open deviceio" << device_io_name; std::cout << "Cannot open deviceio" << device_io_name << std::endl; - - //printf("error opening device\n"); } - // else - // { - // std::cout << "deviceio" << device_io_name << " opened successfully" << std::endl; - // - // } d_map_base = reinterpret_cast(mmap(nullptr, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptor, 0)); @@ -358,16 +240,7 @@ void fpga_multicorrelator_8sc::set_channel(uint32_t channel) LOG(WARNING) << "Cannot map the FPGA tracking module " << d_channel << "into user memory"; std::cout << "Cannot map deviceio" << device_io_name << std::endl; - //printf("error mapping registers\n"); } - // else - // { - // std::cout << "deviceio" << device_io_name << "mapped successfully" << std::endl; - // } - // else - // { - // printf("trk mapping registers succes\n"); // this is for debug -- remove ! - // } // sanity check : check test register uint32_t writeval = TEST_REGISTER_TRACK_WRITEVAL; @@ -376,15 +249,11 @@ void fpga_multicorrelator_8sc::set_channel(uint32_t channel) if (writeval != readval) { LOG(WARNING) << "Test register sanity check failed"; - printf("tracking test register sanity check failed\n"); - - //printf("lslslls test sanity check reg failure\n"); + std::cout << "tracking test register sanity check failed" << std::endl; } else { LOG(INFO) << "Test register sanity check success !"; - //printf("tracking test register sanity check success\n"); - //printf("lslslls test sanity check reg success\n"); } } @@ -392,13 +261,11 @@ void fpga_multicorrelator_8sc::set_channel(uint32_t channel) uint32_t fpga_multicorrelator_8sc::fpga_acquisition_test_register( uint32_t writeval) { - //printf("d_TEST_REG_ADDR = %d\n", d_TEST_REG_ADDR); - uint32_t readval = 0; // write value to test register - d_map_base[d_TEST_REG_ADDR] = writeval; + d_map_base[TEST_REG_ADDR] = writeval; // read value from test register - readval = d_map_base[d_TEST_REG_ADDR]; + readval = d_map_base[TEST_REG_ADDR]; // return read value return readval; } @@ -409,28 +276,10 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR uint32_t k; uint32_t code_chip; uint32_t select_pilot_corelator = LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; - // select_fpga_correlator = 0; - //printf("kkk d_n_correlators = %x\n", d_n_correlators); - //printf("kkk d_code_length_chips = %d\n", d_code_length_chips); - //printf("programming mems d map base %d\n", d_PROG_MEMS_ADDR); - - //FILE *fp; - //char str[80]; - //sprintf(str, "generated_code_PRN%d", PRN); - //fp = fopen(str,"w"); - // for (s = 0; s < d_n_correlators; s++) - // { - - //printf("kkk select_fpga_correlator = %x\n", select_fpga_correlator); - - d_map_base[d_PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; - //printf("trk lib d_code_length_chips = %d, d_code_samples_per_chip = %d\n", d_code_length_chips, d_code_samples_per_chip); + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; for (k = 0; k < d_code_length_chips * d_code_samples_per_chip; k++) { - //if (d_local_code_in[k] == 1) - //printf("kkk d_ca_codes %d = %d\n", k, d_ca_codes[((int(d_code_length)) * (PRN - 1)) + k]); - //fprintf(fp, "%d\n", d_ca_codes[((int(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k]); if (d_ca_codes[((int(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k] == 1) { code_chip = 1; @@ -441,21 +290,14 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR } // copy the local code to the FPGA memory one by one - d_map_base[d_PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip; // | select_fpga_correlator; + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip; // | select_fpga_correlator; } - // select_fpga_correlator = select_fpga_correlator - // + LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; - // } - //fclose(fp); - //printf("kkk d_track_pilot = %d\n", d_track_pilot); if (d_track_pilot) { - //printf("kkk select_fpga_correlator = %x\n", select_fpga_correlator); - d_map_base[d_PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; for (k = 0; k < d_code_length_chips * d_code_samples_per_chip; k++) { - //if (d_local_code_in[k] == 1) if (d_data_codes[((int(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k] == 1) { code_chip = 1; @@ -464,12 +306,9 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR { code_chip = 0; } - //printf("%d %d | ", d_data_codes, code_chip); - // copy the local code to the FPGA memory one by one - d_map_base[d_PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip | select_pilot_corelator; + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip | select_pilot_corelator; } } - //printf("\n"); } @@ -478,39 +317,27 @@ void fpga_multicorrelator_8sc::fpga_compute_code_shift_parameters(void) float temp_calculation; int32_t i; - //printf("ppp d_rem_code_phase_chips = %f\n", d_rem_code_phase_chips); for (i = 0; i < d_n_correlators; i++) { - //printf("ppp d_shifts_chips %d = %f\n", i, d_shifts_chips[i]); - //printf("ppp d_code_samples_per_chip = %d\n", d_code_samples_per_chip); temp_calculation = floor( d_shifts_chips[i] - d_rem_code_phase_chips); - //printf("ppp d_rem_code_phase_chips = %f\n", d_rem_code_phase_chips); - //printf("ppp temp calculation %d = %f ================================ \n", i, temp_calculation); if (temp_calculation < 0) { temp_calculation = temp_calculation + (d_code_length_chips * d_code_samples_per_chip); // % operator does not work as in Matlab with negative numbers } - //printf("ppp d_rem_code_phase_chips = %f\n", d_rem_code_phase_chips); - //printf("ppp temp calculation %d = %f ================================ \n", i, temp_calculation); d_initial_index[i] = static_cast((static_cast(temp_calculation)) % (d_code_length_chips * d_code_samples_per_chip)); - //printf("ppp d_initial_index %d = %d\n", i, d_initial_index[i]); temp_calculation = fmod(d_shifts_chips[i] - d_rem_code_phase_chips, 1.0); - //printf("ppp fmod %d = fmod(%f, 1) = %f\n", i, d_shifts_chips[i] - d_rem_code_phase_chips, temp_calculation); if (temp_calculation < 0) { temp_calculation = temp_calculation + 1.0; // fmod operator does not work as in Matlab with negative numbers } d_initial_interp_counter[i] = static_cast(floor(MAX_CODE_RESAMPLER_COUNTER * temp_calculation)); - //printf("ppp d_initial_interp_counter %d = %d\n", i, d_initial_interp_counter[i]); - //printf("MAX_CODE_RESAMPLER_COUNTER = %d\n", MAX_CODE_RESAMPLER_COUNTER); } if (d_track_pilot) { - //printf("tracking pilot !!!!!!!!!!!!!!!!\n"); temp_calculation = floor( d_prompt_data_shift[0] - d_rem_code_phase_chips); @@ -527,7 +354,6 @@ void fpga_multicorrelator_8sc::fpga_compute_code_shift_parameters(void) } d_initial_interp_counter[d_n_correlators] = static_cast(floor(MAX_CODE_RESAMPLER_COUNTER * temp_calculation)); } - //while(1); } @@ -536,23 +362,16 @@ void fpga_multicorrelator_8sc::fpga_configure_code_parameters_in_fpga(void) int32_t i; for (i = 0; i < d_n_correlators; i++) { - //printf("www writing d map base %d = d_initial_index %d = %d\n", d_INITIAL_INDEX_REG_BASE_ADDR + i, i, d_initial_index[i]); - d_map_base[d_INITIAL_INDEX_REG_BASE_ADDR + i] = d_initial_index[i]; - //d_map_base[1 + d_n_correlators + i] = d_initial_interp_counter[i]; - //printf("www writing d map base %d = d_initial_interp_counter %d = %d\n", d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR + i, i, d_initial_interp_counter[i]); - d_map_base[d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR + i] = d_initial_interp_counter[i]; + d_map_base[INITIAL_INDEX_REG_BASE_ADDR + i] = d_initial_index[i]; + d_map_base[INITIAL_INTERP_COUNTER_REG_BASE_ADDR + i] = d_initial_interp_counter[i]; } if (d_track_pilot) { - //printf("www writing d map base %d = d_initial_index %d = %d\n", d_INITIAL_INDEX_REG_BASE_ADDR + d_n_correlators, d_n_correlators, d_initial_index[d_n_correlators]); - d_map_base[d_INITIAL_INDEX_REG_BASE_ADDR + d_n_correlators] = d_initial_index[d_n_correlators]; - //d_map_base[1 + d_n_correlators + i] = d_initial_interp_counter[i]; - //printf("www writing d map base %d = d_initial_interp_counter %d = %d\n", d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR + d_n_correlators, d_n_correlators, d_initial_interp_counter[d_n_correlators]); - d_map_base[d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR + d_n_correlators] = d_initial_interp_counter[d_n_correlators]; + d_map_base[INITIAL_INDEX_REG_BASE_ADDR + d_n_correlators] = d_initial_index[d_n_correlators]; + d_map_base[INITIAL_INTERP_COUNTER_REG_BASE_ADDR + d_n_correlators] = d_initial_interp_counter[d_n_correlators]; } - //printf("www writing d map base %d = d_code_length_chips*d_code_samples_per_chip - 1 = %d\n", d_CODE_LENGTH_MINUS_1_REG_ADDR, (d_code_length_chips*d_code_samples_per_chip) - 1); - d_map_base[d_CODE_LENGTH_MINUS_1_REG_ADDR] = (d_code_length_chips * d_code_samples_per_chip) - 1; // number of samples - 1 + d_map_base[CODE_LENGTH_MINUS_1_REG_ADDR] = (d_code_length_chips * d_code_samples_per_chip) - 1; // number of samples - 1 } @@ -563,11 +382,9 @@ void fpga_multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(void) d_code_phase_step_chips_num = static_cast(roundf(MAX_CODE_RESAMPLER_COUNTER * d_code_phase_step_chips)); if (d_code_phase_step_chips > 1.0) { - printf("Warning : d_code_phase_step_chips = %f cannot be bigger than one\n", d_code_phase_step_chips); + std::cout << "Warning : d_code_phase_step_chips = " << d_code_phase_step_chips << " cannot be bigger than one" << std::endl; } - //printf("d_rem_carrier_phase_in_rad = %f\n", d_rem_carrier_phase_in_rad); - if (d_rem_carrier_phase_in_rad > M_PI) { d_rem_carrier_phase_in_rad_temp = -2 * M_PI + d_rem_carrier_phase_in_rad; @@ -589,29 +406,23 @@ void fpga_multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(void) d_phase_step_rad_int = static_cast(roundf( (fabs(d_phase_step_rad) / M_PI) * pow(2, PHASE_CARR_NBITS_FRAC))); // the FPGA accepts a range for the phase step between -pi and +pi - //printf("d_phase_step_rad_int = %d\n", d_phase_step_rad_int); if (d_phase_step_rad < 0) { d_phase_step_rad_int = -d_phase_step_rad_int; } - //printf("d_phase_step_rad_int = %d\n", d_phase_step_rad_int); } void fpga_multicorrelator_8sc::fpga_configure_signal_parameters_in_fpga(void) { - //printf("www d map base %d = d_code_phase_step_chips_num = %d\n", d_CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR, d_code_phase_step_chips_num); - d_map_base[d_CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR] = d_code_phase_step_chips_num; + d_map_base[CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR] = d_code_phase_step_chips_num; - //printf("www d map base %d = d_correlator_length_samples - 1 = %d\n", d_NSAMPLES_MINUS_1_REG_ADDR, d_correlator_length_samples - 1); - d_map_base[d_NSAMPLES_MINUS_1_REG_ADDR] = d_correlator_length_samples - 1; + d_map_base[NSAMPLES_MINUS_1_REG_ADDR] = d_correlator_length_samples - 1; - //printf("www d map base %d = d_rem_carr_phase_rad_int = %d\n", d_REM_CARR_PHASE_RAD_REG_ADDR, d_rem_carr_phase_rad_int); - d_map_base[d_REM_CARR_PHASE_RAD_REG_ADDR] = d_rem_carr_phase_rad_int; + d_map_base[REM_CARR_PHASE_RAD_REG_ADDR] = d_rem_carr_phase_rad_int; - //printf("www d map base %d = d_phase_step_rad_int = %d\n", d_PHASE_STEP_RAD_REG_ADDR, d_phase_step_rad_int); - d_map_base[d_PHASE_STEP_RAD_REG_ADDR] = d_phase_step_rad_int; + d_map_base[PHASE_STEP_RAD_REG_ADDR] = d_phase_step_rad_int; } @@ -622,9 +433,7 @@ void fpga_multicorrelator_8sc::fpga_launch_multicorrelator_fpga(void) write(d_device_descriptor, reinterpret_cast(&reenable), sizeof(int32_t)); // writing 1 to reg 14 launches the tracking - //printf("www writing 1 to d map base %d = start flag\n", d_START_FLAG_ADDR); - d_map_base[d_START_FLAG_ADDR] = 1; - //while(1); + d_map_base[START_FLAG_ADDR] = 1; } @@ -634,76 +443,17 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void) int32_t readval_imag; int32_t k; - //printf("www reading trk results\n"); for (k = 0; k < d_n_correlators; k++) { - readval_real = d_map_base[d_RESULT_REG_REAL_BASE_ADDR + k]; - //printf("read real before checking d map base %d = %d\n", d_RESULT_REG_BASE_ADDR + k, readval_real); - //// if (readval_real > debug_max_readval_real[k]) - //// { - //// debug_max_readval_real[k] = readval_real; - //// } - // if (readval_real >= d_result_SAT_value) // 0x100000 (21 bits two's complement) - // { - // readval_real = -2*d_result_SAT_value + readval_real; - // } - //// if (readval_real > debug_max_readval_real_after_check[k]) - //// { - //// debug_max_readval_real_after_check[k] = readval_real; - //// } - //printf("read real d map base %d = %d\n", d_RESULT_REG_BASE_ADDR + k, readval_real); - readval_imag = d_map_base[d_RESULT_REG_IMAG_BASE_ADDR + k]; - //printf("read imag before checking d map base %d = %d\n", d_RESULT_REG_BASE_ADDR + k, readval_imag); - //// if (readval_imag > debug_max_readval_imag[k]) - //// { - //// debug_max_readval_imag[k] = readval_imag; - //// } - // - // if (readval_imag >= d_result_SAT_value) // 0x100000 (21 bits two's complement) - // { - // readval_imag = -2*d_result_SAT_value + readval_imag; - // } - //// if (readval_imag > debug_max_readval_imag_after_check[k]) - //// { - //// debug_max_readval_imag_after_check[k] = readval_real; - //// } - //printf("read imag d map base %d = %d\n", d_RESULT_REG_BASE_ADDR + k, readval_imag); + readval_real = d_map_base[RESULT_REG_REAL_BASE_ADDR + k]; + readval_imag = d_map_base[RESULT_REG_IMAG_BASE_ADDR + k]; d_corr_out[k] = gr_complex(readval_real, readval_imag); - - // if (printcounter > 100) - // { - // printcounter = 0; - // for (int32_t ll=0;ll= d_result_SAT_value) // 0x100000 (21 bits two's complement) - // { - // readval_real = -2*d_result_SAT_value + readval_real; - // } - - //readval_imag = d_map_base[d_RESULT_REG_DATA_IMAG_BASE_ADDR]; - readval_imag = d_map_base[d_RESULT_REG_IMAG_BASE_ADDR + d_n_correlators]; - // if (readval_imag >= d_result_SAT_value) // 0x100000 (21 bits two's complement) - // { - // readval_imag = -2*d_result_SAT_value + readval_imag; - // } - d_Prompt_Data[0] = gr_complex(readval_real, readval_imag); + readval_real = d_map_base[RESULT_REG_REAL_BASE_ADDR + d_n_correlators]; + readval_imag = d_map_base[RESULT_REG_IMAG_BASE_ADDR + d_n_correlators]; + d_Prompt_Data[0] = gr_complex(readval_real, readval_imag); } } @@ -711,9 +461,8 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void) void fpga_multicorrelator_8sc::unlock_channel(void) { // unlock the channel to let the next samples go through - //printf("www writing 1 to d map base %d = drop samples\n", d_DROP_SAMPLES_REG_ADDR); - d_map_base[d_DROP_SAMPLES_REG_ADDR] = 1; // unlock the channel - d_map_base[23] = 1; // set the tracking module back to idle + d_map_base[DROP_SAMPLES_REG_ADDR] = 1; // unlock the channel + d_map_base[STOP_TRACKING_REG_ADDR] = 1; // set the tracking module back to idle } void fpga_multicorrelator_8sc::close_device() @@ -721,7 +470,7 @@ void fpga_multicorrelator_8sc::close_device() auto *aux = const_cast(d_map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { - printf("Failed to unmap memory uio\n"); + std::cout << "Failed to unmap memory uio" << std::endl; } close(d_device_descriptor); } @@ -730,20 +479,6 @@ void fpga_multicorrelator_8sc::close_device() void fpga_multicorrelator_8sc::lock_channel(void) { // lock the channel for processing - //printf("www writing 0 to d map base %d = drop samples\n", d_DROP_SAMPLES_REG_ADDR); - d_map_base[d_DROP_SAMPLES_REG_ADDR] = 0; // lock the channel + d_map_base[DROP_SAMPLES_REG_ADDR] = 0; // lock the channel } -//void fpga_multicorrelator_8sc::read_sample_counters(int32_t *sample_counter, int32_t *secondary_sample_counter, int32_t *counter_corr_0_in, int32_t *counter_corr_0_out) -//{ -// *sample_counter = d_map_base[11]; -// *secondary_sample_counter = d_map_base[8]; -// *counter_corr_0_in = d_map_base[10]; -// *counter_corr_0_out = d_map_base[9]; -// -//} - -//void fpga_multicorrelator_8sc::reset_multicorrelator(void) -//{ -// d_map_base[14] = 2; // writing a 2 to d_map_base[14] resets the multicorrelator -//} diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.h b/src/algorithms/tracking/libs/fpga_multicorrelator.h index ad0d44233..95d5c580a 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.h +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.h @@ -1,8 +1,8 @@ /*! * \file fpga_multicorrelator_8sc.h - * \brief High optimized FPGA vector correlator class for lv_16sc_t (short int32_t complex) + * \brief High optimized FPGA vector correlator class * \authors
    - *
  • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
  • Marc Majoral, 2019. mmajoral(at)cttc.cat *
  • Javier Arribas, 2016. jarribas(at)cttc.es *
* @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -41,7 +41,31 @@ #include #include -#define MAX_LENGTH_DEVICEIO_NAME 50 +// FPGA register addresses + +// write addresses +#define CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR 0 +#define INITIAL_INDEX_REG_BASE_ADDR 1 +#define INITIAL_INTERP_COUNTER_REG_BASE_ADDR 7 +#define NSAMPLES_MINUS_1_REG_ADDR 13 +#define CODE_LENGTH_MINUS_1_REG_ADDR 14 +#define REM_CARR_PHASE_RAD_REG_ADDR 15 +#define PHASE_STEP_RAD_REG_ADDR 16 +#define PROG_MEMS_ADDR 17 +#define DROP_SAMPLES_REG_ADDR 18 +#define INITIAL_COUNTER_VALUE_REG_ADDR_LSW 19 +#define INITIAL_COUNTER_VALUE_REG_ADDR_MSW 20 +#define STOP_TRACKING_REG_ADDR 23 +#define START_FLAG_ADDR 30 +// read-write addresses +#define TEST_REG_ADDR 31 +// read addresses +#define RESULT_REG_REAL_BASE_ADDR 1 +#define RESULT_REG_IMAG_BASE_ADDR 7 +#define SAMPLE_COUNTER_REG_ADDR_LSW 13 +#define SAMPLE_COUNTER_REG_ADDR_MSW 14 + + /*! * \brief Class that implements carrier wipe-off and correlators. @@ -50,36 +74,26 @@ class fpga_multicorrelator_8sc { public: fpga_multicorrelator_8sc(int32_t n_correlators, std::string device_name, - uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, uint32_t multicorr_type, uint32_t code_samples_per_chip); + uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, uint32_t multicorr_type, uint32_t code_samples_per_chip); ~fpga_multicorrelator_8sc(); - //bool set_output_vectors(gr_complex* corr_out); void set_output_vectors(gr_complex *corr_out, gr_complex *Prompt_Data); - // bool set_local_code_and_taps( - // int32_t code_length_chips, const int* local_code_in, - // float *shifts_chips, int32_t PRN); - //bool set_local_code_and_taps( void set_local_code_and_taps( - // int32_t code_length_chips, - float *shifts_chips, float *prompt_data_shift, int32_t PRN); - //bool set_output_vectors(lv_16sc_t* corr_out); + float *shifts_chips, float *prompt_data_shift, int32_t PRN); void update_local_code(float rem_code_phase_chips); - //bool Carrier_wipeoff_multicorrelator_resampler( void Carrier_wipeoff_multicorrelator_resampler( - float rem_carrier_phase_in_rad, float phase_step_rad, - float carrier_phase_rate_step_rad, - float rem_code_phase_chips, float code_phase_step_chips, - float code_phase_rate_step_chips, - int32_t signal_length_samples); + float rem_carrier_phase_in_rad, float phase_step_rad, + float carrier_phase_rate_step_rad, + float rem_code_phase_chips, float code_phase_step_chips, + float code_phase_rate_step_chips, + int32_t signal_length_samples); bool free(); void set_channel(uint32_t channel); void set_initial_sample(uint64_t samples_offset); uint64_t read_sample_counter(); void lock_channel(void); void unlock_channel(void); - //void read_sample_counters(int32_t *sample_counter, int32_t *secondary_sample_counter, int32_t *counter_corr_0_in, int32_t *counter_corr_0_out); // debug private: - //const int32_t *d_local_code_in; gr_complex *d_corr_out; gr_complex *d_Prompt_Data; float *d_shifts_chips; @@ -115,37 +129,11 @@ private: int32_t *d_ca_codes; int32_t *d_data_codes; - //uint32_t d_code_length; // nominal number of chips - uint32_t d_code_samples_per_chip; bool d_track_pilot; uint32_t d_multicorr_type; - // register addresses - // write-only regs - uint32_t d_CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR; - uint32_t d_INITIAL_INDEX_REG_BASE_ADDR; - uint32_t d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR; - uint32_t d_NSAMPLES_MINUS_1_REG_ADDR; - uint32_t d_CODE_LENGTH_MINUS_1_REG_ADDR; - uint32_t d_REM_CARR_PHASE_RAD_REG_ADDR; - uint32_t d_PHASE_STEP_RAD_REG_ADDR; - uint32_t d_PROG_MEMS_ADDR; - uint32_t d_DROP_SAMPLES_REG_ADDR; - uint32_t d_INITIAL_COUNTER_VALUE_REG_ADDR_LSW; - uint32_t d_INITIAL_COUNTER_VALUE_REG_ADDR_MSW; - uint32_t d_START_FLAG_ADDR; - // read-write regs - uint32_t d_TEST_REG_ADDR; - // read-only regs - uint32_t d_RESULT_REG_REAL_BASE_ADDR; - uint32_t d_RESULT_REG_IMAG_BASE_ADDR; - uint32_t d_RESULT_REG_DATA_REAL_BASE_ADDR; - uint32_t d_RESULT_REG_DATA_IMAG_BASE_ADDR; - uint32_t d_SAMPLE_COUNTER_REG_ADDR_LSW; - uint32_t d_SAMPLE_COUNTER_REG_ADDR_MSW; - // private functions uint32_t fpga_acquisition_test_register(uint32_t writeval); void fpga_configure_tracking_gps_local_code(int32_t PRN); @@ -155,17 +143,8 @@ private: void fpga_configure_signal_parameters_in_fpga(void); void fpga_launch_multicorrelator_fpga(void); void read_tracking_gps_results(void); - //void reset_multicorrelator(void); void close_device(void); - uint32_t d_result_SAT_value; - - int32_t debug_max_readval_real[5] = {0, 0, 0, 0, 0}; - int32_t debug_max_readval_imag[5] = {0, 0, 0, 0, 0}; - - int32_t debug_max_readval_real_after_check[5] = {0, 0, 0, 0, 0}; - int32_t debug_max_readval_imag_after_check[5] = {0, 0, 0, 0, 0}; - int32_t printcounter = 0; }; #endif /* GNSS_SDR_FPGA_MULTICORRELATOR_H_ */ diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 0eba503e4..fba66d309 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -274,13 +274,9 @@ int ControlThread::run() cmd_interface_thread_ = std::thread(&ControlThread::telecommand_listener, this); #ifdef ENABLE_FPGA -// bool enable_FPGA = configuration_->property("Channel.enable_FPGA", false); -// if (enable_FPGA == true) -// { - // Create a task for the acquisition such that id doesn't block the flow of the control thread - fpga_helper_thread_=boost::thread(&GNSSFlowgraph::start_acquisition_helper, - flowgraph_); -// } + // Create a task for the acquisition such that id doesn't block the flow of the control thread + fpga_helper_thread_=boost::thread(&GNSSFlowgraph::start_acquisition_helper, + flowgraph_); #endif // Main loop to read and process the control messages while (flowgraph_->running() && !stop_) @@ -306,46 +302,17 @@ int ControlThread::run() flowgraph_->perform_hw_reset(); #endif -// <<<<<<< HEAD - -// Join keyboard thread -//#ifdef OLD_BOOST -// keyboard_thread_.timed_join(boost::posix_time::seconds(1)); -// sysv_queue_thread_.timed_join(boost::posix_time::seconds(1)); -// cmd_interface_thread_.timed_join(boost::posix_time::seconds(1)); -//#ifdef ENABLE_FPGA -//// if (enable_FPGA == true) -//// { -// fpga_helper_thread_.timed_join(boost::posix_time::seconds(1)); -//// } -//#endif -// -//#endif -//#ifndef OLD_BOOST -// keyboard_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); -// sysv_queue_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); -// cmd_interface_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); - pthread_t id = keyboard_thread_.native_handle(); keyboard_thread_.detach(); pthread_cancel(id); #ifdef ENABLE_FPGA -// if (enable_FPGA == true) -// { - fpga_helper_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); -// } + + fpga_helper_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); + #endif -// #endif - LOG(INFO) << "Flowgraph stopped"; -//======= -// // Terminate keyboard thread -// pthread_t id = keyboard_thread_.native_handle(); -// keyboard_thread_.detach(); -// pthread_cancel(id); -//>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 if (restart_) { diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index a87e5bbba..b1e226ca8 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 50f4d6f96..378c135d2 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -9,7 +9,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -126,8 +126,8 @@ void GNSSFlowgraph::connect() #ifndef ENABLE_FPGA for (int i = 0; i < sources_count_; i++) { -// if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) -// { + if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) + { try { sig_source_.at(i)->connect(top_block_); @@ -139,15 +139,15 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } -// } + } } // Signal Source > Signal conditioner > for (unsigned int i = 0; i < sig_conditioner_.size(); i++) { -// if (configuration_->property(sig_conditioner_.at(i)->role() + ".enable_FPGA", false) == false) -// { + if (configuration_->property(sig_conditioner_.at(i)->role() + ".enable_FPGA", false) == false) + { try { sig_conditioner_.at(i)->connect(top_block_); @@ -159,7 +159,7 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } -// } + } } #endif for (unsigned int i = 0; i < channels_count_; i++) @@ -212,137 +212,102 @@ void GNSSFlowgraph::connect() for (int i = 0; i < sources_count_; i++) { -// //FPGA Accelerators do not need signal sources or conditioners -// //as the samples are feed directly to the FPGA fabric, so, if enabled, do not connect any source -// if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) -// { - try - { - //TODO: Remove this array implementation and create generic multistream connector - //(if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) - if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") - { - //Multichannel Array - std::cout << "ARRAY MODE" << std::endl; - for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) - { - std::cout << "connecting ch " << j << std::endl; - top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); - } - } - else - { - //TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - //Include GetRFChannels in the interface to avoid read config parameters here - //read the number of RF channels for each front-end - RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + try + { + //TODO: Remove this array implementation and create generic multistream connector + //(if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) + if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") + { + //Multichannel Array + std::cout << "ARRAY MODE" << std::endl; + for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) + { + std::cout << "connecting ch " << j << std::endl; + top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); + } + } + else + { + //TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + //Include GetRFChannels in the interface to avoid read config parameters here + //read the number of RF channels for each front-end + RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); - for (int j = 0; j < RF_Channels; j++) - { - //Connect the multichannel signal source to multiple signal conditioners - // GNURADIO max_streams=-1 means infinite ports! - LOG(INFO) << "sig_source_.at(i)->get_right_block()->output_signature()->max_streams()=" << sig_source_.at(i)->get_right_block()->output_signature()->max_streams(); - LOG(INFO) << "sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()=" << sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()->max_streams(); + for (int j = 0; j < RF_Channels; j++) + { + //Connect the multichannel signal source to multiple signal conditioners + // GNURADIO max_streams=-1 means infinite ports! + LOG(INFO) << "sig_source_.at(i)->get_right_block()->output_signature()->max_streams()=" << sig_source_.at(i)->get_right_block()->output_signature()->max_streams(); + LOG(INFO) << "sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()=" << sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()->max_streams(); - if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) - { - LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - if (j == 0) - { - // RF_channel 0 backward compatibility with single channel sources - LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) - LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - } - signal_conditioner_ID++; - } - } - } - catch (const std::exception& e) - { - LOG(WARNING) << "Can't connect signal source " << i << " to signal conditioner " << i; - LOG(ERROR) << e.what(); - top_block_->disconnect_all(); - return; - } -// } + if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) + { + LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + if (j == 0) + { + // RF_channel 0 backward compatibility with single channel sources + LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) + LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + } + signal_conditioner_ID++; + } + } + } + catch (const std::exception& e) + { + LOG(WARNING) << "Can't connect signal source " << i << " to signal conditioner " << i; + LOG(ERROR) << e.what(); + top_block_->disconnect_all(); + return; + } } DLOG(INFO) << "Signal source connected to signal conditioner"; -// bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); #endif #if ENABLE_FPGA -//<<<<<<< HEAD -// if (FPGA_enabled == false) -// { -// //connect the signal source to sample counter -// //connect the sample counter to Observables -// try -// { -// double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); -// if (fs == 0.0) -// { -// LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; -// std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; -// throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); -// } -// int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); -// ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); -// //ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); -// top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); -// top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse -// } -// catch (const std::exception& e) -// { -// LOG(WARNING) << "Can't connect sample counter"; -// LOG(ERROR) << e.what(); -// top_block_->disconnect_all(); -// return; -// } -// } -// else -// { -//======= -// if (FPGA_enabled == false) -// { -// //connect the signal source to sample counter -// //connect the sample counter to Observables -// try -// { -// double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); -// if (fs == 0.0) -// { -// LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; -// std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; -// throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); -// } -// int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); -// ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); -// top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); -// top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse -// } -// catch (const std::exception& e) -// { -// LOG(WARNING) << "Can't connect sample counter"; -// LOG(ERROR) << e.what(); -// top_block_->disconnect_all(); -// return; -// } -// } -// else -// { -//>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 +// bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); + + if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) + { + //connect the signal source to sample counter + //connect the sample counter to Observables + try + { + double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); + if (fs == 0.0) + { + LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; + std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; + throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); + } + int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); + ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); + top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); + top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse + } + catch (const std::exception& e) + { + LOG(WARNING) << "Can't connect sample counter"; + LOG(ERROR) << e.what(); + top_block_->disconnect_all(); + return; + } + } + else + { + //create a hardware-defined gnss_synchro pulse for the observables block try { @@ -364,7 +329,7 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } -// } + } #else // connect the signal source to sample counter // connect the sample counter to Observables @@ -402,8 +367,8 @@ void GNSSFlowgraph::connect() { #ifndef ENABLE_FPGA -// if (FPGA_enabled == false) -// { + if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) + { try { selected_signal_conditioner_ID = configuration_->property("Channel" + std::to_string(i) + ".RF_channel_ID", 0); @@ -540,7 +505,7 @@ void GNSSFlowgraph::connect() } DLOG(INFO) << "signal conditioner " << selected_signal_conditioner_ID << " connected to channel " << i; -// } + } #endif // Signal Source > Signal conditioner >> Channels >> Observables try @@ -855,7 +820,6 @@ void GNSSFlowgraph::disconnect() } #endif - //printf("disconnect process point 1\n"); #ifdef ENABLE_FPGA //bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); if (FPGA_enabled == false) diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index b171502bc..877ca888b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -7,7 +7,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -63,7 +63,6 @@ #include "gps_l1_ca_dll_pll_tracking_fpga.h" #include "hybrid_observables.h" #include "signal_generator_flags.h" -//#include "gnss_sdr_sample_counter.h" #include "gnss_sdr_fpga_sample_counter.h" #include "test_flags.h" #include "tracking_tests_flags.h" @@ -79,23 +78,15 @@ #define TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define TEST_OBS_COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define TEST_OBS_NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define TEST_OBS_NSAMPLES_TRACKING 1000000000 // number of samples during which we test the tracking module -#define TEST_OBS_NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module -#define TEST_OBS_NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop -#define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter -#define DOWNSAMPLING_FILTER_DELAY 48 -#define DOWNSAMPLING_FILTER_OFFSET_SAMPLES 0 +#define TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter +#define TEST_OBS_DOWNSAMPLING_FILTER_DELAY 48 + // HW related options -//bool test_observables_doppler_control_in_sw = 1; // 1 => doppler sweep controlled by the SW test code , 0 => doppler sweep controlled by the HW bool test_observables_show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if test_observables_doppler_control_in_sw = 1), 0=> do not show it bool test_observables_skip_samples_already_used = 1; // if test_observables_doppler_control_in_sw = 1 and test_observables_skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops - // (exactly in the same way as the SW) - // if test_observables_doppler_control_in_sw = 1 and test_observables_skip_samples_already_used = 0 => the sampe samples are used for each PRN loop - // if test_observables_doppler_control_in_sw = 0 => test_observables_skip_samples_already_used is not applicable -bool doppler_loop_control_in_sw_obs_test = 0; + // (exactly in the same way as the SW) -// ######## GNURADIO BLOCK MESSAGE RECEVER FOR TRACKING MESSAGES ######### class HybridObservablesTest_msg_rx_Fpga; typedef boost::shared_ptr HybridObservablesTest_msg_rx_Fpga_sptr; @@ -145,10 +136,6 @@ HybridObservablesTest_msg_rx_Fpga::~HybridObservablesTest_msg_rx_Fpga() } -// ########################################################### - - -// ######## GNURADIO BLOCK MESSAGE RECEVER FOR TLM MESSAGES ######### class HybridObservablesTest_tlm_msg_rx_Fpga; typedef boost::shared_ptr HybridObservablesTest_tlm_msg_rx_Fpga_sptr; @@ -197,10 +184,6 @@ HybridObservablesTest_tlm_msg_rx_Fpga::~HybridObservablesTest_tlm_msg_rx_Fpga() { } - -// ########################################################### - - class HybridObservablesTestFpga : public ::testing::Test { public: @@ -394,14 +377,12 @@ void *handler_DMA_obs_test(void *arguments) unsigned int nread_elements; // number of elements effectively read from the input file unsigned int nsamples = 0; // number of complex samples effectively transferred unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA - unsigned int num_bytes_to_transfer; // DMA transfer block size in bytes unsigned int nsamples_transmitted; struct DMA_handler_args *args = (struct DMA_handler_args *) arguments; unsigned int nsamples_tx = args->nsamples_tx; - //printf("in handler DMA to send %d\n", nsamples_tx); std::string file = args->file; // input filename unsigned int skip_used_samples = args->skip_used_samples; @@ -409,46 +390,31 @@ void *handler_DMA_obs_test(void *arguments) tx_fd = open("/dev/loop_tx", O_WRONLY); if ( tx_fd < 0 ) { - printf("DMA can't open loop device\n"); + std::cout << "DMA can't open loop device" << std::endl; exit(1); } else // open input file rx_signal_file_id = fopen(file.c_str(), "rb"); - if (rx_signal_file_id < 0) + if (rx_signal_file_id == NULL) { - printf("DMA can't open input file\n"); + std::cout << "DMA can't open input file" << std::endl; exit(1); } - //printf("in handler DMA waiting for send samples start\n"); while(send_samples_start_obs_test == 0); // wait until acquisition starts - //printf("in handler DMA going to send samples\n"); // skip initial samples int skip_samples = (int) FLAGS_skip_samples; fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); - //printf("sending %d samples starting at position %d\n", nsamples_tx,skip_samples + skip_used_samples); - //printf("\n dma skip_samples = %d\n", skip_samples); - //printf("\n dma skip used samples = %d\n", skip_used_samples); - //printf("dma skip_samples = %d\n", skip_samples); - //printf("dma skip used samples = %d\n", skip_used_samples); - //printf("dma file_completed = %d\n", file_completed); - //printf("dma nsamples = %d\n", nsamples); - //printf("dma nsamples_tx = %d\n", nsamples_tx); usleep(50000); // wait some time to give time to the main thread to start the acquisition module - unsigned int kk; - //printf("enter kk"); - //scanf("%d", &kk); - //printf("args->freq_band = %d\n", (int) args->freq_band); while (file_completed == false) { - //printf("samples sent = %d\n", nsamples); - if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) + if (nsamples_tx - nsamples > TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL) { - nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; + nsamples_block = TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL; } else { @@ -456,21 +422,21 @@ void *handler_DMA_obs_test(void *arguments) file_completed = true; } - nread_elements = fread(input_samples_obs_test, sizeof(int8_t), nsamples_block*COMPLEX_SAMPLE_SIZE, rx_signal_file_id); + nread_elements = fread(input_samples_obs_test, sizeof(int8_t), nsamples_block*TEST_OBS_COMPLEX_SAMPLE_SIZE, rx_signal_file_id); - if (nread_elements != nsamples_block * COMPLEX_SAMPLE_SIZE) + if (nread_elements != nsamples_block * TEST_OBS_COMPLEX_SAMPLE_SIZE) { - printf("file completed\n"); + std::cout << "file completed" << std::endl; file_completed = true; } - nsamples+=(nread_elements/COMPLEX_SAMPLE_SIZE); + nsamples+=(nread_elements/TEST_OBS_COMPLEX_SAMPLE_SIZE); if (nread_elements > 0) { // for the 32-BIT DMA dma_index = 0; - for (index0 = 0;index0 < (nread_elements);index0+=COMPLEX_SAMPLE_SIZE) + for (index0 = 0;index0 < (nread_elements);index0+=TEST_OBS_COMPLEX_SAMPLE_SIZE) { if (args->freq_band == 0) { @@ -492,10 +458,8 @@ void *handler_DMA_obs_test(void *arguments) } dma_index += 4; } - //printf("writing samples to send\n"); - nsamples_transmitted = write(tx_fd, &input_samples_dma_obs_test[0], nread_elements*NUM_QUEUES); - //printf("exited writing samples to send\n"); - if (nsamples_transmitted != nread_elements*NUM_QUEUES) + nsamples_transmitted = write(tx_fd, &input_samples_dma_obs_test[0], nread_elements*TEST_OBS_NUM_QUEUES); + if (nsamples_transmitted != nread_elements*TEST_OBS_NUM_QUEUES) { std::cout << "Error : DMA could not send all the requested samples" << std::endl; } @@ -505,7 +469,6 @@ void *handler_DMA_obs_test(void *arguments) close(tx_fd); fclose(rx_signal_file_id); - //printf("DMA finished\n"); return NULL; } @@ -516,23 +479,6 @@ bool HybridObservablesTestFpga::acquire_signal() pthread_t thread_DMA; - int baseband_sampling_freq_acquisition; - // step 0 determine the sampling frequency - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - //printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - //printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); - } - else - { - baseband_sampling_freq_acquisition = baseband_sampling_freq; - } - // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) gr::top_block_sptr top_block; top_block = gr::make_top_block("Acquisition test"); @@ -543,24 +489,6 @@ bool HybridObservablesTestFpga::acquire_signal() tmp_gnss_synchro.Channel_ID = 0; config = std::make_shared(); config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); - //config->set_property("Acquisition.blocking_on_standby", "true"); -- not used in the HW - //config->set_property("Acquisition.blocking", "true"); -- not used in the HW - //config->set_property("Acquisition.dump", "false"); -- not used in the HW - //config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); -- not used in the HW - //config->set_property("Acquisition.use_CFAR_algorithm", "false"); -- not used in the HW at this moment - - //config->set_property("Acquisition.item_type", "cshort"); - //config->set_property("Acquisition.if", "0"); - //config->set_property("Acquisition.sampled_ms", "4"); - //config->set_property("Acquisition.select_queue_Fpga", "0"); - //config->set_property("Acquisition.devicename", "/dev/uio0"); - - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - - //if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - //{ - // config->set_property("Acquisition.acquire_pilot", "false"); -- ALREADY THE DEFAULT VALUE - //} std::shared_ptr acquisition; @@ -569,20 +497,13 @@ bool HybridObservablesTestFpga::acquire_signal() struct DMA_handler_args_obs_test args; //create the correspondign acquisition block according to the desired tracking signal - //printf("AAAAAAAAAAAAAAAAAAAAA\n"); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.select_queue_Fpga", "0"); - //config->set_property("Acquisition.sampled_ms", "1"); - //printf("AAAAAAAAAAAAAAAAAAAAA2222\n"); tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L1 CA"; - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - ////acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); args.freq_band = 0; @@ -591,15 +512,11 @@ bool HybridObservablesTestFpga::acquire_signal() } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.select_queue_Fpga", "0"); - //config->set_property("Acquisition.sampled_ms", "4"); tmp_gnss_synchro.System = 'E'; std::string signal = "1B"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E1B"; - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); args.freq_band = 0; @@ -609,15 +526,11 @@ bool HybridObservablesTestFpga::acquire_signal() else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.select_queue_Fpga", "1"); - //config->set_property("Acquisition.sampled_ms", "1"); tmp_gnss_synchro.System = 'E'; std::string signal = "5X"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E5a"; - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); args.freq_band = 1; @@ -626,15 +539,11 @@ bool HybridObservablesTestFpga::acquire_signal() } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.select_queue_Fpga", "1"); - //config->set_property("Acquisition.sampled_ms", "1"); tmp_gnss_synchro.System = 'G'; std::string signal = "L5"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L5I"; - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); args.freq_band = 1; @@ -652,9 +561,6 @@ bool HybridObservablesTestFpga::acquire_signal() acquisition->connect(top_block); std::string file = FLAGS_signal_file; - const char* file_name = file.c_str(); - -// struct DMA_handler_args_obs_test args; boost::shared_ptr msg_rx; try @@ -697,412 +603,31 @@ bool HybridObservablesTestFpga::acquire_signal() setup_fpga_switch_obs_test(); - unsigned int code_length; unsigned int nsamples_to_transfer; if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS))); } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / GPS_L5I_CODE_LENGTH_CHIPS))); } - float nbits = ceilf(log2f((float)code_length*2)); - unsigned int fft_size = pow(2, nbits); - unsigned int nsamples_total = fft_size; - //printf("EEEEEEEEEEEEEEEEEEEEE nbits = %f nsamples_total = %d\n", nbits, fft_size); - int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); - /* - if (doppler_loop_control_in_sw_obs_test == 1) - { - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - //printf("EEEEEEEEEEEEEEEEEEEEEEE2\n"); - acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->set_single_doppler_flag(1); - } - - - int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - - float result_table[MAX_PRN_IDX][num_doppler_steps][3]; - - uint32_t index_debug[MAX_PRN_IDX]; - uint32_t samplestamp_debug[MAX_PRN_IDX]; for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 6; PRN < 8; PRN++) { - //printf("PRN %d\n", PRN); - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; - - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - - //printf("main loop doppler_shift = %d\n", doppler_shift); - tmp_gnss_synchro.PRN = PRN; - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL1Ca_Fpga->set_doppler_step(0); - - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("starting configuring acquisition\n"); - acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE1_Fpga->set_doppler_step(0); - - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - args.freq_band = 0; - //printf("ffffffffffff ending configuring acquisition\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE5a_Fpga->set_doppler_step(0); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL5_Fpga->set_doppler_step(0); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - args.freq_band = 1; - } - - args.file = file; - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("gggggggg \n"); - //---------------------------------------------------------------------------------- - // send the previous samples to set the downsampling filter in a good condition - send_samples_start_obs_test = 0; - if (test_observables_skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - else - { - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - //printf("sending pre init %d\n", args.nsamples_tx); - - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - pthread_mutex_lock(&mutex); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex); - pthread_join(thread_DMA, NULL); - send_samples_start_obs_test = 0; - - //printf("finished sending samples init filter status and back to main thread\n"); - //----------------------------------------------------------------------------------- - - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - if (test_observables_skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - else - { - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - } - else - { - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - if (test_observables_skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size; - } - else - { - args.skip_used_samples = 0; - } - } - - - - // create DMA child process - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - - msg_rx->rx_message = 0; - top_block->start(); - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex_obs_test); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->reset(); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); - } - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); - - while (msg_rx->rx_message == 0) - { - usleep(100000); - } - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("iiiiiiiiiiiiii\n"); - acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - - result_table[PRN][doppler_num][0] = max_magnitude_iteration; - result_table[PRN][doppler_num][1] = second_magnitude_iteration; - result_table[PRN][doppler_num][2] = total_fft_scaling_factor; - doppler_num = doppler_num + 1; - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("jjjjjjjjjjjjjjj\n"); - if (max_magnitude_iteration > max_magnitude) - { - int interpolation_factor = 4; - index_debug[PRN - 1] = max_index_iteration; - max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - samplestamp_debug[PRN - 1] = initial_sample_iteration; - initial_sample = 0; //initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - else - { - - if (max_magnitude_iteration > max_magnitude) - { - max_index = max_index_iteration; - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - initial_sample = initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - top_block->stop(); - } - - -// power_sum = (power_sum - max_magnitude) / (fft_size - 1); -// float test_statistics = (max_magnitude / power_sum); -// float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); -// if (test_statistics > threshold) - float test_statistics = max_magnitude/second_magnitude; - float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); - if (test_statistics > threshold) - { - std::cout << " " << PRN << " "; - - //doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); - //code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); - //acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) - - tmp_gnss_synchro.Acq_doppler_hz = doppler_shift_selected; - tmp_gnss_synchro.Acq_delay_samples = max_index; - tmp_gnss_synchro.Acq_samplestamp_samples = initial_sample; // delay due to the downsampling filter in the acquisition - - - gnss_synchro_vec.push_back(tmp_gnss_synchro); - } - else - { - std::cout << " . "; - } - - std::cout.flush(); - - } - - uint32_t max_index = 0; - uint32_t total_fft_scaling_factor; - //uint32_t fw_fft_scaling_factor; - float max_magnitude = 0.0; - uint64_t initial_sample = 0; - float second_magnitude = 0; - float peak_to_power = 0; - float test_statistics; - uint32_t doppler_index = 0; - - if (test_observables_show_results_table == 1) - { - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; - int doppler_num = 0; - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - max_magnitude = result_table[PRN][doppler_num][0]; - //power_sum = result_table[PRN][doppler_num][1]; - second_magnitude = result_table[PRN][doppler_num][1]; - total_fft_scaling_factor = result_table[PRN][doppler_num][2]; - doppler_num = doppler_num + 1; - - std::cout << "==================== Doppler shift " << doppler_shift << std::endl; - std::cout << "Max magnitude = " << max_magnitude << std::endl; - std::cout << "Second magnitude = " << second_magnitude << std::endl; - std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; - test_statistics = (max_magnitude / second_magnitude); - std::cout << " test_statistics = " << test_statistics << std::endl; - - } - int dummy_val; - std::cout << "Enter a value to continue"; - std::cin >> dummy_val; - } - } - } - else // DOPPLER CONTROL IN HW - { - */ - - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 0; PRN < 17; PRN++) - { - - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; tmp_gnss_synchro.PRN = PRN; @@ -1120,53 +645,39 @@ bool HybridObservablesTestFpga::acquire_signal() if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) { - //printf("gggggggg \n"); - //---------------------------------------------------------------------------------- - // send the previous samples to set the downsampling filter in a good condition - //send_samples_start = 0; - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + args.skip_used_samples = - TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES; - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - - //printf("sending pre init %d\n", args.nsamples_tx); + args.nsamples_tx = TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES + TEST_OBS_DOWNSAMPLING_FILTER_DELAY; if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { - printf("ERROR cannot create DMA Process\n"); + std::cout << "ERROR cannot create DMA Process" << std::endl; } pthread_mutex_lock(&mutex); send_samples_start_obs_test = 1; pthread_mutex_unlock(&mutex); pthread_join(thread_DMA, NULL); send_samples_start_obs_test = 0; - //printf("finished sending samples init filter status\n"); - //----------------------------------------------------------------------------------- - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + args.nsamples_tx = nsamples_to_transfer; - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; + args.skip_used_samples = TEST_OBS_DOWNSAMPLING_FILTER_DELAY; } else { - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + + args.nsamples_tx = nsamples_to_transfer; args.skip_used_samples = 0; } - - - // create DMA child process - //printf("||||||||1 args freq_band = %d\n", args.freq_band); - //printf("sending samples main DMA %d\n", args.nsamples_tx); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { - printf("ERROR cannot create DMA Process\n"); + std::cout << "ERROR cannot create DMA Process" << std::endl; } msg_rx->rx_message = 0; @@ -1178,10 +689,6 @@ bool HybridObservablesTestFpga::acquire_signal() acquisition->reset(); // set active -// pthread_mutex_lock(&mutex); // it doesn't work if it is done here -// send_samples_start = 1; -// pthread_mutex_unlock(&mutex); - if (start_msg == true) { std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; @@ -1197,11 +704,6 @@ bool HybridObservablesTestFpga::acquire_signal() send_samples_start_obs_test = 0; pthread_mutex_unlock(&mutex); -// while (msg_rx->rx_message == 0) -// { -// usleep(100000); -// } - // the DMA sends the exact number of samples needed for the acquisition. // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra @@ -1223,89 +725,21 @@ bool HybridObservablesTestFpga::acquire_signal() gnss_synchro_vec.push_back(tmp_gnss_synchro); -// doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); -// code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); -// tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation -// acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); } else { std::cout << " . "; } -// while (msg_rx->rx_message == 0) -// { -// usleep(100000); -// } -// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) -// { -// //printf("iiiiiiiiiiiiii\n"); -// acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// -// if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) -// { -// int interpolation_factor = 4; -// //index_debug[PRN - 1] = max_index_iteration; -// max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); -// max_magnitude = max_magnitude_iteration; -// second_magnitude = second_magnitude_iteration; -// //samplestamp_debug[PRN - 1] = initial_sample_iteration; -// initial_sample = 0; //initial_sample_iteration; -// doppler_index = doppler_index_iteration; -// doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); -// } -// else -// { -// max_index = max_index_iteration; -// max_magnitude = max_magnitude_iteration; -// second_magnitude = second_magnitude_iteration; -// initial_sample = initial_sample_iteration; -// doppler_index = doppler_index_iteration; -// doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); -// } top_block->stop(); -// float test_statistics = max_magnitude/second_magnitude; -// float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); -// if (test_statistics > threshold) -// { -// //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); -// std::cout << " " << PRN << " "; -// doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); -// code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); -// code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); -// acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) -// } -// else -// { -// std::cout << " . "; -// } + std::cout.flush(); -/* } */ - } -// } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -1392,19 +826,6 @@ void HybridObservablesTestFpga::configure_receiver( config->set_property("TelemetryDecoder.implementation", "Galileo_E1B_Telemetry_Decoder"); } -// else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking") == 0) -// { -// gnss_synchro_master.System = 'G'; -// std::string signal = "2S"; -// System_and_Signal = "GPS L2CM"; -// const char* str = signal.c_str(); // get a C style null terminated string -// std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null -// -// config->set_property("Tracking.early_late_space_chips", "0.5"); -// config->set_property("Tracking.track_pilot", "false"); -// -// config->set_property("TelemetryDecoder.implementation", "GPS_L2C_Telemetry_Decoder"); -// } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) { gnss_synchro_master.System = 'E'; @@ -1413,10 +834,6 @@ void HybridObservablesTestFpga::configure_receiver( const char* str = signal.c_str(); // get a C style null terminated string std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null - //if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) - // { - // config->supersede_property("Tracking.implementation", std::string("Galileo_E5a_DLL_PLL_Tracking")); - // } config->set_property("Tracking.early_late_space_chips", "0.5"); config->set_property("Tracking.track_pilot", "true"); config->set_property("Tracking.order", "2"); @@ -2075,10 +1492,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) { generate_signal(); } - else - { - //printf("PATH IS OK 0 \n"); - } + std::chrono::time_point start, end; std::chrono::duration elapsed_seconds(0); @@ -2086,7 +1500,6 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // use generator or use an external capture file if (FLAGS_enable_external_signal_file) { - //printf("PATH IS OK 1 \n"); //create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters ASSERT_EQ(acquire_signal(), true); } @@ -2106,22 +1519,18 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) gnss_synchro_vec.push_back(tmp_gnss_synchro); } } - //printf("KKKKKKKKK FIRST PART FINISHED\n"); - //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ Signal Acquired\n"); configure_receiver(FLAGS_PLL_bw_hz_start, FLAGS_DLL_bw_hz_start, FLAGS_PLL_narrow_bw_hz, FLAGS_DLL_narrow_bw_hz, FLAGS_extend_correlation_symbols); - //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ Receiver Configured\n"); for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) { //setup the signal synchronization, simulating an acquisition if (!FLAGS_enable_external_signal_file) { - //printf("HERE\n"); //based on true observables metadata (for custom sdr generator) //open true observables log file written by the simulator or based on provided RINEX obs //std::vector> true_reader_vec; @@ -2158,49 +1567,13 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } else { - //printf("OR THERE\n"); //based on the signal acquisition process std::cout << "Estimated Initial Doppler " << gnss_synchro_vec.at(n).Acq_doppler_hz << " [Hz], estimated Initial code delay " << gnss_synchro_vec.at(n).Acq_delay_samples << " [Samples]" << " Acquisition SampleStamp is " << gnss_synchro_vec.at(n).Acq_samplestamp_samples << std::endl; - //gnss_synchro_vec.at(n).Acq_samplestamp_samples = 0; // caution ! samplestamp_samples may not zero if doppler runs inside the FPGA } } - //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ First part is done\n"); - - unsigned int code_length; - //unsigned int nsamples_to_transfer; - - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //printf("sssssss code_length = %d \n", code_length); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - //printf("sssssss code_length = %d \n", code_length); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); - //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //printf("sssssss code_length = %d \n", code_length); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); - //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //printf("sssssss code_length = %d \n", code_length); - } - - - float nbits = ceilf(log2f((float)code_length*2)); - unsigned int fft_size = pow(2, nbits); // The HW has been reset after the acquisition phase when the acquisition class was destroyed. // No more samples remained in the DMA. Therefore any intermediate state in the LPF of the @@ -2302,10 +1675,8 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } std::string file; - const char* file_name; ASSERT_NO_THROW({ - //std::string file; if (!FLAGS_enable_external_signal_file) { file = "./" + filename_raw_data; @@ -2314,14 +1685,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) { file = FLAGS_signal_file; } - //const char* file_name = file.c_str(); - file_name = file.c_str(); - //gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); - //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); int observable_interval_ms = 20; - //gnss_sdr_sample_counter_sptr samp_counter = gnss_sdr_make_sample_counter(static_cast(baseband_sampling_freq), observable_interval_ms, sizeof(gr_complex)); - //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); - //top_block->connect(gr_interleaved_char_to_complex, 0, samp_counter, 0); double fs = static_cast(config->property("GNSS-SDR.internal_fs_sps", 0)); @@ -2342,28 +1706,17 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) //top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); top_block->connect(ch_out_fpga_sample_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); //extra port for the sample counter pulse - //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample }) << "Failure connecting the blocks."; args.file = file; - //args.nsamples_tx = TEST_OBS_NSAMPLES_TRACKING; // number of samples to transfer args.nsamples_tx = baseband_sampling_freq*FLAGS_duration;; - //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) - //{ - // args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; - //} - //else - //{ - args.skip_used_samples = 0; - //} + args.skip_used_samples = 0; - //printf("2222222222222 CREATE PROCES\n"); - //printf("%s\n", file.c_str()); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { - printf("ERROR cannot create DMA Process\n"); + std::cout << "ERROR cannot create DMA Process" << std::endl; } @@ -2372,15 +1725,12 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) tracking_ch_vec.at(n)->start_tracking(); } - - //printf("222222222222222222 bis\n"); pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 1; pthread_mutex_unlock(&mutex_obs_test); top_block->start(); - //printf("33333333333333333333 top block started\n"); @@ -2396,37 +1746,9 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) pthread_join(thread_DMA, NULL); - - //printf("444444444444 CHILD PROCESS FINISHED\n"); - top_block->stop(); - //printf("55555555555 TOP BLOCK STOPPED\n"); - - - /* - // send more samples to unblock the tracking process in case it was waiting for samples - args.file = file; - //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) - //{ - // skip the samples that have already been used - args.skip_used_samples = 0; //args.nsamples_tx; - //} - //else - //{ - // args.skip_used_samples = 0; - //} - args.nsamples_tx = TEST_OBS_NSAMPLES_FINAL; - //printf("666666666 CREATE PROCESS TO SEND EXTRA SAMPLES\n"); - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - pthread_join(thread_DMA, NULL); - //printf("777777777 PROCESS FINISHED \n"); -*/ - // reset the HW AGAIN acquisition->stop_acquisition(); @@ -2512,18 +1834,12 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } estimated_observables.restart(); - //printf("Observables : ............................\n"); while (estimated_observables.read_binary_obs()) { for (unsigned int n = 0; n < measured_obs_vec.size(); n++) { if (static_cast(estimated_observables.valid[n])) { - //printf("estimated_observables.RX_time[%d] = %d\n", n, estimated_observables.RX_time[n]); - //printf("estimated_observables.TOW_at_current_symbol_s[%d] = %d\n", n, estimated_observables.TOW_at_current_symbol_s[n]); - //printf("estimated_observables.Carrier_Doppler_hz[%d] = %d\n", n, estimated_observables.Carrier_Doppler_hz[n]); - //printf("estimated_observables.Acc_carrier_phase_hz[%d] = %d\n", n, estimated_observables.Acc_carrier_phase_hz[n]); - //printf("estimated_observables.Pseudorange_m[%d] = %d\n", n, estimated_observables.Pseudorange_m[n]); measured_obs_vec.at(n)(epoch_counters_vec.at(n), 0) = estimated_observables.RX_time[n]; measured_obs_vec.at(n)(epoch_counters_vec.at(n), 1) = estimated_observables.TOW_at_current_symbol_s[n]; measured_obs_vec.at(n)(epoch_counters_vec.at(n), 2) = estimated_observables.Carrier_Doppler_hz[n]; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 0ac450cbf..3675efe5d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -2,12 +2,12 @@ * \file tracking_pull-in_test_fpga.cc * \brief This class implements a tracking Pull-In test for FPGA HW accelerator * implementations based on some input parameters. - * \author Marc Majoral, 2018. majoralmarc(at)cttc.es + * \author Marc Majoral, 2019. majoralmarc(at)cttc.es * Javier Arribas, 2018. jarribas(at)cttc.es * * * ------------------------------------------------------------------------- - * Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -31,31 +31,15 @@ */ #include "GPS_L1_CA.h" -//<<<<<<< HEAD -//#include "Galileo_E1.h" -//#include "Galileo_E5a.h" -//#include "GPS_L5.h" -//======= #include "acquisition_msg_rx.h" #include "galileo_e5a_noncoherent_iq_acquisition_caf.h" #include "galileo_e5a_pcps_acquisition.h" -//>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 #include "gnss_block_factory.h" #include "tracking_interface.h" #include "gps_l1_ca_pcps_acquisition_fpga.h" #include "galileo_e1_pcps_ambiguous_acquisition_fpga.h" #include "galileo_e5a_pcps_acquisition_fpga.h" #include "gps_l5i_pcps_acquisition_fpga.h" -//======= -//#include "galileo_e5a_noncoherent_iq_acquisition_caf.h" -//#include "galileo_e5a_pcps_acquisition.h" -//#include "gnss_block_factory.h" -//#include "gnuplot_i.h" -//#include "gps_l1_ca_pcps_acquisition.h" -//#include "gps_l1_ca_pcps_acquisition_fine_doppler.h" -//#include "gps_l2_m_pcps_acquisition.h" -//#include "gps_l5i_pcps_acquisition.h" -//>>>>>>> b6f0c92fd61c2d20888265dac7e4cca64e7a42cb #include "in_memory_configuration.h" #include "signal_generator_flags.h" #include "test_flags.h" @@ -85,22 +69,14 @@ #define MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define NSAMPLES_TRACKING 1000000000 // number of samples during which we test the tracking module -#define NSAMPLES_FINAL 60000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module -#define NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop #define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter -#define DOWNSAMPLING_FILTER_DELAY 48 -#define DOWNSAMPLING_FILTER_OFFSET_SAMPLES 0 +#define DOWNSAMPLING_FILTER_DELAY 48 // delay of the downsampling filter in samples + + // HW related options -bool show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results, 0=> do not show it bool skip_samples_already_used = 0; // if skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops // (exactly in the same way as the SW) -bool doppler_loop_control_in_sw = 0; -//<<<<<<< HEAD - - -// ######## GNURADIO ACQUISITION BLOCK MESSAGE RECEVER ######### class Acquisition_msg_rx_Fpga; typedef boost::shared_ptr Acquisition_msg_rx_Fpga_sptr; @@ -148,9 +124,7 @@ Acquisition_msg_rx_Fpga::Acquisition_msg_rx_Fpga() : gr::block("Acquisition_msg_ } Acquisition_msg_rx_Fpga::~Acquisition_msg_rx_Fpga() {} -//======= -//>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 -// ######## GNURADIO TRACKING BLOCK MESSAGE RECEVER ######### + class TrackingPullInTestFpga_msg_rx; typedef boost::shared_ptr TrackingPullInTestFpga_msg_rx_sptr; @@ -200,8 +174,6 @@ TrackingPullInTestFpga_msg_rx::~TrackingPullInTestFpga_msg_rx() { } -// ########################################################### - class TrackingPullInTestFpga : public ::testing::Test { public: @@ -323,13 +295,12 @@ void TrackingPullInTestFpga::configure_receiver( config->set_property("Tracking.dump", "true"); config->set_property("Tracking.dump_filename", "./tracking_ch_"); config->set_property("Tracking.implementation", implementation); - //config->set_property("Tracking.item_type", "gr_complex"); config->set_property("Tracking.item_type", "cshort"); config->set_property("Tracking.pll_bw_hz", std::to_string(PLL_wide_bw_hz)); config->set_property("Tracking.dll_bw_hz", std::to_string(DLL_wide_bw_hz)); - //config->set_property("Tracking.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); - //config->set_property("Tracking.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); - //config->set_property("Tracking.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); + config->set_property("Tracking.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); + config->set_property("Tracking.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); + config->set_property("Tracking.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); gnss_synchro.PRN = FLAGS_test_satellite_PRN; gnss_synchro.Channel_ID = 0; config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); @@ -343,8 +314,6 @@ void TrackingPullInTestFpga::configure_receiver( System_and_Signal = "GPS L1 CA"; signal.copy(gnss_synchro.Signal, 2, 0); config->set_property("Tracking.early_late_space_chips", "0.5"); - //config->set_property("Tracking.early_late_space_narrow_chips", "0.5"); - // added by me config->set_property("Tracking.if", "0"); config->set_property("Tracking.order", "3"); @@ -358,8 +327,6 @@ void TrackingPullInTestFpga::configure_receiver( signal.copy(gnss_synchro.Signal, 2, 0); config->set_property("Tracking.early_late_space_chips", "0.15"); config->set_property("Tracking.very_early_late_space_chips", "0.6"); - //config->set_property("Tracking.early_late_space_narrow_chips", "0.15"); - //config->set_property("Tracking.very_early_late_space_narrow_chips", "0.6"); config->set_property("Tracking.track_pilot", "true"); // added by me @@ -374,10 +341,6 @@ void TrackingPullInTestFpga::configure_receiver( std::string signal = "5X"; System_and_Signal = "Galileo E5a"; signal.copy(gnss_synchro.Signal, 2, 0); - //if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) - // { - // config->supersede_property("Tracking.implementation", std::string("Galileo_E5a_DLL_PLL_Tracking")); - // } config->set_property("Tracking.early_late_space_chips", "0.5"); config->set_property("Tracking.track_pilot", "false"); config->set_property("Tracking.order", "2"); @@ -479,7 +442,6 @@ void *handler_DMA(void *arguments) unsigned int nread_elements; // number of elements effectively read from the input file unsigned int nsamples = 0; // number of complex samples effectively transferred unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA - unsigned int num_bytes_to_transfer; // DMA transfer block size in bytes unsigned int nsamples_transmitted; @@ -500,7 +462,7 @@ void *handler_DMA(void *arguments) // open input file rx_signal_file_id = fopen(file.c_str(), "rb"); - if (rx_signal_file_id < 0) + if (rx_signal_file_id == NULL) { std::cout << "DMA can't open input file" << std::endl; exit(1); @@ -513,7 +475,6 @@ void *handler_DMA(void *arguments) fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); usleep(50000); // wait some time to give time to the main thread to start the acquisition module - unsigned int kk; while (file_completed == false) { @@ -586,21 +547,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { pthread_t thread_DMA; - int baseband_sampling_freq_acquisition; - // step 0 determine the sampling frequency - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - } - else - { - baseband_sampling_freq_acquisition = baseband_sampling_freq; - } - // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) gr::top_block_sptr top_block; top_block = gr::make_top_block("Acquisition test"); @@ -652,8 +598,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.sampled_ms", "1"); - //config->set_property("Acquisition.select_queue_Fpga", "1"); tmp_gnss_synchro.System = 'E'; std::string signal = "5X"; const char* str = signal.c_str(); // get a C style null terminated string @@ -693,10 +637,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::string file = FLAGS_signal_file; - //struct DMA_handler_args args; - - const char* file_name = file.c_str(); - boost::shared_ptr msg_rx; try { @@ -743,527 +683,134 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) setup_fpga_switch(); - unsigned int code_length; unsigned int nsamples_to_transfer; if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } - float nbits = ceilf(log2f((float)code_length*2)); - unsigned int fft_size = pow(2, nbits); - unsigned int nsamples_total = fft_size; - int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + + tmp_gnss_synchro.PRN = PRN; + + acquisition->stop_acquisition(); // reset the whole system including the sample counters + acquisition->set_doppler_max(acq_doppler_max); + acquisition->set_doppler_step(acq_doppler_step); + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->init(); + acquisition->set_local_code(); + + args.file = file; + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + // send the previous samples to set the downsampling filter in a good condition + send_samples_start = 0; -/* - if (doppler_loop_control_in_sw == 1) - { + args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { - acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); + std::cout << "ERROR cannot create DMA Process" << std::endl; } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_single_doppler_flag(1); - //printf("eeeeeee just set doppler flag\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + pthread_join(thread_DMA, NULL); + send_samples_start = 0; - acquisition_GpsL5_Fpga->set_single_doppler_flag(1); + args.nsamples_tx = nsamples_to_transfer; + + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY; + + } + else + { + args.nsamples_tx = nsamples_to_transfer; + + args.skip_used_samples = 0; + } + + + + + + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + + + acquisition->reset(); // set active + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; } - int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - - float result_table[MAX_PRN_IDX][num_doppler_steps][3]; - - //uint32_t index_debug[MAX_PRN_IDX]; - //uint32_t samplestamp_debug[MAX_PRN_IDX]; - - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 0; PRN < 17; PRN++) - { - - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; - - - - - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - //printf("doppler_shift = %d\n", doppler_shift); - tmp_gnss_synchro.PRN = PRN; - - pthread_mutex_lock(&mutex); - send_samples_start = 0; - pthread_mutex_unlock(&mutex); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL1Ca_Fpga->set_doppler_step(0); - - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("starting configuring acquisition\n"); - acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE1_Fpga->set_doppler_step(0); - - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - args.freq_band = 0; - //printf("ffffffffffff ending configuring acquisition\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE5a_Fpga->set_doppler_step(0); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL5_Fpga->set_doppler_step(0); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - args.freq_band = 1; - } - - args.file = file; - - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("gggggggg \n"); - //---------------------------------------------------------------------------------- - // send the previous samples to set the downsampling filter in a good condition - send_samples_start = 0; - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - else - { - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - //printf("sending pre init %d\n", args.nsamples_tx); - - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); - pthread_join(thread_DMA, NULL); - send_samples_start = 0; - //printf("finished sending samples init filter status\n"); - //----------------------------------------------------------------------------------- - - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - else - { - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - } - else - { - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size; - } - else - { - args.skip_used_samples = 0; - } - } - - - - - // create DMA child process - //printf("||||||||1 args freq_band = %d\n", args.freq_band); - //printf("sending samples main DMA %d\n", args.nsamples_tx); - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - - msg_rx->rx_message = 0; - top_block->start(); - - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("hhhhhhhhhhhh\n"); - acquisition_GpsE1_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); // set active - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); // set active - } - - // pthread_mutex_lock(&mutex); // it doesn't work if it is done here - // send_samples_start = 1; - // pthread_mutex_unlock(&mutex); - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex); - send_samples_start = 0; - pthread_mutex_unlock(&mutex); - - while (msg_rx->rx_message == 0) - { - usleep(100000); - } - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("iiiiiiiiiiiiii\n"); - acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - - result_table[PRN][doppler_num][0] = max_magnitude_iteration; - result_table[PRN][doppler_num][1] = second_magnitude_iteration; - result_table[PRN][doppler_num][2] = total_fft_scaling_factor; - doppler_num = doppler_num + 1; - - //printf("max_magnitude_iteration = %f\n", max_magnitude_iteration); - //printf("second_magnitude_iteration = %f\n", second_magnitude_iteration); - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("jjjjjjjjjjjjjjj\n"); - if (max_magnitude_iteration > max_magnitude) - { - int interpolation_factor = 4; - //index_debug[PRN - 1] = max_index_iteration; - max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - //samplestamp_debug[PRN - 1] = initial_sample_iteration; - initial_sample = 0; //initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - else - { - - if (max_magnitude_iteration > max_magnitude) - { - max_index = max_index_iteration; - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - initial_sample = initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - top_block->stop(); - } - - //power_sum = (power_sum - max_magnitude) / (fft_size - 1); - //float test_statistics = (max_magnitude / power_sum); - float test_statistics = max_magnitude/second_magnitude; - float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); - if (test_statistics > threshold) - { - //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); - std::cout << " " << PRN << " "; - doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); - code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); - code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); - acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) - } - else - { - std::cout << " . "; - } - - std::cout.flush(); - - } - - uint32_t max_index = 0; - uint32_t total_fft_scaling_factor; - //uint32_t fw_fft_scaling_factor; - float max_magnitude = 0.0; - uint64_t initial_sample = 0; - float second_magnitude = 0; - float peak_to_power = 0; - float test_statistics; - uint32_t doppler_index = 0; - - if (show_results_table == 1) - { - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; - int doppler_num = 0; - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - max_magnitude = result_table[PRN][doppler_num][0]; - second_magnitude = result_table[PRN][doppler_num][1]; - total_fft_scaling_factor = result_table[PRN][doppler_num][2]; - //fw_fft_scaling_factor = result_table[PRN][doppler_num][3]; - doppler_num = doppler_num + 1; - - std::cout << "==================== Doppler shift " << doppler_shift << std::endl; - std::cout << "Max magnitude = " << max_magnitude << std::endl; - std::cout << "Second magnitude = " << second_magnitude << std::endl; - std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; - //peak_to_power = max_magnitude/power_sum; - //power_sum = (power_sum - max_magnitude) / (fft_size - 1); - test_statistics = (max_magnitude / second_magnitude); - std::cout << " test_statistics = " << test_statistics << std::endl; - } - int dummy_val; - std::cout << "Enter a value to continue"; - std::cin >> dummy_val; - } - } - } - else // DOPPLER CONTROL IN HW - { -*/ - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; - - tmp_gnss_synchro.PRN = PRN; - - acquisition->stop_acquisition(); // reset the whole system including the sample counters - acquisition->set_doppler_max(acq_doppler_max); - acquisition->set_doppler_step(acq_doppler_step); - acquisition->set_gnss_synchro(&tmp_gnss_synchro); - acquisition->init(); - acquisition->set_local_code(); - - args.file = file; - - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //---------------------------------------------------------------------------------- - // send the previous samples to set the downsampling filter in a good condition - send_samples_start = 0; - - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - std::cout << "ERROR cannot create DMA Process" << std::endl; - } - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); - pthread_join(thread_DMA, NULL); - send_samples_start = 0; - //----------------------------------------------------------------------------------- - - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - - } - else - { - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - args.skip_used_samples = 0; - } - - - - - - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - std::cout << "ERROR cannot create DMA Process" << std::endl; - } - - msg_rx->rx_message = 0; - top_block->start(); - - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); - - - acquisition->reset(); // set active - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex); - send_samples_start = 0; - pthread_mutex_unlock(&mutex); - - // the DMA sends the exact number of samples needed for the acquisition. - // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate - // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra - // sample the DMA might have sent. - do { - usleep(100000); - } while (msg_rx->rx_message == 0); - - if (msg_rx->rx_message == 1) - { - std::cout << " " << PRN << " "; - doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); - code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); - tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation - acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); - } - else - { - std::cout << " . "; - } - - - top_block->stop(); - - std::cout.flush(); - -/* } */ - - - } + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex); + send_samples_start = 0; + pthread_mutex_unlock(&mutex); + + // the DMA sends the exact number of samples needed for the acquisition. + // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate + // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra + // sample the DMA might have sent. + do { + usleep(100000); + } while (msg_rx->rx_message == 0); + + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); + code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); + tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation + acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); + } + else + { + std::cout << " . "; + } + + + top_block->stop(); + + std::cout.flush(); + + } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -1425,7 +972,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); } @@ -1533,11 +1080,9 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) //******************************************************************** - //args.nsamples_tx = NSAMPLES_TRACKING; // number of samples to transfer args.nsamples_tx = baseband_sampling_freq*FLAGS_duration; - //if (pthread_create(&thread_DMA, NULL, handler_DMA_tracking, (void *)&args) < 0) if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { std::cout << "ERROR cannot create DMA Process" << std::endl;