1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-10-24 20:17:39 +00:00

Add mechanisms for inverted spectrum

This commit is contained in:
Carles Fernandez
2017-11-17 09:21:03 +01:00
parent fe241c8b2d
commit d20902d688
21 changed files with 583 additions and 47 deletions

View File

@@ -32,6 +32,9 @@ set(GNSS_SPLIBS_SOURCES
cshort_to_float_x2.cc
short_x2_to_cshort.cc
complex_float_to_complex_byte.cc
conjugate_cc.cc
conjugate_sc.cc
conjugate_ic.cc
)

View File

@@ -0,0 +1,29 @@
#include "conjugate_cc.h"
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
conjugate_cc_sptr make_conjugate_cc()
{
return conjugate_cc_sptr(new conjugate_cc());
}
conjugate_cc::conjugate_cc() : gr::sync_block("conjugate_cc",
gr::io_signature::make (1, 1, sizeof(gr_complex)),
gr::io_signature::make (1, 1, sizeof(gr_complex)))
{
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple));
}
int conjugate_cc::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = reinterpret_cast<const gr_complex *>(input_items[0]);
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
volk_32fc_conjugate_32fc(out, in, noutput_items);
return noutput_items;
}

View File

@@ -0,0 +1,59 @@
/*!
* \file conjugate_cc.h
* \brief Conjugate
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_CONJUGATE_CC_H_
#define GNSS_SDR_CONJUGATE_CC_H_
#include <boost/shared_ptr.hpp>
#include <gnuradio/sync_block.h>
class conjugate_cc;
typedef boost::shared_ptr<conjugate_cc> conjugate_cc_sptr;
conjugate_cc_sptr make_conjugate_cc();
/*!
* \brief This class adapts a std::complex<short> stream
* into two 32-bits (float) streams
*/
class conjugate_cc : public gr::sync_block
{
private:
friend conjugate_cc_sptr make_conjugate_cc();
public:
conjugate_cc();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif

View File

@@ -0,0 +1,29 @@
#include "conjugate_ic.h"
#include <gnuradio/io_signature.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
conjugate_ic_sptr make_conjugate_ic()
{
return conjugate_ic_sptr(new conjugate_ic());
}
conjugate_ic::conjugate_ic() : gr::sync_block("conjugate_ic",
gr::io_signature::make (1, 1, sizeof(lv_8sc_t)),
gr::io_signature::make (1, 1, sizeof(lv_8sc_t)))
{
const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_8sc_t);
set_alignment(std::max(1, alignment_multiple));
}
int conjugate_ic::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const lv_8sc_t *in = reinterpret_cast<const lv_8sc_t *>(input_items[0]);
lv_8sc_t *out = reinterpret_cast<lv_8sc_t *>(output_items[0]);
volk_gnsssdr_8ic_conjugate_8ic(out, in, noutput_items);
return noutput_items;
}

View File

@@ -0,0 +1,59 @@
/*!
* \file conjugate_ic.h
* \brief Adapts a std::complex<short> stream into two float streams
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_CONJUGATE_IC_H_
#define GNSS_SDR_CONJUGATE_IC_H_
#include <boost/shared_ptr.hpp>
#include <gnuradio/sync_block.h>
class conjugate_ic;
typedef boost::shared_ptr<conjugate_ic> conjugate_ic_sptr;
conjugate_ic_sptr make_conjugate_ic();
/*!
* \brief This class adapts a std::complex<short> stream
* into two 32-bits (float) streams
*/
class conjugate_ic : public gr::sync_block
{
private:
friend conjugate_ic_sptr make_conjugate_ic();
public:
conjugate_ic();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif

View File

@@ -0,0 +1,29 @@
#include "conjugate_sc.h"
#include <gnuradio/io_signature.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
conjugate_sc_sptr make_conjugate_sc()
{
return conjugate_sc_sptr(new conjugate_sc());
}
conjugate_sc::conjugate_sc() : gr::sync_block("conjugate_sc",
gr::io_signature::make (1, 1, sizeof(lv_16sc_t)),
gr::io_signature::make (1, 1, sizeof(lv_16sc_t)))
{
const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_16sc_t);
set_alignment(std::max(1, alignment_multiple));
}
int conjugate_sc::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const lv_16sc_t *in = reinterpret_cast<const lv_16sc_t *>(input_items[0]);
lv_16sc_t *out = reinterpret_cast<lv_16sc_t *>(output_items[0]);
volk_gnsssdr_16ic_conjugate_16ic(out, in, noutput_items);
return noutput_items;
}

View File

@@ -0,0 +1,59 @@
/*!
* \file conjugate_sc.h
* \brief Adapts a std::complex<short> stream into two float streams
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_CONJUGATE_SC_H_
#define GNSS_SDR_CONJUGATE_SC_H_
#include <boost/shared_ptr.hpp>
#include <gnuradio/sync_block.h>
class conjugate_sc;
typedef boost::shared_ptr<conjugate_sc> conjugate_sc_sptr;
conjugate_sc_sptr make_conjugate_sc();
/*!
* \brief This class adapts a std::complex<short> stream
* into two 32-bits (float) streams
*/
class conjugate_sc : public gr::sync_block
{
private:
friend conjugate_sc_sptr make_conjugate_sc();
public:
conjugate_sc();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif

View File

@@ -57,7 +57,7 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
}
item_type_ = configuration->property(role + ".item_type", input_type);
vector_size_ = configuration->property(role + ".vector_size", 1);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
if(item_type_.compare("float") == 0)
{
@@ -66,6 +66,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
else if(item_type_.compare("gr_complex") == 0)
{
item_size_ = sizeof(gr_complex);
if(inverted_spectrum)
{
conjugate_cc_ = make_conjugate_cc();
}
}
else if(item_type_.compare("short") == 0)
{
@@ -78,6 +82,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
else if(item_type_.compare("cshort") == 0)
{
item_size_ = sizeof(lv_16sc_t);
if(inverted_spectrum)
{
conjugate_sc_ = make_conjugate_sc();
}
}
else if(item_type_.compare("byte") == 0)
{
@@ -90,12 +98,17 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
else if(item_type_.compare("cbyte") == 0)
{
item_size_ = sizeof(lv_8sc_t);
if(inverted_spectrum)
{
conjugate_ic_ = make_conjugate_ic();
}
}
else
{
LOG(WARNING) << item_type_ << " unrecognized item type. Using float";
item_size_ = sizeof(float);
}
kludge_copy_ = gr::blocks::copy::make(item_size_);
DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")";
}
@@ -125,6 +138,27 @@ void Pass_Through::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr Pass_Through::get_left_block()
{
if(inverted_spectrum)
{
if(item_type_.compare("gr_complex") == 0)
{
return conjugate_cc_;
}
else if(item_type_.compare("cshort") == 0)
{
return conjugate_sc_;
}
else if(item_type_.compare("cbyte") == 0)
{
return conjugate_ic_;
}
else
{
LOG(WARNING) << "Setting inverted_spectrum to true with item_type "
<< item_type_ << " is not defined and has no effect.";
}
}
return kludge_copy_;
}
@@ -132,5 +166,26 @@ gr::basic_block_sptr Pass_Through::get_left_block()
gr::basic_block_sptr Pass_Through::get_right_block()
{
if(inverted_spectrum)
{
if(item_type_.compare("gr_complex") == 0)
{
return conjugate_cc_;
}
else if(item_type_.compare("cshort") == 0)
{
return conjugate_sc_;
}
else if(item_type_.compare("cbyte") == 0)
{
return conjugate_ic_;
}
else
{
DLOG(WARNING) << "Setting inverted_spectrum to true with item_type "
<< item_type_ << " is not defined and has no effect.";
}
}
return kludge_copy_;
}

View File

@@ -37,6 +37,10 @@
#include <gnuradio/hier_block2.h>
#include <gnuradio/blocks/copy.h>
#include "gnss_block_interface.h"
#include "conjugate_cc.h"
#include "conjugate_sc.h"
#include "conjugate_ic.h"
class ConfigurationInterface;
@@ -69,11 +73,6 @@ public:
return item_type_;
}
inline size_t vector_size() const
{
return vector_size_;
}
inline size_t item_size() override
{
return item_size_;
@@ -86,13 +85,16 @@ public:
private:
std::string item_type_;
size_t vector_size_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
//gr_kludge_copy_sptr kludge_copy_;
gr::blocks::copy::sptr kludge_copy_;
size_t item_size_;
conjugate_cc_sptr conjugate_cc_;
conjugate_sc_sptr conjugate_sc_;
conjugate_ic_sptr conjugate_ic_;
bool inverted_spectrum;
};
#endif /*GNSS_SDR_PASS_THROUGH_H_*/