From a6110eb3347d61d08da5cc9b9f516fc3bac9fc15 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Tue, 2 Apr 2019 18:46:37 +0200 Subject: [PATCH] moved the calculations related to the local code that is specific to the FPGA to the initialisation phase of the tracking modules to save clock cycles during real-time tracking. --- .../galileo_e1_dll_pll_veml_tracking_fpga.cc | 25 ++++++++++--- .../galileo_e5a_dll_pll_tracking_fpga.cc | 28 +++++++++++++-- .../gps_l1_ca_dll_pll_tracking_fpga.cc | 9 +++++ .../adapters/gps_l5_dll_pll_tracking_fpga.cc | 29 +++++++++++++-- .../tracking/libs/fpga_multicorrelator.cc | 35 ++++++++++--------- 5 files changed, 99 insertions(+), 27 deletions(-) diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc index 4c2b90d95..a462cf4c0 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc @@ -83,7 +83,7 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( } trk_param_fpga.pll_bw_hz = pll_bw_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 0.5); - if (FLAGS_dll_bw_hz != 0.0) + if (FLAGS_dll_bw_hz != 0.0) { dll_bw_hz = static_cast(FLAGS_dll_bw_hz); } @@ -228,19 +228,36 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( galileo_e1_code_gen_sinboc11_float(ca_codes_f, pilot_signal, PRN); galileo_e1_code_gen_sinboc11_float(data_codes_f, data_signal, PRN); + // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA for (uint32_t s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++) { - d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); - d_data_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(data_codes_f[s]); + int32_t tmp_value = static_cast(ca_codes_f[s]); + if (tmp_value < 0) + { + tmp_value = 0; + } + d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = tmp_value; + tmp_value = static_cast(data_codes_f[s]); + if (tmp_value < 0) + { + tmp_value = 0; + } + d_data_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = tmp_value; } } else { galileo_e1_code_gen_sinboc11_float(ca_codes_f, data_signal, PRN); + // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA for (uint32_t s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++) { - d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); + uint32_t tmp_value = static_cast(ca_codes_f[s]); + if (tmp_value < 0) + { + tmp_value = 0; + } + d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = tmp_value; } } } diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc index 8c43d1d81..4a06b041f 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc @@ -212,19 +212,41 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( for (uint32_t PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++) { galileo_e5_a_code_gen_complex_primary(aux_code, PRN, const_cast(sig_)); + if (trk_param_fpga.track_pilot) { + // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA for (uint32_t s = 0; s < code_length_chips; s++) { - d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].imag()); - d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].real()); + int32_t tmp_value = static_cast(aux_code[s].imag()); + if (tmp_value < 0) + { + tmp_value = 0; + } + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + + tmp_value = static_cast(aux_code[s].real()); + if (tmp_value < 0) + { + tmp_value = 0; + } + d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + //d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].imag()); + //d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].real()); } } else { + // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA for (uint32_t s = 0; s < code_length_chips; s++) { - d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].real()); + int32_t tmp_value = static_cast(aux_code[s].real()); + if (tmp_value < 0) + { + tmp_value = 0; + } + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + //d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].real()); } } } diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc index fc43cca1e..48598e021 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc @@ -210,6 +210,15 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { gps_l1_ca_code_gen_int(&d_ca_codes[(int32_t(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); + + // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA + for (uint32_t k = 0; k < GPS_L1_CA_CODE_LENGTH_CHIPS; k++) + { + if (d_ca_codes[(int32_t(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1) + k] < 0) + { + d_ca_codes[(int32_t(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1) + k] = 0; + } + } } trk_param_fpga.ca_codes = d_ca_codes; trk_param_fpga.code_length_chips = GPS_L1_CA_CODE_LENGTH_CHIPS; 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 8bbf89aa3..d3e964ca0 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 @@ -233,18 +233,41 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( gps_l5q_code_gen_float(tracking_code, PRN); gps_l5i_code_gen_float(data_code, PRN); + // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA for (uint32_t s = 0; s < code_length_chips; s++) { - d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); - d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); + int32_t tmp_value = static_cast(tracking_code[s]); + if (tmp_value < 0) + { + tmp_value = 0; + } + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + + tmp_value = static_cast(data_code[s]); + if (tmp_value < 0) + { + tmp_value = 0; + } + d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + + //d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); + //d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); } } else { gps_l5i_code_gen_float(tracking_code, PRN); + + // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA for (uint32_t s = 0; s < code_length_chips; s++) { - d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); + int32_t tmp_value = static_cast(tracking_code[s]); + if (tmp_value < 0) + { + tmp_value = 0; + } + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + //d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); } } } diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 3762240ca..c6d448c3c 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -306,15 +306,15 @@ void Fpga_Multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; for (k = 0; k < d_code_length_samples; k++) { - if (d_ca_codes[(d_code_length_samples * (PRN - 1)) + k] == 1) - { - code_chip = 1; - } - else - { - code_chip = 0; - } - + // if (d_ca_codes[(d_code_length_samples * (PRN - 1)) + k] == 1) + // { + // code_chip = 1; + // } + // else + // { + // code_chip = 0; + // } + code_chip = d_ca_codes[(d_code_length_samples * (PRN - 1)) + k]; // copy the local code to the FPGA memory one by one d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip; // | select_fpga_correlator; } @@ -323,14 +323,15 @@ void Fpga_Multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; for (k = 0; k < d_code_length_samples; k++) { - if (d_data_codes[(d_code_length_samples * (PRN - 1)) + k] == 1) - { - code_chip = 1; - } - else - { - code_chip = 0; - } + // if (d_data_codes[(d_code_length_samples * (PRN - 1)) + k] == 1) + // { + // code_chip = 1; + // } + // else + // { + // code_chip = 0; + // } + code_chip = d_data_codes[(d_code_length_samples * (PRN - 1)) + k]; d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip | select_pilot_corelator; } }