2016-01-11 15:49:37 +00:00
|
|
|
/*!
|
|
|
|
* \file cpu_multicorrelator_16sc.cc
|
|
|
|
* \brief High optimized CPU vector multiTAP correlator class
|
|
|
|
* \authors <ul>
|
|
|
|
* <li> Javier Arribas, 2015. jarribas(at)cttc.es
|
|
|
|
* </ul>
|
|
|
|
*
|
|
|
|
* Class that implements a high optimized vector multiTAP correlator class for CPUs
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
2016-01-13 18:38:07 +00:00
|
|
|
|
2016-01-11 15:49:37 +00:00
|
|
|
#include "cpu_multicorrelator_16sc.h"
|
|
|
|
#include <cmath>
|
2016-01-27 20:09:23 +00:00
|
|
|
|
2016-01-12 21:48:59 +00:00
|
|
|
|
2016-01-11 15:49:37 +00:00
|
|
|
|
|
|
|
bool cpu_multicorrelator_16sc::init(
|
2016-01-13 10:42:01 +00:00
|
|
|
int max_signal_length_samples,
|
|
|
|
int n_correlators)
|
2016-01-11 15:49:37 +00:00
|
|
|
{
|
2016-01-13 10:42:01 +00:00
|
|
|
// ALLOCATE MEMORY FOR INTERNAL vectors
|
2016-01-11 15:49:37 +00:00
|
|
|
size_t size = max_signal_length_samples * sizeof(lv_16sc_t);
|
|
|
|
|
2016-02-09 10:49:18 +00:00
|
|
|
d_n_correlators = n_correlators;
|
2016-03-28 14:35:55 +00:00
|
|
|
|
2016-03-30 21:49:53 +00:00
|
|
|
d_local_codes_resampled = static_cast<lv_16sc_t**>(volk_gnsssdr_malloc(n_correlators * sizeof(lv_16sc_t*), volk_gnsssdr_get_alignment()));
|
2016-01-11 15:49:37 +00:00
|
|
|
for (int n = 0; n < n_correlators; n++)
|
|
|
|
{
|
2016-01-27 20:09:23 +00:00
|
|
|
d_local_codes_resampled[n] = static_cast<lv_16sc_t*>(volk_gnsssdr_malloc(size, volk_gnsssdr_get_alignment()));
|
2016-01-11 15:49:37 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cpu_multicorrelator_16sc::set_local_code_and_taps(
|
2016-05-02 21:46:30 +00:00
|
|
|
int code_length_chips,
|
|
|
|
const lv_16sc_t* local_code_in,
|
|
|
|
float *shifts_chips)
|
2016-01-11 15:49:37 +00:00
|
|
|
{
|
|
|
|
d_local_code_in = local_code_in;
|
|
|
|
d_shifts_chips = shifts_chips;
|
|
|
|
d_code_length_chips = code_length_chips;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool cpu_multicorrelator_16sc::set_input_output_vectors(lv_16sc_t* corr_out, const lv_16sc_t* sig_in)
|
|
|
|
{
|
|
|
|
// Save CPU pointers
|
|
|
|
d_sig_in = sig_in;
|
|
|
|
d_corr_out = corr_out;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-28 14:35:55 +00:00
|
|
|
|
|
|
|
void cpu_multicorrelator_16sc::update_local_code(int correlator_length_samples, float rem_code_phase_chips, float code_phase_step_chips)
|
2016-01-11 15:49:37 +00:00
|
|
|
{
|
2016-08-15 10:03:15 +00:00
|
|
|
volk_gnsssdr_16ic_xn_resampler_16ic_xn(d_local_codes_resampled,
|
2016-03-28 14:35:55 +00:00
|
|
|
d_local_code_in,
|
2016-08-15 10:03:15 +00:00
|
|
|
rem_code_phase_chips,
|
2016-03-28 14:35:55 +00:00
|
|
|
code_phase_step_chips,
|
2016-08-15 10:03:15 +00:00
|
|
|
d_shifts_chips,
|
|
|
|
d_code_length_chips,
|
2016-03-28 14:35:55 +00:00
|
|
|
d_n_correlators,
|
2016-08-15 10:03:15 +00:00
|
|
|
correlator_length_samples);
|
2016-01-11 15:49:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool cpu_multicorrelator_16sc::Carrier_wipeoff_multicorrelator_resampler(
|
|
|
|
float rem_carrier_phase_in_rad,
|
|
|
|
float phase_step_rad,
|
|
|
|
float rem_code_phase_chips,
|
|
|
|
float code_phase_step_chips,
|
|
|
|
int signal_length_samples)
|
|
|
|
{
|
2016-02-09 10:49:18 +00:00
|
|
|
update_local_code(signal_length_samples, rem_code_phase_chips, code_phase_step_chips);
|
2016-03-28 14:35:55 +00:00
|
|
|
// Regenerate phase at each call in order to avoid numerical issues
|
2016-01-27 19:16:51 +00:00
|
|
|
lv_32fc_t phase_offset_as_complex[1];
|
|
|
|
phase_offset_as_complex[0] = lv_cmake(std::cos(rem_carrier_phase_in_rad), -std::sin(rem_carrier_phase_in_rad));
|
2016-03-28 14:35:55 +00:00
|
|
|
// call VOLK_GNSSSDR kernel
|
|
|
|
volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn(d_corr_out, d_sig_in, std::exp(lv_32fc_t(0, -phase_step_rad)), phase_offset_as_complex, (const lv_16sc_t**)d_local_codes_resampled, d_n_correlators, signal_length_samples);
|
2016-01-11 15:49:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cpu_multicorrelator_16sc::cpu_multicorrelator_16sc()
|
|
|
|
{
|
2016-03-30 21:49:53 +00:00
|
|
|
d_sig_in = nullptr;
|
|
|
|
d_local_code_in = nullptr;
|
|
|
|
d_shifts_chips = nullptr;
|
|
|
|
d_corr_out = nullptr;
|
|
|
|
d_local_codes_resampled = nullptr;
|
2016-01-11 15:49:37 +00:00
|
|
|
d_code_length_chips = 0;
|
|
|
|
d_n_correlators = 0;
|
|
|
|
}
|
|
|
|
|
2016-03-28 14:35:55 +00:00
|
|
|
|
|
|
|
cpu_multicorrelator_16sc::~cpu_multicorrelator_16sc()
|
|
|
|
{
|
2016-03-30 21:49:53 +00:00
|
|
|
if(d_local_codes_resampled != nullptr)
|
2016-03-28 14:35:55 +00:00
|
|
|
{
|
|
|
|
cpu_multicorrelator_16sc::free();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-11 15:49:37 +00:00
|
|
|
bool cpu_multicorrelator_16sc::free()
|
|
|
|
{
|
|
|
|
// Free memory
|
2016-03-30 21:49:53 +00:00
|
|
|
if (d_local_codes_resampled != nullptr)
|
2016-01-11 15:49:37 +00:00
|
|
|
{
|
2016-03-30 21:49:53 +00:00
|
|
|
for (int n = 0; n < d_n_correlators; n++)
|
|
|
|
{
|
|
|
|
volk_gnsssdr_free(d_local_codes_resampled[n]);
|
|
|
|
}
|
|
|
|
volk_gnsssdr_free(d_local_codes_resampled);
|
|
|
|
d_local_codes_resampled = nullptr;
|
2016-01-11 15:49:37 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|