diff options
Diffstat (limited to 'gr-blocks/lib')
-rw-r--r-- | gr-blocks/lib/CMakeLists.txt | 6 | ||||
-rw-r--r-- | gr-blocks/lib/exponentiate_const_cci_impl.cc | 102 | ||||
-rw-r--r-- | gr-blocks/lib/exponentiate_const_cci_impl.h | 53 | ||||
-rw-r--r-- | gr-blocks/lib/tag_share_impl.cc | 79 | ||||
-rw-r--r-- | gr-blocks/lib/tag_share_impl.h | 51 |
5 files changed, 287 insertions, 4 deletions
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index 1d69f27a1d..e6eabd8f99 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -65,7 +65,6 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/../include ${GR_BLOCKS_INCLUDE_DIRS} ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) @@ -116,6 +115,7 @@ list(APPEND gr_blocks_sources divide_ff_impl.cc delay_impl.cc endian_swap_impl.cc + exponentiate_const_cci_impl.cc file_descriptor_sink_impl.cc file_descriptor_source_impl.cc file_sink_impl.cc @@ -190,6 +190,7 @@ list(APPEND gr_blocks_sources streams_to_vector_impl.cc stretch_ff_impl.cc sub_ff_impl.cc + tag_share_impl.cc tagged_file_sink_impl.cc tagged_stream_to_pdu_impl.cc tagged_stream_multiply_length_impl.cc @@ -251,8 +252,6 @@ list(APPEND blocks_libs gnuradio-runtime ${VOLK_LIBRARIES} ${Boost_LIBRARIES} - ${BLOCKS_LIBRARIES} - ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-blocks SHARED ${gr_blocks_sources}) @@ -329,7 +328,6 @@ if(ENABLE_TESTING) gnuradio-blocks ${Boost_LIBRARIES} ${CPPUNIT_LIBRARIES} - ${LOG4CPP_LIBRARIES} ) GR_ADD_TEST(test_gr_blocks test-gr-blocks) diff --git a/gr-blocks/lib/exponentiate_const_cci_impl.cc b/gr-blocks/lib/exponentiate_const_cci_impl.cc new file mode 100644 index 0000000000..c46930febb --- /dev/null +++ b/gr-blocks/lib/exponentiate_const_cci_impl.cc @@ -0,0 +1,102 @@ +/* -*- c++ -*- */ +/* + * Copyright 2017 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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, or (at your option) + * any later version. + * + * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gnuradio/io_signature.h> +#include "exponentiate_const_cci_impl.h" +#include <volk/volk.h> + +namespace gr { + namespace blocks { + + exponentiate_const_cci::sptr + exponentiate_const_cci::make(int exponent, size_t vlen) + { + return gnuradio::get_initial_sptr + (new exponentiate_const_cci_impl(exponent, vlen)); + } + + /* + * The private constructor + */ + exponentiate_const_cci_impl::exponentiate_const_cci_impl(int exponent, size_t vlen) + : gr::sync_block("exponentiate_const_cci", + gr::io_signature::make(1, -1, sizeof(gr_complex)*vlen), + gr::io_signature::make(1, -1, sizeof(gr_complex)*vlen)), + d_exponent(exponent), + d_vlen(vlen) + { + const int alignment_multiple = volk_get_alignment()/sizeof(gr_complex); + set_alignment(std::max(1, alignment_multiple)); + } + + /* + * Our virtual destructor. + */ + exponentiate_const_cci_impl::~exponentiate_const_cci_impl() + { + } + + bool + exponentiate_const_cci_impl::check_topology(int ninputs, int noutputs) + { + return ninputs == noutputs; + } + + void + exponentiate_const_cci_impl::set_exponent(int exponent) { + gr::thread::scoped_lock guard(d_setlock); + d_exponent = exponent; + } + + int + exponentiate_const_cci_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr::thread::scoped_lock guard(d_setlock); + + for(unsigned int i = 0; i < input_items.size(); i++) { + const gr_complex *in = (const gr_complex *) input_items[i]; + gr_complex *out = (gr_complex *) output_items[i]; + + if(d_exponent > 1) { + volk_32fc_x2_multiply_32fc(out, in, in, noutput_items*d_vlen); + for(int j = 2; j < d_exponent; j++) { + volk_32fc_x2_multiply_32fc(out, out, in, noutput_items*d_vlen); + } + } + else { + memcpy(out, in, sizeof(gr_complex)*noutput_items*d_vlen); + } + } + + // Tell runtime system how many output items we produced. + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/exponentiate_const_cci_impl.h b/gr-blocks/lib/exponentiate_const_cci_impl.h new file mode 100644 index 0000000000..c89fe57646 --- /dev/null +++ b/gr-blocks/lib/exponentiate_const_cci_impl.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2017 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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, or (at your option) + * any later version. + * + * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_BLOCKS_EXPONENTIATE_CONST_CCI_IMPL_H +#define INCLUDED_BLOCKS_EXPONENTIATE_CONST_CCI_IMPL_H + +#include <gnuradio/blocks/exponentiate_const_cci.h> + +namespace gr { + namespace blocks { + + class exponentiate_const_cci_impl : public exponentiate_const_cci + { + private: + int d_exponent; + int d_vlen; + + public: + exponentiate_const_cci_impl(int exponent, size_t vlen); + ~exponentiate_const_cci_impl(); + bool check_topology(int ninputs, int noutputs); + void set_exponent(int exponent); + + // Where all the action really happens + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace blocks +} // namespace gr + +#endif /* INCLUDED_BLOCKS_EXPONENTIATE_CONST_CCI_IMPL_H */ + diff --git a/gr-blocks/lib/tag_share_impl.cc b/gr-blocks/lib/tag_share_impl.cc new file mode 100644 index 0000000000..26a54dbf8c --- /dev/null +++ b/gr-blocks/lib/tag_share_impl.cc @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * Copyright 2017 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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, or (at your option) + * any later version. + * + * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gnuradio/io_signature.h> +#include "tag_share_impl.h" + +namespace gr { + namespace blocks { + + tag_share::sptr + tag_share::make(size_t sizeof_io_item, size_t sizeof_share_item, size_t vlen) + { + return gnuradio::get_initial_sptr + (new tag_share_impl(sizeof_io_item, sizeof_share_item, vlen)); + } + + /* + * The private constructor + */ + tag_share_impl::tag_share_impl(size_t sizeof_io_item, size_t sizeof_share_item, size_t vlen) + : gr::sync_block("tag_share", + gr::io_signature::make2(2, 2, sizeof_io_item*vlen, sizeof_share_item*vlen), + gr::io_signature::make(1, 1, sizeof_io_item*vlen)), + d_sizeof_io_item(sizeof_io_item), + d_vlen(vlen) + { + // This is the entire premise of the block -- to have the GNU Radio runtime + // propagate all the tags from Input 0 and Input 1 to Output 0. + set_tag_propagation_policy(TPP_ALL_TO_ALL); + } + + /* + * Our virtual destructor. + */ + tag_share_impl::~tag_share_impl() + { + } + + int + tag_share_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const void *in = (const void *) input_items[0]; + void *out = (void *) output_items[0]; + + // Input 0 passes through to Output 0 + memcpy(out, in, d_sizeof_io_item*d_vlen*noutput_items); + + // Tell runtime system how many output items we produced. + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/tag_share_impl.h b/gr-blocks/lib/tag_share_impl.h new file mode 100644 index 0000000000..e5df8e3a0c --- /dev/null +++ b/gr-blocks/lib/tag_share_impl.h @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* + * Copyright 2017 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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, or (at your option) + * any later version. + * + * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_BLOCKS_TAG_SHARE_IMPL_H +#define INCLUDED_BLOCKS_TAG_SHARE_IMPL_H + +#include <gnuradio/blocks/tag_share.h> + +namespace gr { + namespace blocks { + + class tag_share_impl : public tag_share + { + private: + size_t d_sizeof_io_item; + size_t d_vlen; + + public: + tag_share_impl(size_t sizeof_io_item, size_t sizeof_share_item, size_t vlen); + ~tag_share_impl(); + + // Where all the action really happens + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace blocks +} // namespace gr + +#endif /* INCLUDED_BLOCKS_TAG_SHARE_IMPL_H */ + |