1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-04-07 19:26:46 +00:00

Fix handling of zero padding option when disabled.

This commit is contained in:
Marc Majoral 2025-02-28 15:15:13 +01:00
parent edf76ec230
commit 4b670c5eca
No known key found for this signature in database
GPG Key ID: 936B91D6A360E8BB
6 changed files with 74 additions and 80 deletions

View File

@ -104,7 +104,7 @@ void GalileoE1PcpsAmbiguousAcquisitionFpga::generate_galileo_e1_prn_codes()
// a channel is assigned)
auto fft_if = gnss_fft_fwd_make_unique(nsamples_total); // Direct FFT
volk_gnsssdr::vector<std::complex<float>> code(nsamples_total); // buffer for the local code
volk_gnsssdr::vector<gr_complex> fft_codes_padded(nsamples_total);
volk_gnsssdr::vector<gr_complex> fft_code(nsamples_total);
d_all_fft_codes_ = volk_gnsssdr::vector<uint32_t>(nsamples_total * GALILEO_E1_NUMBER_OF_CODES); // memory containing all the possible fft codes for PRN 0 to 32
float max;
@ -134,34 +134,34 @@ void GalileoE1PcpsAmbiguousAcquisitionFpga::generate_galileo_e1_prn_codes()
{
// 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<float>(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<float>(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
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_code.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
// normalize the code
max = 0; // initialize maximum value
for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima
{
if (std::abs(fft_codes_padded[i].real()) > max)
if (std::abs(fft_code[i].real()) > max)
{
max = std::abs(fft_codes_padded[i].real());
max = std::abs(fft_code[i].real());
}
if (std::abs(fft_codes_padded[i].imag()) > max)
if (std::abs(fft_code[i].imag()) > max)
{
max = std::abs(fft_codes_padded[i].imag());
max = std::abs(fft_code[i].imag());
}
}
// map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs
// and package codes in a format that is ready to be written to the FPGA
for (uint32_t i = 0; i < nsamples_total; i++)
{
tmp = static_cast<int32_t>(floor(fft_codes_padded[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_codes_padded[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp = static_cast<int32_t>(floor(fft_code[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_code[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;

View File

@ -103,7 +103,7 @@ void GalileoE5aPcpsAcquisitionFpga::generate_galileo_e5a_prn_codes()
// a channel is assigned)
auto fft_if = gnss_fft_fwd_make_unique(nsamples_total); // Direct FFT
volk_gnsssdr::vector<std::complex<float>> code(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_codes_padded(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_code(nsamples_total);
d_all_fft_codes_ = volk_gnsssdr::vector<uint32_t>(nsamples_total * GALILEO_E5A_NUMBER_OF_CODES); // memory containing all the possible fft codes for PRN 0 to 32
if (acq_iq_)
@ -142,33 +142,33 @@ void GalileoE5aPcpsAcquisitionFpga::generate_galileo_e5a_prn_codes()
{
// 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<float>(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<float>(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
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_code.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
max = 0; // initialize maximum value
for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima
{
if (std::abs(fft_codes_padded[i].real()) > max)
if (std::abs(fft_code[i].real()) > max)
{
max = std::abs(fft_codes_padded[i].real());
max = std::abs(fft_code[i].real());
}
if (std::abs(fft_codes_padded[i].imag()) > max)
if (std::abs(fft_code[i].imag()) > max)
{
max = std::abs(fft_codes_padded[i].imag());
max = std::abs(fft_code[i].imag());
}
}
// map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs
// and package codes in a format that is ready to be written to the FPGA
for (uint32_t i = 0; i < nsamples_total; i++)
{
tmp = static_cast<int32_t>(floor(fft_codes_padded[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_codes_padded[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp = static_cast<int32_t>(floor(fft_code[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_code[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;

View File

@ -103,7 +103,7 @@ void GalileoE5bPcpsAcquisitionFpga::generate_galileo_e5b_prn_codes()
// a channel is assigned)
auto fft_if = gnss_fft_fwd_make_unique(nsamples_total); // Direct FFT
volk_gnsssdr::vector<std::complex<float>> code(nsamples_total); // Buffer for local code
volk_gnsssdr::vector<std::complex<float>> fft_codes_padded(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_code(nsamples_total);
d_all_fft_codes_ = volk_gnsssdr::vector<uint32_t>(nsamples_total * GALILEO_E5B_NUMBER_OF_CODES); // memory containing all the possible fft codes for PRN 0 to 32
if (acq_iq_)
@ -142,33 +142,33 @@ void GalileoE5bPcpsAcquisitionFpga::generate_galileo_e5b_prn_codes()
{
// 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<float>(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<float>(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
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_code.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
max = 0; // initialize maximum value
for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima
{
if (std::abs(fft_codes_padded[i].real()) > max)
if (std::abs(fft_code[i].real()) > max)
{
max = std::abs(fft_codes_padded[i].real());
max = std::abs(fft_code[i].real());
}
if (std::abs(fft_codes_padded[i].imag()) > max)
if (std::abs(fft_code[i].imag()) > max)
{
max = std::abs(fft_codes_padded[i].imag());
max = std::abs(fft_code[i].imag());
}
}
// map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs
// and package codes in a format that is ready to be written to the FPGA
for (uint32_t i = 0; i < nsamples_total; i++)
{
tmp = static_cast<int32_t>(floor(fft_codes_padded[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_codes_padded[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp = static_cast<int32_t>(floor(fft_code[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_code[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;

View File

@ -104,7 +104,7 @@ void GpsL1CaPcpsAcquisitionFpga::generate_gps_l1_ca_prn_codes()
auto fft_if = gnss_fft_fwd_make_unique(nsamples_total);
// allocate memory to compute all the PRNs and compute all the possible codes
volk_gnsssdr::vector<std::complex<float>> code(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_codes_padded(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_code(nsamples_total);
d_all_fft_codes_ = volk_gnsssdr::vector<uint32_t>(nsamples_total * NUM_PRNs); // memory containing all the possible fft codes for PRN 0 to 32
float max;
int32_t tmp;
@ -120,33 +120,32 @@ void GpsL1CaPcpsAcquisitionFpga::generate_gps_l1_ca_prn_codes()
{
// 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<float>(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<float>(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
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_code.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
max = 0; // initialize maximum value
for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima
{
if (std::abs(fft_codes_padded[i].real()) > max)
if (std::abs(fft_code[i].real()) > max)
{
max = std::abs(fft_codes_padded[i].real());
max = std::abs(fft_code[i].real());
}
if (std::abs(fft_codes_padded[i].imag()) > max)
if (std::abs(fft_code[i].imag()) > max)
{
max = std::abs(fft_codes_padded[i].imag());
max = std::abs(fft_code[i].imag());
}
}
// map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs
// and package codes in a format that is ready to be written to the FPGA
for (uint32_t i = 0; i < nsamples_total; i++)
{
tmp = static_cast<int32_t>(floor(fft_codes_padded[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_codes_padded[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp = static_cast<int32_t>(floor(fft_code[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_code[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;

View File

@ -104,7 +104,7 @@ void GpsL2MPcpsAcquisitionFpga::generate_gps_l2c_m_prn_codes()
auto fft_if = gnss_fft_fwd_make_unique(nsamples_total); // Direct FFT
// allocate memory to compute all the PRNs and compute all the possible codes
volk_gnsssdr::vector<std::complex<float>> code(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_codes_padded(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_codes(nsamples_total);
d_all_fft_codes_ = volk_gnsssdr::vector<uint32_t>(nsamples_total * NUM_PRNs); // memory containing all the possible fft codes for PRN 0 to 32
float max;
@ -121,38 +121,34 @@ void GpsL2MPcpsAcquisitionFpga::generate_gps_l2c_m_prn_codes()
{
// 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<float>(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<float>(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
max = 0; // initialize maximum value
for (unsigned int i = 0; i < nsamples_total; i++) // search for maxima
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.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
max = 0; // initialize maximum value
for (unsigned int i = 0; i < nsamples_total; i++) // search for maxima
{
if (std::abs(fft_codes_padded[i].real()) > max)
if (std::abs(fft_codes[i].real()) > max)
{
max = std::abs(fft_codes_padded[i].real());
max = std::abs(fft_codes[i].real());
}
if (std::abs(fft_codes_padded[i].imag()) > max)
if (std::abs(fft_codes[i].imag()) > max)
{
max = std::abs(fft_codes_padded[i].imag());
max = std::abs(fft_codes[i].imag());
}
}
// map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs
// and package codes in a format that is ready to be written to the FPGA
for (uint32_t i = 0; i < nsamples_total; i++)
{
tmp = static_cast<int32_t>(floor(fft_codes_padded[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_codes_padded[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp = static_cast<int32_t>(floor(fft_codes[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_codes[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;
// d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast<int32_t>(floor(fft_codes_padded[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max)),
// static_cast<int32_t>(floor(fft_codes_padded[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max)));
}
}

View File

@ -104,7 +104,7 @@ void GpsL5iPcpsAcquisitionFpga::generate_gps_l5i_prn_codes()
// a channel is assigned)
auto fft_if = gnss_fft_fwd_make_unique(nsamples_total); // Direct FFT
volk_gnsssdr::vector<std::complex<float>> code(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_codes_padded(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_codes(nsamples_total);
d_all_fft_codes_ = volk_gnsssdr::vector<uint32_t>(nsamples_total * NUM_PRNs); // memory containing all the possible fft codes for PRN 0 to 32
float max;
@ -121,33 +121,32 @@ void GpsL5iPcpsAcquisitionFpga::generate_gps_l5i_prn_codes()
{
// 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<float>(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<float>(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
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.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
max = 0; // initialize maximum value
for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima
{
if (std::abs(fft_codes_padded[i].real()) > max)
if (std::abs(fft_codes[i].real()) > max)
{
max = std::abs(fft_codes_padded[i].real());
max = std::abs(fft_codes[i].real());
}
if (std::abs(fft_codes_padded[i].imag()) > max)
if (std::abs(fft_codes[i].imag()) > max)
{
max = std::abs(fft_codes_padded[i].imag());
max = std::abs(fft_codes[i].imag());
}
}
// map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs
// and package codes in a format that is ready to be written to the FPGA
for (uint32_t i = 0; i < nsamples_total; i++)
{
tmp = static_cast<int32_t>(floor(fft_codes_padded[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_codes_padded[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp = static_cast<int32_t>(floor(fft_codes[i].real() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
tmp2 = static_cast<int32_t>(floor(fft_codes[i].imag() * (pow(2, QUANT_BITS_LOCAL_CODE - 1) - 1) / max));
local_code = (tmp & SELECT_LSBITS) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBITS); // put together the real part and the imaginary part
fft_data = local_code & SELECT_ALL_CODE_BITS;
d_all_fft_codes_[i + (nsamples_total * (PRN - 1))] = fft_data;