mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-05 15:00:33 +00:00
code refactoring
This commit is contained in:
parent
cbe20c0920
commit
0966ea9dca
@ -65,7 +65,9 @@ GpsL1CaDllPllCAidTrackingFpga::GpsL1CaDllPllCAidTrackingFpga(
|
|||||||
float early_late_space_chips;
|
float early_late_space_chips;
|
||||||
std::string device_name;
|
std::string device_name;
|
||||||
unsigned int device_base;
|
unsigned int device_base;
|
||||||
unsigned int device_range;
|
|
||||||
|
|
||||||
|
|
||||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||||
fs_in = configuration->property("GNSS-SDR.internal_fs_hz", 2048000);
|
fs_in = configuration->property("GNSS-SDR.internal_fs_hz", 2048000);
|
||||||
f_if = configuration->property(role + ".if", 0);
|
f_if = configuration->property(role + ".if", 0);
|
||||||
@ -84,7 +86,6 @@ GpsL1CaDllPllCAidTrackingFpga::GpsL1CaDllPllCAidTrackingFpga(
|
|||||||
std::string default_device_name = "/dev/uio";
|
std::string default_device_name = "/dev/uio";
|
||||||
device_name = configuration->property(role + ".devicename", default_device_name);
|
device_name = configuration->property(role + ".devicename", default_device_name);
|
||||||
device_base = configuration->property(role + ".device_base", 1);
|
device_base = configuration->property(role + ".device_base", 1);
|
||||||
device_range = configuration->property(role + ".device_range", 1);
|
|
||||||
vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS));
|
vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS));
|
||||||
|
|
||||||
//################# MAKE TRACKING GNURadio object ###################
|
//################# MAKE TRACKING GNURadio object ###################
|
||||||
@ -105,8 +106,7 @@ GpsL1CaDllPllCAidTrackingFpga::GpsL1CaDllPllCAidTrackingFpga(
|
|||||||
extend_correlation_ms,
|
extend_correlation_ms,
|
||||||
early_late_space_chips,
|
early_late_space_chips,
|
||||||
device_name,
|
device_name,
|
||||||
device_base,
|
device_base
|
||||||
device_range
|
|
||||||
);
|
);
|
||||||
DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")";
|
DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")";
|
||||||
}
|
}
|
||||||
@ -117,6 +117,9 @@ GpsL1CaDllPllCAidTrackingFpga::GpsL1CaDllPllCAidTrackingFpga(
|
|||||||
// LOG(WARNING) << item_type_ << " unknown tracking item type";
|
// LOG(WARNING) << item_type_ << " unknown tracking item type";
|
||||||
LOG(WARNING) << item_type_ << " the tracking item type for the FPGA tracking test has to be cshort";
|
LOG(WARNING) << item_type_ << " the tracking item type for the FPGA tracking test has to be cshort";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
channel_ = 0;
|
channel_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,18 +73,16 @@ gps_l1_ca_dll_pll_c_aid_make_tracking_fpga_sc(
|
|||||||
int extend_correlation_ms,
|
int extend_correlation_ms,
|
||||||
float early_late_space_chips,
|
float early_late_space_chips,
|
||||||
std::string device_name,
|
std::string device_name,
|
||||||
unsigned int device_base,
|
unsigned int device_base)
|
||||||
unsigned int device_range)
|
|
||||||
{
|
{
|
||||||
return gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc_sptr(new gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc(if_freq,
|
return gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc_sptr(new gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc(if_freq,
|
||||||
fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips,
|
fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips,
|
||||||
device_name, device_base, device_range));
|
device_name, device_base));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::msg_handler_preamble_index(pmt::pmt_t msg)
|
void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::msg_handler_preamble_index(pmt::pmt_t msg)
|
||||||
{
|
{
|
||||||
//pmt::print(msg);
|
|
||||||
DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN);
|
DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN);
|
||||||
if (d_enable_extended_integration == false) //avoid re-setting preamble indicator
|
if (d_enable_extended_integration == false) //avoid re-setting preamble indicator
|
||||||
{
|
{
|
||||||
@ -107,12 +105,14 @@ gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::gps_l1_ca_dll_pll_c_aid_tracking_fpga_
|
|||||||
int extend_correlation_ms,
|
int extend_correlation_ms,
|
||||||
float early_late_space_chips,
|
float early_late_space_chips,
|
||||||
std::string device_name,
|
std::string device_name,
|
||||||
unsigned int device_base,
|
unsigned int device_base) :
|
||||||
unsigned int device_range) :
|
|
||||||
gr::block("gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc", gr::io_signature::make(0, 0, sizeof(lv_16sc_t)),
|
gr::block("gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc", gr::io_signature::make(0, 0, sizeof(lv_16sc_t)),
|
||||||
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
|
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Telemetry bit synchronization message port input
|
// Telemetry bit synchronization message port input
|
||||||
this->message_port_register_in(pmt::mp("preamble_timestamp_s"));
|
this->message_port_register_in(pmt::mp("preamble_timestamp_s"));
|
||||||
this->set_msg_handler(pmt::mp("preamble_timestamp_s"),
|
this->set_msg_handler(pmt::mp("preamble_timestamp_s"),
|
||||||
@ -158,9 +158,8 @@ gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::gps_l1_ca_dll_pll_c_aid_tracking_fpga_
|
|||||||
d_local_code_shift_chips[1] = 0.0;
|
d_local_code_shift_chips[1] = 0.0;
|
||||||
d_local_code_shift_chips[2] = d_early_late_spc_chips;
|
d_local_code_shift_chips[2] = d_early_late_spc_chips;
|
||||||
|
|
||||||
//multicorrelator_fpga_8sc= std::make_shared<fpga_multicorrelator_8sc>();
|
// create multicorrelator class
|
||||||
multicorrelator_fpga_8sc.init(d_n_correlator_taps);
|
multicorrelator_fpga_8sc= std::make_shared<fpga_multicorrelator_8sc>(d_n_correlator_taps, device_name, device_base);
|
||||||
//multicorrelator_fpga_8sc->init(d_n_correlator_taps);
|
|
||||||
|
|
||||||
//--- Perform initializations ------------------------------
|
//--- Perform initializations ------------------------------
|
||||||
// define initial code frequency basis of NCO
|
// define initial code frequency basis of NCO
|
||||||
@ -209,6 +208,8 @@ gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::gps_l1_ca_dll_pll_c_aid_tracking_fpga_
|
|||||||
d_preamble_timestamp_s = 0.0;
|
d_preamble_timestamp_s = 0.0;
|
||||||
d_carr_phase_error_secs_Ti = 0.0;
|
d_carr_phase_error_secs_Ti = 0.0;
|
||||||
//set_min_output_buffer((long int)300);
|
//set_min_output_buffer((long int)300);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -267,8 +268,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::start_tracking()
|
|||||||
gps_l1_ca_code_gen_complex(d_ca_code, d_acquisition_gnss_synchro->PRN, 0);
|
gps_l1_ca_code_gen_complex(d_ca_code, d_acquisition_gnss_synchro->PRN, 0);
|
||||||
volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc, d_ca_code, static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS));
|
volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc, d_ca_code, static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS));
|
||||||
|
|
||||||
multicorrelator_fpga_8sc.set_local_code_and_taps(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips);
|
multicorrelator_fpga_8sc->set_local_code_and_taps(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips);
|
||||||
//multicorrelator_fpga_8sc->set_local_code_and_taps(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips);
|
|
||||||
for (int n = 0; n < d_n_correlator_taps; n++)
|
for (int n = 0; n < d_n_correlator_taps; n++)
|
||||||
{
|
{
|
||||||
d_correlator_outs_16sc[n] = lv_16sc_t(0,0);
|
d_correlator_outs_16sc[n] = lv_16sc_t(0,0);
|
||||||
@ -296,8 +296,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::start_tracking()
|
|||||||
d_preamble_synchronized = false;
|
d_preamble_synchronized = false;
|
||||||
|
|
||||||
// lock the channel
|
// lock the channel
|
||||||
multicorrelator_fpga_8sc.lock_channel();
|
multicorrelator_fpga_8sc->lock_channel();
|
||||||
|
|
||||||
|
|
||||||
LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz
|
LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz
|
||||||
<< " Code Phase correction [samples]=" << delay_correction_samples
|
<< " Code Phase correction [samples]=" << delay_correction_samples
|
||||||
@ -315,8 +314,7 @@ gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::~gps_l1_ca_dll_pll_c_aid_tracking_fpga
|
|||||||
volk_gnsssdr_free(d_correlator_outs_16sc);
|
volk_gnsssdr_free(d_correlator_outs_16sc);
|
||||||
|
|
||||||
delete[] d_Prompt_buffer;
|
delete[] d_Prompt_buffer;
|
||||||
multicorrelator_fpga_8sc.free();
|
multicorrelator_fpga_8sc->free();
|
||||||
//multicorrelator_fpga_8sc->free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -324,6 +322,10 @@ gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::~gps_l1_ca_dll_pll_c_aid_tracking_fpga
|
|||||||
int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
|
int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
|
||||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
|
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// samples offset
|
||||||
|
int samples_offset;
|
||||||
|
|
||||||
// Block input data and block output stream pointers
|
// Block input data and block output stream pointers
|
||||||
Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0];
|
Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0];
|
||||||
|
|
||||||
@ -341,7 +343,6 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work (int noutput_items __
|
|||||||
// Receiver signal alignment
|
// Receiver signal alignment
|
||||||
if (d_pull_in == true)
|
if (d_pull_in == true)
|
||||||
{
|
{
|
||||||
int samples_offset;
|
|
||||||
double acq_trk_shif_correction_samples;
|
double acq_trk_shif_correction_samples;
|
||||||
int acq_to_trk_delay_samples;
|
int acq_to_trk_delay_samples;
|
||||||
acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp;
|
acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp;
|
||||||
@ -354,28 +355,20 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work (int noutput_items __
|
|||||||
current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * GPS_TWO_PI;
|
current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * GPS_TWO_PI;
|
||||||
current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz;
|
current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz;
|
||||||
*out[0] = current_synchro_data;
|
*out[0] = current_synchro_data;
|
||||||
consume_each(samples_offset); // shift input to perform alignment with local replica
|
//consume_each(samples_offset); // shift input to perform alignment with local replica
|
||||||
multicorrelator_fpga_8sc.set_initial_sample(samples_offset);
|
multicorrelator_fpga_8sc->set_initial_sample(samples_offset);
|
||||||
//multicorrelator_fpga_8sc->set_initial_sample(samples_offset);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
|
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
|
||||||
// perform carrier wipe-off and compute Early, Prompt and Late correlation
|
// perform carrier wipe-off and compute Early, Prompt and Late correlation
|
||||||
//multicorrelator_fpga_8sc.set_input_output_vectors(d_correlator_outs_16sc, in);
|
multicorrelator_fpga_8sc->set_output_vectors(d_correlator_outs_16sc);
|
||||||
multicorrelator_fpga_8sc.set_output_vectors(d_correlator_outs_16sc);
|
multicorrelator_fpga_8sc->Carrier_wipeoff_multicorrelator_resampler(d_rem_carrier_phase_rad,
|
||||||
//multicorrelator_fpga_8sc->set_output_vectors(d_correlator_outs_16sc);
|
|
||||||
multicorrelator_fpga_8sc.Carrier_wipeoff_multicorrelator_resampler(d_rem_carrier_phase_rad,
|
|
||||||
d_carrier_phase_step_rad,
|
d_carrier_phase_step_rad,
|
||||||
d_rem_code_phase_chips,
|
d_rem_code_phase_chips,
|
||||||
d_code_phase_step_chips,
|
d_code_phase_step_chips,
|
||||||
d_correlation_length_samples);
|
d_correlation_length_samples);
|
||||||
// multicorrelator_fpga_8sc->Carrier_wipeoff_multicorrelator_resampler(d_rem_carrier_phase_rad,
|
|
||||||
// d_carrier_phase_step_rad,
|
|
||||||
// d_rem_code_phase_chips,
|
|
||||||
// d_code_phase_step_chips,
|
|
||||||
// d_correlation_length_samples);
|
|
||||||
|
|
||||||
// ####### coherent intergration extension
|
// ####### coherent intergration extension
|
||||||
// keep the last symbols
|
// keep the last symbols
|
||||||
@ -383,6 +376,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work (int noutput_items __
|
|||||||
d_P_history.push_back(d_correlator_outs_16sc[1]); // save prompt output
|
d_P_history.push_back(d_correlator_outs_16sc[1]); // save prompt output
|
||||||
d_L_history.push_back(d_correlator_outs_16sc[2]); // save late output
|
d_L_history.push_back(d_correlator_outs_16sc[2]); // save late output
|
||||||
|
|
||||||
|
|
||||||
if (static_cast<int>(d_P_history.size()) > d_extend_correlation_ms)
|
if (static_cast<int>(d_P_history.size()) > d_extend_correlation_ms)
|
||||||
{
|
{
|
||||||
d_E_history.pop_front();
|
d_E_history.pop_front();
|
||||||
@ -540,7 +534,10 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work (int noutput_items __
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--;
|
if (d_carrier_lock_fail_counter > 0)
|
||||||
|
{
|
||||||
|
d_carrier_lock_fail_counter--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (d_carrier_lock_fail_counter > MAXIMUM_LOCK_FAIL_COUNTER)
|
if (d_carrier_lock_fail_counter > MAXIMUM_LOCK_FAIL_COUNTER)
|
||||||
{
|
{
|
||||||
@ -549,7 +546,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work (int noutput_items __
|
|||||||
this->message_port_pub(pmt::mp("events"), pmt::from_long(3));//3 -> loss of lock
|
this->message_port_pub(pmt::mp("events"), pmt::from_long(3));//3 -> loss of lock
|
||||||
d_carrier_lock_fail_counter = 0;
|
d_carrier_lock_fail_counter = 0;
|
||||||
d_enable_tracking = false; // TODO: check if disabling tracking is consistent with the channel state machine
|
d_enable_tracking = false; // TODO: check if disabling tracking is consistent with the channel state machine
|
||||||
multicorrelator_fpga_8sc.unlock_channel();
|
multicorrelator_fpga_8sc->unlock_channel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ########### Output the tracking data to navigation and PVT ##########
|
// ########### Output the tracking data to navigation and PVT ##########
|
||||||
@ -650,7 +647,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work (int noutput_items __
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
consume_each(d_correlation_length_samples); // this is necessary in gr::block derivates
|
//consume_each(d_correlation_length_samples); // this is necessary in gr::block derivates
|
||||||
d_sample_counter += d_correlation_length_samples; //count for the processed samples
|
d_sample_counter += d_correlation_length_samples; //count for the processed samples
|
||||||
|
|
||||||
return 1; //output tracking result ALWAYS even in the case of d_enable_tracking==false
|
return 1; //output tracking result ALWAYS even in the case of d_enable_tracking==false
|
||||||
@ -660,8 +657,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work (int noutput_items __
|
|||||||
void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_channel(unsigned int channel)
|
void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_channel(unsigned int channel)
|
||||||
{
|
{
|
||||||
d_channel = channel;
|
d_channel = channel;
|
||||||
multicorrelator_fpga_8sc.set_channel(d_channel);
|
multicorrelator_fpga_8sc->set_channel(d_channel);
|
||||||
//multicorrelator_fpga_8sc->set_channel(d_channel);
|
|
||||||
LOG(INFO) << "Tracking Channel set to " << d_channel;
|
LOG(INFO) << "Tracking Channel set to " << d_channel;
|
||||||
// ############# ENABLE DATA FILE LOG #################
|
// ############# ENABLE DATA FILE LOG #################
|
||||||
if (d_dump == true)
|
if (d_dump == true)
|
||||||
@ -692,5 +688,5 @@ void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_gnss_synchro(Gnss_Synchro* p_
|
|||||||
|
|
||||||
void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::reset(void)
|
void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::reset(void)
|
||||||
{
|
{
|
||||||
multicorrelator_fpga_8sc.unlock_channel();
|
multicorrelator_fpga_8sc->unlock_channel();
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,7 @@ gps_l1_ca_dll_pll_c_aid_make_tracking_fpga_sc(long if_freq,
|
|||||||
int extend_correlation_ms,
|
int extend_correlation_ms,
|
||||||
float early_late_space_chips,
|
float early_late_space_chips,
|
||||||
std::string device_name,
|
std::string device_name,
|
||||||
unsigned int device_base,
|
unsigned int device_base);
|
||||||
unsigned int device_range);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -105,8 +104,7 @@ private:
|
|||||||
int extend_correlation_ms,
|
int extend_correlation_ms,
|
||||||
float early_late_space_chips,
|
float early_late_space_chips,
|
||||||
std::string device_name,
|
std::string device_name,
|
||||||
unsigned int device_base,
|
unsigned int device_base);
|
||||||
unsigned int device_range);
|
|
||||||
|
|
||||||
gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc(long if_freq,
|
gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc(long if_freq,
|
||||||
long fs_in, unsigned
|
long fs_in, unsigned
|
||||||
@ -120,8 +118,7 @@ private:
|
|||||||
int extend_correlation_ms,
|
int extend_correlation_ms,
|
||||||
float early_late_space_chips,
|
float early_late_space_chips,
|
||||||
std::string device_name,
|
std::string device_name,
|
||||||
unsigned int device_base,
|
unsigned int device_base);
|
||||||
unsigned int device_range);
|
|
||||||
|
|
||||||
// tracking configuration vars
|
// tracking configuration vars
|
||||||
unsigned int d_vector_length;
|
unsigned int d_vector_length;
|
||||||
@ -139,10 +136,9 @@ private:
|
|||||||
gr_complex* d_ca_code;
|
gr_complex* d_ca_code;
|
||||||
lv_16sc_t* d_ca_code_16sc;
|
lv_16sc_t* d_ca_code_16sc;
|
||||||
float* d_local_code_shift_chips;
|
float* d_local_code_shift_chips;
|
||||||
//gr_complex* d_correlator_outs;
|
|
||||||
lv_16sc_t* d_correlator_outs_16sc;
|
lv_16sc_t* d_correlator_outs_16sc;
|
||||||
fpga_multicorrelator_8sc multicorrelator_fpga_8sc;
|
//fpga_multicorrelator_8sc multicorrelator_fpga_8sc;
|
||||||
//std::shared_ptr<fpga_multicorrelator_8sc> multicorrelator_fpga_8sc;
|
std::shared_ptr<fpga_multicorrelator_8sc> multicorrelator_fpga_8sc;
|
||||||
|
|
||||||
// remaining code phase and carrier phase between tracking loops
|
// remaining code phase and carrier phase between tracking loops
|
||||||
double d_rem_code_phase_samples;
|
double d_rem_code_phase_samples;
|
||||||
|
@ -60,6 +60,9 @@
|
|||||||
// logging
|
// logging
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
// string manipulation
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#define PAGE_SIZE 0x10000
|
#define PAGE_SIZE 0x10000
|
||||||
#define MAX_LENGTH_DEVICEIO_NAME 50
|
#define MAX_LENGTH_DEVICEIO_NAME 50
|
||||||
#define CODE_RESAMPLER_NUM_BITS_PRECISION 20
|
#define CODE_RESAMPLER_NUM_BITS_PRECISION 20
|
||||||
@ -72,18 +75,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool fpga_multicorrelator_8sc::init(int n_correlators)
|
|
||||||
{
|
|
||||||
d_n_correlators = n_correlators;
|
|
||||||
|
|
||||||
// instantiate variable length vectors
|
|
||||||
d_initial_index = static_cast<unsigned*>(volk_gnsssdr_malloc(n_correlators * sizeof(unsigned), volk_gnsssdr_get_alignment()));
|
|
||||||
d_initial_interp_counter = static_cast<unsigned*>(volk_gnsssdr_malloc(n_correlators * sizeof(unsigned), volk_gnsssdr_get_alignment()));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void fpga_multicorrelator_8sc::set_initial_sample(int samples_offset)
|
void fpga_multicorrelator_8sc::set_initial_sample(int samples_offset)
|
||||||
{
|
{
|
||||||
d_initial_sample_counter = samples_offset;
|
d_initial_sample_counter = samples_offset;
|
||||||
@ -157,19 +148,31 @@ bool fpga_multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fpga_multicorrelator_8sc::fpga_multicorrelator_8sc()
|
fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int n_correlators, std::string device_name, unsigned int device_base)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
d_n_correlators = n_correlators;
|
||||||
|
d_device_name = device_name;
|
||||||
|
d_device_base = device_base;
|
||||||
|
|
||||||
|
// instantiate variable length vectors
|
||||||
|
d_initial_index = static_cast<unsigned*>(volk_gnsssdr_malloc(n_correlators * sizeof(unsigned), volk_gnsssdr_get_alignment()));
|
||||||
|
d_initial_interp_counter = static_cast<unsigned*>(volk_gnsssdr_malloc(n_correlators * sizeof(unsigned), volk_gnsssdr_get_alignment()));
|
||||||
|
|
||||||
d_local_code_in = nullptr;
|
d_local_code_in = nullptr;
|
||||||
d_shifts_chips = nullptr;
|
d_shifts_chips = nullptr;
|
||||||
d_corr_out = nullptr;
|
d_corr_out = nullptr;
|
||||||
d_code_length_chips = 0;
|
d_code_length_chips = 0;
|
||||||
d_n_correlators = 0;
|
|
||||||
|
d_ena_write_signals = new unsigned[d_n_correlators];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fpga_multicorrelator_8sc::~fpga_multicorrelator_8sc()
|
fpga_multicorrelator_8sc::~fpga_multicorrelator_8sc()
|
||||||
{
|
{
|
||||||
close(d_fd);
|
close(d_fd);
|
||||||
|
delete [] d_ena_write_signals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -200,13 +203,20 @@ void fpga_multicorrelator_8sc::set_channel(unsigned int channel)
|
|||||||
{
|
{
|
||||||
d_channel = channel;
|
d_channel = channel;
|
||||||
|
|
||||||
snprintf(d_device_io_name, MAX_LENGTH_DEVICEIO_NAME, "/dev/uio%d",d_channel + 1);
|
// open the device corresponding to the assigned channel
|
||||||
printf("Opening Device Name : %s\n", d_device_io_name);
|
std::string mergedname;
|
||||||
|
std::stringstream devicebasetemp;
|
||||||
|
|
||||||
|
int numdevice = d_device_base + d_channel;
|
||||||
|
devicebasetemp << numdevice;
|
||||||
|
mergedname = d_device_name + devicebasetemp.str();
|
||||||
|
strcpy(d_device_io_name, mergedname.c_str());
|
||||||
|
printf("Opening Device Name : %s\n", d_device_io_name);
|
||||||
if ((d_fd = open(d_device_io_name, O_RDWR | O_SYNC )) == -1)
|
if ((d_fd = open(d_device_io_name, O_RDWR | O_SYNC )) == -1)
|
||||||
{
|
{
|
||||||
LOG(WARNING) << "Cannot open deviceio" << d_device_io_name;
|
LOG(WARNING) << "Cannot open deviceio" << d_device_io_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
d_map_base = (volatile unsigned *)mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, d_fd,0);
|
d_map_base = (volatile unsigned *)mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, d_fd,0);
|
||||||
|
|
||||||
if (d_map_base == (void *) -1)
|
if (d_map_base == (void *) -1)
|
||||||
@ -246,20 +256,18 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(void)
|
|||||||
{
|
{
|
||||||
int k,s;
|
int k,s;
|
||||||
unsigned temp;
|
unsigned temp;
|
||||||
//unsigned *ena_write_signals;
|
|
||||||
d_ena_write_signals = new unsigned[d_n_correlators];
|
|
||||||
d_ena_write_signals[0] = 0x00000000;
|
d_ena_write_signals[0] = 0x00000000;
|
||||||
d_ena_write_signals[1] = 0x20000000;
|
d_ena_write_signals[1] = 0x20000000;
|
||||||
for (s = 2; s < d_n_correlators; s++)
|
for (s = 2; s < d_n_correlators; s++)
|
||||||
{
|
{
|
||||||
d_ena_write_signals[s]= d_ena_write_signals[s-1]*2; //0x40000000;
|
d_ena_write_signals[s]= d_ena_write_signals[s-1]*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (s = 0; s < d_n_correlators; s++)
|
for (s = 0; s < d_n_correlators; s++)
|
||||||
{
|
{
|
||||||
// clear memory address counter
|
// clear memory address counter
|
||||||
d_map_base[11] = 0x10000000;
|
d_map_base[11] = 0x10000000;
|
||||||
// write correlator 0
|
|
||||||
for (k = 0; k < d_code_length_chips; k++)
|
for (k = 0; k < d_code_length_chips; k++)
|
||||||
{
|
{
|
||||||
if (lv_creal(d_local_code_in[k]) == 1)
|
if (lv_creal(d_local_code_in[k]) == 1)
|
||||||
@ -274,7 +282,6 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete [] ena_write_signals;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -362,8 +369,6 @@ void fpga_multicorrelator_8sc::fpga_configure_signal_parameters_in_fpga(void)
|
|||||||
d_map_base[7] = d_correlator_length_samples - 1;
|
d_map_base[7] = d_correlator_length_samples - 1;
|
||||||
d_map_base[9] = d_rem_carr_phase_rad_int;
|
d_map_base[9] = d_rem_carr_phase_rad_int;
|
||||||
d_map_base[10] = d_phase_step_rad_int;
|
d_map_base[10] = d_phase_step_rad_int;
|
||||||
//printf("locking the channel\n");
|
|
||||||
//d_map_base[12] = 0; // lock the channel
|
|
||||||
d_map_base[13] = d_initial_sample_counter;
|
d_map_base[13] = d_initial_sample_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,55 +385,41 @@ void fpga_multicorrelator_8sc::fpga_launch_multicorrelator_fpga(void)
|
|||||||
|
|
||||||
void fpga_multicorrelator_8sc::read_tracking_gps_results(void)
|
void fpga_multicorrelator_8sc::read_tracking_gps_results(void)
|
||||||
{
|
{
|
||||||
int *readval_real;
|
int readval_real;
|
||||||
int *readval_imag;
|
int readval_imag;
|
||||||
int k;
|
int k;
|
||||||
readval_real = new int[d_n_correlators];
|
|
||||||
readval_imag = new int[d_n_correlators];
|
|
||||||
//static int numtimes = 0;
|
|
||||||
//printf("read results numtimes = %d\n", numtimes);
|
|
||||||
//numtimes = numtimes + 1;
|
|
||||||
|
|
||||||
for (k =0 ; k < d_n_correlators; k++)
|
for (k =0 ; k < d_n_correlators; k++)
|
||||||
{
|
{
|
||||||
readval_real[k] = d_map_base[1 + k];
|
readval_real = d_map_base[1 + k];
|
||||||
if (readval_real[k] >= 1048576) // 0x100000 (21 bits two's complement)
|
if (readval_real >= 1048576) // 0x100000 (21 bits two's complement)
|
||||||
{
|
{
|
||||||
readval_real[k] = -2097152 + readval_real[k];
|
readval_real = -2097152 + readval_real;
|
||||||
}
|
}
|
||||||
readval_real[k] = readval_real[k] * 2; // the results are shifted two bits to the left due to the complex multiplier in the FPGA
|
readval_real = readval_real * 2; // the results are shifted two bits to the left due to the complex multiplier in the FPGA
|
||||||
|
|
||||||
}
|
readval_imag = d_map_base[1 + d_n_correlators + k];
|
||||||
for (k = 0; k < d_n_correlators; k++)
|
if (readval_imag >= 1048576) // 0x100000 (21 bits two's complement)
|
||||||
{
|
|
||||||
readval_imag[k] = d_map_base[1 + d_n_correlators + k];
|
|
||||||
if (readval_imag[k] >= 1048576) // 0x100000 (21 bits two's complement)
|
|
||||||
{
|
{
|
||||||
readval_imag[k] = -2097152 + readval_imag[k];
|
readval_imag = -2097152 + readval_imag;
|
||||||
}
|
}
|
||||||
readval_imag[k] = readval_imag[k] * 2; // the results are shifted two bits to the left due to the complex multiplier in the FPGA
|
readval_imag = readval_imag * 2; // the results are shifted two bits to the left due to the complex multiplier in the FPGA
|
||||||
|
|
||||||
|
d_corr_out[k] = lv_cmake(readval_real, readval_imag);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (k = 0; k < d_n_correlators; k++)
|
|
||||||
{
|
|
||||||
d_corr_out[k] = lv_cmake(readval_real[k], readval_imag[k]);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[] readval_real;
|
|
||||||
delete[] readval_imag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fpga_multicorrelator_8sc::unlock_channel(void)
|
void fpga_multicorrelator_8sc::unlock_channel(void)
|
||||||
{
|
{
|
||||||
//printf("unlock the channel\n");
|
|
||||||
// unlock the channel to let the next samples go through
|
// unlock the channel to let the next samples go through
|
||||||
d_map_base[12] = 1; // unlock the channel
|
d_map_base[12] = 1; // unlock the channel
|
||||||
}
|
}
|
||||||
|
|
||||||
void fpga_multicorrelator_8sc::lock_channel(void)
|
void fpga_multicorrelator_8sc::lock_channel(void)
|
||||||
{
|
{
|
||||||
//printf("locking the channel\n");
|
// lock the channel for processing
|
||||||
d_map_base[12] = 0; // lock the channel
|
d_map_base[12] = 0; // lock the channel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +48,8 @@
|
|||||||
class fpga_multicorrelator_8sc
|
class fpga_multicorrelator_8sc
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
fpga_multicorrelator_8sc();
|
fpga_multicorrelator_8sc(int n_correlators, std::string device_name, unsigned int device_base);
|
||||||
~fpga_multicorrelator_8sc();
|
~fpga_multicorrelator_8sc();
|
||||||
bool init(int n_correlators);
|
|
||||||
bool set_local_code_and_taps(int code_length_chips, const lv_16sc_t* local_code_in, float *shifts_chips);
|
bool set_local_code_and_taps(int code_length_chips, const lv_16sc_t* local_code_in, float *shifts_chips);
|
||||||
bool set_output_vectors(lv_16sc_t* corr_out);
|
bool set_output_vectors(lv_16sc_t* corr_out);
|
||||||
void update_local_code(float rem_code_phase_chips);
|
void update_local_code(float rem_code_phase_chips);
|
||||||
@ -93,6 +92,15 @@ private:
|
|||||||
int d_phase_step_rad_int;
|
int d_phase_step_rad_int;
|
||||||
unsigned d_initial_sample_counter;
|
unsigned d_initial_sample_counter;
|
||||||
unsigned *d_ena_write_signals;
|
unsigned *d_ena_write_signals;
|
||||||
|
|
||||||
|
// driver
|
||||||
|
std::string d_device_name;
|
||||||
|
unsigned int d_device_base;
|
||||||
|
|
||||||
|
|
||||||
|
// results
|
||||||
|
//int *d_readval_real;
|
||||||
|
//int *d_readval_imag;
|
||||||
// FPGA private functions
|
// FPGA private functions
|
||||||
unsigned fpga_acquisition_test_register(unsigned writeval);
|
unsigned fpga_acquisition_test_register(unsigned writeval);
|
||||||
void fpga_configure_tracking_gps_local_code(void);
|
void fpga_configure_tracking_gps_local_code(void);
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
#define MAX_NUM_TEST_CASES 20
|
#define MAX_NUM_TEST_CASES 20
|
||||||
#define MAX_INPUT_SAMPLES_PER_TEST_CASE (8184)
|
#define MAX_INPUT_SAMPLES_PER_TEST_CASE (8184)
|
||||||
#define MAX_INPUT_SAMPLES_TOTAL MAX_INPUT_SAMPLES_PER_TEST_CASE*MAX_NUM_TEST_CASES
|
#define MAX_INPUT_SAMPLES_TOTAL MAX_INPUT_SAMPLES_PER_TEST_CASE*MAX_NUM_TEST_CASES
|
||||||
#define DMA_TRANSFER_SIZE 2046
|
#define DMA_TRANSFER_SIZE 8000 //2046
|
||||||
#define MIN_SAMPLES_REMAINING 20000 // number of remaining samples in the DMA that causes the CPU to stop the flowgraph (it has to be a bit alrger than 2x max packet size)
|
#define MIN_SAMPLES_REMAINING 20000 // number of remaining samples in the DMA that causes the CPU to stop the flowgraph (it has to be a bit alrger than 2x max packet size)
|
||||||
|
|
||||||
|
|
||||||
@ -97,42 +97,40 @@ void send_tracking_gps_input_samples(FILE *ptr_myfile, int num_remaining_samples
|
|||||||
fprintf(stderr, "Memory error!");
|
fprintf(stderr, "Memory error!");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("now i will send the samples\n");
|
|
||||||
|
|
||||||
while(num_remaining_samples > 0)
|
while(num_remaining_samples > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
//printf("num_remaining_samples = %d\n", num_remaining_samples);
|
|
||||||
|
|
||||||
if (num_remaining_samples < MIN_SAMPLES_REMAINING)
|
if (num_remaining_samples < MIN_SAMPLES_REMAINING)
|
||||||
{
|
{
|
||||||
if (flowgraph_stopped == 0)
|
if (flowgraph_stopped == 0)
|
||||||
{
|
{
|
||||||
// stop top module
|
// stop top module
|
||||||
top_block->stop();
|
top_block->stop();
|
||||||
flowgraph_stopped = 1;
|
flowgraph_stopped = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (num_remaining_samples > DMA_TRANSFER_SIZE)
|
if (num_remaining_samples > DMA_TRANSFER_SIZE)
|
||||||
{
|
{
|
||||||
|
|
||||||
fread(buffer, DMA_TRANSFER_SIZE, 1, ptr_myfile);
|
fread(buffer, DMA_TRANSFER_SIZE, 1, ptr_myfile);
|
||||||
|
|
||||||
assert( DMA_TRANSFER_SIZE == write(tx_fd, &buffer[0], DMA_TRANSFER_SIZE) );
|
assert( DMA_TRANSFER_SIZE == write(tx_fd, &buffer[0], DMA_TRANSFER_SIZE) );
|
||||||
num_remaining_samples = num_remaining_samples - DMA_TRANSFER_SIZE;
|
num_remaining_samples = num_remaining_samples - DMA_TRANSFER_SIZE;
|
||||||
num_samples_transferred = num_samples_transferred + DMA_TRANSFER_SIZE;
|
num_samples_transferred = num_samples_transferred + DMA_TRANSFER_SIZE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fread(buffer, num_remaining_samples, 1, ptr_myfile);
|
fread(buffer, num_remaining_samples, 1, ptr_myfile);
|
||||||
|
|
||||||
assert( num_remaining_samples == write(tx_fd, &buffer[0], num_remaining_samples) );
|
assert( num_remaining_samples == write(tx_fd, &buffer[0], num_remaining_samples) );
|
||||||
num_samples_transferred = num_samples_transferred + num_remaining_samples;
|
num_samples_transferred = num_samples_transferred + num_remaining_samples;
|
||||||
num_remaining_samples = 0;
|
num_remaining_samples = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
|
free(buffer);
|
||||||
close(tx_fd);
|
close(tx_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +152,7 @@ void thread(gr::top_block_sptr top_block, const char * file_name)
|
|||||||
fileLen = ftell(ptr_myfile);
|
fileLen = ftell(ptr_myfile);
|
||||||
fseek(ptr_myfile, 0, SEEK_SET);
|
fseek(ptr_myfile, 0, SEEK_SET);
|
||||||
|
|
||||||
wait(20); // wait for some time to give time to the other thread to program the device
|
wait(5); // wait for some time to give time to the other thread to program the device
|
||||||
|
|
||||||
//send_tracking_gps_input_samples(tx_fd, ptr_myfile, fileLen);
|
//send_tracking_gps_input_samples(tx_fd, ptr_myfile, fileLen);
|
||||||
send_tracking_gps_input_samples(ptr_myfile, fileLen, top_block);
|
send_tracking_gps_input_samples(ptr_myfile, fileLen, top_block);
|
||||||
@ -335,9 +333,9 @@ void GpsL1CADllPllTrackingTestFpga::configure_receiver()
|
|||||||
config->set_property("Tracking_1C.pll_bw_hz", "30.0");
|
config->set_property("Tracking_1C.pll_bw_hz", "30.0");
|
||||||
config->set_property("Tracking_1C.dll_bw_hz", "2.0");
|
config->set_property("Tracking_1C.dll_bw_hz", "2.0");
|
||||||
config->set_property("Tracking_1C.early_late_space_chips", "0.5");
|
config->set_property("Tracking_1C.early_late_space_chips", "0.5");
|
||||||
config->set_property("Tracking_GPS.devicename", "/dev/uio");
|
config->set_property("Tracking_1C.devicename", "/dev/uio");
|
||||||
config->set_property("Tracking_GPS.device_base", "0");
|
config->set_property("Tracking_1C.device_base", "1");
|
||||||
config->set_property("Tracking_GPS.device_range", "0");
|
config->set_property("Tracking_1C.device_range", "10");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -462,7 +460,7 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
|
|||||||
}) << "Failure opening true observables file" << std::endl;
|
}) << "Failure opening true observables file" << std::endl;
|
||||||
|
|
||||||
top_block = gr::make_top_block("Tracking test");
|
top_block = gr::make_top_block("Tracking test");
|
||||||
std::shared_ptr<TrackingInterface> tracking = std::make_shared<GpsL1CaDllPllCAidTrackingFpga>(config.get(), "Tracking_1C", 1, 1);
|
std::shared_ptr<GpsL1CaDllPllCAidTrackingFpga> tracking = std::make_shared<GpsL1CaDllPllCAidTrackingFpga>(config.get(), "Tracking_1C", 1, 1);
|
||||||
|
|
||||||
boost::shared_ptr<GpsL1CADllPllTrackingTestFpga_msg_rx> msg_rx = GpsL1CADllPllTrackingTestFpga_msg_rx_make();
|
boost::shared_ptr<GpsL1CADllPllTrackingTestFpga_msg_rx> msg_rx = GpsL1CADllPllTrackingTestFpga_msg_rx_make();
|
||||||
|
|
||||||
@ -513,7 +511,7 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
|
|||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
begin = tv.tv_sec * 1000000 + tv.tv_usec;
|
begin = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||||
top_block->run(); // Start threads and wait
|
top_block->run(); // Start threads and wait
|
||||||
tracking.reset();
|
tracking->reset(); // unlock the channel
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
end = tv.tv_sec * 1000000 + tv.tv_usec;
|
end = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||||
}) << "Failure running the top_block." << std::endl;
|
}) << "Failure running the top_block." << std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user