summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnathan Corgan2012-07-04 07:22:49 -0700
committerJohnathan Corgan2012-07-04 07:22:49 -0700
commita76cd7d47576054d7fac37710a8f79b908d18b00 (patch)
tree1692fd16e2f11fa4edf5eb1414931303e76fb442
parent4c85f46aee089432b090b988dedbc42091084ba3 (diff)
downloadgnuradio-a76cd7d47576054d7fac37710a8f79b908d18b00.tar.gz
gnuradio-a76cd7d47576054d7fac37710a8f79b908d18b00.tar.bz2
gnuradio-a76cd7d47576054d7fac37710a8f79b908d18b00.zip
blocks: added gr::blocks::xor_XX (bb ss ii)
-rw-r--r--gr-blocks/grc/blocks_block_tree.xml1
-rw-r--r--gr-blocks/grc/blocks_xor_xx.xml48
-rw-r--r--gr-blocks/include/blocks/CMakeLists.txt1
-rw-r--r--gr-blocks/include/blocks/xor_XX.h.t53
-rw-r--r--gr-blocks/lib/CMakeLists.txt1
-rw-r--r--gr-blocks/lib/xor_XX_impl.cc.t69
-rw-r--r--gr-blocks/lib/xor_XX_impl.h.t48
-rwxr-xr-xgr-blocks/python/qa_boolean_operators.py11
-rw-r--r--gr-blocks/swig/blocks_swig.i9
9 files changed, 236 insertions, 5 deletions
diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml
index e2658a373..853086858 100644
--- a/gr-blocks/grc/blocks_block_tree.xml
+++ b/gr-blocks/grc/blocks_block_tree.xml
@@ -47,6 +47,7 @@
<block>blocks_and_const_xx.xml</block>
<block>blocks_not_xx.xml</block>
<block>blocks_or_xx.xml</block>
+ <block>blocks_xor_xx.xml</block>
</cat>
<cat>
<name>Stream Type Conversions (New) </name>
diff --git a/gr-blocks/grc/blocks_xor_xx.xml b/gr-blocks/grc/blocks_xor_xx.xml
new file mode 100644
index 000000000..d2886a4e0
--- /dev/null
+++ b/gr-blocks/grc/blocks_xor_xx.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Logical Xor Block
+###################################################
+ -->
+<block>
+ <name>Xor</name>
+ <key>blocks_xor_xx</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.xor_$(type.fcn)()</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:ii</opt>
+ </option>
+ <option>
+ <name>Shxort</name>
+ <key>short</key>
+ <opt>fcn:ss</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>fcn:bb</opt>
+ </option>
+ </param>
+ <param>
+ <name>Num Inputs</name>
+ <key>num_inputs</key>
+ <value>2</value>
+ <type>int</type>
+ </param>
+ <check>$num_inputs &gt;= 2</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <nports>$num_inputs</nports>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+</block>
diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt
index 434fb2944..523ac2bb3 100644
--- a/gr-blocks/include/blocks/CMakeLists.txt
+++ b/gr-blocks/include/blocks/CMakeLists.txt
@@ -77,6 +77,7 @@ expand_h(multiply_const_vXX ss ii ff cc)
expand_h(not_XX bb ss ii)
expand_h(or_XX bb ss ii)
expand_h(sub_XX ss ii ff cc)
+expand_h(xor_XX bb ss ii)
add_custom_target(blocks_generated_includes DEPENDS
${generated_includes}
diff --git a/gr-blocks/include/blocks/xor_XX.h.t b/gr-blocks/include/blocks/xor_XX.h.t
new file mode 100644
index 000000000..ba0c508f6
--- /dev/null
+++ b/gr-blocks/include/blocks/xor_XX.h.t
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 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 <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief output = input_0 ^ input_1 ^ , ... ^ input_N)
+ * \ingroup math_blk
+ *
+ * Bitwise boolean xor across all input streams.
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_block
+ {
+ public:
+
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ static sptr make(size_t vlen=1);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index 3e3650d67..77f0c6eca 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -98,6 +98,7 @@ expand_cc_h_impl(multiply_const_vXX ss ii ff cc)
expand_cc_h_impl(not_XX bb ss ii)
expand_cc_h_impl(or_XX bb ss ii)
expand_cc_h_impl(sub_XX ss ii ff cc)
+expand_cc_h_impl(xor_XX bb ss ii)
########################################################################
# Setup the include and linker paths
diff --git a/gr-blocks/lib/xor_XX_impl.cc.t b/gr-blocks/lib/xor_XX_impl.cc.t
new file mode 100644
index 000000000..eea926512
--- /dev/null
+++ b/gr-blocks/lib/xor_XX_impl.cc.t
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 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 <gr_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)
+ : gr_sync_block ("@NAME@",
+ gr_make_io_signature (1, -1, sizeof (@I_TYPE@)*vlen),
+ gr_make_io_signature (1, 1, sizeof (@O_TYPE@)*vlen)),
+ d_vlen(vlen)
+ {
+ }
+
+ 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 (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;
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/xor_XX_impl.h.t b/gr-blocks/lib/xor_XX_impl.h.t
new file mode 100644
index 000000000..25f0da0c8
--- /dev/null
+++ b/gr-blocks/lib/xor_XX_impl.h.t
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 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 <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API @NAME_IMPL@ : public @NAME@
+ {
+ size_t d_vlen;
+
+ public:
+ @NAME_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 /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/python/qa_boolean_operators.py b/gr-blocks/python/qa_boolean_operators.py
index 43de72a89..5572f60ac 100755
--- a/gr-blocks/python/qa_boolean_operators.py
+++ b/gr-blocks/python/qa_boolean_operators.py
@@ -60,12 +60,12 @@ class test_boolean_operators (gr_unittest.TestCase):
self.tb.run ()
result_data = dst.data ()
self.assertEqual (exp_data, result_data)
- """
+
def test_xor_ss (self):
src1_data = (1, 2, 3, 0x5004, 0x1150)
src2_data = (8, 2, 1 , 0x0508, 0x1105)
expected_result = (9, 0, 2, 0x550C, 0x0055)
- op = gr.xor_ss ()
+ op = blocks_swig.xor_ss ()
self.help_ss ((src1_data, src2_data),
expected_result, op)
@@ -73,7 +73,7 @@ class test_boolean_operators (gr_unittest.TestCase):
src1_data = (1, 2, 3, 4, 0x50)
src2_data = (8, 2, 1 , 8, 0x05)
expected_result = (9, 0, 2, 0xC, 0x55)
- op = gr.xor_bb ()
+ op = blocks_swig.xor_bb ()
self.help_bb ((src1_data, src2_data),
expected_result, op)
@@ -82,10 +82,11 @@ class test_boolean_operators (gr_unittest.TestCase):
src1_data = (1, 2, 3, 0x5000004, 0x11000050)
src2_data = (8, 2, 1 , 0x0500008, 0x11000005)
expected_result = (9, 0, 2, 0x550000C, 0x00000055)
- op = gr.xor_ii ()
+ op = blocks_swig.xor_ii ()
self.help_ii ((src1_data, src2_data),
expected_result, op)
- """
+
+
def test_and_ss (self):
src1_data = (1, 2, 3, 0x5004, 0x1150)
src2_data = (8, 2, 1 , 0x0508, 0x1105)
diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i
index 9cb48191c..4405b91b7 100644
--- a/gr-blocks/swig/blocks_swig.i
+++ b/gr-blocks/swig/blocks_swig.i
@@ -98,6 +98,9 @@
#include "blocks/sub_ii.h"
#include "blocks/sub_cc.h"
#include "blocks/uchar_to_float.h"
+#include "blocks/xor_bb.h"
+#include "blocks/xor_ss.h"
+#include "blocks/xor_ii.h"
%}
%include "blocks/add_ff.h"
@@ -170,6 +173,9 @@
%include "blocks/sub_ii.h"
%include "blocks/sub_cc.h"
%include "blocks/uchar_to_float.h"
+%include "blocks/xor_bb.h"
+%include "blocks/xor_ss.h"
+%include "blocks/xor_ii.h"
GR_SWIG_BLOCK_MAGIC2(blocks, add_ff);
GR_SWIG_BLOCK_MAGIC2(blocks, add_ss);
@@ -241,3 +247,6 @@ GR_SWIG_BLOCK_MAGIC2(blocks, sub_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, sub_ii);
GR_SWIG_BLOCK_MAGIC2(blocks, sub_cc);
GR_SWIG_BLOCK_MAGIC2(blocks, uchar_to_float);
+GR_SWIG_BLOCK_MAGIC2(blocks, xor_bb);
+GR_SWIG_BLOCK_MAGIC2(blocks, xor_ss);
+GR_SWIG_BLOCK_MAGIC2(blocks, xor_ii);