diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 7fe87c9f6..af36b9c4a 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -223,7 +223,7 @@ void pcps_acquisition_fpga::set_active(bool active) // no CFAR algorithm in the FPGA << ", use_CFAR_algorithm_flag: false"; - unsigned long int initial_sample; + unsigned long long int initial_sample; float input_power_all = 0.0; float input_power_computed = 0.0; @@ -325,11 +325,11 @@ void pcps_acquisition_fpga::set_active(bool active) if (d_test_statistics > d_threshold) { d_active = false; - printf("##### d_test_statistics = %f\n", d_test_statistics); - printf("##### debug_d_max_absolute =%f\n",debug_d_max_absolute); - printf("##### debug_d_input_power_absolute =%f\n",debug_d_input_power_absolute); - printf("##### initial_sample = %lu\n",initial_sample); - printf("##### debug_doppler_index = %d\n",debug_doppler_index); +// printf("##### d_test_statistics = %f\n", d_test_statistics); +// printf("##### debug_d_max_absolute =%f\n",debug_d_max_absolute); +// printf("##### debug_d_input_power_absolute =%f\n",debug_d_input_power_absolute); +// printf("##### initial_sample = %llu\n",initial_sample); +// printf("##### debug_doppler_index = %d\n",debug_doppler_index); send_positive_acquisition(); d_state = 0; // Positive acquisition } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index e684b0971..7775a14e8 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -115,7 +115,7 @@ private: unsigned int d_doppler_step; unsigned int d_fft_size; unsigned int d_num_doppler_bins; - unsigned long int d_sample_counter; + unsigned long long int d_sample_counter; Gnss_Synchro* d_gnss_synchro; std::shared_ptr acquisition_fpga; diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 4e74e1779..6bb2ff266 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -369,18 +369,20 @@ void fpga_acquisition::set_phase_step(unsigned int doppler_index) void fpga_acquisition::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, unsigned long int *initial_sample, float *power_sum, unsigned *doppler_index) + float *max_magnitude, unsigned long long int *initial_sample, float *power_sum, unsigned *doppler_index) { - unsigned long int initial_sample_tmp; + unsigned long long int initial_sample_tmp = 0; + unsigned readval = 0; - unsigned long int readval_long = 0; + unsigned long long int readval_long = 0; + unsigned long long int readval_long_shifted = 0; readval = d_map_base[1]; initial_sample_tmp = readval; - //*initial_sample = readval; - //printf("read initial sample dmap 1 = %d\n", readval); readval_long = d_map_base[2]; - initial_sample_tmp = initial_sample_tmp + (readval_long * (2^32)); + readval_long_shifted = readval_long << 32; // 2^32 + initial_sample_tmp = initial_sample_tmp + readval_long_shifted; // 2^32 + //printf("----------------------------------------------------------------> acq initial sample TOTAL = %llu\n", initial_sample_tmp); *initial_sample = initial_sample_tmp; readval = d_map_base[6]; *max_magnitude = static_cast(readval); diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index 8219037a7..36bb4df0e 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -61,7 +61,7 @@ public: void run_acquisition(void); void set_phase_step(unsigned int doppler_index); void read_acquisition_results(uint32_t *max_index, float *max_magnitude, - unsigned long int *initial_sample, float *power_sum, unsigned *doppler_index); + unsigned long long int *initial_sample, float *power_sum, unsigned *doppler_index); void block_samples(); void unblock_samples(); 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 7ea045401..a04d9fede 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 @@ -1251,15 +1251,15 @@ int dll_pll_veml_tracking_fpga::general_work (int noutput_items __attribute__((u { d_pull_in = 0; multicorrelator_fpga->lock_channel(); - unsigned long int counter_value = multicorrelator_fpga->read_sample_counter(); - //printf("333333 counter_value = %d\n", counter_value); + unsigned long long int counter_value = multicorrelator_fpga->read_sample_counter(); + //printf("333333 counter_value = %llu\n", counter_value); //printf("333333 current_synchro_data.Acq_samplestamp_samples = %d\n", current_synchro_data.Acq_samplestamp_samples); //printf("333333 current_synchro_data.Acq_delay_samples = %f\n", current_synchro_data.Acq_delay_samples); //printf("333333 d_correlation_length_samples = %d\n", d_correlation_length_samples); unsigned num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples - current_synchro_data.Acq_delay_samples)/d_correlation_length_samples); //printf("333333 num_frames = %d\n", num_frames); - unsigned long int absolute_samples_offset = current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples + num_frames*d_correlation_length_samples; - //printf("333333 absolute_samples_offset = %d\n", absolute_samples_offset); + unsigned long long int absolute_samples_offset = current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples + num_frames*d_correlation_length_samples; + //printf("333333 absolute_samples_offset = %llu\n", absolute_samples_offset); multicorrelator_fpga->set_initial_sample(absolute_samples_offset); d_absolute_samples_offset = absolute_samples_offset; d_sample_counter = absolute_samples_offset; 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 a58e4b04a..c5419c93c 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 @@ -213,9 +213,9 @@ private: // PRN period in samples int d_current_prn_length_samples; // processing samples counters - unsigned long int d_sample_counter; - unsigned long int d_acq_sample_stamp; - unsigned long int d_absolute_samples_offset; + unsigned long long int d_sample_counter; + unsigned long long int d_acq_sample_stamp; + unsigned long long int d_absolute_samples_offset; // CN0 estimation and lock detector int d_cn0_estimation_counter; @@ -232,7 +232,7 @@ private: // extra int d_correlation_length_samples; int d_next_prn_length_samples; - unsigned long int d_sample_counter_next; + unsigned long long int d_sample_counter_next; unsigned int d_pull_in = 0; diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 5fa8f06fd..a1a051d55 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -84,17 +84,18 @@ #define LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY 0x0C000000 #define TEST_REGISTER_TRACK_WRITEVAL 0x55AA -unsigned long int fpga_multicorrelator_8sc::read_sample_counter() +unsigned long long int fpga_multicorrelator_8sc::read_sample_counter() { - unsigned long int sample_counter_tmp, sample_counter_msw_tmp; + unsigned long long int 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 = sample_counter_tmp + (sample_counter_msw_tmp * (2^32)); + 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(unsigned long int samples_offset) +void fpga_multicorrelator_8sc::set_initial_sample(unsigned long long int 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); diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.h b/src/algorithms/tracking/libs/fpga_multicorrelator.h index 563433297..13c4d21f9 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.h +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.h @@ -68,8 +68,8 @@ public: float rem_code_phase_chips, float code_phase_step_chips, int signal_length_samples);bool free(); void set_channel(unsigned int channel); - void set_initial_sample(unsigned long int samples_offset); - unsigned long int read_sample_counter(); + void set_initial_sample(unsigned long long int samples_offset); + unsigned long long int read_sample_counter(); void lock_channel(void); void unlock_channel(void); //void read_sample_counters(int *sample_counter, int *secondary_sample_counter, int *counter_corr_0_in, int *counter_corr_0_out); // debug @@ -103,7 +103,7 @@ private: unsigned d_code_phase_step_chips_num; int d_rem_carr_phase_rad_int; int d_phase_step_rad_int; - unsigned long int d_initial_sample_counter; + unsigned long long int d_initial_sample_counter; // driver std::string d_device_name;