[hamradio-commits] [gnss-sdr] 04/44: adding std::complex<unsigned char>, aka lv_8sc_t, as a native input data type. To be later used with volk_gnsssdr_8ic_* kernels

Carles Fernandez carles_fernandez-guest at moszumanska.debian.org
Sun Feb 15 15:32:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

carles_fernandez-guest pushed a commit to branch next
in repository gnss-sdr.

commit 70ff04707e98c386104c8a07fc04441b4a714d44
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date:   Sat Jan 31 14:29:43 2015 +0100

    adding std::complex<unsigned char>, aka lv_8sc_t, as a native input data
    type. To be later used with volk_gnsssdr_8ic_* kernels
---
 src/algorithms/data_type_adapter/CMakeLists.txt    |   3 +
 .../data_type_adapter/adapters/CMakeLists.txt      |   6 +-
 .../data_type_adapter/adapters/ibyte_to_cbyte.cc   | 105 +++++++++++++++++++++
 .../data_type_adapter/adapters/ibyte_to_cbyte.h    |  91 ++++++++++++++++++
 .../{ => gnuradio_blocks}/CMakeLists.txt           |  15 ++-
 .../interleaved_byte_to_complex_byte.cc            |  70 ++++++++++++++
 .../interleaved_byte_to_complex_byte.h             |  61 ++++++++++++
 7 files changed, 348 insertions(+), 3 deletions(-)

diff --git a/src/algorithms/data_type_adapter/CMakeLists.txt b/src/algorithms/data_type_adapter/CMakeLists.txt
index 135bc29..5724f1d 100644
--- a/src/algorithms/data_type_adapter/CMakeLists.txt
+++ b/src/algorithms/data_type_adapter/CMakeLists.txt
@@ -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)
+
diff --git a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt
index 4fcccb5..718ca30 100644
--- a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt
+++ b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt
@@ -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})
 
diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc
new file mode 100644
index 0000000..a17904d
--- /dev/null
+++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc
@@ -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_;
+}
+
diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h
new file mode 100644
index 0000000..f326b60
--- /dev/null
+++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h
@@ -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
diff --git a/src/algorithms/data_type_adapter/CMakeLists.txt b/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt
similarity index 62%
copy from src/algorithms/data_type_adapter/CMakeLists.txt
copy to src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt
index 135bc29..cff3635 100644
--- a/src/algorithms/data_type_adapter/CMakeLists.txt
+++ b/src/algorithms/data_type_adapter/gnuradio_blocks/CMakeLists.txt
@@ -16,4 +16,17 @@
 # along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
 #
 
-add_subdirectory(adapters)
+
+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})
\ No newline at end of file
diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc
new file mode 100644
index 0000000..8851788
--- /dev/null
+++ b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc
@@ -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;
+}
diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.h b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.h
new file mode 100644
index 0000000..4645fe7
--- /dev/null
+++ b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.h
@@ -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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git



More information about the pkg-hamradio-commits mailing list