commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 01/07: digital: wip: burst shaper compiles


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/07: digital: wip: burst shaper compiles and installs
Date: Wed, 22 Apr 2015 03:12:51 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 2e2cc50976b4669a18e61e4c3f2ec3da36bae41f
Author: Sean Nowlan <address@hidden>
Date:   Fri Apr 17 12:43:11 2015 -0400

    digital: wip: burst shaper compiles and installs
---
 gr-digital/grc/digital_burst_shaper.xml            |  71 +++++++++++++
 gr-digital/include/gnuradio/digital/CMakeLists.txt |   1 +
 .../include/gnuradio/digital/burst_shaper_XX.h.t   | 115 ++++++++++++++++++++
 gr-digital/lib/CMakeLists.txt                      |   1 +
 gr-digital/lib/burst_shaper_XX_impl.cc.t           | 116 +++++++++++++++++++++
 gr-digital/lib/burst_shaper_XX_impl.h.t            |  74 +++++++++++++
 gr-digital/python/digital/qa_burst_shaper.py       |  43 ++++++++
 gr-digital/swig/digital_swig.i                     |   6 ++
 8 files changed, 427 insertions(+)

diff --git a/gr-digital/grc/digital_burst_shaper.xml 
b/gr-digital/grc/digital_burst_shaper.xml
new file mode 100644
index 0000000..5c0bc78
--- /dev/null
+++ b/gr-digital/grc/digital_burst_shaper.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<block>
+    <name>Burst Shaper</name>
+    <key>digital_burst_shaper_xx</key>
+    <category>Packet Operators</category>
+    <import>from gnuradio import digital</import>
+    <make>digital.burst_shaper_$(type.fcn)($window, $pre_padding, 
$post_padding, $insert_phasing, $length_tag_name)</make>
+    <param>
+        <name>Type</name>
+        <key>type</key>
+        <type>enum</type>
+        <option>
+            <name>Float</name>
+            <key>float</key>
+            <opt>fcn:ff</opt>
+           <opt>taps:float_vector</opt>
+        </option>
+        <option>
+            <name>Complex</name>
+            <key>complex</key>
+            <opt>fcn:cc</opt>
+           <opt>taps:complex_vector</opt>
+        </option>
+    </param>
+    <param>
+        <name>Window Taps</name>
+        <key>window</key>
+        <value>([])</value>
+        <type>$(type.taps)</type>
+    </param>
+    <param>
+        <name>Pre-padding Length</name>
+        <key>pre_padding</key>
+        <value>0</value>
+        <type>int</type>
+    </param>
+    <param>
+        <name>Post-padding Length</name>
+        <key>post_padding</key>
+        <value>0</value>
+        <type>int</type>
+    </param>
+    <param>
+        <name>Insert phasing symbols</name>
+        <key>insert_phasing</key>
+        <value>False</value>
+        <type>enum</type>
+        <option>
+            <name>No</name>
+            <key>False</key>
+        </option>
+        <option>
+            <name>Yes</name>
+            <key>True</key>
+        </option>
+    </param>
+    <param>
+        <name>Length Tag Name</name>
+        <key>length_tag_name</key>
+        <value>"packet_len"</value>
+        <type>string</type>
+    </param>
+    <sink>
+        <name>in</name>
+        <type>$type</type>
+    </sink>
+    <source>
+        <name>out</name>
+        <type>$type</type>
+    </source>
+</block>
diff --git a/gr-digital/include/gnuradio/digital/CMakeLists.txt 
b/gr-digital/include/gnuradio/digital/CMakeLists.txt
index e85e5bc..d8fe2b6 100644
--- a/gr-digital/include/gnuradio/digital/CMakeLists.txt
+++ b/gr-digital/include/gnuradio/digital/CMakeLists.txt
@@ -22,6 +22,7 @@
 #######################################################################
 include(GrMiscUtils)
 GR_EXPAND_X_H(digital chunks_to_symbols_XX     bf bc sf sc if ic)
+GR_EXPAND_X_H(digital burst_shaper_XX     cc ff)
 
 add_custom_target(digital_generated_includes DEPENDS
     ${generated_includes}
diff --git a/gr-digital/include/gnuradio/digital/burst_shaper_XX.h.t 
b/gr-digital/include/gnuradio/digital/burst_shaper_XX.h.t
new file mode 100644
index 0000000..d527428
--- /dev/null
+++ b/gr-digital/include/gnuradio/digital/burst_shaper_XX.h.t
@@ -0,0 +1,115 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 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/digital/api.h>
+#include <gnuradio/block.h>
+
+namespace gr {
+  namespace digital {
+
+    /*!
+     * \brief Burst shaper block for applying burst padding and ramping.
+     * \ingroup packet_operators_blk
+     *
+     * \details
+     *
+     * This block applies a configurable amount of zero padding before
+     * and/or after a burst indicated by tagged stream length tags.
+     *
+     * If phasing symbols are used, an alternating pattern of +1/-1
+     * symbols of length ceil(N/2) will be inserted before and after
+     * each burst, where N is the length of the taps vector. The ramp-
+     * up/ramp-down shape will be applied to these phasing symbols.
+     *
+     * If phasing symbols are not used, the taper will be applied
+     * directly to the head and tail of each burst.
+     *
+     * Length tags will be updated to include the length of any added
+     * zero padding or phasing symbols.
+     *
+     * \li input: stream of @I_TYPE@
+     * \li output: stream of @O_TYPE@
+     */
+    class DIGITAL_API @NAME@ : virtual public gr::block
+    {
+    public:
+      // gr::digital::@BASE_NAME@::sptr
+      typedef boost::shared_ptr<@BASE_NAME@> sptr;
+
+      /*!
+       * Make a burst shaper block.
+       *
+       * \param taps: vector of window taper taps; the first ceil(N/2)
+       *              items are the up flank and the last ceil(N/2)
+       *              items are the down flank. If taps.size() is odd,
+       *              the middle tap will be used as the last item of
+       *              the up flank and first item of the down flank.
+       * \param pre_padding: number of zero samples to insert before
+       *                     the burst.
+       * \param post_padding: number of zero samples to append after
+       *                      the burst.
+       * \param insert_phasing: if true, insert alternating +1/-1
+       *                        pattern of length ceil(N/2) before and
+       *                        after the burst and apply ramp up and
+       *                        ramp down taps, respectively, to the
+       *                        inserted patterns instead of the head
+       *                        and tail items of the burst.
+       * \param length_tag_name: the name of the tagged stream length
+       *                         tag key.
+       */
+      static sptr make(const std::vector<@I_TYPE@> &taps,
+                       int pre_padding=0, int post_padding=0,
+                       bool insert_phasing=false,
+                       const std::string &length_tag_name="packet_len");
+
+      /*!
+       * Returns the amount of zero padding inserted before each burst.
+       */
+      virtual unsigned int pre_padding() const = 0;
+
+      /*!
+       * Returns the amount of zero padding inserted after each burst.
+       */
+      virtual unsigned int post_padding() const = 0;
+
+      /*!
+       * Returns the total amount of zero padding and phasing symbols
+       * inserted before each burst.
+       */
+      virtual unsigned int prefix_length() const = 0;
+
+      /*!
+       * Returns the total amount of zero padding and phasing symbols
+       * inserted after each burst.
+       */
+      virtual unsigned int suffix_length() const = 0;
+    };
+
+  } // namespace digital
+} // namespace gr
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt
index c5591e8..daa577f 100644
--- a/gr-digital/lib/CMakeLists.txt
+++ b/gr-digital/lib/CMakeLists.txt
@@ -45,6 +45,7 @@ endif(ENABLE_GR_CTRLPORT)
 ########################################################################
 include(GrMiscUtils)
 GR_EXPAND_X_CC_H(digital chunks_to_symbols_XX_impl     bf bc sf sc if ic)
+GR_EXPAND_X_CC_H(digital burst_shaper_XX_impl     cc ff)
 
 ########################################################################
 # Setup library
diff --git a/gr-digital/lib/burst_shaper_XX_impl.cc.t 
b/gr-digital/lib/burst_shaper_XX_impl.cc.t
new file mode 100644
index 0000000..eb7338a
--- /dev/null
+++ b/gr-digital/lib/burst_shaper_XX_impl.cc.t
@@ -0,0 +1,116 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 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 <gnuradio/io_signature.h>
+#include "@address@hidden"
+
+namespace gr {
+  namespace digital {
+
+    @BASE_NAME@::sptr
+    @BASE_NAME@::make(const std::vector<@I_TYPE@> &taps,
+                      int pre_padding, int post_padding,
+                      bool insert_phasing,
+                      const std::string &length_tag_name)
+    {
+      return gnuradio::get_initial_sptr
+        (new @IMPL_NAME@(taps, pre_padding, post_padding,
+                         insert_phasing, length_tag_name));
+    }
+
+    @IMPL_NAME@::@IMPL_NAME@(const std::vector<@I_TYPE@> &taps,
+                             int pre_padding, int post_padding,
+                             bool insert_phasing,
+                             const std::string &length_tag_name)
+      : gr::block("@BASE_NAME@",
+              gr::io_signature::make(1, 1, sizeof(@I_TYPE@)),
+              gr::io_signature::make(1, 1, sizeof(@O_TYPE@))),
+        d_upflank(taps.begin(), taps.begin() + taps.size()/2 + taps.size()%2),
+        d_downflank(taps.begin() + taps.size()/2, taps.end()),
+        d_nprepad(pre_padding),
+        d_npostpad(post_padding),
+        d_insert_phasing(insert_phasing),
+        d_length_tag_key(pmt::string_to_symbol(length_tag_name)),
+        d_state(STATE_WAITING)
+    {
+        if(d_insert_phasing)
+            for(unsigned int i = 0; i < d_upflank.size(); i++)
+                d_phasing.push_back(i%2 ? @I_TYPE@(1.0f) : @I_TYPE@(-1.0f));
+    }
+
+    @IMPL_NAME@::address@hidden@()
+    {
+    }
+
+    void
+    @IMPL_NAME@::forecast(int noutput_items, gr_vector_int 
&ninput_items_required)
+    {
+        ninput_items_required[0] = noutput_items;
+    }
+
+    int
+    @IMPL_NAME@::general_work(int noutput_items,
+                      gr_vector_int &ninput_items,
+                      gr_vector_const_void_star &input_items,
+                      gr_vector_void_star &output_items)
+    {
+        const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0];
+        @O_TYPE@ *out = (@O_TYPE@ *) output_items[0];
+
+        int nwritten = 0;
+        int nread = 0;
+        int curr_tag_index = 0;
+        int nprocess = 0;
+
+        std::vector<tag_t> tags;
+        get_tags_in_window(tags, 0, 0, ninput_items[0]);
+       std::sort(tags.begin(), tags.end(), tag_t::offset_compare);
+
+        //TODO: figure out what to do with tag gaps - should probably just drop
+        while((nwritten < noutput_items) && (nread < ninput_items[0])) {
+            switch(d_state) {
+                case(STATE_WAITING):
+                case(STATE_PREPAD):
+                   std::memset(out, 0x00, nprocess * sizeof(@O_TYPE@));
+                case(STATE_RAMPUP):
+                case(STATE_COPY):
+                    std::memcpy(out, in, nprocess * sizeof(@O_TYPE@));
+                case(STATE_RAMPDOWN):
+                case(STATE_POSTPAD):
+                   std::memset(out, 0x00, nprocess * sizeof(@O_TYPE@));
+            }
+        }
+
+        consume_each (noutput_items);
+
+        // Tell runtime system how many output items we produced.
+        return noutput_items;
+    }
+
+  } /* namespace digital */
+} /* namespace gr */
diff --git a/gr-digital/lib/burst_shaper_XX_impl.h.t 
b/gr-digital/lib/burst_shaper_XX_impl.h.t
new file mode 100644
index 0000000..c36a3ad
--- /dev/null
+++ b/gr-digital/lib/burst_shaper_XX_impl.h.t
@@ -0,0 +1,74 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 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/digital/@address@hidden>
+
+namespace gr {
+  namespace digital {
+
+    class @IMPL_NAME@ : public @BASE_NAME@
+    {
+    protected:
+      enum state_t {STATE_WAITING, STATE_PREPAD, STATE_RAMPUP,
+                    STATE_COPY, STATE_RAMPDOWN, STATE_POSTPAD};
+
+    private:
+      const std::vector<@I_TYPE@> d_upflank;
+      const std::vector<@I_TYPE@> d_downflank;
+      const int d_nprepad;
+      const int d_npostpad;
+      const bool d_insert_phasing;
+      const pmt::pmt_t d_length_tag_key;
+      std::vector<@I_TYPE@> d_phasing;
+      int d_remaining;
+      state_t d_state;
+
+    public:
+      @IMPL_NAME@(const std::vector<@I_TYPE@> &taps, int pre_padding,
+                  int post_padding, bool insert_phasing,
+                  const std::string &length_tag_name);
+      address@hidden@();
+
+      void forecast(int noutput_items,
+                    gr_vector_int &ninput_items_required);
+
+      int general_work(int noutput_items,
+                      gr_vector_int &ninput_items,
+                      gr_vector_const_void_star &input_items,
+                      gr_vector_void_star &output_items);
+      unsigned int pre_padding() const { return d_nprepad; }
+      unsigned int post_padding() const { return d_npostpad; }
+      unsigned int prefix_length() const { return d_nprepad +
+                                           d_upflank.size(); }
+      unsigned int suffix_length() const { return d_npostpad +
+                                           d_downflank.size(); }
+    };
+
+  } // namespace digital
+} // namespace gr
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-digital/python/digital/qa_burst_shaper.py 
b/gr-digital/python/digital/qa_burst_shaper.py
new file mode 100755
index 0000000..6ba4ac0
--- /dev/null
+++ b/gr-digital/python/digital/qa_burst_shaper.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# 
+# Copyright 2015 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
+from gnuradio import blocks
+import digital_swig as digital
+
+class qa_burst_shaper_cc (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block ()
+
+    def tearDown (self):
+        self.tb = None
+
+    def test_001_t (self):
+        # set up fg
+        self.tb.run ()
+        # check data
+
+
+if __name__ == '__main__':
+    gr_unittest.run(qa_burst_shaper_cc, "qa_burst_shaper_cc.xml")
diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i
index 9797e79..d7a3b81 100644
--- a/gr-digital/swig/digital_swig.i
+++ b/gr-digital/swig/digital_swig.i
@@ -39,6 +39,8 @@
 %{
 #include "gnuradio/digital/additive_scrambler_bb.h"
 #include "gnuradio/digital/binary_slicer_fb.h"
+#include "gnuradio/digital/burst_shaper_cc.h"
+#include "gnuradio/digital/burst_shaper_ff.h"
 #include "gnuradio/digital/chunks_to_symbols_bc.h"
 #include "gnuradio/digital/chunks_to_symbols_bf.h"
 #include "gnuradio/digital/chunks_to_symbols_ic.h"
@@ -118,6 +120,8 @@
 
 %include "gnuradio/digital/additive_scrambler_bb.h"
 %include "gnuradio/digital/binary_slicer_fb.h"
+%include "gnuradio/digital/burst_shaper_cc.h"
+%include "gnuradio/digital/burst_shaper_ff.h"
 %include "gnuradio/digital/chunks_to_symbols_bc.h"
 %include "gnuradio/digital/chunks_to_symbols_bf.h"
 %include "gnuradio/digital/chunks_to_symbols_ic.h"
@@ -193,6 +197,8 @@
 
 GR_SWIG_BLOCK_MAGIC2(digital, additive_scrambler_bb);
 GR_SWIG_BLOCK_MAGIC2(digital, binary_slicer_fb);
+GR_SWIG_BLOCK_MAGIC2(digital, burst_shaper_cc);
+GR_SWIG_BLOCK_MAGIC2(digital, burst_shaper_ff);
 GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_bc);
 GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_bf);
 GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_ic);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]