mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 04:00:34 +00:00
refactoring code
This commit is contained in:
parent
6413a11450
commit
cbe20c0920
@ -34,7 +34,6 @@
|
||||
#include "gps_l1_ca_pcps_acquisition_fpga.h"
|
||||
#include <boost/math/distributions/exponential.hpp>
|
||||
#include <glog/logging.h>
|
||||
#include "gps_sdr_signal_processing.h"
|
||||
#include "GPS_L1_CA.h"
|
||||
#include "configuration_interface.h"
|
||||
|
||||
@ -46,6 +45,18 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
|
||||
unsigned int in_streams, unsigned int out_streams) :
|
||||
role_(role), in_streams_(in_streams), out_streams_(out_streams)
|
||||
{
|
||||
unsigned int code_length;
|
||||
bool bit_transition_flag;
|
||||
bool use_CFAR_algorithm_flag;
|
||||
unsigned int sampled_ms;
|
||||
long fs_in;
|
||||
long ifreq;
|
||||
bool dump;
|
||||
std::string dump_filename;
|
||||
unsigned int nsamples_total;
|
||||
unsigned int select_queue_Fpga;
|
||||
std::string device_name;
|
||||
|
||||
configuration_ = configuration;
|
||||
|
||||
std::string default_item_type = "cshort";
|
||||
@ -55,50 +66,53 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
|
||||
|
||||
item_type_ = configuration_->property(role + ".item_type", default_item_type);
|
||||
|
||||
fs_in_ = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000);
|
||||
if_ = configuration_->property(role + ".if", 0);
|
||||
dump_ = configuration_->property(role + ".dump", false);
|
||||
fs_in = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000);
|
||||
ifreq = configuration_->property(role + ".if", 0);
|
||||
dump = configuration_->property(role + ".dump", false);
|
||||
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);
|
||||
sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1);
|
||||
sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1);
|
||||
|
||||
// note : the FPGA is implemented according to bit transition flag = 0. Setting bit transition flag to 1 has no effect.
|
||||
bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false);
|
||||
bit_transition_flag = configuration_->property(role + ".bit_transition_flag", false);
|
||||
|
||||
// note : the FPGA is implemented according to use_CFAR_algorithm = 0. Setting use_CFAR_algorithm to 1 has no effect.
|
||||
use_CFAR_algorithm_flag_=configuration_->property(role + ".use_CFAR_algorithm", false);
|
||||
use_CFAR_algorithm_flag=configuration_->property(role + ".use_CFAR_algorithm", false);
|
||||
|
||||
// note : the FPGA does not use the max_dwells variable.
|
||||
max_dwells_ = configuration_->property(role + ".max_dwells", 1);
|
||||
|
||||
dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename);
|
||||
dump_filename = configuration_->property(role + ".dump_filename", default_dump_filename);
|
||||
|
||||
//--- Find number of samples per spreading code -------------------------
|
||||
code_length_ = round(fs_in_ / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS));
|
||||
code_length = round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS));
|
||||
|
||||
// code length has the same value as d_fft_size
|
||||
float nbits;
|
||||
nbits = ceilf(log2f(code_length_));
|
||||
nsamples_total_ = pow(2,nbits);
|
||||
nbits = ceilf(log2f(code_length));
|
||||
nsamples_total = pow(2,nbits);
|
||||
|
||||
//vector_length_ = code_length_ * sampled_ms_;
|
||||
vector_length_ = nsamples_total_ * sampled_ms_;
|
||||
vector_length_ = nsamples_total * sampled_ms;
|
||||
|
||||
|
||||
if( bit_transition_flag_ )
|
||||
{
|
||||
vector_length_ *= 2;
|
||||
}
|
||||
// if( bit_transition_flag_ )
|
||||
// {
|
||||
// vector_length_ *= 2;
|
||||
// }
|
||||
|
||||
code_ = new gr_complex[vector_length_];
|
||||
|
||||
select_queue_Fpga_ = configuration_->property(role + ".select_queue_Fpga", 0);
|
||||
|
||||
select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0);
|
||||
|
||||
std::string default_device_name = "/dev/uio0";
|
||||
device_name = configuration_->property(role + ".devicename", default_device_name);
|
||||
|
||||
if (item_type_.compare("cshort") == 0 )
|
||||
{
|
||||
item_size_ = sizeof(lv_16sc_t);
|
||||
gps_acquisition_fpga_sc_ = gps_pcps_make_acquisition_fpga_sc(sampled_ms_, max_dwells_,
|
||||
doppler_max_, if_, fs_in_, code_length_, code_length_, vector_length_,
|
||||
bit_transition_flag_, use_CFAR_algorithm_flag_, select_queue_Fpga_, dump_, dump_filename_);
|
||||
gps_acquisition_fpga_sc_ = gps_pcps_make_acquisition_fpga_sc(sampled_ms, max_dwells_,
|
||||
doppler_max_, ifreq, fs_in, code_length, code_length, vector_length_, nsamples_total,
|
||||
bit_transition_flag, use_CFAR_algorithm_flag, select_queue_Fpga, device_name, dump, dump_filename);
|
||||
DLOG(INFO) << "acquisition(" << gps_acquisition_fpga_sc_->unique_id() << ")";
|
||||
|
||||
}
|
||||
@ -107,6 +121,8 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
channel_ = 0;
|
||||
threshold_ = 0.0;
|
||||
doppler_step_ = 0;
|
||||
@ -116,7 +132,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
|
||||
|
||||
GpsL1CaPcpsAcquisitionFpga::~GpsL1CaPcpsAcquisitionFpga()
|
||||
{
|
||||
delete[] code_;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -194,26 +210,8 @@ void GpsL1CaPcpsAcquisitionFpga::init()
|
||||
void GpsL1CaPcpsAcquisitionFpga::set_local_code()
|
||||
{
|
||||
|
||||
std::complex<float>* code = new std::complex<float>[vector_length_];
|
||||
gps_acquisition_fpga_sc_->set_local_code();
|
||||
|
||||
|
||||
//init to zeros for the zero padding of the fft
|
||||
for (uint s=0;s<vector_length_;s++)
|
||||
{
|
||||
code[s] = std::complex<float>(0, 0);
|
||||
}
|
||||
|
||||
gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_ , 0);
|
||||
|
||||
for (unsigned int i = 0; i < sampled_ms_; i++)
|
||||
{
|
||||
memcpy(&(code_[i*vector_length_]), code, sizeof(gr_complex)*vector_length_);
|
||||
|
||||
}
|
||||
|
||||
gps_acquisition_fpga_sc_->set_local_code(code_);
|
||||
|
||||
delete[] code;
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,35 +137,19 @@ public:
|
||||
private:
|
||||
ConfigurationInterface* configuration_;
|
||||
gps_pcps_acquisition_fpga_sc_sptr gps_acquisition_fpga_sc_;
|
||||
gr::blocks::stream_to_vector::sptr stream_to_vector_;
|
||||
gr::blocks::float_to_complex::sptr float_to_complex_;
|
||||
complex_byte_to_float_x2_sptr cbyte_to_float_x2_;
|
||||
size_t item_size_;
|
||||
std::string item_type_;
|
||||
unsigned int vector_length_;
|
||||
unsigned int code_length_;
|
||||
bool bit_transition_flag_;
|
||||
bool use_CFAR_algorithm_flag_;
|
||||
unsigned int channel_;
|
||||
float threshold_;
|
||||
unsigned int doppler_max_;
|
||||
unsigned int doppler_step_;
|
||||
unsigned int sampled_ms_;
|
||||
unsigned int max_dwells_;
|
||||
long fs_in_;
|
||||
long if_;
|
||||
bool dump_;
|
||||
std::string dump_filename_;
|
||||
std::complex<float> * code_;
|
||||
Gnss_Synchro * gnss_synchro_;
|
||||
std::string role_;
|
||||
unsigned int in_streams_;
|
||||
unsigned int out_streams_;
|
||||
|
||||
unsigned int nsamples_total_;
|
||||
|
||||
unsigned int select_queue_Fpga_;
|
||||
|
||||
float calculate_threshold(float pfa);
|
||||
};
|
||||
|
||||
|
@ -52,24 +52,24 @@ void wait3(int seconds)
|
||||
gps_pcps_acquisition_fpga_sc_sptr gps_pcps_make_acquisition_fpga_sc(
|
||||
unsigned int sampled_ms, unsigned int max_dwells,
|
||||
unsigned int doppler_max, long freq, long fs_in,
|
||||
int samples_per_ms, int samples_per_code, int vector_length,
|
||||
int samples_per_ms, int samples_per_code, int vector_length, unsigned int nsamples_total,
|
||||
bool bit_transition_flag, bool use_CFAR_algorithm_flag,
|
||||
unsigned int select_queue_Fpga,
|
||||
unsigned int select_queue_Fpga, std::string device_name,
|
||||
bool dump,
|
||||
std::string dump_filename)
|
||||
{
|
||||
|
||||
return gps_pcps_acquisition_fpga_sc_sptr(
|
||||
new gps_pcps_acquisition_fpga_sc(sampled_ms, max_dwells, doppler_max, freq, fs_in, samples_per_ms,
|
||||
samples_per_code, vector_length, bit_transition_flag, use_CFAR_algorithm_flag, select_queue_Fpga, dump, dump_filename));
|
||||
samples_per_code, vector_length, nsamples_total, bit_transition_flag, use_CFAR_algorithm_flag, select_queue_Fpga, device_name, dump, dump_filename));
|
||||
}
|
||||
|
||||
gps_pcps_acquisition_fpga_sc::gps_pcps_acquisition_fpga_sc(
|
||||
unsigned int sampled_ms, unsigned int max_dwells,
|
||||
unsigned int doppler_max, long freq, long fs_in,
|
||||
int samples_per_ms, int samples_per_code, int vector_length,
|
||||
int samples_per_ms, int samples_per_code, int vector_length, unsigned int nsamples_total,
|
||||
bool bit_transition_flag, bool use_CFAR_algorithm_flag,
|
||||
unsigned int select_queue_Fpga,
|
||||
unsigned int select_queue_Fpga, std::string device_name,
|
||||
bool dump,
|
||||
std::string dump_filename) :
|
||||
|
||||
@ -79,62 +79,27 @@ gps_pcps_acquisition_fpga_sc::gps_pcps_acquisition_fpga_sc(
|
||||
d_sample_counter = 0; // SAMPLE COUNTER
|
||||
d_active = false;
|
||||
d_state = 0;
|
||||
d_freq = freq;
|
||||
d_fs_in = fs_in;
|
||||
d_samples_per_ms = samples_per_ms;
|
||||
d_samples_per_code = samples_per_code;
|
||||
d_sampled_ms = sampled_ms;
|
||||
d_max_dwells = max_dwells; // Note : d_max_dwells is not used in the FPGA implementation
|
||||
d_well_count = 0;
|
||||
d_doppler_max = doppler_max;
|
||||
d_fft_size = d_sampled_ms * d_samples_per_ms;
|
||||
d_fft_size = sampled_ms * samples_per_ms;
|
||||
d_mag = 0;
|
||||
d_input_power = 0.0;
|
||||
d_num_doppler_bins = 0;
|
||||
d_bit_transition_flag = bit_transition_flag; // Note : bit transition flag is ignored and assumed 0 in the FPGA implementation
|
||||
d_use_CFAR_algorithm_flag = use_CFAR_algorithm_flag; // Note : user CFAR algorithm flag is ignored and assumed 0 in the FPGA implementation
|
||||
d_threshold = 0.0;
|
||||
d_doppler_step = 250;
|
||||
d_code_phase = 0;
|
||||
d_test_statistics = 0.0;
|
||||
d_channel = 0;
|
||||
d_doppler_freq = 0.0;
|
||||
|
||||
d_nsamples_total = vector_length;
|
||||
|
||||
//if( d_bit_transition_flag )
|
||||
// {
|
||||
// d_fft_size *= 2;
|
||||
// d_max_dwells = 1;
|
||||
// }
|
||||
|
||||
d_fft_codes = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
|
||||
d_magnitude = static_cast<float*>(volk_gnsssdr_malloc(d_nsamples_total * sizeof(float), volk_gnsssdr_get_alignment()));
|
||||
//temporary storage for the input conversion from 16sc to float 32fc
|
||||
d_in_32fc = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
|
||||
|
||||
d_fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
|
||||
|
||||
|
||||
// Direct FFT
|
||||
d_fft_if = new gr::fft::fft_complex(d_nsamples_total, true);
|
||||
|
||||
// Inverse FFT
|
||||
d_ifft = new gr::fft::fft_complex(d_nsamples_total, false);
|
||||
|
||||
// FPGA queue selection
|
||||
d_select_queue_Fpga = select_queue_Fpga;
|
||||
|
||||
// For dumping samples into a file
|
||||
d_dump = dump;
|
||||
d_dump_filename = dump_filename;
|
||||
|
||||
d_gnss_synchro = 0;
|
||||
d_grid_doppler_wipeoffs = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
// instantiate HW accelerator class
|
||||
acquisition_fpga_8sc= std::make_shared<gps_fpga_acquisition_8sc>(device_name, vector_length, d_fft_size, nsamples_total, fs_in, freq, sampled_ms, select_queue_Fpga);
|
||||
|
||||
|
||||
}
|
||||
@ -142,73 +107,23 @@ gps_pcps_acquisition_fpga_sc::gps_pcps_acquisition_fpga_sc(
|
||||
|
||||
gps_pcps_acquisition_fpga_sc::~gps_pcps_acquisition_fpga_sc()
|
||||
{
|
||||
if (d_num_doppler_bins > 0)
|
||||
{
|
||||
for (unsigned int i = 0; i < d_num_doppler_bins; i++)
|
||||
{
|
||||
volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]);
|
||||
}
|
||||
delete[] d_grid_doppler_wipeoffs;
|
||||
}
|
||||
|
||||
volk_gnsssdr_free(d_fft_codes);
|
||||
volk_gnsssdr_free(d_magnitude);
|
||||
volk_gnsssdr_free(d_in_32fc);
|
||||
|
||||
delete d_ifft;
|
||||
delete d_fft_if;
|
||||
|
||||
if (d_dump)
|
||||
{
|
||||
d_dump_file.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
acquisition_fpga_8sc.free();
|
||||
acquisition_fpga_8sc->free();
|
||||
}
|
||||
|
||||
|
||||
void gps_pcps_acquisition_fpga_sc::set_local_code(std::complex<float> * code)
|
||||
{
|
||||
// COD
|
||||
// Here we want to create a buffer that looks like this:
|
||||
// [ 0 0 0 ... 0 c_0 c_1 ... c_L]
|
||||
// where c_i is the local code and there are L zeros and L chips
|
||||
|
||||
|
||||
|
||||
|
||||
int offset = 0;
|
||||
// if( d_bit_transition_flag )
|
||||
// {
|
||||
// std::fill_n( d_fft_if->get_inbuf(), d_nsamples_total, gr_complex( 0.0, 0.0 ) );
|
||||
// offset = d_nsamples_total;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
memcpy(d_fft_if->get_inbuf() + offset, code, sizeof(gr_complex) * d_nsamples_total);
|
||||
d_fft_if->execute(); // We need the FFT of local code
|
||||
volk_32fc_conjugate_32fc(d_fft_codes_padded, d_fft_if->get_outbuf(), d_nsamples_total);
|
||||
|
||||
acquisition_fpga_8sc.set_local_code(d_fft_codes_padded);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void gps_pcps_acquisition_fpga_sc::update_local_carrier(gr_complex* carrier_vector, int correlator_length_samples, float freq)
|
||||
void gps_pcps_acquisition_fpga_sc::set_local_code()
|
||||
{
|
||||
|
||||
float phase_step_rad = GPS_TWO_PI * freq / static_cast<float>(d_fs_in);
|
||||
|
||||
float _phase[1];
|
||||
_phase[0] = 0;
|
||||
volk_gnsssdr_s32f_sincos_32fc(carrier_vector, - phase_step_rad, _phase, correlator_length_samples);
|
||||
acquisition_fpga_8sc->set_local_code(d_gnss_synchro->PRN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void gps_pcps_acquisition_fpga_sc::init()
|
||||
{
|
||||
d_gnss_synchro->Flag_valid_acquisition = false;
|
||||
@ -221,19 +136,12 @@ void gps_pcps_acquisition_fpga_sc::init()
|
||||
d_gnss_synchro->Acq_doppler_hz = 0.0;
|
||||
d_gnss_synchro->Acq_samplestamp_samples = 0;
|
||||
d_mag = 0.0;
|
||||
d_input_power = 0.0;
|
||||
|
||||
d_num_doppler_bins = ceil( static_cast<double>(static_cast<int>(d_doppler_max) - static_cast<int>(-d_doppler_max)) / static_cast<double>(d_doppler_step));
|
||||
|
||||
// Create the carrier Doppler wipeoff signals
|
||||
d_grid_doppler_wipeoffs = new gr_complex*[d_num_doppler_bins];
|
||||
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
|
||||
{
|
||||
d_grid_doppler_wipeoffs[doppler_index] = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
|
||||
int doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
|
||||
update_local_carrier(d_grid_doppler_wipeoffs[doppler_index], d_fft_size, d_freq + doppler);
|
||||
}
|
||||
acquisition_fpga_8sc.init(d_fft_size, d_nsamples_total, d_freq, d_doppler_max, d_doppler_step, d_num_doppler_bins, d_fs_in, d_select_queue_Fpga);
|
||||
acquisition_fpga_8sc->open_device();
|
||||
|
||||
acquisition_fpga_8sc->init();
|
||||
|
||||
|
||||
|
||||
@ -253,8 +161,6 @@ void gps_pcps_acquisition_fpga_sc::set_state(int state)
|
||||
d_gnss_synchro->Acq_samplestamp_samples = 0;
|
||||
d_well_count = 0;
|
||||
d_mag = 0.0;
|
||||
d_input_power = 0.0;
|
||||
d_test_statistics = 0.0;
|
||||
}
|
||||
else if (d_state == 0)
|
||||
{}
|
||||
@ -275,147 +181,142 @@ void gps_pcps_acquisition_fpga_sc::set_active(bool active)
|
||||
|
||||
float temp_peak_to_noise_level = 0.0;
|
||||
float peak_to_noise_level = 0.0;
|
||||
acquisition_fpga_8sc.block_samples(); // block the samples to run the acquisition this is only necessary for the tests
|
||||
float input_power;
|
||||
float test_statistics = 0.0;
|
||||
acquisition_fpga_8sc->block_samples(); // block the samples to run the acquisition this is only necessary for the tests
|
||||
|
||||
|
||||
d_active = active;
|
||||
|
||||
|
||||
// while (d_well_count < d_max_dwells)
|
||||
// {
|
||||
int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL
|
||||
int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL
|
||||
|
||||
d_state = 1;
|
||||
d_state = 1;
|
||||
|
||||
// initialize acquisition algorithm
|
||||
int doppler;
|
||||
uint32_t indext = 0;
|
||||
float magt = 0.0;
|
||||
//int effective_fft_size = ( d_bit_transition_flag ? d_fft_size/2 : d_fft_size );
|
||||
int effective_fft_size = d_fft_size;
|
||||
//float fft_normalization_factor = static_cast<float>(d_fft_size) * static_cast<float>(d_fft_size);
|
||||
// initialize acquisition algorithm
|
||||
int doppler;
|
||||
uint32_t indext = 0;
|
||||
float magt = 0.0;
|
||||
//int effective_fft_size = ( d_bit_transition_flag ? d_fft_size/2 : d_fft_size );
|
||||
int effective_fft_size = d_fft_size;
|
||||
//float fft_normalization_factor = static_cast<float>(d_fft_size) * static_cast<float>(d_fft_size);
|
||||
|
||||
d_mag = 0.0;
|
||||
d_mag = 0.0;
|
||||
|
||||
unsigned int initial_sample;
|
||||
unsigned int initial_sample;
|
||||
|
||||
d_well_count++;
|
||||
d_well_count++;
|
||||
|
||||
DLOG(INFO) << "Channel: " << d_channel
|
||||
<< " , doing acquisition of satellite: " << d_gnss_synchro->System << " "<< d_gnss_synchro->PRN
|
||||
<< " ,sample stamp: " << d_sample_counter << ", threshold: "
|
||||
<< ", threshold: "
|
||||
<< d_threshold << ", doppler_max: " << d_doppler_max
|
||||
<< ", doppler_step: " << d_doppler_step;
|
||||
DLOG(INFO) << "Channel: " << d_channel
|
||||
<< " , doing acquisition of satellite: " << d_gnss_synchro->System << " "<< d_gnss_synchro->PRN
|
||||
<< " ,sample stamp: " << d_sample_counter << ", threshold: "
|
||||
<< ", threshold: "
|
||||
<< d_threshold << ", doppler_max: " << d_doppler_max
|
||||
<< ", doppler_step: " << d_doppler_step;
|
||||
|
||||
// Doppler frequency search loop
|
||||
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
|
||||
// Doppler frequency search loop
|
||||
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
|
||||
{
|
||||
|
||||
|
||||
doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
|
||||
|
||||
acquisition_fpga_8sc->set_phase_step(doppler_index);
|
||||
acquisition_fpga_8sc->run_acquisition(); // runs acquisition and waits until it is finished
|
||||
|
||||
acquisition_fpga_8sc->read_acquisition_results(&indext, &magt, &initial_sample, &input_power);
|
||||
|
||||
d_sample_counter = initial_sample;
|
||||
|
||||
temp_peak_to_noise_level = (float) (magt / input_power);
|
||||
if (peak_to_noise_level < temp_peak_to_noise_level)
|
||||
{
|
||||
peak_to_noise_level = temp_peak_to_noise_level;
|
||||
d_mag = magt;
|
||||
|
||||
input_power = (input_power - d_mag) / (effective_fft_size - 1);
|
||||
|
||||
doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
|
||||
|
||||
acquisition_fpga_8sc.set_phase_step(doppler_index);
|
||||
acquisition_fpga_8sc.run_acquisition(); // runs acquisition and waits until it is finished
|
||||
|
||||
acquisition_fpga_8sc.read_acquisition_results(&indext, &magt, &initial_sample, &d_input_power);
|
||||
|
||||
d_sample_counter = initial_sample;
|
||||
|
||||
temp_peak_to_noise_level = (float) (magt / d_input_power);
|
||||
if (peak_to_noise_level < temp_peak_to_noise_level)
|
||||
{
|
||||
peak_to_noise_level = temp_peak_to_noise_level;
|
||||
d_mag = magt;
|
||||
|
||||
d_input_power = (d_input_power - d_mag) / (effective_fft_size - 1);
|
||||
|
||||
//if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag)
|
||||
// {
|
||||
d_gnss_synchro->Acq_delay_samples = static_cast<double>(indext % d_samples_per_code);
|
||||
d_gnss_synchro->Acq_doppler_hz = static_cast<double>(doppler);
|
||||
d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter;
|
||||
d_test_statistics = d_mag / d_input_power;
|
||||
// }
|
||||
}
|
||||
|
||||
// Record results to file if required
|
||||
if (d_dump)
|
||||
{
|
||||
std::stringstream filename;
|
||||
std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write
|
||||
filename.str("");
|
||||
|
||||
boost::filesystem::path p = d_dump_filename;
|
||||
filename << p.parent_path().string()
|
||||
<< boost::filesystem::path::preferred_separator
|
||||
<< p.stem().string()
|
||||
<< "_" << d_gnss_synchro->System
|
||||
<<"_" << d_gnss_synchro->Signal << "_sat_"
|
||||
<< d_gnss_synchro->PRN << "_doppler_"
|
||||
<< doppler
|
||||
<< p.extension().string();
|
||||
|
||||
DLOG(INFO) << "Writing ACQ out to " << filename.str();
|
||||
|
||||
d_dump_file.open(filename.str().c_str(), std::ios::out | std::ios::binary);
|
||||
d_dump_file.write((char*)d_ifft->get_outbuf(), n); //write directly |abs(x)|^2 in this Doppler bin?
|
||||
d_dump_file.close();
|
||||
}
|
||||
d_gnss_synchro->Acq_delay_samples = static_cast<double>(indext % d_samples_per_code);
|
||||
d_gnss_synchro->Acq_doppler_hz = static_cast<double>(doppler);
|
||||
d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter;
|
||||
test_statistics = d_mag / input_power;
|
||||
}
|
||||
|
||||
// Record results to file if required
|
||||
if (d_dump)
|
||||
{
|
||||
std::stringstream filename;
|
||||
//std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write
|
||||
filename.str("");
|
||||
|
||||
if (d_test_statistics > d_threshold)
|
||||
{
|
||||
d_state = 2; // Positive acquisition
|
||||
boost::filesystem::path p = d_dump_filename;
|
||||
filename << p.parent_path().string()
|
||||
<< boost::filesystem::path::preferred_separator
|
||||
<< p.stem().string()
|
||||
<< "_" << d_gnss_synchro->System
|
||||
<<"_" << d_gnss_synchro->Signal << "_sat_"
|
||||
<< d_gnss_synchro->PRN << "_doppler_"
|
||||
<< doppler
|
||||
<< p.extension().string();
|
||||
|
||||
// 6.1- Declare positive acquisition using a message port
|
||||
DLOG(INFO) << "positive acquisition";
|
||||
DLOG(INFO) << "satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN;
|
||||
DLOG(INFO) << "sample_stamp " << d_sample_counter;
|
||||
DLOG(INFO) << "test statistics value " << d_test_statistics;
|
||||
DLOG(INFO) << "test statistics threshold " << d_threshold;
|
||||
DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples;
|
||||
DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz;
|
||||
DLOG(INFO) << "magnitude " << d_mag;
|
||||
DLOG(INFO) << "input signal power " << d_input_power;
|
||||
DLOG(INFO) << "Writing ACQ out to " << filename.str();
|
||||
|
||||
d_active = false;
|
||||
d_state = 0;
|
||||
d_dump_file.open(filename.str().c_str(), std::ios::out | std::ios::binary);
|
||||
d_dump_file.close();
|
||||
}
|
||||
}
|
||||
|
||||
acquisition_message = 1;
|
||||
this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message));
|
||||
|
||||
// break;
|
||||
if (test_statistics > d_threshold)
|
||||
{
|
||||
d_state = 2; // Positive acquisition
|
||||
|
||||
}
|
||||
else //if (d_well_count == d_max_dwells)
|
||||
{
|
||||
d_state = 3; // Negative acquisition
|
||||
// 6.1- Declare positive acquisition using a message port
|
||||
DLOG(INFO) << "positive acquisition";
|
||||
DLOG(INFO) << "satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN;
|
||||
DLOG(INFO) << "sample_stamp " << d_sample_counter;
|
||||
DLOG(INFO) << "test statistics value " << test_statistics;
|
||||
DLOG(INFO) << "test statistics threshold " << d_threshold;
|
||||
DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples;
|
||||
DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz;
|
||||
DLOG(INFO) << "magnitude " << d_mag;
|
||||
DLOG(INFO) << "input signal power " << input_power;
|
||||
|
||||
// 6.2- Declare negative acquisition using a message port
|
||||
DLOG(INFO) << "negative acquisition";
|
||||
DLOG(INFO) << "satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN;
|
||||
DLOG(INFO) << "sample_stamp " << d_sample_counter;
|
||||
DLOG(INFO) << "test statistics value " << d_test_statistics;
|
||||
DLOG(INFO) << "test statistics threshold " << d_threshold;
|
||||
DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples;
|
||||
DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz;
|
||||
DLOG(INFO) << "magnitude " << d_mag;
|
||||
DLOG(INFO) << "input signal power " << d_input_power;
|
||||
d_active = false;
|
||||
d_state = 0;
|
||||
|
||||
d_active = false;
|
||||
d_state = 0;
|
||||
acquisition_message = 1;
|
||||
this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message));
|
||||
|
||||
acquisition_message = 2;
|
||||
this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message));
|
||||
|
||||
// break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d_state = 3; // Negative acquisition
|
||||
|
||||
// }
|
||||
// 6.2- Declare negative acquisition using a message port
|
||||
DLOG(INFO) << "negative acquisition";
|
||||
DLOG(INFO) << "satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN;
|
||||
DLOG(INFO) << "sample_stamp " << d_sample_counter;
|
||||
DLOG(INFO) << "test statistics value " << test_statistics;
|
||||
DLOG(INFO) << "test statistics threshold " << d_threshold;
|
||||
DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples;
|
||||
DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz;
|
||||
DLOG(INFO) << "magnitude " << d_mag;
|
||||
DLOG(INFO) << "input signal power " << input_power;
|
||||
|
||||
acquisition_fpga_8sc.unblock_samples();
|
||||
d_active = false;
|
||||
d_state = 0;
|
||||
|
||||
acquisition_message = 2;
|
||||
this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message));
|
||||
|
||||
}
|
||||
|
||||
|
||||
acquisition_fpga_8sc->unblock_samples();
|
||||
|
||||
acquisition_fpga_8sc->close_device();
|
||||
|
||||
DLOG(INFO) << "Done. Consumed 1 item.";
|
||||
|
||||
|
@ -64,9 +64,9 @@ typedef boost::shared_ptr<gps_pcps_acquisition_fpga_sc> gps_pcps_acquisition_fpg
|
||||
gps_pcps_acquisition_fpga_sc_sptr
|
||||
gps_pcps_make_acquisition_fpga_sc(unsigned int sampled_ms, unsigned int max_dwells,
|
||||
unsigned int doppler_max, long freq, long fs_in,
|
||||
int samples_per_ms, int samples_per_code, int vector_length_,
|
||||
int samples_per_ms, int samples_per_code, int vector_length_, unsigned int nsamples_total_,
|
||||
bool bit_transition_flag, bool use_CFAR_algorithm_flag,
|
||||
unsigned int select_queue_Fpga,
|
||||
unsigned int select_queue_Fpga, std::string device_name,
|
||||
bool dump,
|
||||
std::string dump_filename);
|
||||
|
||||
@ -82,52 +82,35 @@ private:
|
||||
friend gps_pcps_acquisition_fpga_sc_sptr
|
||||
gps_pcps_make_acquisition_fpga_sc(unsigned int sampled_ms, unsigned int max_dwells,
|
||||
unsigned int doppler_max, long freq, long fs_in,
|
||||
int samples_per_ms, int samples_per_code, int vector_length,
|
||||
int samples_per_ms, int samples_per_code, int vector_length, unsigned int nsamples_total,
|
||||
bool bit_transition_flag, bool use_CFAR_algorithm_flag,
|
||||
unsigned int select_queue_Fpga,
|
||||
std::string device_name,
|
||||
bool dump,
|
||||
std::string dump_filename);
|
||||
|
||||
gps_pcps_acquisition_fpga_sc(unsigned int sampled_ms, unsigned int max_dwells,
|
||||
unsigned int doppler_max, long freq, long fs_in,
|
||||
int samples_per_ms, int samples_per_code, int vector_length,
|
||||
int samples_per_ms, int samples_per_code, int vector_length, unsigned int nsamples_total,
|
||||
bool bit_transition_flag, bool use_CFAR_algorithm_flag,
|
||||
unsigned int select_queue_Fpga,
|
||||
std::string device_name,
|
||||
bool dump,
|
||||
std::string dump_filename);
|
||||
|
||||
void update_local_carrier(gr_complex* carrier_vector,
|
||||
int correlator_length_samples,
|
||||
float freq);
|
||||
|
||||
long d_fs_in;
|
||||
long d_freq;
|
||||
int d_samples_per_ms;
|
||||
int d_samples_per_code;
|
||||
float d_threshold;
|
||||
std::string d_satellite_str;
|
||||
unsigned int d_doppler_max;
|
||||
unsigned int d_doppler_step;
|
||||
unsigned int d_sampled_ms;
|
||||
unsigned int d_max_dwells;
|
||||
unsigned int d_well_count;
|
||||
unsigned int d_fft_size;
|
||||
unsigned int d_nsamples_total; // the closest power of two approximation to d_fft_size
|
||||
unsigned long int d_sample_counter;
|
||||
gr_complex** d_grid_doppler_wipeoffs;
|
||||
unsigned int d_num_doppler_bins;
|
||||
gr_complex* d_fft_codes;
|
||||
gr_complex* d_fft_codes_padded;
|
||||
gr_complex* d_in_32fc;
|
||||
gr::fft::fft_complex* d_fft_if;
|
||||
gr::fft::fft_complex* d_ifft;
|
||||
|
||||
Gnss_Synchro *d_gnss_synchro;
|
||||
unsigned int d_code_phase;
|
||||
float d_doppler_freq;
|
||||
float d_mag;
|
||||
float* d_magnitude;
|
||||
float d_input_power;
|
||||
float d_test_statistics;
|
||||
bool d_bit_transition_flag;
|
||||
bool d_use_CFAR_algorithm_flag;
|
||||
std::ofstream d_dump_file;
|
||||
@ -135,10 +118,10 @@ private:
|
||||
int d_state;
|
||||
bool d_dump;
|
||||
unsigned int d_channel;
|
||||
unsigned int d_select_queue_Fpga;
|
||||
std::string d_dump_filename;
|
||||
|
||||
gps_fpga_acquisition_8sc acquisition_fpga_8sc;
|
||||
|
||||
std::shared_ptr<gps_fpga_acquisition_8sc> acquisition_fpga_8sc;
|
||||
|
||||
public:
|
||||
/*!
|
||||
@ -173,7 +156,7 @@ public:
|
||||
* \brief Sets local code for PCPS acquisition algorithm.
|
||||
* \param code - Pointer to the PRN code.
|
||||
*/
|
||||
void set_local_code(std::complex<float> * code);
|
||||
void set_local_code();
|
||||
|
||||
/*!
|
||||
* \brief Starts acquisition algorithm, turning from standby mode to
|
||||
@ -215,6 +198,7 @@ public:
|
||||
void set_doppler_max(unsigned int doppler_max)
|
||||
{
|
||||
d_doppler_max = doppler_max;
|
||||
acquisition_fpga_8sc->set_doppler_max(doppler_max);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -224,6 +208,7 @@ public:
|
||||
void set_doppler_step(unsigned int doppler_step)
|
||||
{
|
||||
d_doppler_step = doppler_step;
|
||||
acquisition_fpga_8sc->set_doppler_step(doppler_step);
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,6 +55,7 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/core/system_parameters
|
||||
${CMAKE_SOURCE_DIR}/src/core/interfaces
|
||||
${CMAKE_SOURCE_DIR}/src/core/receiver
|
||||
${CMAKE_SOURCE_DIR}/src/algorithms/libs
|
||||
${VOLK_INCLUDE_DIRS}
|
||||
${GLOG_INCLUDE_DIRS}
|
||||
${GFlags_INCLUDE_DIRS}
|
||||
|
@ -34,6 +34,7 @@
|
||||
*/
|
||||
|
||||
#include "gps_fpga_acquisition_8sc.h"
|
||||
#include "gps_sdr_signal_processing.h"
|
||||
#include <cmath>
|
||||
|
||||
// allocate memory dynamically
|
||||
@ -59,139 +60,122 @@
|
||||
// logging
|
||||
#include <glog/logging.h>
|
||||
|
||||
|
||||
#include <volk/volk.h>
|
||||
|
||||
#include "GPS_L1_CA.h"
|
||||
|
||||
#define PAGE_SIZE 0x10000
|
||||
#define CODE_RESAMPLER_NUM_BITS_PRECISION 20
|
||||
#define CODE_PHASE_STEP_CHIPS_NUM_NBITS CODE_RESAMPLER_NUM_BITS_PRECISION
|
||||
#define pwrtwo(x) (1 << (x))
|
||||
#define MAX_CODE_RESAMPLER_COUNTER pwrtwo(CODE_PHASE_STEP_CHIPS_NUM_NBITS) // 2^CODE_PHASE_STEP_CHIPS_NUM_NBITS
|
||||
#define PHASE_CARR_NBITS 32
|
||||
#define PHASE_CARR_NBITS_INT 1
|
||||
#define PHASE_CARR_NBITS_FRAC PHASE_CARR_NBITS - PHASE_CARR_NBITS_INT
|
||||
|
||||
#define MAX_PHASE_STEP_RAD 0.999999999534339 // 1 - pow(2,-31);
|
||||
#define NUM_PRNs 32
|
||||
#define TEST_REGISTER_WRITEVAL 0x55AA
|
||||
|
||||
|
||||
bool gps_fpga_acquisition_8sc::init(unsigned int fft_size, unsigned int nsamples_total, long freq, unsigned int doppler_max, unsigned int doppler_step, int num_doppler_bins, long fs_in, unsigned select_queue)
|
||||
bool gps_fpga_acquisition_8sc::init()
|
||||
{
|
||||
float phase_step_rad_fpga;
|
||||
// configure the acquisition with the main initialization values
|
||||
gps_fpga_acquisition_8sc::configure_acquisition();
|
||||
return true;
|
||||
}
|
||||
|
||||
d_phase_step_rad_vector = new float[num_doppler_bins];
|
||||
|
||||
for (int doppler_index = 0; doppler_index < num_doppler_bins; doppler_index++)
|
||||
{
|
||||
int doppler = -static_cast<int>(doppler_max) + doppler_step * doppler_index;
|
||||
float phase_step_rad = GPS_TWO_PI * (freq + doppler) / static_cast<float>(fs_in);
|
||||
// The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing
|
||||
// The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi)
|
||||
// The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x)
|
||||
// while the gnss-sdr software (volk_gnsssdr_s32f_sincos_32fc) generates cos(x) + j*sin(x)
|
||||
phase_step_rad_fpga = phase_step_rad / (GPS_TWO_PI / 2);
|
||||
// avoid saturation of the fixed point representation in the fpga
|
||||
// (only the positive value can saturate due to the 2's complement representation)
|
||||
if (phase_step_rad_fpga == 1.0)
|
||||
{
|
||||
phase_step_rad_fpga = MAX_PHASE_STEP_RAD;
|
||||
}
|
||||
d_phase_step_rad_vector[doppler_index] = phase_step_rad_fpga;
|
||||
}
|
||||
|
||||
// sanity check : check test register
|
||||
unsigned writeval = 0x55AA;
|
||||
unsigned readval;
|
||||
readval = gps_fpga_acquisition_8sc::fpga_acquisition_test_register(writeval);
|
||||
if (writeval != readval)
|
||||
{
|
||||
printf("test register fail\n");
|
||||
LOG(WARNING) << "Acquisition test register sanity check failed";
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("test register success\n");
|
||||
LOG(INFO) << "Acquisition test register sanity check success !";
|
||||
}
|
||||
bool gps_fpga_acquisition_8sc::set_local_code(unsigned int PRN)
|
||||
{
|
||||
|
||||
d_nsamples = fft_size;
|
||||
d_nsamples_total = nsamples_total;
|
||||
// select the code with the chosen PRN
|
||||
gps_fpga_acquisition_8sc::fpga_configure_acquisition_local_code(&d_all_fft_codes[d_vector_length*PRN]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gps_fpga_acquisition_8sc::gps_fpga_acquisition_8sc(std::string device_name, unsigned int vector_length, unsigned int nsamples, unsigned int nsamples_total, long fs_in, long freq, unsigned int sampled_ms, unsigned select_queue)
|
||||
{
|
||||
|
||||
// initial values
|
||||
|
||||
d_device_name = device_name;
|
||||
d_freq = freq;
|
||||
d_fs_in = fs_in;
|
||||
d_vector_length = vector_length;
|
||||
d_nsamples = nsamples; // number of samples not including padding
|
||||
d_select_queue = select_queue;
|
||||
|
||||
gps_fpga_acquisition_8sc::configure_acquisition();
|
||||
d_doppler_step = 0;
|
||||
d_fd = 0; // driver descriptor
|
||||
d_map_base = nullptr; // driver memory map
|
||||
|
||||
|
||||
// compute all the possible code ffts
|
||||
|
||||
// Direct FFT
|
||||
d_fft_if = new gr::fft::fft_complex(vector_length, true);
|
||||
|
||||
// allocate memory to compute all the PRNs
|
||||
// and compute all the possible codes
|
||||
std::complex<float>* code = new std::complex<float>[nsamples_total]; // buffer for the local code
|
||||
std::complex<float> * code_total = new gr_complex[vector_length]; // buffer for the local code repeate every number of ms
|
||||
|
||||
gr_complex* d_fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(vector_length * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
|
||||
|
||||
d_all_fft_codes = new lv_16sc_t[vector_length*NUM_PRNs]; // memory containing all the possible fft codes for PRN 0 to 32
|
||||
|
||||
float max; // temporary maxima search
|
||||
|
||||
for (unsigned int PRN = 0; PRN < NUM_PRNs; PRN ++)
|
||||
{
|
||||
gps_l1_ca_code_gen_complex_sampled(code, PRN, fs_in , 0); // generate PRN code
|
||||
|
||||
for (unsigned int i = 0; i < sampled_ms; i++)
|
||||
{
|
||||
memcpy(&(code_total[i*nsamples_total]), code, sizeof(gr_complex)*nsamples_total); // repeat for each ms
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
|
||||
memcpy(d_fft_if->get_inbuf() + offset, code_total, sizeof(gr_complex) * vector_length); // copy to FFT buffer
|
||||
|
||||
d_fft_if->execute(); // Run the FFT of local code
|
||||
|
||||
volk_32fc_conjugate_32fc(d_fft_codes_padded, d_fft_if->get_outbuf(), vector_length); // conjugate values
|
||||
|
||||
max = 0; // initialize maximum value
|
||||
|
||||
for (unsigned int i=0;i<vector_length;i++) // search for maxima
|
||||
{
|
||||
if(std::abs(d_fft_codes_padded[i].real()) > max)
|
||||
{
|
||||
max = std::abs(d_fft_codes_padded[i].real());
|
||||
}
|
||||
if(std::abs(d_fft_codes_padded[i].imag()) > max)
|
||||
{
|
||||
max = std::abs(d_fft_codes_padded[i].imag());
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i=0;i<vector_length;i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs
|
||||
{
|
||||
d_all_fft_codes[i + vector_length*PRN] = lv_16sc_t((int) (d_fft_codes_padded[i].real()*(pow(2,7) - 1)/max), (int) (d_fft_codes_padded[i].imag()*(pow(2,7) - 1)/max));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// temporary buffers that we can delete
|
||||
delete[] code;
|
||||
delete[] code_total;
|
||||
delete d_fft_if;
|
||||
delete[] d_fft_codes_padded;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool gps_fpga_acquisition_8sc::set_local_code(gr_complex* fft_codes)
|
||||
{
|
||||
unsigned int i;
|
||||
float max = 0;
|
||||
d_fft_codes = new lv_16sc_t[d_nsamples_total];
|
||||
|
||||
for (i=0;i<d_nsamples_total;i++)
|
||||
{
|
||||
if(std::abs(fft_codes[i].real()) > max)
|
||||
{
|
||||
max = std::abs(fft_codes[i].real());
|
||||
}
|
||||
if(std::abs(fft_codes[i].imag()) > max)
|
||||
{
|
||||
max = std::abs(fft_codes[i].imag());
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0;i<d_nsamples_total;i++)
|
||||
{
|
||||
d_fft_codes[i] = lv_16sc_t((int) (fft_codes[i].real()*(pow(2,7) - 1)/max), (int) (fft_codes[i].imag()*(pow(2,7) - 1)/max));
|
||||
}
|
||||
|
||||
gps_fpga_acquisition_8sc::fpga_configure_acquisition_local_code(d_fft_codes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gps_fpga_acquisition_8sc::gps_fpga_acquisition_8sc()
|
||||
{
|
||||
if ((d_fd = open(d_device_io_name, O_RDWR | O_SYNC )) == -1)
|
||||
{
|
||||
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);
|
||||
|
||||
if (d_map_base == (void *) -1)
|
||||
{
|
||||
LOG(WARNING) << "Cannot map the FPGA acquisition module into user memory";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gps_fpga_acquisition_8sc::~gps_fpga_acquisition_8sc()
|
||||
{
|
||||
if (munmap((void*)d_map_base, PAGE_SIZE) == -1)
|
||||
{
|
||||
printf("Failed to unmap memory uio\n");
|
||||
}
|
||||
|
||||
close(d_fd);
|
||||
delete [] d_all_fft_codes;
|
||||
}
|
||||
|
||||
|
||||
bool gps_fpga_acquisition_8sc::free()
|
||||
{
|
||||
if (d_fft_codes != nullptr)
|
||||
{
|
||||
delete [] d_fft_codes;
|
||||
d_fft_codes = nullptr;
|
||||
}
|
||||
if (d_phase_step_rad_vector != nullptr)
|
||||
{
|
||||
delete [] d_phase_step_rad_vector;
|
||||
d_phase_step_rad_vector = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -215,7 +199,7 @@ void gps_fpga_acquisition_8sc::fpga_configure_acquisition_local_code(lv_16sc_t f
|
||||
|
||||
// clear memory address counter
|
||||
d_map_base[4] = 0x10000000;
|
||||
for (k = 0; k < d_nsamples_total; k++)
|
||||
for (k = 0; k < d_vector_length; k++)
|
||||
{
|
||||
tmp = fft_local_code[k].real();
|
||||
tmp2 = fft_local_code[k].imag();
|
||||
@ -248,7 +232,7 @@ void gps_fpga_acquisition_8sc::run_acquisition(void)
|
||||
void gps_fpga_acquisition_8sc::configure_acquisition()
|
||||
{
|
||||
d_map_base[0] = d_select_queue;
|
||||
d_map_base[1] = d_nsamples_total;
|
||||
d_map_base[1] = d_vector_length;
|
||||
d_map_base[2] = d_nsamples;
|
||||
}
|
||||
|
||||
@ -259,8 +243,19 @@ void gps_fpga_acquisition_8sc::set_phase_step(unsigned int doppler_index)
|
||||
float phase_step_rad_int_temp;
|
||||
int32_t phase_step_rad_int;
|
||||
|
||||
phase_step_rad_real = d_phase_step_rad_vector[doppler_index];
|
||||
|
||||
int doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
|
||||
float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast<float>(d_fs_in);
|
||||
// The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing
|
||||
// The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi)
|
||||
// The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x)
|
||||
// while the gnss-sdr software (volk_gnsssdr_s32f_sincos_32fc) generates cos(x) + j*sin(x)
|
||||
phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2);
|
||||
// avoid saturation of the fixed point representation in the fpga
|
||||
// (only the positive value can saturate due to the 2's complement representation)
|
||||
if (phase_step_rad_real == 1.0)
|
||||
{
|
||||
phase_step_rad_real = MAX_PHASE_STEP_RAD;
|
||||
}
|
||||
phase_step_rad_int_temp = phase_step_rad_real*4; // * 2^2
|
||||
phase_step_rad_int = (int32_t) (phase_step_rad_int_temp*(536870912)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings
|
||||
|
||||
@ -280,6 +275,8 @@ void gps_fpga_acquisition_8sc::read_acquisition_results(uint32_t* max_index, flo
|
||||
*power_sum = (float) readval;
|
||||
readval = d_map_base[3];
|
||||
*max_index = readval;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -295,3 +292,50 @@ void gps_fpga_acquisition_8sc::unblock_samples()
|
||||
}
|
||||
|
||||
|
||||
void gps_fpga_acquisition_8sc::open_device()
|
||||
{
|
||||
|
||||
if ((d_fd = open(d_device_name.c_str(), O_RDWR | O_SYNC )) == -1)
|
||||
{
|
||||
LOG(WARNING) << "Cannot open deviceio" << d_device_name;
|
||||
printf("kk\n");
|
||||
}
|
||||
d_map_base = (volatile unsigned *)mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, d_fd,0);
|
||||
|
||||
if (d_map_base == (void *) -1)
|
||||
{
|
||||
LOG(WARNING) << "Cannot map the FPGA acquisition module into user memory";
|
||||
printf("kk^2\n");
|
||||
}
|
||||
|
||||
// sanity check : check test register
|
||||
// we only nee to do this when the class is created
|
||||
// but the device is not opened yet when the class is create
|
||||
// because we need to open and close the device every time we run an acquisition
|
||||
// since the same device may be used by more than one class (gps acquisition, galileo
|
||||
// acquisition, etc ..)
|
||||
unsigned writeval = TEST_REGISTER_WRITEVAL;
|
||||
unsigned readval;
|
||||
readval = gps_fpga_acquisition_8sc::fpga_acquisition_test_register(writeval);
|
||||
if (writeval != readval)
|
||||
{
|
||||
LOG(WARNING) << "Acquisition test register sanity check failed";
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(INFO) << "Acquisition test register sanity check success !";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void gps_fpga_acquisition_8sc::close_device()
|
||||
{
|
||||
printf("CLOSE DEVICE\n");
|
||||
if (munmap((void*)d_map_base, PAGE_SIZE) == -1)
|
||||
{
|
||||
printf("Failed to unmap memory uio\n");
|
||||
}
|
||||
close(d_fd);
|
||||
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <volk_gnsssdr/volk_gnsssdr.h>
|
||||
|
||||
#include <gnuradio/block.h>
|
||||
|
||||
#include <gnuradio/fft/fft.h>
|
||||
|
||||
/*!
|
||||
* \brief Class that implements carrier wipe-off and correlators.
|
||||
@ -47,35 +47,55 @@
|
||||
class gps_fpga_acquisition_8sc
|
||||
{
|
||||
public:
|
||||
gps_fpga_acquisition_8sc();
|
||||
gps_fpga_acquisition_8sc(std::string device_name, unsigned int vector_length, unsigned int nsamples, unsigned int nsamples_total, long fs_in, long freq, unsigned int sampled_ms, unsigned select_queue);
|
||||
~gps_fpga_acquisition_8sc();
|
||||
bool init(unsigned int fft_size, unsigned int nsamples_total, long d_freq, unsigned int doppler_max, unsigned int doppler_step, int num_doppler_bins, long fs_in, unsigned select_queue);
|
||||
bool set_local_code(gr_complex* fft_codes); //int code_length_chips, const lv_16sc_t* local_code_in, float *shifts_chips);
|
||||
bool init();
|
||||
bool set_local_code(unsigned int PRN); //int code_length_chips, const lv_16sc_t* local_code_in, float *shifts_chips);
|
||||
bool free();
|
||||
void run_acquisition(void);
|
||||
void set_phase_step(unsigned int doppler_index);
|
||||
void read_acquisition_results(uint32_t* max_index, float* max_magnitude, unsigned *initial_sample, float *power_sum);
|
||||
void block_samples();
|
||||
void unblock_samples();
|
||||
void open_device();
|
||||
void close_device();
|
||||
|
||||
/*!
|
||||
* \brief Set maximum Doppler grid search
|
||||
* \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
|
||||
*/
|
||||
void set_doppler_max(unsigned int doppler_max)
|
||||
{
|
||||
d_doppler_max = doppler_max;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set Doppler steps for the grid search
|
||||
* \param doppler_step - Frequency bin of the search grid [Hz].
|
||||
*/
|
||||
void set_doppler_step(unsigned int doppler_step)
|
||||
{
|
||||
d_doppler_step = doppler_step;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
const lv_16sc_t *d_local_code_in;
|
||||
lv_16sc_t *d_corr_out;
|
||||
float *d_shifts_chips;
|
||||
int d_code_length_chips;
|
||||
int d_n_correlators;
|
||||
|
||||
long d_freq;
|
||||
long d_fs_in;
|
||||
gr::fft::fft_complex* d_fft_if; // function used to run the fft of the local codes
|
||||
|
||||
// data related to the hardware module and the driver
|
||||
char d_device_io_name[11] = "/dev/uio13"; // driver io name
|
||||
int d_fd; // driver descriptor
|
||||
volatile unsigned *d_map_base; // driver memory map
|
||||
int d_fd; // driver descriptor
|
||||
volatile unsigned *d_map_base; // driver memory map
|
||||
lv_16sc_t *d_all_fft_codes; // memory that contains all the code ffts
|
||||
unsigned int d_vector_length; // number of samples incluing padding and number of ms
|
||||
unsigned int d_nsamples; // number of samples not including padding
|
||||
unsigned int d_select_queue; // queue selection
|
||||
std::string d_device_name; // HW device name
|
||||
unsigned int d_doppler_max; // max doppler
|
||||
unsigned int d_doppler_step; // doppler step
|
||||
|
||||
// configuration data received from the interface
|
||||
lv_16sc_t *d_fft_codes = nullptr;
|
||||
float *d_phase_step_rad_vector = nullptr;
|
||||
|
||||
unsigned int d_nsamples_total; // total number of samples in the fft including padding
|
||||
unsigned int d_nsamples; // number of samples not including padding
|
||||
unsigned int d_select_queue; // queue selection
|
||||
|
||||
// FPGA private functions
|
||||
unsigned fpga_acquisition_test_register(unsigned writeval);
|
||||
|
@ -63,6 +63,9 @@ GpsL1CaDllPllCAidTrackingFpga::GpsL1CaDllPllCAidTrackingFpga(
|
||||
float dll_bw_hz;
|
||||
float dll_bw_narrow_hz;
|
||||
float early_late_space_chips;
|
||||
std::string device_name;
|
||||
unsigned int device_base;
|
||||
unsigned int device_range;
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
fs_in = configuration->property("GNSS-SDR.internal_fs_hz", 2048000);
|
||||
f_if = configuration->property(role + ".if", 0);
|
||||
@ -77,7 +80,11 @@ GpsL1CaDllPllCAidTrackingFpga::GpsL1CaDllPllCAidTrackingFpga(
|
||||
early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5);
|
||||
std::string default_dump_filename = "./track_ch";
|
||||
dump_filename = configuration->property(role + ".dump_filename",
|
||||
default_dump_filename); //unused!
|
||||
default_dump_filename);
|
||||
std::string default_device_name = "/dev/uio";
|
||||
device_name = configuration->property(role + ".devicename", default_device_name);
|
||||
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));
|
||||
|
||||
//################# MAKE TRACKING GNURadio object ###################
|
||||
@ -96,7 +103,11 @@ GpsL1CaDllPllCAidTrackingFpga::GpsL1CaDllPllCAidTrackingFpga(
|
||||
pll_bw_narrow_hz,
|
||||
dll_bw_narrow_hz,
|
||||
extend_correlation_ms,
|
||||
early_late_space_chips);
|
||||
early_late_space_chips,
|
||||
device_name,
|
||||
device_base,
|
||||
device_range
|
||||
);
|
||||
DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")";
|
||||
}
|
||||
else
|
||||
@ -207,3 +218,11 @@ gr::basic_block_sptr GpsL1CaDllPllCAidTrackingFpga::get_right_block()
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void GpsL1CaDllPllCAidTrackingFpga::reset(void)
|
||||
{
|
||||
|
||||
tracking_fpga_sc->reset();
|
||||
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,8 @@ public:
|
||||
|
||||
void start_tracking();
|
||||
|
||||
void reset(void);
|
||||
|
||||
private:
|
||||
gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc_sptr tracking_fpga_sc;
|
||||
size_t item_size_;
|
||||
|
@ -71,10 +71,14 @@ gps_l1_ca_dll_pll_c_aid_make_tracking_fpga_sc(
|
||||
float pll_bw_narrow_hz,
|
||||
float dll_bw_narrow_hz,
|
||||
int extend_correlation_ms,
|
||||
float early_late_space_chips)
|
||||
float early_late_space_chips,
|
||||
std::string device_name,
|
||||
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,
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@ -101,7 +105,10 @@ gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::gps_l1_ca_dll_pll_c_aid_tracking_fpga_
|
||||
float pll_bw_narrow_hz,
|
||||
float dll_bw_narrow_hz,
|
||||
int extend_correlation_ms,
|
||||
float early_late_space_chips) :
|
||||
float early_late_space_chips,
|
||||
std::string device_name,
|
||||
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::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
|
||||
|
||||
@ -151,7 +158,9 @@ 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[2] = d_early_late_spc_chips;
|
||||
|
||||
//multicorrelator_fpga_8sc= std::make_shared<fpga_multicorrelator_8sc>();
|
||||
multicorrelator_fpga_8sc.init(d_n_correlator_taps);
|
||||
//multicorrelator_fpga_8sc->init(d_n_correlator_taps);
|
||||
|
||||
//--- Perform initializations ------------------------------
|
||||
// define initial code frequency basis of NCO
|
||||
@ -259,6 +268,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::start_tracking()
|
||||
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);
|
||||
for (int n = 0; n < d_n_correlator_taps; n++)
|
||||
{
|
||||
d_correlator_outs_16sc[n] = lv_16sc_t(0,0);
|
||||
@ -285,6 +295,10 @@ void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::start_tracking()
|
||||
d_enable_extended_integration = false;
|
||||
d_preamble_synchronized = false;
|
||||
|
||||
// lock the channel
|
||||
multicorrelator_fpga_8sc.lock_channel();
|
||||
|
||||
|
||||
LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz
|
||||
<< " Code Phase correction [samples]=" << delay_correction_samples
|
||||
<< " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples;
|
||||
@ -302,6 +316,7 @@ gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::~gps_l1_ca_dll_pll_c_aid_tracking_fpga
|
||||
|
||||
delete[] d_Prompt_buffer;
|
||||
multicorrelator_fpga_8sc.free();
|
||||
//multicorrelator_fpga_8sc->free();
|
||||
}
|
||||
|
||||
|
||||
@ -341,6 +356,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work (int noutput_items __
|
||||
*out[0] = current_synchro_data;
|
||||
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);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -349,11 +365,17 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work (int noutput_items __
|
||||
// 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,
|
||||
d_carrier_phase_step_rad,
|
||||
d_rem_code_phase_chips,
|
||||
d_code_phase_step_chips,
|
||||
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
|
||||
// keep the last symbols
|
||||
@ -527,6 +549,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
|
||||
d_carrier_lock_fail_counter = 0;
|
||||
d_enable_tracking = false; // TODO: check if disabling tracking is consistent with the channel state machine
|
||||
multicorrelator_fpga_8sc.unlock_channel();
|
||||
}
|
||||
}
|
||||
// ########### Output the tracking data to navigation and PVT ##########
|
||||
@ -638,7 +661,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_channel(unsigned int channel)
|
||||
{
|
||||
d_channel = channel;
|
||||
multicorrelator_fpga_8sc.set_channel(d_channel);
|
||||
|
||||
//multicorrelator_fpga_8sc->set_channel(d_channel);
|
||||
LOG(INFO) << "Tracking Channel set to " << d_channel;
|
||||
// ############# ENABLE DATA FILE LOG #################
|
||||
if (d_dump == true)
|
||||
@ -666,3 +689,8 @@ void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_gnss_synchro(Gnss_Synchro* p_
|
||||
{
|
||||
d_acquisition_gnss_synchro = p_gnss_synchro;
|
||||
}
|
||||
|
||||
void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::reset(void)
|
||||
{
|
||||
multicorrelator_fpga_8sc.unlock_channel();
|
||||
}
|
||||
|
@ -67,7 +67,10 @@ gps_l1_ca_dll_pll_c_aid_make_tracking_fpga_sc(long if_freq,
|
||||
float pll_bw_narrow_hz,
|
||||
float dll_bw_narrow_hz,
|
||||
int extend_correlation_ms,
|
||||
float early_late_space_chips);
|
||||
float early_late_space_chips,
|
||||
std::string device_name,
|
||||
unsigned int device_base,
|
||||
unsigned int device_range);
|
||||
|
||||
|
||||
|
||||
@ -86,6 +89,8 @@ public:
|
||||
int general_work (int noutput_items, gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
|
||||
|
||||
void reset(void);
|
||||
|
||||
private:
|
||||
friend gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc_sptr
|
||||
gps_l1_ca_dll_pll_c_aid_make_tracking_fpga_sc(long if_freq,
|
||||
@ -98,7 +103,10 @@ private:
|
||||
float pll_bw_narrow_hz,
|
||||
float dll_bw_narrow_hz,
|
||||
int extend_correlation_ms,
|
||||
float early_late_space_chips);
|
||||
float early_late_space_chips,
|
||||
std::string device_name,
|
||||
unsigned int device_base,
|
||||
unsigned int device_range);
|
||||
|
||||
gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc(long if_freq,
|
||||
long fs_in, unsigned
|
||||
@ -110,7 +118,10 @@ private:
|
||||
float pll_bw_narrow_hz,
|
||||
float dll_bw_narrow_hz,
|
||||
int extend_correlation_ms,
|
||||
float early_late_space_chips);
|
||||
float early_late_space_chips,
|
||||
std::string device_name,
|
||||
unsigned int device_base,
|
||||
unsigned int device_range);
|
||||
|
||||
// tracking configuration vars
|
||||
unsigned int d_vector_length;
|
||||
@ -131,6 +142,7 @@ private:
|
||||
//gr_complex* d_correlator_outs;
|
||||
lv_16sc_t* d_correlator_outs_16sc;
|
||||
fpga_multicorrelator_8sc multicorrelator_fpga_8sc;
|
||||
//std::shared_ptr<fpga_multicorrelator_8sc> multicorrelator_fpga_8sc;
|
||||
|
||||
// remaining code phase and carrier phase between tracking loops
|
||||
double d_rem_code_phase_samples;
|
||||
|
@ -176,6 +176,7 @@ fpga_multicorrelator_8sc::~fpga_multicorrelator_8sc()
|
||||
bool fpga_multicorrelator_8sc::free()
|
||||
{
|
||||
// unlock the hardware
|
||||
|
||||
fpga_multicorrelator_8sc::unlock_channel(); // unlock the channel
|
||||
|
||||
// free the FPGA dynamically created variables
|
||||
@ -199,7 +200,7 @@ void fpga_multicorrelator_8sc::set_channel(unsigned int channel)
|
||||
{
|
||||
d_channel = channel;
|
||||
|
||||
snprintf(d_device_io_name, MAX_LENGTH_DEVICEIO_NAME, "/dev/uio%d",d_channel);
|
||||
snprintf(d_device_io_name, MAX_LENGTH_DEVICEIO_NAME, "/dev/uio%d",d_channel + 1);
|
||||
printf("Opening Device Name : %s\n", d_device_io_name);
|
||||
|
||||
if ((d_fd = open(d_device_io_name, O_RDWR | O_SYNC )) == -1)
|
||||
@ -245,13 +246,13 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(void)
|
||||
{
|
||||
int k,s;
|
||||
unsigned temp;
|
||||
unsigned *ena_write_signals;
|
||||
ena_write_signals = new unsigned[d_n_correlators];
|
||||
ena_write_signals[0] = 0x00000000;
|
||||
ena_write_signals[1] = 0x20000000;
|
||||
//unsigned *ena_write_signals;
|
||||
d_ena_write_signals = new unsigned[d_n_correlators];
|
||||
d_ena_write_signals[0] = 0x00000000;
|
||||
d_ena_write_signals[1] = 0x20000000;
|
||||
for (s = 2; s < d_n_correlators; s++)
|
||||
{
|
||||
ena_write_signals[s]= ena_write_signals[s-1]*2; //0x40000000;
|
||||
d_ena_write_signals[s]= d_ena_write_signals[s-1]*2; //0x40000000;
|
||||
}
|
||||
|
||||
for (s = 0; s < d_n_correlators; s++)
|
||||
@ -269,11 +270,11 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(void)
|
||||
{
|
||||
temp = 0;
|
||||
}
|
||||
d_map_base[11] = 0x0C000000 | (temp & 0xFFFF) | ena_write_signals[s];
|
||||
d_map_base[11] = 0x0C000000 | (temp & 0xFFFF) | d_ena_write_signals[s];
|
||||
}
|
||||
}
|
||||
|
||||
delete [] ena_write_signals;
|
||||
// delete [] ena_write_signals;
|
||||
}
|
||||
|
||||
|
||||
@ -361,7 +362,8 @@ void fpga_multicorrelator_8sc::fpga_configure_signal_parameters_in_fpga(void)
|
||||
d_map_base[7] = d_correlator_length_samples - 1;
|
||||
d_map_base[9] = d_rem_carr_phase_rad_int;
|
||||
d_map_base[10] = d_phase_step_rad_int;
|
||||
d_map_base[12] = 0; // lock the channel
|
||||
//printf("locking the channel\n");
|
||||
//d_map_base[12] = 0; // lock the channel
|
||||
d_map_base[13] = d_initial_sample_counter;
|
||||
}
|
||||
|
||||
@ -383,6 +385,9 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void)
|
||||
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++)
|
||||
{
|
||||
@ -416,6 +421,15 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void)
|
||||
|
||||
void fpga_multicorrelator_8sc::unlock_channel(void)
|
||||
{
|
||||
//printf("unlock the channel\n");
|
||||
// unlock the channel to let the next samples go through
|
||||
d_map_base[12] = 1; // unlock the channel
|
||||
}
|
||||
|
||||
void fpga_multicorrelator_8sc::lock_channel(void)
|
||||
{
|
||||
//printf("locking the channel\n");
|
||||
d_map_base[12] = 0; // lock the channel
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,6 +59,10 @@ public:
|
||||
|
||||
void set_channel(unsigned int channel);
|
||||
void set_initial_sample(int samples_offset);
|
||||
void lock_channel(void);
|
||||
void unlock_channel(void);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
const lv_16sc_t *d_local_code_in;
|
||||
@ -88,7 +92,7 @@ private:
|
||||
int d_rem_carr_phase_rad_int;
|
||||
int d_phase_step_rad_int;
|
||||
unsigned d_initial_sample_counter;
|
||||
|
||||
unsigned *d_ena_write_signals;
|
||||
// FPGA private functions
|
||||
unsigned fpga_acquisition_test_register(unsigned writeval);
|
||||
void fpga_configure_tracking_gps_local_code(void);
|
||||
@ -98,7 +102,9 @@ private:
|
||||
void fpga_configure_signal_parameters_in_fpga(void);
|
||||
void fpga_launch_multicorrelator_fpga(void);
|
||||
void read_tracking_gps_results(void);
|
||||
void unlock_channel(void);
|
||||
|
||||
//void unlock_channel(void);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -137,7 +137,6 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block, const char
|
||||
for (int k=0;k<NTIMES_CYCLE_THROUGH_RX_SAMPLES_FILE;k++)
|
||||
{
|
||||
|
||||
|
||||
fseek(ptr_myfile, 0, SEEK_SET);
|
||||
|
||||
int transfer_size;
|
||||
@ -239,7 +238,7 @@ GpsL1CaPcpsAcquisitionTestFpga_msg_rx::~GpsL1CaPcpsAcquisitionTestFpga_msg_rx()
|
||||
{}
|
||||
|
||||
|
||||
// ###########################################################
|
||||
|
||||
|
||||
class GpsL1CaPcpsAcquisitionTestFpga: public ::testing::Test
|
||||
{
|
||||
@ -283,7 +282,10 @@ void GpsL1CaPcpsAcquisitionTestFpga::init()
|
||||
config->set_property("Acquisition.doppler_step", "500");
|
||||
config->set_property("Acquisition.repeat_satellite", "false");
|
||||
config->set_property("Acquisition.pfa", "0.0");
|
||||
// extra configuration properties for the FPGA
|
||||
config->set_property("Acquisition.select_queue_Fpga", "0");
|
||||
config->set_property("Acquisition.devicename", "/dev/uio0");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,8 +97,13 @@ void send_tracking_gps_input_samples(FILE *ptr_myfile, int num_remaining_samples
|
||||
fprintf(stderr, "Memory error!");
|
||||
}
|
||||
|
||||
printf("now i will send the samples\n");
|
||||
|
||||
while(num_remaining_samples > 0)
|
||||
{
|
||||
|
||||
//printf("num_remaining_samples = %d\n", num_remaining_samples);
|
||||
|
||||
if (num_remaining_samples < MIN_SAMPLES_REMAINING)
|
||||
{
|
||||
if (flowgraph_stopped == 0)
|
||||
@ -330,6 +335,9 @@ void GpsL1CADllPllTrackingTestFpga::configure_receiver()
|
||||
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.early_late_space_chips", "0.5");
|
||||
config->set_property("Tracking_GPS.devicename", "/dev/uio");
|
||||
config->set_property("Tracking_GPS.device_base", "0");
|
||||
config->set_property("Tracking_GPS.device_range", "0");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user