summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-blocks/grc/blocks_block_tree.xml4
-rw-r--r--gr-blocks/grc/blocks_deinterleave.xml67
-rw-r--r--gr-blocks/include/blocks/CMakeLists.txt1
-rw-r--r--gr-blocks/include/blocks/deinterleave.h50
-rw-r--r--gr-blocks/lib/CMakeLists.txt1
-rw-r--r--gr-blocks/lib/deinterleave_impl.cc76
-rw-r--r--gr-blocks/lib/deinterleave_impl.h49
-rwxr-xr-xgr-blocks/python/qa_interleave.py83
-rw-r--r--gr-blocks/swig/blocks_swig.i3
9 files changed, 334 insertions, 0 deletions
diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml
index 853086858..e4aed9809 100644
--- a/gr-blocks/grc/blocks_block_tree.xml
+++ b/gr-blocks/grc/blocks_block_tree.xml
@@ -71,4 +71,8 @@
<block>blocks_short_to_float</block>
<block>blocks_uchar_to_float</block>
</cat>
+ <cat>
+ <name>Stream Operations (New) </name>
+ <block>blocks_deinterleave.xml</block>
+ </cat>
</cat>
diff --git a/gr-blocks/grc/blocks_deinterleave.xml b/gr-blocks/grc/blocks_deinterleave.xml
new file mode 100644
index 000000000..103091324
--- /dev/null
+++ b/gr-blocks/grc/blocks_deinterleave.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Deinterleave
+###################################################
+ -->
+<block>
+ <name>Deinterleave</name>
+ <key>blocks_deinterleave</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.deinterleave($type.size*$vlen)</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:blocks.sizeof_blocks_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:blocks.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:blocks.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:blocks.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:blocks.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Num Streams</name>
+ <key>num_streams</key>
+ <value>2</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$num_streams &gt; 0</check>
+ <check>$vlen &gt;= 1</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ <nports>$num_streams</nports>
+ </source>
+</block>
diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt
index 523ac2bb3..c3ad9d033 100644
--- a/gr-blocks/include/blocks/CMakeLists.txt
+++ b/gr-blocks/include/blocks/CMakeLists.txt
@@ -100,6 +100,7 @@ install(FILES
complex_to_mag_squared.h
complex_to_arg.h
conjugate_cc.h
+ deinterleave.h
float_to_char.h
float_to_complex.h
float_to_int.h
diff --git a/gr-blocks/include/blocks/deinterleave.h b/gr-blocks/include/blocks/deinterleave.h
new file mode 100644
index 000000000..24074d2fc
--- /dev/null
+++ b/gr-blocks/include/blocks/deinterleave.h
@@ -0,0 +1,50 @@
+/* -*- 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.
+ */
+
+#ifndef INCLUDED_BLOCKS_DEINTERLEAVE_H
+#define INCLUDED_BLOCKS_DEINTERLEAVE_H
+
+#include <blocks/api.h>
+#include <gr_sync_decimator.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief deinterleave a single input into N outputs
+ * \ingroup slicedice_blk
+ * \param itemsize stream itemsize
+ */
+ class BLOCKS_API deinterleave : virtual public gr_sync_decimator
+ {
+ public:
+
+ // gr::blocks::deinterleave::sptr
+ typedef boost::shared_ptr<deinterleave> sptr;
+
+ static sptr make(size_t itemsize);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_DEINTERLEAVE_H */
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index 77f0c6eca..081064629 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -134,6 +134,7 @@ list(APPEND gr_blocks_sources
complex_to_mag_squared_impl.cc
complex_to_arg_impl.cc
conjugate_cc_impl.cc
+ deinterleave_impl.cc
float_to_char_impl.cc
float_to_complex_impl.cc
float_array_to_int.cc
diff --git a/gr-blocks/lib/deinterleave_impl.cc b/gr-blocks/lib/deinterleave_impl.cc
new file mode 100644
index 000000000..badf4973a
--- /dev/null
+++ b/gr-blocks/lib/deinterleave_impl.cc
@@ -0,0 +1,76 @@
+/* -*- 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "deinterleave_impl.h"
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ deinterleave::sptr deinterleave::make(size_t itemsize)
+ {
+ return gnuradio::get_initial_sptr(new deinterleave_impl(itemsize));
+ }
+
+ deinterleave_impl::deinterleave_impl(size_t itemsize)
+ : gr_sync_decimator("deinterleave",
+ gr_make_io_signature (1, 1, itemsize),
+ gr_make_io_signature (1, gr_io_signature::IO_INFINITE, itemsize),
+ 1),
+ d_itemsize(itemsize)
+ {
+ }
+
+ bool
+ deinterleave_impl::check_topology(int ninputs, int noutputs)
+ {
+ set_decimation(noutputs);
+ return true;
+ }
+
+ int
+ deinterleave_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ size_t nchan = output_items.size();
+ size_t itemsize = d_itemsize;
+ const char *in = (const char *)input_items[0];
+ char **out = (char **)&output_items[0];
+
+ for (int i = 0; i < noutput_items; i++){
+ for (unsigned int n = 0; n < nchan; n++){
+ memcpy(out[n], in, itemsize);
+ out[n] += itemsize;
+ in += itemsize;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/deinterleave_impl.h b/gr-blocks/lib/deinterleave_impl.h
new file mode 100644
index 000000000..762c9d5fe
--- /dev/null
+++ b/gr-blocks/lib/deinterleave_impl.h
@@ -0,0 +1,49 @@
+/* -*- 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.
+ */
+
+#ifndef INCLUDED_DEINTERLEAVE_IMPL_H
+#define INCLUDED_DEINTERLEAVE_IMPL_H
+
+#include <blocks/deinterleave.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API deinterleave_impl : public deinterleave
+ {
+ size_t d_itemsize;
+
+ public:
+ deinterleave_impl(size_t itemsize);
+
+ bool check_topology(int ninputs, int noutputs);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+
+#endif /* INCLUDED_DEINTERLEAVE_IMPL_H */
diff --git a/gr-blocks/python/qa_interleave.py b/gr-blocks/python/qa_interleave.py
new file mode 100755
index 000000000..56c8bdfdf
--- /dev/null
+++ b/gr-blocks/python/qa_interleave.py
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2007,2010,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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig
+import math
+
+class test_interleave (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ """
+ def test_int_001 (self):
+ lenx = 64
+ src0 = gr.vector_source_f (range (0, lenx, 4))
+ src1 = gr.vector_source_f (range (1, lenx, 4))
+ src2 = gr.vector_source_f (range (2, lenx, 4))
+ src3 = gr.vector_source_f (range (3, lenx, 4))
+ op = gr.interleave (gr.sizeof_float)
+ dst = gr.vector_sink_f ()
+
+ self.tb.connect (src0, (op, 0))
+ self.tb.connect (src1, (op, 1))
+ self.tb.connect (src2, (op, 2))
+ self.tb.connect (src3, (op, 3))
+ self.tb.connect (op, dst)
+ self.tb.run ()
+ expected_result = tuple (range (lenx))
+ result_data = dst.data ()
+ self.assertFloatTuplesAlmostEqual (expected_result, result_data)
+ """
+ def test_deint_001 (self):
+ lenx = 64
+ src = gr.vector_source_f (range (lenx))
+ op = blocks_swig.deinterleave (gr.sizeof_float)
+ dst0 = gr.vector_sink_f ()
+ dst1 = gr.vector_sink_f ()
+ dst2 = gr.vector_sink_f ()
+ dst3 = gr.vector_sink_f ()
+
+ self.tb.connect (src, op)
+ self.tb.connect ((op, 0), dst0)
+ self.tb.connect ((op, 1), dst1)
+ self.tb.connect ((op, 2), dst2)
+ self.tb.connect ((op, 3), dst3)
+ self.tb.run ()
+
+ expected_result0 = tuple (range (0, lenx, 4))
+ expected_result1 = tuple (range (1, lenx, 4))
+ expected_result2 = tuple (range (2, lenx, 4))
+ expected_result3 = tuple (range (3, lenx, 4))
+
+ self.assertFloatTuplesAlmostEqual (expected_result0, dst0.data ())
+ self.assertFloatTuplesAlmostEqual (expected_result1, dst1.data ())
+ self.assertFloatTuplesAlmostEqual (expected_result2, dst2.data ())
+ self.assertFloatTuplesAlmostEqual (expected_result3, dst3.data ())
+
+if __name__ == '__main__':
+ gr_unittest.run(test_interleave, "test_interleave.xml")
+
diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i
index 4405b91b7..4bd87db3f 100644
--- a/gr-blocks/swig/blocks_swig.i
+++ b/gr-blocks/swig/blocks_swig.i
@@ -56,6 +56,7 @@
#include "blocks/complex_to_mag_squared.h"
#include "blocks/complex_to_arg.h"
#include "blocks/conjugate_cc.h"
+#include "blocks/deinterleave.h"
#include "blocks/divide_ff.h"
#include "blocks/divide_ss.h"
#include "blocks/divide_ii.h"
@@ -131,6 +132,7 @@
%include "blocks/complex_to_mag_squared.h"
%include "blocks/complex_to_arg.h"
%include "blocks/conjugate_cc.h"
+%include "blocks/deinterleave.h"
%include "blocks/divide_ff.h"
%include "blocks/divide_ss.h"
%include "blocks/divide_ii.h"
@@ -205,6 +207,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_mag);
GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_mag_squared);
GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_arg);
GR_SWIG_BLOCK_MAGIC2(blocks, conjugate_cc);
+GR_SWIG_BLOCK_MAGIC2(blocks, deinterleave);
GR_SWIG_BLOCK_MAGIC2(blocks, divide_ff);
GR_SWIG_BLOCK_MAGIC2(blocks, divide_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, divide_ii);