summaryrefslogtreecommitdiff
path: root/gr-blocks
diff options
context:
space:
mode:
authorJohnathan Corgan2012-07-06 08:17:40 -0700
committerJohnathan Corgan2012-07-06 08:17:40 -0700
commit27694edd168bc1260ff04950e837a6580afc49ab (patch)
treec7d7a7dbaf9c156f9859e411f9360a473a2eb791 /gr-blocks
parent44647064669928517b233ca26bd97cd87847a235 (diff)
downloadgnuradio-27694edd168bc1260ff04950e837a6580afc49ab.tar.gz
gnuradio-27694edd168bc1260ff04950e837a6580afc49ab.tar.bz2
gnuradio-27694edd168bc1260ff04950e837a6580afc49ab.zip
blocks: added gr::blocks::interleave
Diffstat (limited to 'gr-blocks')
-rw-r--r--gr-blocks/grc/blocks_block_tree.xml1
-rw-r--r--gr-blocks/grc/blocks_interleave.xml67
-rw-r--r--gr-blocks/include/blocks/CMakeLists.txt1
-rw-r--r--gr-blocks/include/blocks/interleave.h50
-rw-r--r--gr-blocks/lib/CMakeLists.txt1
-rw-r--r--gr-blocks/lib/interleave_impl.cc76
-rw-r--r--gr-blocks/lib/interleave_impl.h49
-rwxr-xr-xgr-blocks/python/qa_interleave.py5
-rw-r--r--gr-blocks/swig/blocks_swig.i3
9 files changed, 250 insertions, 3 deletions
diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml
index e4aed9809..dfbe88b05 100644
--- a/gr-blocks/grc/blocks_block_tree.xml
+++ b/gr-blocks/grc/blocks_block_tree.xml
@@ -74,5 +74,6 @@
<cat>
<name>Stream Operations (New) </name>
<block>blocks_deinterleave.xml</block>
+ <block>blocks_interleave.xml</block>
</cat>
</cat>
diff --git a/gr-blocks/grc/blocks_interleave.xml b/gr-blocks/grc/blocks_interleave.xml
new file mode 100644
index 000000000..f01a3be6d
--- /dev/null
+++ b/gr-blocks/grc/blocks_interleave.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Interleave
+###################################################
+ -->
+<block>
+ <name>Interleave</name>
+ <key>blocks_interleave</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.interleave($type.size*$vlen)</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.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>
+ <nports>$num_streams</nports>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt
index c3ad9d033..a8a1c5a62 100644
--- a/gr-blocks/include/blocks/CMakeLists.txt
+++ b/gr-blocks/include/blocks/CMakeLists.txt
@@ -107,6 +107,7 @@ install(FILES
float_to_short.h
float_to_uchar.h
int_to_float.h
+ interleave.h
interleaved_short_to_complex.h
multiply_cc.h
multiply_ff.h
diff --git a/gr-blocks/include/blocks/interleave.h b/gr-blocks/include/blocks/interleave.h
new file mode 100644
index 000000000..e98d01df9
--- /dev/null
+++ b/gr-blocks/include/blocks/interleave.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_INTERLEAVE_H
+#define INCLUDED_BLOCKS_INTERLEAVE_H
+
+#include <blocks/api.h>
+#include <gr_sync_interpolator.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief interleave N inputs into a single output
+ * \ingroup slicedice_blk
+ * \param itemsize stream itemsize
+ */
+ class BLOCKS_API interleave : virtual public gr_sync_interpolator
+ {
+ public:
+
+ // gr::blocks::interleave::sptr
+ typedef boost::shared_ptr<interleave> sptr;
+
+ static sptr make(size_t itemsize);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_INTERLEAVE_H */
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index 081064629..f224330d4 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -143,6 +143,7 @@ list(APPEND gr_blocks_sources
float_array_to_uchar.cc
float_to_uchar_impl.cc
int_to_float_impl.cc
+ interleave_impl.cc
interleaved_short_array_to_complex.cc
interleaved_short_to_complex_impl.cc
multiply_cc_impl.cc
diff --git a/gr-blocks/lib/interleave_impl.cc b/gr-blocks/lib/interleave_impl.cc
new file mode 100644
index 000000000..df37ed26d
--- /dev/null
+++ b/gr-blocks/lib/interleave_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 "interleave_impl.h"
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ interleave::sptr interleave::make(size_t itemsize)
+ {
+ return gnuradio::get_initial_sptr(new interleave_impl(itemsize));
+ }
+
+ interleave_impl::interleave_impl(size_t itemsize)
+ : gr_sync_interpolator("interleave",
+ gr_make_io_signature (1, gr_io_signature::IO_INFINITE, itemsize),
+ gr_make_io_signature (1, 1, itemsize),
+ 1),
+ d_itemsize(itemsize)
+ {
+ }
+
+ bool
+ interleave_impl::check_topology(int ninputs, int noutputs)
+ {
+ set_interpolation(ninputs);
+ return true;
+ }
+
+ int
+ interleave_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ size_t nchan = input_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 += nchan) {
+ for (unsigned int n = 0; n < nchan; n++) {
+ memcpy (out, in[n], itemsize);
+ out += itemsize;
+ in[n] += itemsize;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/interleave_impl.h b/gr-blocks/lib/interleave_impl.h
new file mode 100644
index 000000000..a02517e3e
--- /dev/null
+++ b/gr-blocks/lib/interleave_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_INTERLEAVE_IMPL_H
+#define INCLUDED_INTERLEAVE_IMPL_H
+
+#include <blocks/interleave.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API interleave_impl : public interleave
+ {
+ size_t d_itemsize;
+
+ public:
+ interleave_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_INTERLEAVE_IMPL_H */
diff --git a/gr-blocks/python/qa_interleave.py b/gr-blocks/python/qa_interleave.py
index 56c8bdfdf..376d487b1 100755
--- a/gr-blocks/python/qa_interleave.py
+++ b/gr-blocks/python/qa_interleave.py
@@ -32,14 +32,13 @@ class test_interleave (gr_unittest.TestCase):
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)
+ op = blocks_swig.interleave (gr.sizeof_float)
dst = gr.vector_sink_f ()
self.tb.connect (src0, (op, 0))
@@ -51,7 +50,7 @@ class test_interleave (gr_unittest.TestCase):
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))
diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i
index 4bd87db3f..108232e0f 100644
--- a/gr-blocks/swig/blocks_swig.i
+++ b/gr-blocks/swig/blocks_swig.i
@@ -71,6 +71,7 @@
#include "blocks/integrate_ii.h"
#include "blocks/integrate_ff.h"
#include "blocks/integrate_cc.h"
+#include "blocks/interleave.h"
#include "blocks/interleaved_short_to_complex.h"
#include "blocks/multiply_ss.h"
#include "blocks/multiply_ii.h"
@@ -147,6 +148,7 @@
%include "blocks/integrate_ii.h"
%include "blocks/integrate_ff.h"
%include "blocks/integrate_cc.h"
+%include "blocks/interleave.h"
%include "blocks/interleaved_short_to_complex.h"
%include "blocks/multiply_ss.h"
%include "blocks/multiply_ii.h"
@@ -222,6 +224,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, integrate_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, integrate_ii);
GR_SWIG_BLOCK_MAGIC2(blocks, integrate_ff);
GR_SWIG_BLOCK_MAGIC2(blocks, integrate_cc);
+GR_SWIG_BLOCK_MAGIC2(blocks, interleave);
GR_SWIG_BLOCK_MAGIC2(blocks, interleaved_short_to_complex);
GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ii);