mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 12:10:34 +00:00
adding std::complex<unsigned char>, aka lv_8sc_t, as a native input data
type. To be later used with volk_gnsssdr_8ic_* kernels
This commit is contained in:
parent
6984e78b70
commit
70ff04707e
@ -1,3 +1,4 @@
|
||||
#
|
||||
# Copyright (C) 2012-2015 (see AUTHORS file for a list of contributors)
|
||||
#
|
||||
# This file is part of GNSS-SDR.
|
||||
@ -17,3 +18,5 @@
|
||||
#
|
||||
|
||||
add_subdirectory(adapters)
|
||||
add_subdirectory(gnuradio_blocks)
|
||||
|
||||
|
@ -20,12 +20,14 @@
|
||||
set(DATATYPE_ADAPTER_SOURCES
|
||||
ishort_to_complex.cc
|
||||
ibyte_to_complex.cc
|
||||
byte_to_short.cc )
|
||||
byte_to_short.cc
|
||||
ibyte_to_cbyte.cc )
|
||||
|
||||
include_directories(
|
||||
$(CMAKE_CURRENT_SOURCE_DIR)
|
||||
${CMAKE_SOURCE_DIR}/src/core/system_parameters
|
||||
${CMAKE_SOURCE_DIR}/src/core/interfaces
|
||||
${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/gnuradio_blocks
|
||||
${GLOG_INCLUDE_DIRS}
|
||||
${GFlags_INCLUDE_DIRS}
|
||||
${GNURADIO_RUNTIME_INCLUDE_DIRS}
|
||||
@ -35,5 +37,5 @@ file(GLOB DATATYPE_ADAPTER_HEADERS "*.h")
|
||||
add_library(datatype_adapters ${DATATYPE_ADAPTER_SOURCES} ${DATATYPE_ADAPTER_HEADERS})
|
||||
source_group(Headers FILES ${DATATYPE_ADAPTER_HEADERS})
|
||||
add_dependencies(datatype_adapters glog-${glog_RELEASE})
|
||||
target_link_libraries(datatype_adapters ${GNURADIO_FILTER_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES})
|
||||
target_link_libraries(datatype_adapters data_type_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES})
|
||||
|
||||
|
105
src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc
Normal file
105
src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc
Normal file
@ -0,0 +1,105 @@
|
||||
/*!
|
||||
* \file ibyte_to_cbyte.cc
|
||||
* \brief Adapts an I/Q interleaved byte (unsigned char) sample stream
|
||||
* into a std::complex<unsigned char> stream
|
||||
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* GNSS-SDR is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNSS-SDR is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "ibyte_to_cbyte.h"
|
||||
#include <volk/volk.h>
|
||||
#include <glog/logging.h>
|
||||
#include "configuration_interface.h"
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
config_(configuration), role_(role), in_streams_(in_streams),
|
||||
out_streams_(out_streams), queue_(queue)
|
||||
{
|
||||
std::string default_input_item_type = "byte";
|
||||
std::string default_output_item_type = "lv_8sc_t";
|
||||
std::string default_dump_filename = "../data/input_filter.dat";
|
||||
|
||||
DLOG(INFO) << "role " << role_;
|
||||
|
||||
input_item_type_ = config_->property(role_ + ".input_item_type", default_input_item_type);
|
||||
|
||||
dump_ = config_->property(role_ + ".dump", false);
|
||||
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
|
||||
|
||||
size_t item_size = sizeof(lv_8sc_t);
|
||||
|
||||
ibyte_to_cbyte_ = make_interleaved_byte_to_complex_byte();
|
||||
|
||||
DLOG(INFO) << "data_type_adapter_(" << ibyte_to_cbyte_->unique_id() << ")";
|
||||
|
||||
if (dump_)
|
||||
{
|
||||
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
||||
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
IbyteToCbyte::~IbyteToCbyte()
|
||||
{}
|
||||
|
||||
|
||||
void IbyteToCbyte::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(ibyte_to_cbyte_, 0, file_sink_, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IbyteToCbyte::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(ibyte_to_cbyte_, 0, file_sink_, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
gr::basic_block_sptr IbyteToCbyte::get_left_block()
|
||||
{
|
||||
return ibyte_to_cbyte_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gr::basic_block_sptr IbyteToCbyte::get_right_block()
|
||||
{
|
||||
return ibyte_to_cbyte_;
|
||||
}
|
||||
|
91
src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h
Normal file
91
src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h
Normal file
@ -0,0 +1,91 @@
|
||||
/*!
|
||||
* \file ibyte_to_cbyte.h
|
||||
* \brief \brief Adapts an I/Q interleaved byte (unsigned char) sample stream
|
||||
* into a std::complex<unsigned char> stream
|
||||
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* GNSS-SDR is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNSS-SDR is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef GNSS_SDR_IBYTE_TO_COMPLEX_H_
|
||||
#define GNSS_SDR_IBYTE_TO_COMPLEX_H_
|
||||
|
||||
#include <string>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include "gnss_synchro.h"
|
||||
#include "gnss_block_interface.h"
|
||||
#include "interleaved_byte_to_complex_byte.h"
|
||||
|
||||
|
||||
class ConfigurationInterface;
|
||||
|
||||
/*!
|
||||
* \briefAdapts an I/Q interleaved byte (unsigned char) sample stream
|
||||
* into a std::complex<unsigned char> stream
|
||||
*/
|
||||
class IbyteToCbyte : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
IbyteToCbyte(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_streams,
|
||||
unsigned int out_streams, boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~IbyteToCbyte();
|
||||
|
||||
std::string role()
|
||||
{
|
||||
return role_;
|
||||
}
|
||||
//! Returns "IbyteToCbyte"
|
||||
std::string implementation()
|
||||
{
|
||||
return "IbyteToCbyte";
|
||||
}
|
||||
size_t item_size()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void connect(gr::top_block_sptr top_block);
|
||||
void disconnect(gr::top_block_sptr top_block);
|
||||
gr::basic_block_sptr get_left_block();
|
||||
gr::basic_block_sptr get_right_block();
|
||||
|
||||
private:
|
||||
interleaved_byte_to_complex_byte_sptr ibyte_to_cbyte_;
|
||||
ConfigurationInterface* config_;
|
||||
bool dump_;
|
||||
std::string dump_filename_;
|
||||
std::string input_item_type_;
|
||||
std::string output_item_type_;
|
||||
std::string role_;
|
||||
unsigned int in_streams_;
|
||||
unsigned int out_streams_;
|
||||
boost::shared_ptr<gr::msg_queue> queue_;
|
||||
gr::blocks::file_sink::sptr file_sink_;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,32 @@
|
||||
# Copyright (C) 2012-2015 (see AUTHORS file for a list of contributors)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
|
||||
set(DATA_TYPE_GR_BLOCKS_SOURCES
|
||||
interleaved_byte_to_complex_byte.cc
|
||||
)
|
||||
|
||||
include_directories(
|
||||
$(CMAKE_CURRENT_SOURCE_DIR)
|
||||
${GNURADIO_RUNTIME_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
file(GLOB DATA_TYPE_GR_BLOCKS_HEADERS "*.h")
|
||||
add_library(data_type_gr_blocks ${DATA_TYPE_GR_BLOCKS_SOURCES} ${DATA_TYPE_GR_BLOCKS_HEADERS})
|
||||
source_group(Headers FILES ${DATA_TYPE_GR_BLOCKS_HEADERS})
|
||||
target_link_libraries(data_type_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES})
|
@ -0,0 +1,70 @@
|
||||
/*!
|
||||
* \file interleaved_byte_to_complex_byte.cc
|
||||
* \brief Adapts an 8-bits interleaved sample stream into a 16-bits complex stream
|
||||
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* GNSS-SDR is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNSS-SDR is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "interleaved_byte_to_complex_byte.h"
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <volk/volk.h>
|
||||
|
||||
|
||||
interleaved_byte_to_complex_byte_sptr make_interleaved_byte_to_complex_byte()
|
||||
{
|
||||
return interleaved_byte_to_complex_byte_sptr(new interleaved_byte_to_complex_byte());
|
||||
}
|
||||
|
||||
|
||||
|
||||
interleaved_byte_to_complex_byte::interleaved_byte_to_complex_byte() : sync_decimator("interleaved_byte_to_complex_byte",
|
||||
gr::io_signature::make (1, 1, sizeof(char)),
|
||||
gr::io_signature::make (1, 1, sizeof(lv_8sc_t)), // lv_8sc_t is a Volk's typedef for std::complex<signed char>
|
||||
2)
|
||||
{
|
||||
const int alignment_multiple = volk_get_alignment() / sizeof(lv_8sc_t);
|
||||
set_alignment(std::max(1, alignment_multiple));
|
||||
}
|
||||
|
||||
|
||||
int interleaved_byte_to_complex_byte::work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
const signed char *in = (const signed char *) input_items[0];
|
||||
lv_8sc_t *out = (lv_8sc_t *) output_items[0];
|
||||
// This could be put into a Volk kernel
|
||||
unsigned int sample_index = 0;
|
||||
for(unsigned int number = 0; number < 2 * noutput_items; number++)
|
||||
{
|
||||
// lv_cmake(r, i) defined at volk/volk_complex.h
|
||||
*out++ = lv_cmake(in[sample_index], in[sample_index + 1]);
|
||||
sample_index = sample_index + 2;
|
||||
}
|
||||
|
||||
return noutput_items;
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*!
|
||||
* \file interleaved_byte_to_complex_byte.h
|
||||
* \brief Adapts an 8-bits interleaved sample stream into a 16-bits complex stream
|
||||
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* GNSS-SDR is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNSS-SDR is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef GNSS_SDR_INTERLEAVED_BYTE_TO_COMPLEX_BYTE_H_
|
||||
#define GNSS_SDR_INTERLEAVED_BYTE_TO_COMPLEX_BYTE_H_
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <gnuradio/sync_decimator.h>
|
||||
|
||||
class interleaved_byte_to_complex_byte;
|
||||
|
||||
typedef boost::shared_ptr<interleaved_byte_to_complex_byte> interleaved_byte_to_complex_byte_sptr;
|
||||
|
||||
interleaved_byte_to_complex_byte_sptr make_interleaved_byte_to_complex_byte();
|
||||
|
||||
/*!
|
||||
* \brief This class adapts an 8-bits interleaved sample stream
|
||||
* into a 16-bits complex stream (std::complex<unsigned char>)
|
||||
*/
|
||||
class interleaved_byte_to_complex_byte : public gr::sync_decimator
|
||||
{
|
||||
private:
|
||||
friend interleaved_byte_to_complex_byte_sptr make_interleaved_byte_to_complex_byte();
|
||||
public:
|
||||
interleaved_byte_to_complex_byte();
|
||||
|
||||
int work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user