mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 04:30:33 +00:00
Improving SPIR GSS6450 signal source
This commit is contained in:
parent
514b9dd35f
commit
1302614613
@ -153,7 +153,8 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface*
|
|||||||
valve_vec_.push_back(gnss_sdr_make_valve(sizeof(gr_complex), samples_, queue_));
|
valve_vec_.push_back(gnss_sdr_make_valve(sizeof(gr_complex), samples_, queue_));
|
||||||
if (dump_)
|
if (dump_)
|
||||||
{
|
{
|
||||||
sink_vec_.push_back(gr::blocks::file_sink::make(sizeof(gr_complex), dump_filename_.c_str()));
|
std::string tmp_str = dump_filename_ + "_ch" + std::to_string(i);
|
||||||
|
sink_vec_.push_back(gr::blocks::file_sink::make(sizeof(gr_complex), tmp_str.c_str()));
|
||||||
}
|
}
|
||||||
if (enable_throttle_control_)
|
if (enable_throttle_control_)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*
|
*
|
||||||
* \brief Unpacks SPIR int samples
|
* \brief Unpacks SPIR int samples
|
||||||
* \author Antonio Ramos, antonio(at)cttc.es
|
* \author Antonio Ramos, antonio(at)cttc.es
|
||||||
|
* \author Javier Arribas jarribas (at) cttc.es
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||||
@ -45,10 +46,6 @@ unpack_spir_gss6450_samples::unpack_spir_gss6450_samples(unsigned int adc_nbit)
|
|||||||
{
|
{
|
||||||
adc_bits = adc_nbit;
|
adc_bits = adc_nbit;
|
||||||
samples_per_int = 16 / adc_bits;
|
samples_per_int = 16 / adc_bits;
|
||||||
i_data.resize(adc_bits, false);
|
|
||||||
q_data.resize(adc_bits, false);
|
|
||||||
adc_bits_two_pow = static_cast<int>(std::exp2(adc_bits));
|
|
||||||
two_compl_thres = adc_bits_two_pow / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -56,50 +53,87 @@ unpack_spir_gss6450_samples::~unpack_spir_gss6450_samples()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unpack_spir_gss6450_samples::decode_4bits_word(uint32_t input_uint32, gr_complex* out, int adc_bits)
|
||||||
int unpack_spir_gss6450_samples::compute_two_complement(unsigned long data)
|
|
||||||
{
|
{
|
||||||
int res = 0;
|
int8_t tmp_char;
|
||||||
if (static_cast<int>(data) < two_compl_thres)
|
float Q;
|
||||||
|
float I;
|
||||||
|
switch (adc_bits)
|
||||||
{
|
{
|
||||||
res = static_cast<int>(data);
|
case 2:
|
||||||
}
|
//four bits per complex sample (2 I + 2 Q), 8 samples per int32[s0,s1,s2,s3,s4,s5,s6,s7]
|
||||||
else
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
res = static_cast<int>(data) - adc_bits_two_pow;
|
tmp_char = input_uint32 & 3;
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (tmp_char >= 2)
|
||||||
|
{
|
||||||
|
I = (tmp_char - 4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
I = tmp_char;
|
||||||
|
}
|
||||||
|
input_uint32 = input_uint32 >> 2;
|
||||||
|
tmp_char = input_uint32 & 3;
|
||||||
|
if (tmp_char >= 2)
|
||||||
|
{
|
||||||
|
Q = (tmp_char - 4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Q = tmp_char;
|
||||||
|
}
|
||||||
|
input_uint32 = input_uint32 >> 2;
|
||||||
|
|
||||||
|
out[7 - i] = gr_complex(I, Q);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
//eight bits per complex sample (4 I + 4 Q), 4 samples per int32= [s0,s1,s2,s3]
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
tmp_char = input_uint32 & 0x0F;
|
||||||
|
|
||||||
|
if (tmp_char >= 8)
|
||||||
|
{
|
||||||
|
I = (tmp_char - 16);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
I = tmp_char;
|
||||||
|
}
|
||||||
|
input_uint32 = input_uint32 >> 4;
|
||||||
|
tmp_char = input_uint32 & 0x0F;
|
||||||
|
if (tmp_char >= 8)
|
||||||
|
{
|
||||||
|
Q = (tmp_char - 16);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Q = tmp_char;
|
||||||
|
}
|
||||||
|
input_uint32 = input_uint32 >> 4;
|
||||||
|
|
||||||
|
out[3 - i] = gr_complex(I, Q);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int unpack_spir_gss6450_samples::work(int noutput_items,
|
int unpack_spir_gss6450_samples::work(int noutput_items,
|
||||||
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)
|
||||||
{
|
{
|
||||||
const int* in = reinterpret_cast<const int*>(input_items[0]);
|
const int32_t* in = reinterpret_cast<const int32_t*>(input_items[0]);
|
||||||
gr_complex* out = reinterpret_cast<gr_complex*>(output_items[0]);
|
gr_complex* out = reinterpret_cast<gr_complex*>(output_items[0]);
|
||||||
unsigned int n_sample = 0;
|
int n_sample = 0;
|
||||||
unsigned int in_counter = 0;
|
int in_counter = 0;
|
||||||
std::bitset<32> bs;
|
do
|
||||||
for (int i = 0; i < noutput_items; i++)
|
|
||||||
{
|
{
|
||||||
bs = in[in_counter];
|
decode_4bits_word(in[in_counter++], &out[n_sample], adc_bits);
|
||||||
int i_shift = adc_bits * 2 * (samples_per_int - n_sample - 1) + adc_bits;
|
n_sample += samples_per_int;
|
||||||
int q_shift = adc_bits * 2 * (samples_per_int - n_sample - 1);
|
|
||||||
for (unsigned int k = 0; k < adc_bits; k++)
|
|
||||||
{
|
|
||||||
i_data[k] = bs[i_shift + k];
|
|
||||||
q_data[k] = bs[q_shift + k];
|
|
||||||
}
|
|
||||||
//out[i] = gr_complex(static_cast<float>(compute_two_complement(i_data.to_ulong())) + 0.5,
|
|
||||||
// static_cast<float>(compute_two_complement(q_data.to_ulong())) + 0.5);
|
|
||||||
out[i] = gr_complex(static_cast<float>(compute_two_complement(q_data.to_ulong())) + 0.5,
|
|
||||||
static_cast<float>(compute_two_complement(i_data.to_ulong())) + 0.5);
|
|
||||||
n_sample++;
|
|
||||||
if (n_sample == samples_per_int)
|
|
||||||
{
|
|
||||||
n_sample = 0;
|
|
||||||
in_counter++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
while (n_sample < noutput_items);
|
||||||
|
|
||||||
return noutput_items;
|
return noutput_items;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*
|
*
|
||||||
* \brief Unpacks SPIR int samples
|
* \brief Unpacks SPIR int samples
|
||||||
* \author Antonio Ramos, antonio.ramos(at)cttc.es
|
* \author Antonio Ramos, antonio.ramos(at)cttc.es
|
||||||
|
* \author Javier Arribas jarribas (at) cttc.es
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||||
@ -32,7 +33,6 @@
|
|||||||
#define GNSS_SDR_UNPACK_SPIR_GSS6450_SAMPLES_H
|
#define GNSS_SDR_UNPACK_SPIR_GSS6450_SAMPLES_H
|
||||||
|
|
||||||
#include <gnuradio/sync_interpolator.h>
|
#include <gnuradio/sync_interpolator.h>
|
||||||
#include <boost/dynamic_bitset.hpp>
|
|
||||||
|
|
||||||
class unpack_spir_gss6450_samples;
|
class unpack_spir_gss6450_samples;
|
||||||
|
|
||||||
@ -47,18 +47,13 @@ public:
|
|||||||
int work(int noutput_items,
|
int work(int noutput_items,
|
||||||
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);
|
||||||
friend unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples_sptr(unsigned int adc_nbit);
|
friend unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples_sptr(unsigned int adc_nbit);
|
||||||
|
void decode_4bits_word(uint32_t input_int32, gr_complex *out, int adc_bits);
|
||||||
unpack_spir_gss6450_samples(unsigned int adc_nbit);
|
unpack_spir_gss6450_samples(unsigned int adc_nbit);
|
||||||
~unpack_spir_gss6450_samples();
|
~unpack_spir_gss6450_samples();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int compute_two_complement(unsigned long data);
|
|
||||||
|
|
||||||
unsigned int adc_bits;
|
unsigned int adc_bits;
|
||||||
unsigned int samples_per_int;
|
unsigned int samples_per_int;
|
||||||
int two_compl_thres;
|
|
||||||
int adc_bits_two_pow;
|
|
||||||
boost::dynamic_bitset<> i_data;
|
|
||||||
boost::dynamic_bitset<> q_data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user