diff options
author | Tom Rondeau <tom@trondeau.com> | 2014-07-29 15:24:16 -0400 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2014-07-29 19:27:58 -0400 |
commit | 89f684339d1d75617badb5f8b19c5e0e8dc9b711 (patch) | |
tree | 81d171dc2ee039446df97c74d9440050fbecb894 | |
parent | bf914b6ca9b64d12c510c92a3cc6f4762639c0f8 (diff) |
blocks: adding VOLK support for some functions.
* multipy_const_vcc and _vff
* sub_ff
* float_to_complex
* binary_slicer
Also adds a min_XX block to complement max_XX.
24 files changed, 1129 insertions, 27 deletions
diff --git a/gr-blocks/grc/blocks_min_xx.xml b/gr-blocks/grc/blocks_min_xx.xml new file mode 100644 index 0000000000..7d117c0d4a --- /dev/null +++ b/gr-blocks/grc/blocks_min_xx.xml @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Min: +## 1 output, 2 to inf inputs +################################################### + --> +<block> + <name>Min</name> + <key>blocks_min_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.min_$(type.fcn)($vlen)</make> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:ff</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:ii</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:ss</opt> + </option> + </param> + <param> + <name>Num Inputs</name> + <key>num_inputs</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$num_inputs >= 1</check> + <check>$vlen >= 1</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + <nports>$num_inputs</nports> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>1</vlen> + </source> +</block> diff --git a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt index 96e86078f3..662f705901 100644 --- a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt +++ b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt @@ -30,11 +30,12 @@ GR_EXPAND_X_H(blocks and_const_XX bb ss ii) GR_EXPAND_X_H(blocks argmax_XX fs is ss) GR_EXPAND_X_H(blocks divide_XX ss ii ff cc) GR_EXPAND_X_H(blocks integrate_XX ss ii ff cc) -GR_EXPAND_X_H(blocks max_XX ff ii ss) +GR_EXPAND_X_H(blocks max_XX ss ii ff) +GR_EXPAND_X_H(blocks min_XX ss ii ff) GR_EXPAND_X_H(blocks moving_average_XX ss ii ff cc) GR_EXPAND_X_H(blocks multiply_XX ss ii) GR_EXPAND_X_H(blocks multiply_const_XX ss ii) -GR_EXPAND_X_H(blocks multiply_const_vXX ss ii ff cc) +GR_EXPAND_X_H(blocks multiply_const_vXX ss ii) GR_EXPAND_X_H(blocks multiply_matrix_XX ff cc) GR_EXPAND_X_H(blocks mute_XX ss ii ff cc) GR_EXPAND_X_H(blocks not_XX bb ss ii) @@ -43,7 +44,7 @@ GR_EXPAND_X_H(blocks peak_detector_XX fb ib sb) GR_EXPAND_X_H(blocks probe_signal_X b s i f c) GR_EXPAND_X_H(blocks probe_signal_vX b s i f c) GR_EXPAND_X_H(blocks sample_and_hold_XX bb ss ii ff) -GR_EXPAND_X_H(blocks sub_XX ss ii ff cc) +GR_EXPAND_X_H(blocks sub_XX ss ii cc) GR_EXPAND_X_H(blocks tsb_vector_sink_X b s i f c) GR_EXPAND_X_H(blocks xor_XX bb ss ii) GR_EXPAND_X_H(blocks packed_to_unpacked_XX bb ss ii) @@ -122,7 +123,9 @@ install(FILES multiply_ff.h multiply_conjugate_cc.h multiply_const_cc.h + multiply_const_vcc.h multiply_const_ff.h + multiply_const_vff.h nlog10_ff.h nop.h null_sink.h @@ -155,6 +158,7 @@ install(FILES streams_to_stream.h streams_to_vector.h stretch_ff.h + sub_ff.h tag_debug.h tag_gate.h tagged_file_sink.h diff --git a/gr-blocks/include/gnuradio/blocks/min_XX.h.t b/gr-blocks/include/gnuradio/blocks/min_XX.h.t new file mode 100644 index 0000000000..45c7357f02 --- /dev/null +++ b/gr-blocks/include/gnuradio/blocks/min_XX.h.t @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <gnuradio/blocks/api.h> +#include <gnuradio/sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Compares vectors from multiple streams and determines + * the minimum value from each vector over all streams. + * \ingroup math_operators_blk + * + * \details + * Data is passed in as a vector of length \p vlen from multiple + * input sources. It will look through these streams of \p vlen + * data items and the output stream will contain the minimum value + * in the vector. + */ + class BLOCKS_API @NAME@ : virtual public sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(size_t vlen); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h b/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h index ff72572da9..3e8ed7c889 100644 --- a/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h +++ b/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h @@ -20,8 +20,6 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - #ifndef INCLUDED_MULTIPLY_CONST_CC_H #define INCLUDED_MULTIPLY_CONST_CC_H diff --git a/gr-blocks/include/gnuradio/blocks/multiply_const_vcc.h b/gr-blocks/include/gnuradio/blocks/multiply_const_vcc.h new file mode 100644 index 0000000000..78d2752751 --- /dev/null +++ b/gr-blocks/include/gnuradio/blocks/multiply_const_vcc.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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_MULTIPLY_CONST_VCC_H +#define INCLUDED_MULTIPLY_CONST_VCC_H + +#include <gnuradio/blocks/api.h> +#include <gnuradio/sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief output = input * constant vector (element-wise) + * \ingroup math_operators_blk + */ + class BLOCKS_API multiply_const_vcc : virtual public sync_block + { + public: + // gr::blocks::multiply_const_vcc::sptr + typedef boost::shared_ptr<multiply_const_vcc> sptr; + + /*! + * \brief Create an instance of multiply_const_vcc + * \param k multiplicative constant vector + */ + static sptr make(std::vector<gr_complex> k); + + /*! + * \brief Return multiplicative constant vector + */ + virtual std::vector<gr_complex> k() const = 0; + + /*! + * \brief Set multiplicative constant vector + */ + virtual void set_k(std::vector<gr_complex> k) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_MULTIPLY_CONST_VCC_H */ diff --git a/gr-blocks/include/gnuradio/blocks/multiply_const_vff.h b/gr-blocks/include/gnuradio/blocks/multiply_const_vff.h new file mode 100644 index 0000000000..884088e288 --- /dev/null +++ b/gr-blocks/include/gnuradio/blocks/multiply_const_vff.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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_MULTIPLY_CONST_VFF_H +#define INCLUDED_MULTIPLY_CONST_VFF_H + +#include <gnuradio/blocks/api.h> +#include <gnuradio/sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief output = input * constant vector (element-wise) + * \ingroup math_operators_blk + */ + class BLOCKS_API multiply_const_vff : virtual public sync_block + { + public: + // gr::blocks::multiply_const_vff::sptr + typedef boost::shared_ptr<multiply_const_vff> sptr; + + /*! + * \brief Create an instance of multiply_const_vff + * \param k multiplicative constant vector + */ + static sptr make(std::vector<float> k); + + /*! + * \brief Return multiplicative constant vector + */ + virtual std::vector<float> k() const = 0; + + /*! + * \brief Set multiplicative constant vector + */ + virtual void set_k(std::vector<float> k) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_MULTIPLY_CONST_VFF_H */ diff --git a/gr-blocks/include/gnuradio/blocks/sub_ff.h b/gr-blocks/include/gnuradio/blocks/sub_ff.h new file mode 100644 index 0000000000..3cc844f888 --- /dev/null +++ b/gr-blocks/include/gnuradio/blocks/sub_ff.h @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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_SUB_FF_H +#define INCLUDED_BLOCKS_SUB_FF_H + +#include <gnuradio/blocks/api.h> +#include <gnuradio/sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief output = input_0 - input_1 - ...) + * \ingroup math_operators_blk + * + * \details + * Subtract across all input streams. + */ + class BLOCKS_API sub_ff : virtual public sync_block + { + public: + // gr::blocks::sub_ff::sptr + typedef boost::shared_ptr<sub_ff> sptr; + + static sptr make(size_t vlen=1); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_SUB_FF_H */ diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index b3892ce64e..b2711c9e86 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -35,11 +35,12 @@ GR_EXPAND_X_CC_H_IMPL(blocks and_const_XX bb ss ii) GR_EXPAND_X_CC_H_IMPL(blocks argmax_XX fs is ss) GR_EXPAND_X_CC_H_IMPL(blocks divide_XX ss ii ff cc) GR_EXPAND_X_CC_H_IMPL(blocks integrate_XX ss ii ff cc) -GR_EXPAND_X_CC_H_IMPL(blocks max_XX ff ii ss) +GR_EXPAND_X_CC_H_IMPL(blocks max_XX ss ii ff) +GR_EXPAND_X_CC_H_IMPL(blocks min_XX ss ii ff) GR_EXPAND_X_CC_H_IMPL(blocks moving_average_XX ss ii ff cc) GR_EXPAND_X_CC_H_IMPL(blocks multiply_XX ss ii) GR_EXPAND_X_CC_H_IMPL(blocks multiply_const_XX ss ii) -GR_EXPAND_X_CC_H_IMPL(blocks multiply_const_vXX ss ii ff cc) +GR_EXPAND_X_CC_H_IMPL(blocks multiply_const_vXX ss ii) GR_EXPAND_X_CC_H_IMPL(blocks mute_XX ss ii ff cc) GR_EXPAND_X_CC_H_IMPL(blocks not_XX bb ss ii) GR_EXPAND_X_CC_H_IMPL(blocks or_XX bb ss ii) @@ -47,7 +48,7 @@ GR_EXPAND_X_CC_H_IMPL(blocks peak_detector_XX fb ib sb) GR_EXPAND_X_CC_H_IMPL(blocks probe_signal_X b s i f c) GR_EXPAND_X_CC_H_IMPL(blocks probe_signal_vX b s i f c) GR_EXPAND_X_CC_H_IMPL(blocks sample_and_hold_XX bb ss ii ff) -GR_EXPAND_X_CC_H_IMPL(blocks sub_XX ss ii ff cc) +GR_EXPAND_X_CC_H_IMPL(blocks sub_XX ss ii cc) GR_EXPAND_X_CC_H_IMPL(blocks tsb_vector_sink_X b s i f c) GR_EXPAND_X_CC_H_IMPL(blocks xor_XX bb ss ii) GR_EXPAND_X_CC_H_IMPL(blocks packed_to_unpacked_XX bb ss ii) @@ -140,7 +141,9 @@ list(APPEND gr_blocks_sources multiply_ff_impl.cc multiply_conjugate_cc_impl.cc multiply_const_cc_impl.cc + multiply_const_vcc_impl.cc multiply_const_ff_impl.cc + multiply_const_vff_impl.cc nlog10_ff_impl.cc nop_impl.cc null_sink_impl.cc @@ -175,6 +178,7 @@ list(APPEND gr_blocks_sources streams_to_stream_impl.cc streams_to_vector_impl.cc stretch_ff_impl.cc + sub_ff_impl.cc tagged_file_sink_impl.cc tagged_stream_to_pdu_impl.cc tagged_stream_multiply_length_impl.cc diff --git a/gr-blocks/lib/float_to_complex_impl.cc b/gr-blocks/lib/float_to_complex_impl.cc index 236438daac..a2dd0d3bb8 100644 --- a/gr-blocks/lib/float_to_complex_impl.cc +++ b/gr-blocks/lib/float_to_complex_impl.cc @@ -31,15 +31,17 @@ namespace gr { namespace blocks { - float_to_complex::sptr float_to_complex::make(size_t vlen) + float_to_complex::sptr + float_to_complex::make(size_t vlen) { - return gnuradio::get_initial_sptr(new float_to_complex_impl(vlen)); + return gnuradio::get_initial_sptr + (new float_to_complex_impl(vlen)); } float_to_complex_impl::float_to_complex_impl(size_t vlen) : sync_block("float_to_complex", - io_signature::make (1, 2, sizeof(float)*vlen), - io_signature::make (1, 1, sizeof(gr_complex)*vlen)), + io_signature::make(1, 2, sizeof(float)*vlen), + io_signature::make(1, 1, sizeof(gr_complex)*vlen)), d_vlen(vlen) { const int alignment_multiple = @@ -63,8 +65,9 @@ namespace gr { break; case 2: - for (size_t j = 0; j < noutput_items*d_vlen; j++) - out[j] = gr_complex (r[j], i[j]); + //for (size_t j = 0; j < noutput_items*d_vlen; j++) + // out[j] = gr_complex (r[j], i[j]); + volk_32f_x2_interleave_32fc(out, r, i, noutput_items*d_vlen); break; default: diff --git a/gr-blocks/lib/min_XX_impl.cc.t b/gr-blocks/lib/min_XX_impl.cc.t new file mode 100644 index 0000000000..d77dda208d --- /dev/null +++ b/gr-blocks/lib/min_XX_impl.cc.t @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gnuradio/io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(size_t vlen) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(vlen)); + } + + @NAME_IMPL@::@NAME_IMPL@(size_t vlen) + : sync_block("@BASE_NAME@", + io_signature::make(1, -1, vlen*sizeof(@I_TYPE@)), + io_signature::make(1, 1, sizeof(@O_TYPE@))), + d_vlen(vlen) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; + + int ninputs = input_items.size(); + + for(int i = 0; i < noutput_items; i++) { + @I_TYPE@ min = ((@I_TYPE@ *)input_items[0])[i*d_vlen]; + + for(int j = 0; j < (int)d_vlen; j++ ) { + for(int k = 0; k < ninputs; k++) { + if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] < min) { + min = ((@I_TYPE@*)input_items[k])[i*d_vlen + j]; + } + } + } + + *optr++ = (@O_TYPE@)min; + } + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/min_XX_impl.h.t b/gr-blocks/lib/min_XX_impl.h.t new file mode 100644 index 0000000000..33be614a8a --- /dev/null +++ b/gr-blocks/lib/min_XX_impl.h.t @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <gnuradio/blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + size_t d_vlen; + + public: + @NAME_IMPL@(size_t vlen); + ~@NAME_IMPL@(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/multiply_const_cc_impl.cc b/gr-blocks/lib/multiply_const_cc_impl.cc index f6b8dc3d63..c082a1ddd8 100644 --- a/gr-blocks/lib/multiply_const_cc_impl.cc +++ b/gr-blocks/lib/multiply_const_cc_impl.cc @@ -20,8 +20,6 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/gr-blocks/lib/multiply_const_cc_impl.h b/gr-blocks/lib/multiply_const_cc_impl.h index 29ba6dd14c..06f60b13dc 100644 --- a/gr-blocks/lib/multiply_const_cc_impl.h +++ b/gr-blocks/lib/multiply_const_cc_impl.h @@ -20,8 +20,6 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ - #ifndef INCLUDED_MULTIPLY_CONST_CC_IMPL_H #define INCLUDED_MULTIPLY_CONST_CC_IMPL_H diff --git a/gr-blocks/lib/multiply_const_vcc_impl.cc b/gr-blocks/lib/multiply_const_vcc_impl.cc new file mode 100644 index 0000000000..637f79eb12 --- /dev/null +++ b/gr-blocks/lib/multiply_const_vcc_impl.cc @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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 <multiply_const_vcc_impl.h> +#include <gnuradio/io_signature.h> +#include <volk/volk.h> + +namespace gr { + namespace blocks { + + multiply_const_vcc::sptr + multiply_const_vcc::make(std::vector<gr_complex> k) + { + return gnuradio::get_initial_sptr + (new multiply_const_vcc_impl(k)); + } + + multiply_const_vcc_impl::multiply_const_vcc_impl(std::vector<gr_complex> k) + : sync_block("multiply_const_vcc", + io_signature::make(1, 1, sizeof(gr_complex)*k.size()), + io_signature::make(1, 1, sizeof(gr_complex)*k.size())), + d_k(k) + { + const int alignment_multiple = + volk_get_alignment() / sizeof(gr_complex); + set_alignment(std::max(1,alignment_multiple)); + } + + int + multiply_const_vcc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr_complex *iptr = (gr_complex*)input_items[0]; + gr_complex *optr = (gr_complex*)output_items[0]; + + int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(gr_complex); + + for(int i = 0; i < noutput_items; i++) { + for(int j = 0; j < nitems_per_block; j++) { + *optr++ = *iptr++ * d_k[j]; + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/multiply_const_vcc_impl.h b/gr-blocks/lib/multiply_const_vcc_impl.h new file mode 100644 index 0000000000..18886ed00e --- /dev/null +++ b/gr-blocks/lib/multiply_const_vcc_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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_MULTIPLY_CONST_VCC_IMPL_H +#define INCLUDED_BLOCKS_MULTIPLY_CONST_VCC_IMPL_H + +#include <gnuradio/blocks/multiply_const_vcc.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API multiply_const_vcc_impl : public multiply_const_vcc + { + private: + std::vector<gr_complex> d_k; + + public: + multiply_const_vcc_impl(std::vector<gr_complex> k); + + std::vector<gr_complex> k() const { return d_k; } + void set_k(std::vector<gr_complex> k) { d_k = k; } + + 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_MULTIPLY_CONST_VCC_IMPL_H */ diff --git a/gr-blocks/lib/multiply_const_vff_impl.cc b/gr-blocks/lib/multiply_const_vff_impl.cc new file mode 100644 index 0000000000..ab53ce3ce3 --- /dev/null +++ b/gr-blocks/lib/multiply_const_vff_impl.cc @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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 <multiply_const_vff_impl.h> +#include <gnuradio/io_signature.h> +#include <volk/volk.h> + +namespace gr { + namespace blocks { + + multiply_const_vff::sptr + multiply_const_vff::make(std::vector<float> k) + { + return gnuradio::get_initial_sptr + (new multiply_const_vff_impl(k)); + } + + multiply_const_vff_impl::multiply_const_vff_impl(std::vector<float> k) + : sync_block("multiply_const_vff", + io_signature::make(1, 1, sizeof(float)*k.size()), + io_signature::make(1, 1, sizeof(float)*k.size())), + d_k(k) + { + const int alignment_multiple = + volk_get_alignment() / sizeof(float); + set_alignment(std::max(1,alignment_multiple)); + } + + int + multiply_const_vff_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + float *iptr = (float*)input_items[0]; + float *optr = (float*)output_items[0]; + + int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(float); + + for(int i = 0; i < noutput_items; i++) { + for(int j = 0; j < nitems_per_block; j++) { + *optr++ = *iptr++ * d_k[j]; + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/multiply_const_vff_impl.h b/gr-blocks/lib/multiply_const_vff_impl.h new file mode 100644 index 0000000000..4fda2a831e --- /dev/null +++ b/gr-blocks/lib/multiply_const_vff_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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_MULTIPLY_CONST_VFF_IMPL_H +#define INCLUDED_BLOCKS_MULTIPLY_CONST_VFF_IMPL_H + +#include <gnuradio/blocks/multiply_const_vff.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API multiply_const_vff_impl : public multiply_const_vff + { + private: + std::vector<float> d_k; + + public: + multiply_const_vff_impl(std::vector<float> k); + + std::vector<float> k() const { return d_k; } + void set_k(std::vector<float> k) { d_k = k; } + + 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_MULTIPLY_CONST_VFF_IMPL_H */ diff --git a/gr-blocks/lib/sub_ff_impl.cc b/gr-blocks/lib/sub_ff_impl.cc new file mode 100644 index 0000000000..d3a0815ca7 --- /dev/null +++ b/gr-blocks/lib/sub_ff_impl.cc @@ -0,0 +1,82 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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 <sub_ff_impl.h> +#include <gnuradio/io_signature.h> +#include <volk/volk.h> + +namespace gr { + namespace blocks { + + sub_ff::sptr + sub_ff::make(size_t vlen) + { + return gnuradio::get_initial_sptr + (new sub_ff_impl(vlen)); + } + + sub_ff_impl::sub_ff_impl(size_t vlen) + : sync_block("@sub_ff", + io_signature::make(1, -1, sizeof(float)*vlen), + io_signature::make(1, 1, sizeof(float)*vlen)), + d_vlen(vlen) + { + const int alignment_multiple = + volk_get_alignment() / sizeof(float); + set_alignment(std::max(1, alignment_multiple)); + } + + int + sub_ff_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + float *out = (float*)output_items[0]; + + int ninputs = input_items.size(); + int noi = noutput_items*d_vlen; + + //for(size_t i = 0; i < noutput_items*d_vlen; i++){ + // @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; + // for (int j = 1; j < ninputs; j++) + // acc -= ((@I_TYPE@ *) input_items[j])[i]; + // + // *optr++ = (@O_TYPE@) acc; + //} + + const float *in = (const float*)input_items[0]; + for(int i = 0; i < noi; i++) + out[i] = -in[i]; + for(int i = 1; i < ninputs; i++) { + in = (const float*)input_items[i]; + volk_32f_x2_subtract_32f(out, out, in, noi); + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/sub_ff_impl.h b/gr-blocks/lib/sub_ff_impl.h new file mode 100644 index 0000000000..b4eff66ae6 --- /dev/null +++ b/gr-blocks/lib/sub_ff_impl.h @@ -0,0 +1,47 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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_SUB_FF_IMPL_H +#define INCLUDED_BLOCKS_SUB_FF_IMPL_H + +#include <gnuradio/blocks/sub_ff.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API sub_ff_impl : public sub_ff + { + private: + size_t d_vlen; + + public: + sub_ff_impl(size_t vlen); + + 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_SUB_FF_IMPL_H */ diff --git a/gr-blocks/python/blocks/qa_max.py b/gr-blocks/python/blocks/qa_max.py index 441582ac88..709dbee72e 100755 --- a/gr-blocks/python/blocks/qa_max.py +++ b/gr-blocks/python/blocks/qa_max.py @@ -46,7 +46,7 @@ class test_max(gr_unittest.TestCase): result_data = dst.data() self.assertEqual(expected_result, result_data) - def test_002(self): + def stest_002(self): src_data=(-100,-99,-98,-97,-96,-1) expected_result = (float(max(src_data)),) @@ -60,6 +60,120 @@ class test_max(gr_unittest.TestCase): result_data = dst.data() self.assertEqual(expected_result, result_data) + def stest_003(self): + src_data0 = (0, 2, -3, 0, 12, 0) + src_data1 = (1, 1, 1, 1, 1, 1) + + expected_result = [float(max(x,y)) for x,y in zip(src_data0, src_data1)] + + src0 = blocks.vector_source_f(src_data0) + src1 = blocks.vector_source_f(src_data1) + op = blocks.max_ff(1) + dst = blocks.vector_sink_f() + + self.tb.connect(src0, (op, 0)) + self.tb.connect(src1, (op, 1)) + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def stest_004(self): + dim = 2 + src_data0 = (0, 2, -3, 0, 12, 0) + src_data1 = (1, 1, 1, 1, 1, 1) + + expected_data = [] + tmp = [float(max(x,y)) for x,y in zip(src_data0, src_data1)] + for i in xrange(len(tmp)/dim): + expected_data.append(float(max(tmp[i*dim:(i+1)*dim]))) + + src0 = blocks.vector_source_f(src_data0) + s2v0 = blocks.stream_to_vector(gr.sizeof_float,dim) + src1 = blocks.vector_source_f(src_data1) + s2v1 = blocks.stream_to_vector(gr.sizeof_float,dim) + op = blocks.max_ff(dim) + dst = blocks.vector_sink_f() + + self.tb.connect(src0, s2v0, (op, 0)) + self.tb.connect(src1, s2v1, (op, 1)) + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + + def stest_s001(self): + src_data = (0, 2, -3, 0, 12, 0) + expected_result = (max(src_data),) + + src = blocks.vector_source_s(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_short,len(src_data)) + op = blocks.max_ss(len(src_data)) + dst = blocks.vector_sink_s() + + self.tb.connect(src, s2v, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def stest_s002(self): + src_data=(-100,-99,-98,-97,-96,-1) + expected_result = (max(src_data),) + + src = blocks.vector_source_s(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_short, len(src_data)) + op = blocks.max_ss(len(src_data)) + dst = blocks.vector_sink_s() + + self.tb.connect(src, s2v, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + + def stest_s003(self): + src_data0 = (0, 2, -3, 0, 12, 0) + src_data1 = (1, 1, 1, 1, 1, 1) + + expected_result = [max(x,y) for x,y in zip(src_data0, src_data1)] + + src0 = blocks.vector_source_s(src_data0) + src1 = blocks.vector_source_s(src_data1) + op = blocks.max_ss(1) + dst = blocks.vector_sink_s() + + self.tb.connect(src0, (op, 0)) + self.tb.connect(src1, (op, 1)) + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def stest_s004(self): + dim = 2 + src_data0 = (0, 2, -3, 0, 12, 0) + src_data1 = (1, 1, 1, 1, 1, 1) + + expected_data = [] + tmp = [max(x,y) for x,y in zip(src_data0, src_data1)] + for i in xrange(len(tmp)/dim): + expected_data.append(max(tmp[i*dim:(i+1)*dim])) + + src0 = blocks.vector_source_s(src_data0) + s2v0 = blocks.stream_to_vector(gr.sizeof_short,dim) + src1 = blocks.vector_source_s(src_data1) + s2v1 = blocks.stream_to_vector(gr.sizeof_short,dim) + op = blocks.max_ss(dim) + dst = blocks.vector_sink_s() + + self.tb.connect(src0, s2v0, (op, 0)) + self.tb.connect(src1, s2v1, (op, 1)) + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + if __name__ == '__main__': gr_unittest.run(test_max, "test_max.xml") - diff --git a/gr-blocks/python/blocks/qa_min.py b/gr-blocks/python/blocks/qa_min.py new file mode 100644 index 0000000000..642782a1a1 --- /dev/null +++ b/gr-blocks/python/blocks/qa_min.py @@ -0,0 +1,178 @@ +#!/usr/bin/env python +# +# Copyright 2014 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. +# + +from gnuradio import gr, gr_unittest, blocks + +import math + +class test_min(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = (0, 0.2, -0.25, 0, 12, 0) + expected_result = (float(min(src_data)),) + + src = blocks.vector_source_f(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) + op = blocks.min_ff(len(src_data)) + dst = blocks.vector_sink_f() + + self.tb.connect(src, s2v, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def stest_002(self): + src_data=(-100,-99,-98,-97,-96,-1) + expected_result = (float(min(src_data)),) + + src = blocks.vector_source_f(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) + op = blocks.min_ff(len(src_data)) + dst = blocks.vector_sink_f() + + self.tb.connect(src, s2v, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def stest_003(self): + src_data0 = (0, 2, -3, 0, 12, 0) + src_data1 = (1, 1, 1, 1, 1, 1) + + expected_result = [float(min(x,y)) for x,y in zip(src_data0, src_data1)] + + src0 = blocks.vector_source_f(src_data0) + src1 = blocks.vector_source_f(src_data1) + op = blocks.min_ff(1) + dst = blocks.vector_sink_f() + + self.tb.connect(src0, (op, 0)) + self.tb.connect(src1, (op, 1)) + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def stest_004(self): + dim = 2 + src_data0 = (0, 2, -3, 0, 12, 0) + src_data1 = (1, 1, 1, 1, 1, 1) + + expected_data = [] + tmp = [float(min(x,y)) for x,y in zip(src_data0, src_data1)] + for i in xrange(len(tmp)/dim): + expected_data.append(float(min(tmp[i*dim:(i+1)*dim]))) + + src0 = blocks.vector_source_f(src_data0) + s2v0 = blocks.stream_to_vector(gr.sizeof_float,dim) + src1 = blocks.vector_source_f(src_data1) + s2v1 = blocks.stream_to_vector(gr.sizeof_float,dim) + op = blocks.min_ff(dim) + dst = blocks.vector_sink_f() + + self.tb.connect(src0, s2v0, (op, 0)) + self.tb.connect(src1, s2v1, (op, 1)) + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + + def stest_s001(self): + src_data = (0, 2, -3, 0, 12, 0) + expected_result = (min(src_data),) + + src = blocks.vector_source_s(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_short,len(src_data)) + op = blocks.min_ss(len(src_data)) + dst = blocks.vector_sink_s() + + self.tb.connect(src, s2v, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def stest_s002(self): + src_data=(-100,-99,-98,-97,-96,-1) + expected_result = (min(src_data),) + + src = blocks.vector_source_s(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_short, len(src_data)) + op = blocks.min_ss(len(src_data)) + dst = blocks.vector_sink_s() + + self.tb.connect(src, s2v, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + + def stest_s003(self): + src_data0 = (0, 2, -3, 0, 12, 0) + src_data1 = (1, 1, 1, 1, 1, 1) + + expected_result = [min(x,y) for x,y in zip(src_data0, src_data1)] + + src0 = blocks.vector_source_s(src_data0) + src1 = blocks.vector_source_s(src_data1) + op = blocks.min_ss(1) + dst = blocks.vector_sink_s() + + self.tb.connect(src0, (op, 0)) + self.tb.connect(src1, (op, 1)) + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def stest_s004(self): + dim = 2 + src_data0 = (0, 2, -3, 0, 12, 0) + src_data1 = (1, 1, 1, 1, 1, 1) + + expected_data = [] + tmp = [min(x,y) for x,y in zip(src_data0, src_data1)] + for i in xrange(len(tmp)/dim): + expected_data.append(min(tmp[i*dim:(i+1)*dim])) + + src0 = blocks.vector_source_s(src_data0) + s2v0 = blocks.stream_to_vector(gr.sizeof_short,dim) + src1 = blocks.vector_source_s(src_data1) + s2v1 = blocks.stream_to_vector(gr.sizeof_short,dim) + op = blocks.min_ss(dim) + dst = blocks.vector_sink_s() + + self.tb.connect(src0, s2v0, (op, 0)) + self.tb.connect(src1, s2v1, (op, 1)) + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + +if __name__ == '__main__': + gr_unittest.run(test_min, "test_min.xml") diff --git a/gr-blocks/swig/blocks_swig3.i b/gr-blocks/swig/blocks_swig3.i index 43cc78a4a6..9c0208388e 100644 --- a/gr-blocks/swig/blocks_swig3.i +++ b/gr-blocks/swig/blocks_swig3.i @@ -47,6 +47,9 @@ #include "gnuradio/blocks/max_ff.h" #include "gnuradio/blocks/max_ii.h" #include "gnuradio/blocks/max_ss.h" +#include "gnuradio/blocks/min_ff.h" +#include "gnuradio/blocks/min_ii.h" +#include "gnuradio/blocks/min_ss.h" #include "gnuradio/blocks/moving_average_cc.h" #include "gnuradio/blocks/moving_average_ff.h" #include "gnuradio/blocks/moving_average_ii.h" @@ -90,6 +93,9 @@ %include "gnuradio/blocks/max_ff.h" %include "gnuradio/blocks/max_ii.h" %include "gnuradio/blocks/max_ss.h" +%include "gnuradio/blocks/min_ff.h" +%include "gnuradio/blocks/min_ii.h" +%include "gnuradio/blocks/min_ss.h" %include "gnuradio/blocks/moving_average_cc.h" %include "gnuradio/blocks/moving_average_ff.h" %include "gnuradio/blocks/moving_average_ii.h" @@ -132,6 +138,9 @@ GR_SWIG_BLOCK_MAGIC2(blocks, lfsr_32k_source_s); GR_SWIG_BLOCK_MAGIC2(blocks, max_ff); GR_SWIG_BLOCK_MAGIC2(blocks, max_ii); GR_SWIG_BLOCK_MAGIC2(blocks, max_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, min_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, min_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, min_ss); GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_cc); GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ff); GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ii); diff --git a/gr-digital/lib/binary_slicer_fb_impl.cc b/gr-digital/lib/binary_slicer_fb_impl.cc index 565f751ec6..6852661ead 100644 --- a/gr-digital/lib/binary_slicer_fb_impl.cc +++ b/gr-digital/lib/binary_slicer_fb_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2010-2012 Free Software Foundation, Inc. + * Copyright 2006,2010-2012,2014 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -27,6 +27,7 @@ #include "binary_slicer_fb_impl.h" #include <gnuradio/io_signature.h> #include <gnuradio/math.h> +#include <volk/volk.h> namespace gr { namespace digital { @@ -38,9 +39,12 @@ namespace gr { binary_slicer_fb_impl::binary_slicer_fb_impl() : sync_block("binary_slicer_fb", - io_signature::make(1, 1, sizeof(float)), - io_signature::make(1, 1, sizeof(unsigned char))) + io_signature::make(1, 1, sizeof(float)), + io_signature::make(1, 1, sizeof(int8_t))) { + const int alignment_multiple = + volk_get_alignment() / sizeof(int8_t); + set_alignment(std::max(1,alignment_multiple)); } binary_slicer_fb_impl::~binary_slicer_fb_impl() @@ -53,11 +57,9 @@ namespace gr { gr_vector_void_star &output_items) { const float *in = (const float *)input_items[0]; - unsigned char *out = (unsigned char *)output_items[0]; + int8_t *out = (int8_t *)output_items[0]; - for(int i = 0; i < noutput_items; i++) { - out[i] = gr::binary_slicer(in[i]); - } + volk_32f_binary_slicer_8i(out, in, noutput_items); return noutput_items; } diff --git a/gr-fec/lib/dummy_decoder_impl.cc b/gr-fec/lib/dummy_decoder_impl.cc index 5ab91d0799..105057447f 100644 --- a/gr-fec/lib/dummy_decoder_impl.cc +++ b/gr-fec/lib/dummy_decoder_impl.cc @@ -116,6 +116,7 @@ namespace gr { int8_t *out = (int8_t*)outbuffer; //memcpy(out, in, d_frame_size*sizeof(char)); + //volk_32f_binary_slicer_8i(out, in, d_frame_size); volk_32f_s32f_convert_8i(out, in, 1.0/2.0, d_frame_size); } |