commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 02/25: polar: encoder implemented in C++


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/25: polar: encoder implemented in C++
Date: Wed, 23 Sep 2015 14:51:36 +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 87670ad6f14e61bf4bde6c6e5b18d19b262fe33f
Author: Johannes Demel <address@hidden>
Date:   Mon Jun 15 12:04:34 2015 +0200

    polar: encoder implemented in C++
---
 README                                          |   23 +
 gr-fec/examples/.gitignore                      |    3 +
 gr-fec/examples/polar_encoder_decoder_chain.grc | 1116 +++++++++++++++++++++++
 gr-fec/grc/fec_block_tree.xml                   |    1 +
 gr-fec/grc/fec_polar_encoder.xml                |   50 +
 gr-fec/include/gnuradio/fec/CMakeLists.txt      |    2 +-
 gr-fec/include/gnuradio/fec/polar_encoder.h     |  106 +++
 gr-fec/lib/CMakeLists.txt                       |    3 +-
 gr-fec/lib/polar_encoder.cc                     |  318 +++++++
 gr-fec/python/fec/polar/__init__.py             |   22 +
 gr-fec/python/fec/polar/helper_functions.py     |   28 +
 gr-fec/python/fec/polar/testbed.py              |    4 +-
 gr-fec/python/fec/qa_polar_encoder.py           |  133 +++
 gr-fec/swig/fec_swig.i                          |    2 +
 14 files changed, 1808 insertions(+), 3 deletions(-)

diff --git a/README b/README
new file mode 100644
index 0000000..8d6fc4b
--- /dev/null
+++ b/README
@@ -0,0 +1,23 @@
+ESA Summer of Code in Space 2015 POLAR Code implementation for GNU Radio
+================
+
+This is a GNU Radio clone which contains all the files for my POLAR code 
project for ESA Summer of Code in Space 2015. My name is Johannes Demel and I 
am a Master degree student at *Karlsruhe Institute of Technology (KIT)*.
+
+Basics
+----------
+The project is based on Erdal Arikan's 2009 paper *Channel Polarization: A 
Method for Constructing Capacity-Achieving Codes for Symmetric Binary-Input 
Memoryless Channels*. An in-depth explanation of my project is given in my 
project proposal <https://github.com/jdemel/socis-proposal>.
+
+Structure
+----------
+The aim of the project is to add POLAR code encoder, decoder, channel 
construction capabilities to GNU Radio. POLAR codes are used for channel 
coding, thus all files shall reside within the *gr-fec* submodule. Also encoder 
and decoder shall use the FECAPI. The decision to do all development in-tree is 
driven by previous experience that out-of-tree modules are often terribly hard 
to merge later on and it may take years to do so.
+
+Project
+-------
+A quick overview of my project timeline goes as follows.
+
+1. create Python testcode
+2. implement encoder and decoder in C++ for FECAPI.
+3. optimize blocks and create VOLK kernels.
+4. implement channel construction algorithms.
+
+This may get continuously updated and I will add more details during project 
development.
\ No newline at end of file
diff --git a/gr-fec/examples/.gitignore b/gr-fec/examples/.gitignore
new file mode 100644
index 0000000..c339347
--- /dev/null
+++ b/gr-fec/examples/.gitignore
@@ -0,0 +1,3 @@
+*.py
+callgrind.out.*
+perf.*
diff --git a/gr-fec/examples/polar_encoder_decoder_chain.grc 
b/gr-fec/examples/polar_encoder_decoder_chain.grc
new file mode 100644
index 0000000..c648aea
--- /dev/null
+++ b/gr-fec/examples/polar_encoder_decoder_chain.grc
@@ -0,0 +1,1116 @@
+<?xml version='1.0' encoding='ASCII'?>
+<?grc format='1' created='3.7.8'?>
+<flow_graph>
+  <timestamp>Mon Jun 15 10:51:02 2015</timestamp>
+  <block>
+    <key>options</key>
+    <param>
+      <key>author</key>
+      <value>Johannes Demel</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>category</key>
+      <value>Custom</value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>description</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(10, 10)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>generate_options</key>
+      <value>no_gui</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>polar_encoder_decoder_chain</value>
+    </param>
+    <param>
+      <key>max_nouts</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>realtime_scheduling</key>
+      <value></value>
+    </param>
+    <param>
+      <key>run_options</key>
+      <value>run</value>
+    </param>
+    <param>
+      <key>run</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>thread_safe_setters</key>
+      <value></value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>POLAR Encoder and Decoder</value>
+    </param>
+    <param>
+      <key>window_size</key>
+      <value>1920, 1080</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_cc_decoder_def</key>
+    <param>
+      <key>padding</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>k</key>
+      <value>7</value>
+    </param>
+    <param>
+      <key>dim1</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>dim2</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>state_end</key>
+      <value>-1</value>
+    </param>
+    <param>
+      <key>framebits</key>
+      <value>2048</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(640, 35)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>cc_decoder</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>"ok"</value>
+    </param>
+    <param>
+      <key>ndim</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>polys</key>
+      <value>[79,109]</value>
+    </param>
+    <param>
+      <key>rate</key>
+      <value>2</value>
+    </param>
+    <param>
+      <key>state_start</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>mode</key>
+      <value>fec.CC_STREAMING</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_cc_encoder_def</key>
+    <param>
+      <key>padding</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>k</key>
+      <value>7</value>
+    </param>
+    <param>
+      <key>dim1</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>dim2</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>framebits</key>
+      <value>2048</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(304, 43)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>cc_encoder</value>
+    </param>
+    <param>
+      <key>ndim</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>polys</key>
+      <value>[79,109]</value>
+    </param>
+    <param>
+      <key>rate</key>
+      <value>2</value>
+    </param>
+    <param>
+      <key>state_start</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>mode</key>
+      <value>fec.CC_STREAMING</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_polar_encoder_def</key>
+    <param>
+      <key>num_info_bits</key>
+      <value>128</value>
+    </param>
+    <param>
+      <key>block_size</key>
+      <value>256</value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>frozen_bit_positions</key>
+      <value>range(128)</value>
+    </param>
+    <param>
+      <key>frozen_bit_values</key>
+      <value>[0] * 128</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(576, 307)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>polar_encoder</value>
+    </param>
+    <param>
+      <key>is_packed</key>
+      <value>True</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(10, 170)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>32000</value>
+    </param>
+  </block>
+  <block>
+    <key>analog_random_source_x</key>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(136, 227)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>analog_random_source_x_0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>max</key>
+      <value>2</value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>min</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>num_samps</key>
+      <value>2 ** 10</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>repeat</key>
+      <value>True</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_char_to_float</key>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1272, 251)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>blocks_char_to_float_0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>scale</key>
+      <value>10</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_head</key>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1080, 363)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>blocks_head_0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>num_items</key>
+      <value>2 ** 32</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_null_sink</key>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>bus_conns</key>
+      <value>[[0,],]</value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1256, 368)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>blocks_null_sink_0</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>num_inputs</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_pack_k_bits_bb</key>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(408, 251)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>blocks_pack_k_bits_bb_0</value>
+    </param>
+    <param>
+      <key>k</key>
+      <value>8</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_unpack_k_bits_bb</key>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(904, 363)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>blocks_unpack_k_bits_bb_0</value>
+    </param>
+    <param>
+      <key>k</key>
+      <value>8</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>fec_generic_decoder</key>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>decoder</key>
+      <value>cc_decoder</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1040, 251)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>fec_generic_decoder_0</value>
+    </param>
+    <param>
+      <key>itype</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>otype</key>
+      <value>byte</value>
+    </param>
+  </block>
+  <block>
+    <key>fec_generic_encoder</key>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>encoder</key>
+      <value>polar_encoder</value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(576, 251)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>fec_generic_encoder_0</value>
+    </param>
+    <param>
+      <key>itype</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>otype</key>
+      <value>byte</value>
+    </param>
+  </block>
+  <block>
+    <key>import</key>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(968, 32)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>import_0</value>
+    </param>
+    <param>
+      <key>import</key>
+      <value>import time</value>
+    </param>
+  </block>
+  <block>
+    <key>qtgui_time_sink_x</key>
+    <param>
+      <key>autoscale</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>comment</key>
+      <value></value>
+    </param>
+    <param>
+      <key>ctrlpanel</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>entags</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1432, 235)</value>
+    </param>
+    <param>
+      <key>gui_hint</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>grid</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>id</key>
+      <value>qtgui_time_sink_x_0</value>
+    </param>
+    <param>
+      <key>legend</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>alpha1</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>color1</key>
+      <value>"blue"</value>
+    </param>
+    <param>
+      <key>label1</key>
+      <value></value>
+    </param>
+    <param>
+      <key>marker1</key>
+      <value>-1</value>
+    </param>
+    <param>
+      <key>style1</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>width1</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alpha10</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>color10</key>
+      <value>"blue"</value>
+    </param>
+    <param>
+      <key>label10</key>
+      <value></value>
+    </param>
+    <param>
+      <key>marker10</key>
+      <value>-1</value>
+    </param>
+    <param>
+      <key>style10</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>width10</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alpha2</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>color2</key>
+      <value>"red"</value>
+    </param>
+    <param>
+      <key>label2</key>
+      <value></value>
+    </param>
+    <param>
+      <key>marker2</key>
+      <value>-1</value>
+    </param>
+    <param>
+      <key>style2</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>width2</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alpha3</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>color3</key>
+      <value>"green"</value>
+    </param>
+    <param>
+      <key>label3</key>
+      <value></value>
+    </param>
+    <param>
+      <key>marker3</key>
+      <value>-1</value>
+    </param>
+    <param>
+      <key>style3</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>width3</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alpha4</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>color4</key>
+      <value>"black"</value>
+    </param>
+    <param>
+      <key>label4</key>
+      <value></value>
+    </param>
+    <param>
+      <key>marker4</key>
+      <value>-1</value>
+    </param>
+    <param>
+      <key>style4</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>width4</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alpha5</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>color5</key>
+      <value>"cyan"</value>
+    </param>
+    <param>
+      <key>label5</key>
+      <value></value>
+    </param>
+    <param>
+      <key>marker5</key>
+      <value>-1</value>
+    </param>
+    <param>
+      <key>style5</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>width5</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alpha6</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>color6</key>
+      <value>"magenta"</value>
+    </param>
+    <param>
+      <key>label6</key>
+      <value></value>
+    </param>
+    <param>
+      <key>marker6</key>
+      <value>-1</value>
+    </param>
+    <param>
+      <key>style6</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>width6</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alpha7</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>color7</key>
+      <value>"yellow"</value>
+    </param>
+    <param>
+      <key>label7</key>
+      <value></value>
+    </param>
+    <param>
+      <key>marker7</key>
+      <value>-1</value>
+    </param>
+    <param>
+      <key>style7</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>width7</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alpha8</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>color8</key>
+      <value>"dark red"</value>
+    </param>
+    <param>
+      <key>label8</key>
+      <value></value>
+    </param>
+    <param>
+      <key>marker8</key>
+      <value>-1</value>
+    </param>
+    <param>
+      <key>style8</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>width8</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alpha9</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>color9</key>
+      <value>"dark green"</value>
+    </param>
+    <param>
+      <key>label9</key>
+      <value></value>
+    </param>
+    <param>
+      <key>marker9</key>
+      <value>-1</value>
+    </param>
+    <param>
+      <key>style9</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>width9</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>name</key>
+      <value>""</value>
+    </param>
+    <param>
+      <key>nconnections</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>size</key>
+      <value>2048</value>
+    </param>
+    <param>
+      <key>srate</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>tr_chan</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>tr_delay</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>tr_level</key>
+      <value>0.0</value>
+    </param>
+    <param>
+      <key>tr_mode</key>
+      <value>qtgui.TRIG_MODE_FREE</value>
+    </param>
+    <param>
+      <key>tr_slope</key>
+      <value>qtgui.TRIG_SLOPE_POS</value>
+    </param>
+    <param>
+      <key>tr_tag</key>
+      <value>""</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>float</value>
+    </param>
+    <param>
+      <key>update_time</key>
+      <value>0.10</value>
+    </param>
+    <param>
+      <key>ylabel</key>
+      <value>Amplitude</value>
+    </param>
+    <param>
+      <key>yunit</key>
+      <value>""</value>
+    </param>
+    <param>
+      <key>ymax</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>ymin</key>
+      <value>-1</value>
+    </param>
+  </block>
+  <connection>
+    <source_block_id>analog_random_source_x_0</source_block_id>
+    <sink_block_id>blocks_pack_k_bits_bb_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blocks_char_to_float_0</source_block_id>
+    <sink_block_id>qtgui_time_sink_x_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blocks_head_0</source_block_id>
+    <sink_block_id>blocks_null_sink_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blocks_pack_k_bits_bb_0</source_block_id>
+    <sink_block_id>fec_generic_encoder_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blocks_unpack_k_bits_bb_0</source_block_id>
+    <sink_block_id>blocks_head_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>fec_generic_decoder_0</source_block_id>
+    <sink_block_id>blocks_char_to_float_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>fec_generic_encoder_0</source_block_id>
+    <sink_block_id>blocks_char_to_float_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>fec_generic_encoder_0</source_block_id>
+    <sink_block_id>blocks_unpack_k_bits_bb_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>fec_generic_encoder_0</source_block_id>
+    <sink_block_id>fec_generic_decoder_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+</flow_graph>
diff --git a/gr-fec/grc/fec_block_tree.xml b/gr-fec/grc/fec_block_tree.xml
index 0fddcf3..f2f2c5b 100644
--- a/gr-fec/grc/fec_block_tree.xml
+++ b/gr-fec/grc/fec_block_tree.xml
@@ -24,6 +24,7 @@
       <block>variable_ldpc_encoder_def</block>
       <block>variable_tpc_encoder_def</block>
       <block>variable_dummy_encoder_def</block>
+      <block>variable_polar_encoder_def</block>
     </cat>
     <block>fec_extended_encoder</block>
     <block>fec_extended_async_encoder</block>
diff --git a/gr-fec/grc/fec_polar_encoder.xml b/gr-fec/grc/fec_polar_encoder.xml
new file mode 100644
index 0000000..14f1b88
--- /dev/null
+++ b/gr-fec/grc/fec_polar_encoder.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<block>
+  <name>POLAR Encoder Definition</name>
+  <key>variable_polar_encoder_def</key>
+  <import>from gnuradio import fec</import>
+  <var_make>
+self.$(id) = $(id) = fec.polar_encoder.make($block_size, $num_info_bits, 
$frozen_bit_positions, $frozen_bit_values, $is_packed)
+  </var_make>
+  <var_value>fec.polar_encoder.make($block_size, $num_info_bits, 
$frozen_bit_positions, $frozen_bit_values, $is_packed)</var_value>
+  <make></make>
+
+  <param>
+    <name>Packed Bits</name>
+    <key>is_packed</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>Block size (N)</name>
+    <key>block_size</key>
+    <type>int</type>
+  </param>
+
+  <param>
+    <name>#Info Bits (K)</name>
+    <key>num_info_bits</key>
+    <type>int</type>
+  </param>
+
+  <param>
+    <name>Frozen Bit Positions</name>
+    <key>frozen_bit_positions</key>
+    <type>int_vector</type>
+  </param>
+
+  <param>
+    <name>Frozen Bit Values</name>
+    <key>frozen_bit_values</key>
+    <type>int_vector</type>
+  </param>
+</block>
diff --git a/gr-fec/include/gnuradio/fec/CMakeLists.txt 
b/gr-fec/include/gnuradio/fec/CMakeLists.txt
index 9c13f78..0b3a5a3 100644
--- a/gr-fec/include/gnuradio/fec/CMakeLists.txt
+++ b/gr-fec/include/gnuradio/fec/CMakeLists.txt
@@ -47,6 +47,6 @@ install(FILES
     puncture_bb.h
     puncture_ff.h
     depuncture_bb.h
-    DESTINATION ${GR_INCLUDE_DIR}/gnuradio/fec
+    polar_encoder.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio/fec
     COMPONENT "fec_devel"
 )
diff --git a/gr-fec/include/gnuradio/fec/polar_encoder.h 
b/gr-fec/include/gnuradio/fec/polar_encoder.h
new file mode 100644
index 0000000..9cd37b8
--- /dev/null
+++ b/gr-fec/include/gnuradio/fec/polar_encoder.h
@@ -0,0 +1,106 @@
+/* -*- 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.
+ */
+
+
+#ifndef INCLUDED_FEC_POLAR_ENCODER_H
+#define INCLUDED_FEC_POLAR_ENCODER_H
+
+#include <gnuradio/fec/api.h>
+#include <gnuradio/fec/generic_encoder.h>
+
+// Forward declaration for those objects. SWIG doesn't like them to be 
#include'd.
+namespace gr {
+  namespace blocks {
+    namespace kernel {
+      class pack_k_bits;
+      class unpack_k_bits;
+    }
+  }
+}
+
+namespace gr {
+  namespace fec {
+
+    /*!
+     * \brief POLAR encoder
+     *
+     */
+    class FEC_API polar_encoder : public generic_encoder
+    {
+    public:
+      static generic_encoder::sptr make(int block_size, int num_info_bits, 
std::vector<int> frozen_bit_positions, std::vector<char> frozen_bit_values, 
bool is_packed = false);
+      ~polar_encoder();
+
+      // FECAPI
+      void generic_work(void *in_buffer, void *out_buffer);
+      double rate(){return (1.0 * get_input_size() / get_output_size());};
+      int get_input_size(){return d_input_size;};
+      int get_output_size(){return d_output_size;};
+      bool set_frame_size(unsigned int frame_size){return false;};
+
+    private:
+      polar_encoder(int block_size, int num_info_bits, std::vector<int> 
frozen_bit_positions, std::vector<char> frozen_bit_values, bool is_packed);
+      int d_block_size; // depending on paper called 'N' or 'm'
+      int d_block_power;
+      int d_input_size, d_output_size;
+      bool d_is_packed;
+      int d_num_info_bits; // mostly abbreviated by 'K'
+      std::vector<int> d_frozen_bit_positions;
+      std::vector<int> d_info_bit_positions;
+      std::vector<char> d_frozen_bit_values;
+
+      // for unpacked bits an 'easier-to-grasp' algorithm.
+      void insert_frozen_bits(unsigned char* target, const unsigned char* 
input);
+      void bit_reverse_vector(unsigned char* target, const unsigned char* 
input);
+      void encode_vector(unsigned char* target);
+
+      // c'tor method for packed algorithm setup.
+      void setup_frozen_bit_inserter();
+
+      // methods insert input bits and frozen bits into packed array for 
encoding
+      unsigned char* d_block_array; // use for encoding
+      unsigned char* d_frozen_bit_prototype; // packed frozen bits are written 
onto it and later copies are used.
+      void insert_unpacked_frozen_bits_and_reverse(unsigned char* target, 
const unsigned char* input) const;
+      void insert_packed_frozen_bits_and_reverse(unsigned char* target, const 
unsigned char* input) const;
+      void insert_unpacked_bit_into_packed_array_at_position(unsigned char* 
target, const unsigned char bit, const int pos) const;
+      void insert_packet_bit_into_packed_array_at_position(unsigned char* 
target, const unsigned char bit, const int target_pos, const int bit_pos) const;
+
+      // packed encoding methods
+      void encode_vector_packed(unsigned char* target) const;
+      void encode_vector_packed_subbyte(unsigned char* target) const;
+      void encode_packed_byte(unsigned char* target) const;
+      void encode_vector_packed_interbyte(unsigned char* target) const;
+
+      // helper functions
+      long bit_reverse(long value, int active_bits) const;
+      void print_packed_bit_array(const unsigned char* printed_array, const 
int num_bytes) const;
+
+      gr::blocks::kernel::pack_k_bits *d_packer;
+      gr::blocks::kernel::unpack_k_bits *d_unpacker;
+
+    };
+
+  } // namespace fec
+} // namespace gr
+
+#endif /* INCLUDED_FEC_POLAR_ENCODER_H */
+
diff --git a/gr-fec/lib/CMakeLists.txt b/gr-fec/lib/CMakeLists.txt
index 2c116fe..00cb061 100644
--- a/gr-fec/lib/CMakeLists.txt
+++ b/gr-fec/lib/CMakeLists.txt
@@ -80,7 +80,8 @@ list(APPEND gnuradio_fec_sources
   alist.cc
   tpc_common.cc
   tpc_decoder.cc
-  tpc_encoder.cc 
+  tpc_encoder.cc
+    polar_encoder.cc
 )
 
 #Add Windows DLL resource file if using MSVC
diff --git a/gr-fec/lib/polar_encoder.cc b/gr-fec/lib/polar_encoder.cc
new file mode 100644
index 0000000..1214e80
--- /dev/null
+++ b/gr-fec/lib/polar_encoder.cc
@@ -0,0 +1,318 @@
+/* -*- 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gnuradio/io_signature.h>
+#include <gnuradio/fec/polar_encoder.h>
+#include <cmath>
+#include <stdexcept>
+#include <volk/volk.h>
+
+#include <gnuradio/blocks/pack_k_bits.h>
+#include <gnuradio/blocks/unpack_k_bits.h>
+
+namespace gr {
+  namespace fec {
+
+    generic_encoder::sptr
+    polar_encoder::make(int block_size, int num_info_bits, std::vector<int> 
frozen_bit_positions,
+                        std::vector<char> frozen_bit_values, bool is_packed)
+    {
+      return generic_encoder::sptr(new polar_encoder(block_size, 
num_info_bits, frozen_bit_positions, frozen_bit_values, is_packed));
+    }
+
+    polar_encoder::polar_encoder(int block_size, int num_info_bits, 
std::vector<int> frozen_bit_positions, std::vector<char> frozen_bit_values, 
bool is_packed):
+        d_block_size(block_size),
+        d_input_size(num_info_bits / (is_packed ? 8 : 1)),
+        d_output_size(block_size / (is_packed ? 8 : 1)),
+        d_is_packed(is_packed),
+        d_num_info_bits(num_info_bits),
+        d_frozen_bit_positions(frozen_bit_positions),
+        d_frozen_bit_values(frozen_bit_values)
+    {
+      int n = (int) log2(float(block_size));
+      d_block_power = n;
+      if(pow(2, n) != block_size){
+        throw std::runtime_error("block_size MUST be a power of 2!");
+      }
+
+      unsigned int num_frozen_bits = d_block_size - d_num_info_bits;
+      if(num_frozen_bits != d_frozen_bit_positions.size()){
+        throw std::runtime_error("number of frozen bit positions must equal 
block_size - num_info_bits");
+      }
+
+      while(d_frozen_bit_values.size() < num_frozen_bits){
+        d_frozen_bit_values.push_back(0);
+      }
+
+      int k = 8;
+      d_unpacker = new gr::blocks::kernel::unpack_k_bits(k);
+      d_packer = new gr::blocks::kernel::pack_k_bits(k);
+
+      setup_frozen_bit_inserter();
+    }
+
+    void
+    polar_encoder::setup_frozen_bit_inserter()
+    {
+      d_block_array = (unsigned char*) volk_malloc(d_block_size >> 3, 
volk_get_alignment());
+      d_frozen_bit_prototype = (unsigned char*) volk_malloc(d_block_size >> 3, 
volk_get_alignment());
+      memset(d_frozen_bit_prototype, 0, d_block_size >> 3);
+
+      for(unsigned int i = 0; i < d_frozen_bit_positions.size(); i++){
+        int rev_pos = (int) bit_reverse((long) d_frozen_bit_positions.at(i), 
d_block_power);
+        unsigned char frozen_bit = (unsigned char) d_frozen_bit_values.at(i);
+        
insert_unpacked_bit_into_packed_array_at_position(d_frozen_bit_prototype, 
frozen_bit, rev_pos);
+      }
+
+//      print_packed_bit_array(d_frozen_bit_prototype, d_block_size >> 3);
+
+      int num_frozen_bit = 0;
+      for(int i = 0; i < d_block_size; i++){
+        int frozen_pos = d_frozen_bit_positions.at(num_frozen_bit);
+        if(i != frozen_pos){
+          d_info_bit_positions.push_back((int) bit_reverse((long) i, 
d_block_power));
+        }
+        else{
+          num_frozen_bit++;
+          num_frozen_bit = std::min(num_frozen_bit, (int) 
(d_frozen_bit_positions.size() - 1));
+        }
+      }
+      if((int) d_info_bit_positions.size() != d_num_info_bits){
+        throw std::runtime_error("number of info bit positions MUST equal 
num_info_bits (K)!");
+      }
+    }
+
+    polar_encoder::~polar_encoder()
+    {
+      delete d_unpacker;
+      delete d_packer;
+
+      volk_free(d_block_array);
+      volk_free(d_frozen_bit_prototype);
+    }
+
+    void
+    polar_encoder::generic_work(void* in_buffer, void* out_buffer)
+    {
+      const unsigned char *in = (const unsigned char*) in_buffer;
+      unsigned char *out = (unsigned char*) out_buffer;
+
+      if(d_is_packed){
+        insert_packed_frozen_bits_and_reverse(out, in);
+        encode_vector_packed(out);
+      }
+      else{
+        insert_unpacked_frozen_bits_and_reverse(d_block_array, in);
+        encode_vector_packed(d_block_array);
+        d_unpacker->unpack(out, d_block_array, d_block_size >> 3);
+      }
+
+//      insert_frozen_bits(d_block_array, in);
+//      bit_reverse_vector(out, d_block_array);
+//      encode_vector(out);
+    }
+
+    void
+    polar_encoder::encode_vector_packed(unsigned char* target) const
+    {
+      encode_vector_packed_subbyte(target);
+      encode_vector_packed_interbyte(target);
+    }
+
+    void
+    polar_encoder::encode_vector_packed_subbyte(unsigned char* target) const
+    {
+      int num_bytes_per_block = d_block_size >> 3;
+      while(num_bytes_per_block){
+        encode_packed_byte(target);
+        ++target;
+        --num_bytes_per_block;
+      }
+    }
+
+    void
+    polar_encoder::encode_packed_byte(unsigned char* target) const
+    {
+      // this method only produces correct results if d_block_size > 4.
+      // this is assumed to be the case.
+      *target ^= 0xaa & (*target << 1);
+      *target ^= 0xcc & (*target << 2);
+      *target ^= *target << 4;
+    }
+
+    void
+    polar_encoder::encode_vector_packed_interbyte(unsigned char* target) const
+    {
+      int branch_byte_size = 1;
+      unsigned char* pos;
+      int n_branches = d_block_size >> 4;
+      int byte = 0;
+      for(int stage = 3; stage < d_block_power; ++stage){
+        pos = target;
+
+        for(int branch = 0; branch < n_branches; ++branch){
+
+          byte = 0;
+          while(byte < branch_byte_size){
+            *pos ^= *(pos + branch_byte_size);
+            ++pos;
+            ++byte;
+          }
+
+          pos += branch_byte_size;
+        }
+
+        n_branches >>= 1;
+        branch_byte_size <<= 1;
+      }
+    }
+
+    void
+    polar_encoder::insert_unpacked_frozen_bits_and_reverse(unsigned char* 
target,
+                                                           const unsigned 
char* input) const
+    {
+      memcpy(target, d_frozen_bit_prototype, d_block_size >> 3);
+      const int* info_bit_positions_ptr = &d_info_bit_positions[0];
+      const unsigned char* end_input = input + d_num_info_bits;
+      int bit_pos = 7;
+      while(input < end_input){
+        insert_packet_bit_into_packed_array_at_position(target, *input++, 
*info_bit_positions_ptr++, bit_pos);
+      }
+    }
+
+    void
+    polar_encoder::insert_packed_frozen_bits_and_reverse(unsigned char* target,
+                                                         const unsigned char* 
input) const
+    {
+      memcpy(target, d_frozen_bit_prototype, d_block_size >> 3);
+      const int* info_bit_positions_ptr = &d_info_bit_positions[0];
+      int bit_num = 0;
+      unsigned char byte = *input;
+      int bit_pos;
+      while(bit_num < d_num_info_bits){
+        bit_pos = *info_bit_positions_ptr++;
+        insert_packet_bit_into_packed_array_at_position(target, byte, bit_pos, 
bit_num % 8);
+        ++bit_num;
+        if(bit_num % 8 == 0){
+          ++input;
+          byte = *input;
+        }
+      }
+    }
+
+    void
+    polar_encoder::insert_unpacked_bit_into_packed_array_at_position(unsigned 
char* target,
+                                                                     const 
unsigned char bit,
+                                                                     const int 
pos) const
+    {
+      int byte_pos = pos >> 3;
+      int bit_pos = pos & 0x7;
+      *(target + byte_pos) ^= bit << (7 - bit_pos);
+    }
+
+    void
+    polar_encoder::insert_packet_bit_into_packed_array_at_position(unsigned 
char* target,
+                                                                   const 
unsigned char bit,
+                                                                   const int 
target_pos,
+                                                                   const int 
bit_pos) const
+    {
+      insert_unpacked_bit_into_packed_array_at_position(target, (bit >> (7 - 
bit_pos)) & 0x01, target_pos);
+    }
+
+    void
+    polar_encoder::print_packed_bit_array(const unsigned char* printed_array, 
const int num_bytes) const
+    {
+      int num_bits = num_bytes << 3;
+      unsigned char* temp = (unsigned char*) volk_malloc(num_bits, 
volk_get_alignment());
+      d_unpacker->unpack(temp, printed_array, num_bytes);
+
+
+      std::cout << "[";
+      for(int i = 0; i < num_bits; i++){
+        std::cout << (int) *(temp + i) << " ";
+      }
+      std::cout << "]" << std::endl;
+
+      volk_free(temp);
+    }
+
+    void
+    polar_encoder::insert_frozen_bits(unsigned char* target, const unsigned 
char* input)
+    {
+      int frozen_num = 0;
+      int num_frozen_bits = d_block_size - d_num_info_bits;
+      int info_num = 0;
+      for(int i = 0; i < d_block_size; i++){
+        if(frozen_num < num_frozen_bits && 
d_frozen_bit_positions.at(frozen_num) == i){
+          target[i] = d_frozen_bit_values.at(frozen_num);
+          frozen_num++;
+        }
+        else{
+          target[i] = input[info_num];
+          info_num++;
+        }
+      }
+    }
+
+    void
+    polar_encoder::bit_reverse_vector(unsigned char* target, const unsigned 
char* input)
+    {
+      for(int i = 0; i < d_block_size; i++){
+        target[bit_reverse(long(i), d_block_power)] = input[i];
+      }
+    }
+
+    void
+    polar_encoder::encode_vector(unsigned char* target)
+    {
+      for(int stage = 0; stage < d_block_power; stage++){
+        int n_branches = pow(2, stage);
+        int branch_elements = d_block_size / (2 * n_branches);
+        for(int branch = 0; branch < n_branches; branch++){
+          for(int e = 0; e < branch_elements; e++){
+            int pos = branch * branch_elements * 2 + e;
+            target[pos] ^= target[pos + branch_elements];
+          }
+        }
+      }
+    }
+
+    long
+    polar_encoder::bit_reverse(long value, int active_bits) const
+    {
+      long r = 0;
+      for(int i = 0; i < active_bits; i++){
+        r <<= 1;
+        r |= value & 1;
+        value >>= 1;
+      }
+      return r;
+    }
+
+  } /* namespace fec */
+} /* namespace gr */
+
+
diff --git a/gr-fec/python/fec/polar/__init__.py 
b/gr-fec/python/fec/polar/__init__.py
new file mode 100644
index 0000000..497c064
--- /dev/null
+++ b/gr-fec/python/fec/polar/__init__.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+#
+# 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.
+
+# turn this folder into a Python module
diff --git a/gr-fec/python/fec/polar/helper_functions.py 
b/gr-fec/python/fec/polar/helper_functions.py
index 1d82457..ffa4fc1 100644
--- a/gr-fec/python/fec/polar/helper_functions.py
+++ b/gr-fec/python/fec/polar/helper_functions.py
@@ -70,6 +70,29 @@ def pack_byte(bits):
     return res
 
 
+def get_frozen_bit_positions(directory, n, k, p):
+    import glob, os
+    os.chdir(directory)
+    prefix = 'frozen_bit_positions_'
+    prefix_len = len(prefix)
+    for file in glob.glob("*.npy"):
+        if file.find(prefix) < 0:
+            continue
+        filename = file
+        file = file[file.find(prefix) + prefix_len:]
+        file = file[:-4]
+        file = file.split('_')
+        nstr = [x for x in file if x.startswith('n')]
+        kstr = [x for x in file if x.startswith('k')]
+        pstr = [x for x in file if x.startswith('p')]
+        nstr = int(nstr[0][1:])
+        kstr = int(kstr[0][1:])
+        pstr = float(pstr[0][1:])
+        if n == nstr and k == kstr:
+            return np.load(filename)
+    return np.arange(k)
+
+
 def main():
     print 'helper functions'
 
@@ -79,6 +102,11 @@ def main():
     k = n // 2
     eta = 0.3
 
+    # frozen_bit_positions = get_frozen_bit_positions('.', 256, 128, 0.11)
+    # print(frozen_bit_positions)
+
+    print(np.arange(16))
+    print bit_reverse_vector(np.arange(16), 4)
 
 if __name__ == '__main__':
     main()
diff --git a/gr-fec/python/fec/polar/testbed.py 
b/gr-fec/python/fec/polar/testbed.py
index f34f8a6..4ace91e 100755
--- a/gr-fec/python/fec/polar/testbed.py
+++ b/gr-fec/python/fec/polar/testbed.py
@@ -114,7 +114,9 @@ def channel_analysis():
     print(np.min(channel_counter), np.max(channel_counter))
     channel_counter[0] = np.min(channel_counter)
     good_indices = find_good_indices(channel_counter, channel_counter.size // 
2)
-    frozen_bit_positions = np.where(good_indices > 0)
+    info_bit_positions = np.where(good_indices > 0)
+    print(info_bit_positions)
+    frozen_bit_positions = np.delete(np.arange(channel_counter.size), 
info_bit_positions)
     print(frozen_bit_positions)
     np.save('frozen_bit_positions_n256_k128_p0.11.npy', frozen_bit_positions)
     good_indices *= 2000
diff --git a/gr-fec/python/fec/qa_polar_encoder.py 
b/gr-fec/python/fec/qa_polar_encoder.py
new file mode 100644
index 0000000..0362935
--- /dev/null
+++ b/gr-fec/python/fec/qa_polar_encoder.py
@@ -0,0 +1,133 @@
+#!/usr/bin/env python
+#
+# 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, blocks
+import fec_swig as fec
+from _qa_helper import _qa_helper
+import numpy as np
+
+from extended_encoder import extended_encoder
+from extended_decoder import extended_decoder
+from polar.encoder import PolarEncoder
+from polar.helper_functions import get_frozen_bit_positions
+from polar.helper_functions import bit_reverse_vector
+
+
+class test_polar_encoder(gr_unittest.TestCase):
+
+    def setUp(self):
+        self.tb = gr.top_block()
+
+    def tearDown(self):
+        self.tb = None
+
+    def test_001_setup(self):
+        block_size = 16
+        num_info_bits = 8
+        frozen_bit_positions = np.arange(block_size - num_info_bits)
+        frozen_bit_values = np.array([],)
+
+        polar_encoder = fec.polar_encoder.make(block_size, num_info_bits, 
frozen_bit_positions, frozen_bit_values)
+
+        self.assertEqual(block_size, polar_encoder.get_output_size())
+        self.assertEqual(num_info_bits, polar_encoder.get_input_size())
+        self.assertFloatTuplesAlmostEqual((float(num_info_bits) / block_size, 
), (polar_encoder.rate(), ))
+        self.assertFalse(polar_encoder.set_frame_size(10))
+
+    def test_002_work_function(self):
+        block_size = 256
+        num_info_bits = 128
+        num_frozen_bits = block_size - num_info_bits
+        frozen_bit_positions = get_frozen_bit_positions('polar', block_size, 
num_frozen_bits, 0.11)
+        frozen_bit_values = np.array([0] * num_frozen_bits,)
+        python_encoder = PolarEncoder(block_size, num_info_bits, 
frozen_bit_positions, frozen_bit_values)
+
+        is_packed = False
+        polar_encoder = fec.polar_encoder.make(block_size, num_info_bits, 
frozen_bit_positions, frozen_bit_values, is_packed)
+
+        data = np.ones(num_info_bits, dtype=int)
+        src = blocks.vector_source_b(data, False)
+        packer = blocks.pack_k_bits_bb(8)
+        enc_block = extended_encoder(polar_encoder, None, '11')
+        unpacker = blocks.unpack_k_bits_bb(8)
+        snk = blocks.vector_sink_b(1)
+
+        if is_packed:
+            self.tb.connect(src, packer, enc_block, unpacker, snk)
+        else:
+            self.tb.connect(src, enc_block, snk)
+        self.tb.run()
+
+        res = np.array(snk.data()).astype(dtype=int)
+        penc = python_encoder.encode(data)
+
+        print(res)
+        print(penc)
+        self.assertTupleEqual(tuple(res), tuple(penc))
+
+    def test_003_big_input(self):
+        is_packed = False
+        num_blocks = 30
+        block_size = 256
+        num_info_bits = 128
+        num_frozen_bits = block_size - num_info_bits
+        frozen_bit_positions = 
get_frozen_bit_positions('/home/johannes/src/gnuradio-polar/gr-fec/python/fec/polar',
 block_size, num_frozen_bits, 0.11)
+        frozen_bit_values = np.array([0] * num_frozen_bits,)
+        python_encoder = PolarEncoder(block_size, num_info_bits, 
frozen_bit_positions, frozen_bit_values)
+
+        polar_encoder = fec.polar_encoder.make(block_size, num_info_bits, 
frozen_bit_positions, frozen_bit_values, is_packed)
+
+        data = np.array([], dtype=int)
+        ref = np.array([], dtype=int)
+
+        for i in range(num_blocks):
+            d = np.random.randint(2, size=num_info_bits)
+            data = np.append(data, d)
+            ref = np.append(ref, python_encoder.encode(d))
+
+
+        src = blocks.vector_source_b(data, False)
+        packer = blocks.pack_k_bits_bb(8)
+        enc_block = extended_encoder(polar_encoder, None, '11')
+        unpacker = blocks.unpack_k_bits_bb(8)
+        snk = blocks.vector_sink_b(1)
+
+        if is_packed:
+            self.tb.connect(src, packer, enc_block, unpacker, snk)
+        else:
+            self.tb.connect(src, enc_block, snk)
+        self.tb.run()
+
+        res = np.array(snk.data()).astype(dtype=int)
+        # penc = python_encoder.encode(data)
+
+        print(res)
+        print(ref)
+        self.assertTupleEqual(tuple(res), tuple(ref))
+
+
+
+
+
+if __name__ == '__main__':
+    gr_unittest.run(test_polar_encoder)
+
diff --git a/gr-fec/swig/fec_swig.i b/gr-fec/swig/fec_swig.i
index abc78e3..b5735aa 100644
--- a/gr-fec/swig/fec_swig.i
+++ b/gr-fec/swig/fec_swig.i
@@ -62,6 +62,7 @@
 #include "gnuradio/fec/ldpc_decoder.h"
 #include "gnuradio/fec/tpc_encoder.h"
 #include "gnuradio/fec/tpc_decoder.h"
+#include "gnuradio/fec/polar_encoder.h"
 %}
 
 %include "gnuradio/fec/generic_decoder.h"
@@ -104,3 +105,4 @@ GR_SWIG_BLOCK_MAGIC2(fec, conv_bit_corr_bb);
 GR_SWIG_BLOCK_MAGIC2(fec, puncture_bb);
 GR_SWIG_BLOCK_MAGIC2(fec, puncture_ff);
 GR_SWIG_BLOCK_MAGIC2(fec, depuncture_bb);
+%include "gnuradio/fec/polar_encoder.h"



reply via email to

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