diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 900e7ac91..1610bb3c5 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -81,7 +81,6 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( int32_t tmp2; int32_t local_code; int32_t fft_data; - for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) { bool cboc = false; // cboc is set to 0 when using the FPGA @@ -100,16 +99,14 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( cboc, PRN, fs_in_, 0, false); } - for (uint32_t s = code_length; s < 2 * code_length; s++) + if (acq_parameters_.enable_zero_padding) { - code[s] = code[s - code_length]; + // Duplicate the code sequence + std::copy(code.begin(), code.begin() + code_length, code.begin() + code_length); } - // fill in zero padding - for (uint32_t s = 2 * code_length; s < nsamples_total; s++) - { - code[s] = std::complex(0.0, 0.0); - } + // Fill in zero padding for the rest + std::fill(code.begin() + (acq_parameters_.enable_zero_padding ? 2 * code_length : code_length), code.end(), std::complex(0.0, 0.0)); std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 98e8bcf3c..0fa8a554a 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -107,16 +107,14 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga( galileo_e5_a_code_gen_complex_sampled(code, PRN, signal_, fs_in_, 0); - for (uint32_t s = code_length; s < 2 * code_length; s++) + if (acq_parameters_.enable_zero_padding) { - code[s] = code[s - code_length]; + // Duplicate the code sequence + std::copy(code.begin(), code.begin() + code_length, code.begin() + code_length); } - // fill in zero padding - for (uint32_t s = 2 * code_length; s < nsamples_total; s++) - { - code[s] = std::complex(0.0, 0.0); - } + // Fill in zero padding for the rest + std::fill(code.begin() + (acq_parameters_.enable_zero_padding ? 2 * code_length : code_length), code.end(), std::complex(0.0, 0.0)); std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc index f7a303f2d..295ba4f23 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc @@ -106,16 +106,14 @@ GalileoE5bPcpsAcquisitionFpga::GalileoE5bPcpsAcquisitionFpga(const Configuration galileo_e5_b_code_gen_complex_sampled(code, PRN, signal_, fs_in_, 0); - for (uint32_t s = code_length; s < 2 * code_length; s++) + if (acq_parameters_.enable_zero_padding) { - code[s] = code[s - code_length]; + // Duplicate the code sequence + std::copy(code.begin(), code.begin() + code_length, code.begin() + code_length); } - // fill in zero padding - for (uint32_t s = 2 * code_length; s < nsamples_total; s++) - { - code[s] = std::complex(0.0, 0.0); - } + // Fill in zero padding for the rest + std::fill(code.begin() + (acq_parameters_.enable_zero_padding ? 2 * code_length : code_length), code.end(), std::complex(0.0, 0.0)); std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 0242062b0..892f2de6a 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -87,16 +87,14 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( { gps_l1_ca_code_gen_complex_sampled(code, PRN, fs_in_, 0); // generate PRN code - for (uint32_t s = code_length; s < 2 * code_length; s++) + if (acq_parameters_.enable_zero_padding) { - code[s] = code[s - code_length]; + // Duplicate the code sequence + std::copy(code.begin(), code.begin() + code_length, code.begin() + code_length); } - // fill in zero padding - for (uint32_t s = 2 * code_length; s < nsamples_total; s++) - { - code[s] = std::complex(0.0, 0.0); - } + // Fill in zero padding for the rest + std::fill(code.begin() + (acq_parameters_.enable_zero_padding ? 2 * code_length : code_length), code.end(), std::complex(0.0, 0.0)); std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc index e78b1b174..5d7662c59 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc @@ -87,11 +87,16 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) { gps_l2c_m_code_gen_complex_sampled(code, PRN, fs_in_); - // fill in zero padding - for (unsigned int s = code_length; s < nsamples_total; s++) + + if (acq_parameters_.enable_zero_padding) { - code[s] = std::complex(0.0, 0.0); + // Duplicate the code sequence + std::copy(code.begin(), code.begin() + code_length, code.begin() + code_length); } + + // Fill in zero padding for the rest + std::fill(code.begin() + (acq_parameters_.enable_zero_padding ? 2 * code_length : code_length), code.end(), std::complex(0.0, 0.0)); + std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code volk_32fc_conjugate_32fc(fft_codes_padded.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index 0e379d034..924034987 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -88,16 +88,15 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( { gps_l5i_code_gen_complex_sampled(code, PRN, fs_in_); - for (uint32_t s = code_length; s < 2 * code_length; s++) + if (acq_parameters_.enable_zero_padding) { - code[s] = code[s - code_length]; + // Duplicate the code sequence + std::copy(code.begin(), code.begin() + code_length, code.begin() + code_length); } - for (uint32_t s = 2 * code_length; s < nsamples_total; s++) - { - // fill in zero padding - code[s] = std::complex(0.0, 0.0); - } + // Fill in zero padding for the rest + std::fill(code.begin() + (acq_parameters_.enable_zero_padding ? 2 * code_length : code_length), code.end(), std::complex(0.0, 0.0)); + std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code volk_32fc_conjugate_32fc(fft_codes_padded.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values diff --git a/src/algorithms/acquisition/libs/acq_conf_fpga.cc b/src/algorithms/acquisition/libs/acq_conf_fpga.cc index 00e47b153..79f02b477 100644 --- a/src/algorithms/acquisition/libs/acq_conf_fpga.cc +++ b/src/algorithms/acquisition/libs/acq_conf_fpga.cc @@ -46,9 +46,11 @@ void Acq_Conf_Fpga::SetFromConfiguration(const ConfigurationInterface *configura // code length in samples code_length = static_cast(std::round(static_cast(fs_in) / (chip_rate / code_length_chips))); + enable_zero_padding = configuration->property(role + ".enable_zero_padding", true); + // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f(static_cast(code_length) * 2.0F)); - samples_per_code = pow(2, nbits); + float factor = enable_zero_padding ? 2.0F : 1.0F; + samples_per_code = pow(2, ceilf(log2f(static_cast(code_length) * factor))); // repeat satellite repeat_satellite = configuration->property(role + ".repeat_satellite", false); diff --git a/src/algorithms/acquisition/libs/acq_conf_fpga.h b/src/algorithms/acquisition/libs/acq_conf_fpga.h index 11a2c7856..fd20ad953 100644 --- a/src/algorithms/acquisition/libs/acq_conf_fpga.h +++ b/src/algorithms/acquisition/libs/acq_conf_fpga.h @@ -57,6 +57,7 @@ public: uint32_t samples_per_code{1U}; uint32_t code_length{16000U}; bool make_2_steps{false}; + bool enable_zero_padding{true}; bool repeat_satellite{false}; private: