diff options
author | Johannes Demel <ufcsy@student.kit.edu> | 2015-07-06 19:22:26 +0200 |
---|---|---|
committer | Johannes Demel <ufcsy@student.kit.edu> | 2015-09-21 10:45:12 +0200 |
commit | 8b486050a7e425e21f069ad6742385d6496c63eb (patch) | |
tree | 5c1c32834d66555b5bcd3ef364132dc34483f3a8 | |
parent | 13592802e792a417b1db511dbb1d0445ff4955c8 (diff) |
polar: Python implementation for channel construction
22 files changed, 3874 insertions, 693 deletions
diff --git a/gr-fec/examples/polar_ber_curve_gen.grc b/gr-fec/examples/polar_ber_curve_gen.grc new file mode 100644 index 0000000000..01fed838c4 --- /dev/null +++ b/gr-fec/examples/polar_ber_curve_gen.grc @@ -0,0 +1,1583 @@ +<?xml version='1.0' encoding='utf-8'?> +<?grc format='1' created='3.7.8'?> +<flow_graph> + <timestamp>Fri Jul 17 15:23:09 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>qt_gui</value> + </param> + <param> + <key>id</key> + <value>polar_ber_curve_gen</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>prompt</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 code BER curve generator</value> + </param> + <param> + <key>window_size</key> + <value>1920,1080</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>(304, 35)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>block_size</value> + </param> + <param> + <key>value</key> + <value>1024</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>k</value> + </param> + <param> + <key>dim1</key> + <value>len(esno)</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>block_size</value> + </param> + <param> + <key>_coordinate</key> + <value>(1368, 395)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>dec_cc</value> + </param> + <param> + <key>value</key> + <value>"ok"</value> + </param> + <param> + <key>ndim</key> + <value>2</value> + </param> + <param> + <key>polys</key> + <value>polys</value> + </param> + <param> + <key>rate</key> + <value>rate</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>k</value> + </param> + <param> + <key>dim1</key> + <value>len(esno)</value> + </param> + <param> + <key>dim2</key> + <value>1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>framebits</key> + <value>block_size</value> + </param> + <param> + <key>_coordinate</key> + <value>(1368, 187)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>enc_cc</value> + </param> + <param> + <key>ndim</key> + <value>2</value> + </param> + <param> + <key>polys</key> + <value>polys</value> + </param> + <param> + <key>rate</key> + <value>rate</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</key> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(704, 19)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>esno</value> + </param> + <param> + <key>value</key> + <value>numpy.arange(-1, 4, 0.5)</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>(1368, 115)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>k</value> + </param> + <param> + <key>value</key> + <value>7</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>(536, 171)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>list_size</value> + </param> + <param> + <key>value</key> + <value>8</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>(424, 35)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>n_info_bits</value> + </param> + <param> + <key>value</key> + <value>block_size / 2</value> + </param> + </block> + <block> + <key>variable_polar_code_configurator</key> + <param> + <key>num_info_bits</key> + <value>n_info_bits</value> + </param> + <param> + <key>block_size</key> + <value>block_size</value> + </param> + <param> + <key>channel</key> + <value>bsc</value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(328, 107)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polar_config</value> + </param> + <param> + <key>design_snr</key> + <value>0.0</value> + </param> + <param> + <key>mu</key> + <value>32</value> + </param> + </block> + <block> + <key>variable_polar_decoder_sc_def</key> + <param> + <key>num_info_bits</key> + <value>n_info_bits</value> + </param> + <param> + <key>block_size</key> + <value>block_size</value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>dim1</key> + <value>len(esno)</value> + </param> + <param> + <key>dim2</key> + <value>1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>frozen_bit_positions</key> + <value>polar_config['positions']</value> + </param> + <param> + <key>frozen_bit_values</key> + <value>polar_config['values']</value> + </param> + <param> + <key>_coordinate</key> + <value>(192, 419)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polar_decoder</value> + </param> + <param> + <key>is_packed</key> + <value>False</value> + </param> + <param> + <key>ndim</key> + <value>2</value> + </param> + </block> + <block> + <key>variable_polar_encoder_def</key> + <param> + <key>num_info_bits</key> + <value>n_info_bits</value> + </param> + <param> + <key>block_size</key> + <value>block_size</value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>dim1</key> + <value>len(esno)</value> + </param> + <param> + <key>dim2</key> + <value>1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>frozen_bit_positions</key> + <value>polar_config['positions']</value> + </param> + <param> + <key>frozen_bit_values</key> + <value>polar_config['values']</value> + </param> + <param> + <key>_coordinate</key> + <value>(192, 251)</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>False</value> + </param> + <param> + <key>ndim</key> + <value>2</value> + </param> + </block> + <block> + <key>variable_polar_encoder_def</key> + <param> + <key>num_info_bits</key> + <value>n_info_bits</value> + </param> + <param> + <key>block_size</key> + <value>block_size</value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>dim1</key> + <value>len(esno)</value> + </param> + <param> + <key>dim2</key> + <value>1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>frozen_bit_positions</key> + <value>polar_config['positions']</value> + </param> + <param> + <key>frozen_bit_values</key> + <value>polar_config['values']</value> + </param> + <param> + <key>_coordinate</key> + <value>(456, 243)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polar_encoder_scld</value> + </param> + <param> + <key>is_packed</key> + <value>False</value> + </param> + <param> + <key>ndim</key> + <value>2</value> + </param> + </block> + <block> + <key>variable_polar_decoder_sc_list_def</key> + <param> + <key>num_info_bits</key> + <value>n_info_bits</value> + </param> + <param> + <key>block_size</key> + <value>block_size</value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>dim1</key> + <value>len(esno)</value> + </param> + <param> + <key>dim2</key> + <value>1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>frozen_bit_positions</key> + <value>polar_config['positions']</value> + </param> + <param> + <key>frozen_bit_values</key> + <value>polar_config['values']</value> + </param> + <param> + <key>_coordinate</key> + <value>(456, 411)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polar_scld</value> + </param> + <param> + <key>max_list_size</key> + <value>list_size</value> + </param> + <param> + <key>is_packed</key> + <value>False</value> + </param> + <param> + <key>ndim</key> + <value>2</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>(1440, 115)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polys</value> + </param> + <param> + <key>value</key> + <value>[79, 109]</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>(1368, 51)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>rate</value> + </param> + <param> + <key>value</key> + <value>2</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>(16, 107)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>value</key> + <value>350e3</value> + </param> + </block> + <block> + <key>fec_bercurve_generator</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_list</key> + <value>polar_decoder</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>encoder_list</key> + <value>polar_encoder</value> + </param> + <param> + <key>esno</key> + <value>esno</value> + </param> + <param> + <key>_coordinate</key> + <value>(808, 123)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polar_curve_gen_sc</value> + </param> + <param> + <key>maxoutbuf</key> + <value>0</value> + </param> + <param> + <key>minoutbuf</key> + <value>0</value> + </param> + <param> + <key>seed</key> + <value>0</value> + </param> + <param> + <key>puncpat</key> + <value>'11'</value> + </param> + <param> + <key>samp_rate</key> + <value>3200000</value> + </param> + <param> + <key>threadtype</key> + <value>"none"</value> + </param> + <bus_source>1</bus_source> + </block> + <block> + <key>fec_bercurve_generator</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_list</key> + <value>polar_scld</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>encoder_list</key> + <value>polar_encoder_scld</value> + </param> + <param> + <key>esno</key> + <value>esno</value> + </param> + <param> + <key>_coordinate</key> + <value>(808, 227)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polar_curve_gen_scld</value> + </param> + <param> + <key>maxoutbuf</key> + <value>0</value> + </param> + <param> + <key>minoutbuf</key> + <value>0</value> + </param> + <param> + <key>seed</key> + <value>0</value> + </param> + <param> + <key>puncpat</key> + <value>'11'</value> + </param> + <param> + <key>samp_rate</key> + <value>3200000</value> + </param> + <param> + <key>threadtype</key> + <value>"none"</value> + </param> + <bus_source>1</bus_source> + </block> + <block> + <key>fec_bercurve_generator</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_list</key> + <value>dec_cc</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>encoder_list</key> + <value>enc_cc</value> + </param> + <param> + <key>esno</key> + <value>esno</value> + </param> + <param> + <key>_coordinate</key> + <value>(808, 331)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polar_curve_gen_scld_0</value> + </param> + <param> + <key>maxoutbuf</key> + <value>0</value> + </param> + <param> + <key>minoutbuf</key> + <value>0</value> + </param> + <param> + <key>seed</key> + <value>0</value> + </param> + <param> + <key>puncpat</key> + <value>'11'</value> + </param> + <param> + <key>samp_rate</key> + <value>3200000</value> + </param> + <param> + <key>threadtype</key> + <value>"capillary"</value> + </param> + <bus_source>1</bus_source> + </block> + <block> + <key>qtgui_bercurve_sink</key> + <param> + <key>berlimit</key> + <value>-7.0</value> + </param> + <param> + <key>alias</key> + <value></value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>affinity</key> + <value></value> + </param> + <param> + <key>curvenames</key> + <value>['POLAR decoder', 'POLAR decoder list', 'CC']</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(1176, 146)</value> + </param> + <param> + <key>gui_hint</key> + <value></value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>qtgui_bercurve_sink_0</value> + </param> + <param> + <key>alpha1</key> + <value>1.0</value> + </param> + <param> + <key>color1</key> + <value>"blue"</value> + </param> + <param> + <key>label1</key> + <value>POLAR decoder</value> + </param> + <param> + <key>marker1</key> + <value>0</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>0</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>POLAR list decoder</value> + </param> + <param> + <key>marker2</key> + <value>0</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>CC convolutional</value> + </param> + <param> + <key>marker3</key> + <value>0</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>0</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>0</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>0</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>0</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>0</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>0</value> + </param> + <param> + <key>style9</key> + <value>1</value> + </param> + <param> + <key>width9</key> + <value>1</value> + </param> + <param> + <key>berminerrors</key> + <value>100</value> + </param> + <param> + <key>num_curves</key> + <value>3</value> + </param> + <param> + <key>update_time</key> + <value>0.10</value> + </param> + <param> + <key>ymax</key> + <value>0</value> + </param> + <param> + <key>ymin</key> + <value>-10</value> + </param> + <param> + <key>esno</key> + <value>esno</value> + </param> + <bus_sink>1</bus_sink> + </block> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>20</source_key> + <sink_key>60</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>1</source_key> + <sink_key>1</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>10</source_key> + <sink_key>10</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>11</source_key> + <sink_key>11</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>12</source_key> + <sink_key>12</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>13</source_key> + <sink_key>13</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>14</source_key> + <sink_key>14</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>15</source_key> + <sink_key>15</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>16</source_key> + <sink_key>16</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>17</source_key> + <sink_key>17</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>18</source_key> + <sink_key>18</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>19</source_key> + <sink_key>19</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>2</source_key> + <sink_key>2</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>3</source_key> + <sink_key>3</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>4</source_key> + <sink_key>4</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>5</source_key> + <sink_key>5</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>6</source_key> + <sink_key>6</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>7</source_key> + <sink_key>7</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>8</source_key> + <sink_key>8</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_sc</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>9</source_key> + <sink_key>9</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>20</source_key> + <sink_key>61</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>0</source_key> + <sink_key>20</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>1</source_key> + <sink_key>21</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>10</source_key> + <sink_key>30</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>11</source_key> + <sink_key>31</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>12</source_key> + <sink_key>32</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>13</source_key> + <sink_key>33</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>14</source_key> + <sink_key>34</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>15</source_key> + <sink_key>35</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>16</source_key> + <sink_key>36</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>17</source_key> + <sink_key>37</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>18</source_key> + <sink_key>38</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>19</source_key> + <sink_key>39</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>2</source_key> + <sink_key>22</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>3</source_key> + <sink_key>23</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>4</source_key> + <sink_key>24</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>5</source_key> + <sink_key>25</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>6</source_key> + <sink_key>26</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>7</source_key> + <sink_key>27</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>8</source_key> + <sink_key>28</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>9</source_key> + <sink_key>29</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>20</source_key> + <sink_key>62</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>0</source_key> + <sink_key>40</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>1</source_key> + <sink_key>41</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>10</source_key> + <sink_key>50</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>11</source_key> + <sink_key>51</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>12</source_key> + <sink_key>52</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>13</source_key> + <sink_key>53</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>14</source_key> + <sink_key>54</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>15</source_key> + <sink_key>55</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>16</source_key> + <sink_key>56</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>17</source_key> + <sink_key>57</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>18</source_key> + <sink_key>58</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>19</source_key> + <sink_key>59</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>2</source_key> + <sink_key>42</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>3</source_key> + <sink_key>43</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>4</source_key> + <sink_key>44</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>5</source_key> + <sink_key>45</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>6</source_key> + <sink_key>46</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>7</source_key> + <sink_key>47</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>8</source_key> + <sink_key>48</sink_key> + </connection> + <connection> + <source_block_id>polar_curve_gen_scld_0</source_block_id> + <sink_block_id>qtgui_bercurve_sink_0</sink_block_id> + <source_key>9</source_key> + <sink_key>49</sink_key> + </connection> +</flow_graph> diff --git a/gr-fec/examples/polar_code_example.grc b/gr-fec/examples/polar_code_example.grc new file mode 100644 index 0000000000..729e8fe873 --- /dev/null +++ b/gr-fec/examples/polar_code_example.grc @@ -0,0 +1,1378 @@ +<?xml version='1.0' encoding='utf-8'?> +<?grc format='1' created='3.7.8'?> +<flow_graph> + <timestamp>Thu Jul 16 16:19:12 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>qt_gui</value> + </param> + <param> + <key>id</key> + <value>polar_code_example</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>prompt</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 code example flowgraph</value> + </param> + <param> + <key>window_size</key> + <value>1280, 1024</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>(440, 11)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>block_size</value> + </param> + <param> + <key>value</key> + <value>1024</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>(560, 11)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>n_info_bits</value> + </param> + <param> + <key>value</key> + <value>block_size / 2</value> + </param> + </block> + <block> + <key>variable_polar_code_configurator</key> + <param> + <key>num_info_bits</key> + <value>n_info_bits</value> + </param> + <param> + <key>block_size</key> + <value>block_size</value> + </param> + <param> + <key>channel</key> + <value>bsc</value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(456, 75)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polar_config</value> + </param> + <param> + <key>design_snr</key> + <value>0.0</value> + </param> + <param> + <key>mu</key> + <value>32</value> + </param> + </block> + <block> + <key>variable_polar_decoder_sc_def</key> + <param> + <key>num_info_bits</key> + <value>n_info_bits</value> + </param> + <param> + <key>block_size</key> + <value>block_size</value> + </param> + <param> + <key>comment</key> + <value></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>frozen_bit_positions</key> + <value>polar_config['positions']</value> + </param> + <param> + <key>frozen_bit_values</key> + <value>polar_config['values']</value> + </param> + <param> + <key>_coordinate</key> + <value>(640, 203)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polar_decoder</value> + </param> + <param> + <key>is_packed</key> + <value>False</value> + </param> + <param> + <key>ndim</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_polar_encoder_def</key> + <param> + <key>num_info_bits</key> + <value>n_info_bits</value> + </param> + <param> + <key>block_size</key> + <value>block_size</value> + </param> + <param> + <key>comment</key> + <value></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>frozen_bit_positions</key> + <value>polar_config['positions']</value> + </param> + <param> + <key>frozen_bit_values</key> + <value>polar_config['values']</value> + </param> + <param> + <key>_coordinate</key> + <value>(256, 203)</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>False</value> + </param> + <param> + <key>ndim</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_polar_decoder_sc_list_def</key> + <param> + <key>num_info_bits</key> + <value>n_info_bits</value> + </param> + <param> + <key>block_size</key> + <value>block_size</value> + </param> + <param> + <key>comment</key> + <value></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>frozen_bit_positions</key> + <value>polar_config['positions']</value> + </param> + <param> + <key>frozen_bit_values</key> + <value>polar_config['values']</value> + </param> + <param> + <key>_coordinate</key> + <value>(424, 203)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polar_scld</value> + </param> + <param> + <key>max_list_size</key> + <value>8</value> + </param> + <param> + <key>is_packed</key> + <value>False</value> + </param> + <param> + <key>ndim</key> + <value>0</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>(8, 107)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>value</key> + <value>350e3</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>(40, 467)</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 +1</value> + </param> + <param> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>repeat</key> + <value>True</value> + </param> + </block> + <block> + <key>blocks_add_const_vxx</key> + <param> + <key>alias</key> + <value></value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>const</key> + <value>1.0</value> + </param> + <param> + <key>affinity</key> + <value></value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(616, 491)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>blocks_add_const_vxx_0</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>maxoutbuf</key> + <value>0</value> + </param> + <param> + <key>minoutbuf</key> + <value>0</value> + </param> + <param> + <key>vlen</key> + <value>1</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>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(976, 491)</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>1.0</value> + </param> + <param> + <key>vlen</key> + <value>1</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>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(480, 491)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>blocks_char_to_float_0_0</value> + </param> + <param> + <key>maxoutbuf</key> + <value>0</value> + </param> + <param> + <key>minoutbuf</key> + <value>0</value> + </param> + <param> + <key>scale</key> + <value>-0.5</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + </block> + <block> + <key>fec_ber_bf</key> + <param> + <key>berlimit</key> + <value>-7.0</value> + </param> + <param> + <key>berminerrors</key> + <value>100</value> + </param> + <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>(728, 360)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>fec_ber_bf_0</value> + </param> + <param> + <key>maxoutbuf</key> + <value>0</value> + </param> + <param> + <key>minoutbuf</key> + <value>0</value> + </param> + <param> + <key>test_mode</key> + <value>False</value> + </param> + </block> + <block> + <key>fec_extended_decoder</key> + <param> + <key>ann</key> + <value>None</value> + </param> + <param> + <key>alias</key> + <value></value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>affinity</key> + <value></value> + </param> + <param> + <key>decoder_list</key> + <value>polar_scld</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(736, 467)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>fec_extended_decoder_0</value> + </param> + <param> + <key>maxoutbuf</key> + <value>0</value> + </param> + <param> + <key>minoutbuf</key> + <value>0</value> + </param> + <param> + <key>puncpat</key> + <value>'11'</value> + </param> + <param> + <key>threadtype</key> + <value>none</value> + </param> + <param> + <key>value</key> + <value>fec_extended_decoder</value> + </param> + </block> + <block> + <key>fec_extended_encoder</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>encoder_list</key> + <value>polar_encoder</value> + </param> + <param> + <key>_coordinate</key> + <value>(224, 475)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>fec_extended_encoder_0</value> + </param> + <param> + <key>maxoutbuf</key> + <value>0</value> + </param> + <param> + <key>minoutbuf</key> + <value>0</value> + </param> + <param> + <key>puncpat</key> + <value>'11'</value> + </param> + <param> + <key>threadtype</key> + <value>none</value> + </param> + </block> + <block> + <key>qtgui_number_sink</key> + <param> + <key>autoscale</key> + <value>False</value> + </param> + <param> + <key>avg</key> + <value>0</value> + </param> + <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>(1008, 355)</value> + </param> + <param> + <key>gui_hint</key> + <value></value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>graph_type</key> + <value>qtgui.NUM_GRAPH_HORIZ</value> + </param> + <param> + <key>id</key> + <value>qtgui_number_sink_0</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>color1</key> + <value>("black", "black")</value> + </param> + <param> + <key>factor1</key> + <value>1</value> + </param> + <param> + <key>label1</key> + <value></value> + </param> + <param> + <key>unit1</key> + <value></value> + </param> + <param> + <key>color10</key> + <value>("black", "black")</value> + </param> + <param> + <key>factor10</key> + <value>1</value> + </param> + <param> + <key>label10</key> + <value></value> + </param> + <param> + <key>unit10</key> + <value></value> + </param> + <param> + <key>color2</key> + <value>("black", "black")</value> + </param> + <param> + <key>factor2</key> + <value>1</value> + </param> + <param> + <key>label2</key> + <value></value> + </param> + <param> + <key>unit2</key> + <value></value> + </param> + <param> + <key>color3</key> + <value>("black", "black")</value> + </param> + <param> + <key>factor3</key> + <value>1</value> + </param> + <param> + <key>label3</key> + <value></value> + </param> + <param> + <key>unit3</key> + <value></value> + </param> + <param> + <key>color4</key> + <value>("black", "black")</value> + </param> + <param> + <key>factor4</key> + <value>1</value> + </param> + <param> + <key>label4</key> + <value></value> + </param> + <param> + <key>unit4</key> + <value></value> + </param> + <param> + <key>color5</key> + <value>("black", "black")</value> + </param> + <param> + <key>factor5</key> + <value>1</value> + </param> + <param> + <key>label5</key> + <value></value> + </param> + <param> + <key>unit5</key> + <value></value> + </param> + <param> + <key>color6</key> + <value>("black", "black")</value> + </param> + <param> + <key>factor6</key> + <value>1</value> + </param> + <param> + <key>label6</key> + <value></value> + </param> + <param> + <key>unit6</key> + <value></value> + </param> + <param> + <key>color7</key> + <value>("black", "black")</value> + </param> + <param> + <key>factor7</key> + <value>1</value> + </param> + <param> + <key>label7</key> + <value></value> + </param> + <param> + <key>unit7</key> + <value></value> + </param> + <param> + <key>color8</key> + <value>("black", "black")</value> + </param> + <param> + <key>factor8</key> + <value>1</value> + </param> + <param> + <key>label8</key> + <value></value> + </param> + <param> + <key>unit8</key> + <value></value> + </param> + <param> + <key>color9</key> + <value>("black", "black")</value> + </param> + <param> + <key>factor9</key> + <value>1</value> + </param> + <param> + <key>label9</key> + <value></value> + </param> + <param> + <key>unit9</key> + <value></value> + </param> + <param> + <key>max</key> + <value>1</value> + </param> + <param> + <key>min</key> + <value>-1</value> + </param> + <param> + <key>name</key> + <value>""</value> + </param> + <param> + <key>nconnections</key> + <value>1</value> + </param> + <param> + <key>update_time</key> + <value>0.10</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>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(1112, 475)</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>fec_ber_bf_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>analog_random_source_x_0</source_block_id> + <sink_block_id>fec_extended_encoder_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_add_const_vxx_0</source_block_id> + <sink_block_id>fec_extended_decoder_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_char_to_float_0_0</source_block_id> + <sink_block_id>blocks_add_const_vxx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>fec_ber_bf_0</source_block_id> + <sink_block_id>qtgui_number_sink_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>fec_extended_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_extended_decoder_0</source_block_id> + <sink_block_id>fec_ber_bf_0</sink_block_id> + <source_key>0</source_key> + <sink_key>1</sink_key> + </connection> + <connection> + <source_block_id>fec_extended_encoder_0</source_block_id> + <sink_block_id>blocks_char_to_float_0_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-fec/examples/polar_encoder_decoder_chain.grc b/gr-fec/examples/polar_encoder_decoder_chain.grc index 7cab62d291..69fb68bcfe 100644 --- a/gr-fec/examples/polar_encoder_decoder_chain.grc +++ b/gr-fec/examples/polar_encoder_decoder_chain.grc @@ -1,4 +1,4 @@ -<?xml version='1.0' encoding='ASCII'?> +<?xml version='1.0' encoding='utf-8'?> <?grc format='1' created='3.7.8'?> <flow_graph> <timestamp>Mon Jun 15 10:51:02 2015</timestamp> @@ -48,7 +48,7 @@ </param> <param> <key>generate_options</key> - <value>no_gui</value> + <value>qt_gui</value> </param> <param> <key>id</key> @@ -111,6 +111,49 @@ </param> </block> <block> + <key>variable_polar_code_configurator</key> + <param> + <key>num_info_bits</key> + <value>128</value> + </param> + <param> + <key>block_size</key> + <value>256</value> + </param> + <param> + <key>channel</key> + <value>bsc</value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(600, 139)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>polar_config</value> + </param> + <param> + <key>design_snr</key> + <value>2.0</value> + </param> + <param> + <key>mu</key> + <value>16</value> + </param> + </block> + <block> <key>variable_polar_decoder_sc_def</key> <param> <key>num_info_bits</key> @@ -125,6 +168,14 @@ <value></value> </param> <param> + <key>dim1</key> + <value>1</value> + </param> + <param> + <key>dim2</key> + <value>4</value> + </param> + <param> <key>_enabled</key> <value>True</value> </param> @@ -152,6 +203,10 @@ <key>is_packed</key> <value>False</value> </param> + <param> + <key>ndim</key> + <value>0</value> + </param> </block> <block> <key>variable_polar_encoder_def</key> @@ -168,6 +223,14 @@ <value></value> </param> <param> + <key>dim1</key> + <value>1</value> + </param> + <param> + <key>dim2</key> + <value>4</value> + </param> + <param> <key>_enabled</key> <value>True</value> </param> @@ -195,6 +258,10 @@ <key>is_packed</key> <value>True</value> </param> + <param> + <key>ndim</key> + <value>0</value> + </param> </block> <block> <key>variable_polar_decoder_sc_list_def</key> @@ -211,16 +278,24 @@ <value></value> </param> <param> + <key>dim1</key> + <value>1</value> + </param> + <param> + <key>dim2</key> + <value>4</value> + </param> + <param> <key>_enabled</key> <value>True</value> </param> <param> <key>frozen_bit_positions</key> - <value>range(128)</value> + <value>polar_config['positions']</value> </param> <param> <key>frozen_bit_values</key> - <value>[0,] * 128</value> + <value>polar_config['values']</value> </param> <param> <key>_coordinate</key> @@ -242,6 +317,10 @@ <key>is_packed</key> <value>False</value> </param> + <param> + <key>ndim</key> + <value>0</value> + </param> </block> <block> <key>analog_random_source_x</key> diff --git a/gr-fec/grc/fec_block_tree.xml b/gr-fec/grc/fec_block_tree.xml index d15ef26b63..65a4fc8a14 100644 --- a/gr-fec/grc/fec_block_tree.xml +++ b/gr-fec/grc/fec_block_tree.xml @@ -45,5 +45,6 @@ <block>fec_depuncture_bb</block> <block>fec_ber_bf</block> <block>fec_bercurve_generator</block> + <block>variable_polar_code_configurator</block> </cat> </cat> diff --git a/gr-fec/grc/fec_polar_decoder_sc.xml b/gr-fec/grc/fec_polar_decoder_sc.xml index e7cb1eaa48..8b04c3d6ec 100644 --- a/gr-fec/grc/fec_polar_decoder_sc.xml +++ b/gr-fec/grc/fec_polar_decoder_sc.xml @@ -3,9 +3,13 @@ <name>POLAR Decoder SC Definition</name> <key>variable_polar_decoder_sc_def</key> <import>from gnuradio import fec</import> - <var_make> -self.$(id) = $(id) = fec.polar_decoder_sc.make($block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed) - </var_make> + <var_make>#if int($ndim())==0 # +self.$(id) = $(id) = fec.polar_decoder_sc.make($block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed) #slurp +#else if int($ndim())==1 # +self.$(id) = $(id) = map((lambda a: fec.polar_decoder_sc.make($block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed)), range(0, $dim1) ) #slurp +#else +self.$(id) = $(id) = map((lambda b: map((lambda a: fec.polar_decoder_sc.make($block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed)), range(0, $dim2))), range(0, $dim1)) #slurp +#end if</var_make> <var_value>fec.polar_decoder_sc.make($block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed)</var_value> <make></make> @@ -25,6 +29,41 @@ self.$(id) = $(id) = fec.polar_decoder_sc.make($block_size, $num_info_bits, $fro </param> <param> + <name>Parallelism</name> + <key>ndim</key> + <value>0</value> + <type>enum</type> + <option> + <name>0</name> + <key>0</key> + </option> + <option> + <name>1</name> + <key>1</key> + </option> + <option> + <name>2</name> + <key>2</key> + </option> + </param> + + <param> + <name>Dimension 1</name> + <key>dim1</key> + <value>1</value> + <type>int</type> + <hide>#if (int($ndim()) >= 1) then 'none' else 'all' #</hide> + </param> + + <param> + <name>Dimension 2</name> + <key>dim2</key> + <value>4</value> + <type>int</type> + <hide>#if (int($ndim()) >= 2) then 'none' else 'all' #</hide> + </param> + + <param> <name>Block size (N)</name> <key>block_size</key> <type>int</type> diff --git a/gr-fec/grc/fec_polar_decoder_sc_list.xml b/gr-fec/grc/fec_polar_decoder_sc_list.xml index fa8208f141..f178664c83 100644 --- a/gr-fec/grc/fec_polar_decoder_sc_list.xml +++ b/gr-fec/grc/fec_polar_decoder_sc_list.xml @@ -3,13 +3,16 @@ <name>POLAR Decoder SC List Definition</name> <key>variable_polar_decoder_sc_list_def</key> <import>from gnuradio import fec</import> - <var_make> -self.$(id) = $(id) = fec.polar_decoder_sc_list.make($max_list_size, $block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed) - </var_make> + <var_make>#if int($ndim())==0 # +self.$(id) = $(id) = fec.polar_decoder_sc_list.make($max_list_size, $block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed) #slurp +#else if int($ndim())==1 # +self.$(id) = $(id) = map((lambda a: fec.polar_decoder_sc_list.make($max_list_size, $block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed)), range(0, $dim1)) #slurp +#else +self.$(id) = $(id) = map((lambda b: map((lambda a: fec.polar_decoder_sc_list.make($max_list_size, $block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed)), range(0, $dim2))), range(0, $dim1)) #slurp +#end if</var_make> <var_value>fec.polar_decoder_sc_list.make($max_list_size, $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> @@ -26,6 +29,41 @@ self.$(id) = $(id) = fec.polar_decoder_sc_list.make($max_list_size, $block_size, </param> <param> + <name>Parallelism</name> + <key>ndim</key> + <value>0</value> + <type>enum</type> + <option> + <name>0</name> + <key>0</key> + </option> + <option> + <name>1</name> + <key>1</key> + </option> + <option> + <name>2</name> + <key>2</key> + </option> + </param> + + <param> + <name>Dimension 1</name> + <key>dim1</key> + <value>1</value> + <type>int</type> + <hide>#if (int($ndim()) >= 1) then 'none' else 'all' #</hide> + </param> + + <param> + <name>Dimension 2</name> + <key>dim2</key> + <value>4</value> + <type>int</type> + <hide>#if (int($ndim()) >= 2) then 'none' else 'all' #</hide> + </param> + + <param> <name>Maximum List Size (L)</name> <key>max_list_size</key> <type>int</type> diff --git a/gr-fec/grc/fec_polar_encoder.xml b/gr-fec/grc/fec_polar_encoder.xml index 14f1b88c4a..4147cf1edf 100644 --- a/gr-fec/grc/fec_polar_encoder.xml +++ b/gr-fec/grc/fec_polar_encoder.xml @@ -3,9 +3,13 @@ <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_make>#if int($ndim())==0 # +self.$(id) = $(id) = fec.polar_encoder.make($block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed) #slurp +#else if int($ndim())==1 # +self.$(id) = $(id) = map((lambda a: fec.polar_encoder.make($block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed)), range(0, $dim1)) #slurp +#else +self.$(id) = $(id) = map((lambda b: map((lambda a: fec.polar_encoder.make($block_size, $num_info_bits, $frozen_bit_positions, $frozen_bit_values, $is_packed)), range(0, $dim2))), range(0, $dim1)) #slurp +#end if</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> @@ -25,6 +29,41 @@ self.$(id) = $(id) = fec.polar_encoder.make($block_size, $num_info_bits, $frozen </param> <param> + <name>Parallelism</name> + <key>ndim</key> + <value>0</value> + <type>enum</type> + <option> + <name>0</name> + <key>0</key> + </option> + <option> + <name>1</name> + <key>1</key> + </option> + <option> + <name>2</name> + <key>2</key> + </option> + </param> + + <param> + <name>Dimension 1</name> + <key>dim1</key> + <value>1</value> + <type>int</type> + <hide>#if (int($ndim()) >= 1) then 'none' else 'all' #</hide> + </param> + + <param> + <name>Dimension 2</name> + <key>dim2</key> + <value>4</value> + <type>int</type> + <hide>#if (int($ndim()) >= 2) then 'none' else 'all' #</hide> + </param> + + <param> <name>Block size (N)</name> <key>block_size</key> <type>int</type> diff --git a/gr-fec/grc/polar_code_configurator.xml b/gr-fec/grc/polar_code_configurator.xml new file mode 100644 index 0000000000..cfde368b1d --- /dev/null +++ b/gr-fec/grc/polar_code_configurator.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?> +<block> + <name>POLAR code Configurator</name> + <key>variable_polar_code_configurator</key> + <import>from gnuradio.fec import polar</import> + <var_make>self.$(id) = $(id) = polar.load_frozen_bits_info(False, $channel.c, $block_size, $num_info_bits, $design_snr, $mu)</var_make> + <var_value>polar.load_frozen_bits_info(True, $channel.c, $block_size, $num_info_bits, $design_snr, $mu)</var_value> + <make></make> + + <param> + <name>Channel</name> + <key>channel</key> + <type>enum</type> + <option> + <name>BEC</name> + <key>bec</key> + <opt>c:'BEC'</opt> + <opt>h:True</opt> + </option> + <option> + <name>BSC</name> + <key>bsc</key> + <opt>c:'BSC'</opt> + <opt>h:False</opt> + </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>design SNR</name> + <key>design_snr</key> + <value>0.0</value> + <type>float</type> + </param> + + <param> + <name>mu</name> + <key>mu</key> + <value>16</value> + <type>int</type> + <hide>#if str($channel.h) == 'True' then 'all' else 'none'#</hide> + </param> +</block>
\ No newline at end of file diff --git a/gr-fec/include/gnuradio/fec/polar_decoder_sc.h b/gr-fec/include/gnuradio/fec/polar_decoder_sc.h index d9aa959fb9..e9fa6a244d 100644 --- a/gr-fec/include/gnuradio/fec/polar_decoder_sc.h +++ b/gr-fec/include/gnuradio/fec/polar_decoder_sc.h @@ -33,8 +33,8 @@ namespace gr { /*! * \brief Standard successive cancellation decoder for POLAR codes - * It expects float input with bits mapped 1 --> -1, 0 --> 1 - * Or: f = 1.0 - 2.0 * bit + * It expects float input with bits mapped 1 --> 1, 0 --> -1 + * Or: f = 2.0 * bit - 1.0 * */ class FEC_API polar_decoder_sc : public polar_decoder_common diff --git a/gr-fec/lib/polar_decoder_common.cc b/gr-fec/lib/polar_decoder_common.cc index 028564101f..bcb70fc0f2 100644 --- a/gr-fec/lib/polar_decoder_common.cc +++ b/gr-fec/lib/polar_decoder_common.cc @@ -39,7 +39,7 @@ namespace gr { std::vector<int> frozen_bit_positions, std::vector<char> frozen_bit_values, bool is_packed) : polar_common(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values, is_packed), - D_LLR_FACTOR(2.19722458f), + D_LLR_FACTOR(-2.19722458f), d_frozen_bit_positions(frozen_bit_positions), d_frozen_bit_values(frozen_bit_values) { diff --git a/gr-fec/python/fec/CMakeLists.txt b/gr-fec/python/fec/CMakeLists.txt index 032816866d..d5bebd7638 100644 --- a/gr-fec/python/fec/CMakeLists.txt +++ b/gr-fec/python/fec/CMakeLists.txt @@ -39,6 +39,8 @@ GR_PYTHON_INSTALL( COMPONENT "fec_python" ) +add_subdirectory(polar) + ######################################################################## # Handle the unit tests ######################################################################## diff --git a/gr-fec/python/fec/polar/CMakeLists.txt b/gr-fec/python/fec/polar/CMakeLists.txt new file mode 100644 index 0000000000..1362ce18bb --- /dev/null +++ b/gr-fec/python/fec/polar/CMakeLists.txt @@ -0,0 +1,41 @@ +# 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. + +######################################################################## +include(GrPython) + +GR_PYTHON_INSTALL( + FILES + __init__.py + channel_construction.py + channel_construction_bsc.py + channel_construction_bec.py + helper_functions.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/fec/polar + COMPONENT "fec_python" +) + +GR_PYTHON_INSTALL( + PROGRAMS + polar_channel_construction + DESTINATION ${GR_RUNTIME_DIR} + COMPONENT "fec_python" +) + + diff --git a/gr-fec/python/fec/polar/__init__.py b/gr-fec/python/fec/polar/__init__.py index 497c064995..4a9cc75667 100644 --- a/gr-fec/python/fec/polar/__init__.py +++ b/gr-fec/python/fec/polar/__init__.py @@ -20,3 +20,42 @@ # Boston, MA 02110-1301, USA. # turn this folder into a Python module + +import channel_construction as cc +from channel_construction_bec import bhattacharyya_bounds +from helper_functions import is_power_of_two + + +def get_z_params(is_prototype, channel, block_size, design_snr, mu): + print('POLAR code channel construction called with parameters channel={0}, blocksize={1}, design SNR={2}, mu={3}'.format(channel, block_size, design_snr, mu)) + if not (channel == 'BSC' or channel == 'BEC'): + raise ValueError("channel is {0}, but only BEC and BSC are supported!".format(channel)) + if not is_power_of_two(block_size): + raise ValueError("block size={0} is not a power of 2!".format(block_size)) + if design_snr < -1.5917: + raise ValueError("design SNR={0} < -1.5917. MUST be greater!".format(design_snr)) + if not mu > 0: + raise ValueError("mu={0} < 1. MUST be > 1!".format(mu)) + if not is_prototype and channel == 'BSC': + z_params = cc.load_z_parameters(block_size, design_snr, mu) + print('Read Z-parameter file: {0}'.format(cc.default_dir() + cc.generate_filename(block_size, design_snr, mu))) + return z_params + return bhattacharyya_bounds(design_snr, block_size) + + +def load_frozen_bits_info(is_prototype, channel, block_size, num_info_bits, design_snr, mu): + num_frozen_bits = block_size - num_info_bits + if not mu > 0: + mu = 2 + z_params = get_z_params(is_prototype, channel, block_size, design_snr, mu) + data_set = { + 'positions': cc.get_frozen_bit_indices_from_z_parameters(z_params, num_frozen_bits), + 'values': [0, ] * num_frozen_bits, + 'block_size': block_size, + 'num_info_bits': num_info_bits, + 'num_frozenbits': num_frozen_bits, + 'design_snr': design_snr, + 'channel': channel, + 'mu': mu, + } + return data_set diff --git a/gr-fec/python/fec/polar/channel_construction.py b/gr-fec/python/fec/polar/channel_construction.py new file mode 100644 index 0000000000..f971ce4f61 --- /dev/null +++ b/gr-fec/python/fec/polar/channel_construction.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python +# +# Copyright 2015 Free Software Foundation, Inc. +# +# 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. +# + +''' +[0] Erdal Arikan: 'Channel Polarization: A Method for Constructing Capacity-Achieving Codes for Symmetric Binary-Input Memoryless Channels', 2009 +foundational paper for polar codes. +''' + + +import numpy as np +from channel_construction_bec import calculate_bec_channel_capacities +from channel_construction_bec import design_snr_to_bec_eta +from channel_construction_bsc import tal_vardy_tpm_algorithm +import matplotlib.pyplot as plt + + +Z_PARAM_FIRST_HEADER_LINE = "Bhattacharyya parameters (Z-parameters) for a polar code" + + +def get_frozen_bit_indices_from_capacities(chan_caps, nfrozen): + indexes = np.array([], dtype=int) + while indexes.size < nfrozen: + index = np.argmin(chan_caps) + indexes = np.append(indexes, index) + chan_caps[index] = 1.0 + return np.sort(indexes) + + +def get_frozen_bit_indices_from_z_parameters(z_params, nfrozen): + indexes = np.array([], dtype=int) + while indexes.size < nfrozen: + index = np.argmax(z_params) + indexes = np.append(indexes, index) + z_params[index] = 0.0 + return np.sort(indexes) + + +def get_bec_frozen_indices(nblock, kfrozen, eta): + bec_caps = calculate_bec_channel_capacities(eta, nblock) + positions = get_frozen_bit_indices_from_capacities(bec_caps, kfrozen) + return positions + + +def frozen_bit_positions(block_size, info_size, design_snr=0.0): + if not design_snr > -1.5917: + print('bad value for design_nsr, must be > -1.5917! default=0.0') + design_snr = 0.0 + eta = design_snr_to_bec_eta(design_snr) + return get_bec_frozen_indices(block_size, block_size - info_size, eta) + + +def generate_filename(block_size, design_snr, mu): + filename = "polar_code_z_parameters_N" + str(int(block_size)) + filename += "_SNR" + str(float(design_snr)) + "_MU" + str(int(mu)) + ".polar" + return filename + + +def default_dir(): + dir_def = "~/.gnuradio/polar/" + import os + path = os.path.expanduser(dir_def) + + try: + os.makedirs(path) + except OSError: + if not os.path.isdir(path): + raise + return path + + +def save_z_parameters(z_params, block_size, design_snr, mu): + path = default_dir() + filename = generate_filename(block_size, design_snr, mu) + header = Z_PARAM_FIRST_HEADER_LINE + "\n" + header += "Channel construction method: Tal-Vardy algorithm\n" + header += "Parameters:\n" + header += "block_size=" + str(block_size) + "\n" + header += "design_snr=" + str(design_snr) + "\n" + header += "mu=" + str(mu) + np.savetxt(path + filename, z_params, header=header) + + +def load_z_parameters(block_size, design_snr, mu): + path = default_dir() + filename = generate_filename(block_size, design_snr, mu) + full_file = path + filename + import os + if not os.path.isfile(full_file): + z_params = tal_vardy_tpm_algorithm(block_size, design_snr, mu) + save_z_parameters(z_params, block_size, design_snr, mu) + z_params = np.loadtxt(full_file) + return z_params + + +def main(): + print 'channel construction Bhattacharyya bounds by Arikan' + n = 8 + m = 2 ** n + k = m // 2 + design_snr = -1.59 + mu = 32 + + # ztv = tal_vardy_tpm_algorithm(m, design_snr, mu) + + z_params = load_z_parameters(m, design_snr, mu) + plt.plot(z_params) + plt.show() + + + +if __name__ == '__main__': + main() + + diff --git a/gr-fec/python/fec/polar/channel_construction_bec.py b/gr-fec/python/fec/polar/channel_construction_bec.py index 4d3654d010..341b290057 100644 --- a/gr-fec/python/fec/polar/channel_construction_bec.py +++ b/gr-fec/python/fec/polar/channel_construction_bec.py @@ -19,24 +19,7 @@ # import numpy as np -import matplotlib.pyplot as plt - -def bsc_channel(p): - ''' - binary symmetric channel (BSC) - output alphabet Y = {0, 1} and - W(0|0) = W(1|1) and W(1|0) = W(0|1) - - this function returns a prob's vector for a BSC - p denotes an erroneous transistion - ''' - if not (p >= 0.0 and p <= 1.0): - print "given p is out of range!" - return np.array([], dtype=float) - - # 0 -> 0, 0 -> 1, 1 -> 0, 1 -> 1 - W = np.array([[1 - p, p], [p, 1 - p]], dtype=float) - return W +import helper_functions as hf def bec_channel(eta): @@ -51,7 +34,6 @@ def bec_channel(eta): W = np.array((1 - eta, eta, 1 - eta), dtype=float) return W - def odd_rec(iwn): return iwn ** 2 @@ -69,48 +51,64 @@ def calc_one_recursion(iw0): return iw1 -def calculate_bec_channel_capacities(eta, n): +def calculate_bec_channel_capacities(eta, block_size): + # compare [0, Arikan] eq. 6 iw = 1 - eta # holds for BEC as stated in paper iw = np.array([iw, ], dtype=float) - lw = int(np.log2(n)) + lw = int(np.log2(block_size)) for i in range(lw): iw = calc_one_recursion(iw) return iw -def get_frozen_bit_indices_from_capacities(chan_caps, nfrozen): - indexes = np.array([], dtype=int) - while indexes.size < nfrozen: - index = np.argmin(chan_caps) - indexes = np.append(indexes, index) - chan_caps[index] = 1.0 - return np.sort(indexes) +def calculate_z_parameters_one_recursion(z_params): + z_next = np.zeros(2 * z_params.size) + for i in range(z_params.size): + z_sq = z_params[i] ** 2 + z_next[2 * i] = 2 * z_params[i] - z_sq + z_next[2 * i + 1] = z_sq + return z_next -def get_bec_frozen_indices(nblock, kfrozen, eta): - bec_caps = calculate_bec_channel_capacities(eta, nblock) - positions = get_frozen_bit_indices_from_capacities(bec_caps, kfrozen) - return positions +def calculate_bec_channel_z_parameters(eta, block_size): + # compare [0, Arikan] eq. 38 + block_power = hf.power_of_2_int(block_size) + z_params = np.array([eta,], dtype=float) + for block_size in range(block_power): + z_params = calculate_z_parameters_one_recursion(z_params) + return z_params -def bec_channel_contruction_tests(): - n = 2 ** 10 - k = n // 2 - eta = 0.3 - bec_capacities = calculate_bec_channel_capacities(eta, n) - print(bec_capacities) +def design_snr_to_bec_eta(design_snr): + s = 10. ** (design_snr / 10.) + return np.exp(-s) - frozenbits_position = get_frozen_bit_indices_from_capacities(bec_capacities, k) - print('frozenbit_positions:') - print(frozenbits_position) - print('frozenbit_num:', frozenbits_position.size) +def bhattacharyya_bounds(design_snr, block_size): + ''' + Harish Vangala, Emanuele Viterbo, Yi Hong: 'A Comparative Study of Polar Code Constructions for the AWGN Channel', 2015 + In this paper it is called Bhattacharyya bounds channel construction and is abbreviated PCC-0 + Best design SNR for block_size = 2048, R = 0.5, is 0dB. + Compare with Arikan: 'Channel Polarization: A Method for Constructing Capacity-Achieving Codes for Symmetric Binary-Input Memoryless Channels. + Proposition 5. inequalities turn into equalities for BEC channel. Otherwise they represent an upper bound. + Also compare [0, Arikan] eq. 6 and 38 + For BEC that translates to capacity(i) = 1 - bhattacharyya(i) + :return Z-parameters in natural bit-order. Choose according to desired rate. + ''' + # minimum design snr = -1.5917 corresponds to BER = 0.5 + s = 10 ** (design_snr / 10) # 'initial z parameter'. + eta = np.exp(-s) + return calculate_bec_channel_z_parameters(eta, block_size) def main(): print 'channel construction main' - bec_channel_contruction_tests() - + n = 4 + block_size = 2 ** n + design_snr = 1.0 + eta = design_snr_to_bec_eta(design_snr) + print(calculate_bec_channel_z_parameters(eta, block_size)) + print(calculate_bec_channel_capacities(eta, block_size)) if __name__ == '__main__': main() diff --git a/gr-fec/python/fec/polar/channel_construction_bsc.py b/gr-fec/python/fec/polar/channel_construction_bsc.py index 2263bf0091..fddad2e755 100755 --- a/gr-fec/python/fec/polar/channel_construction_bsc.py +++ b/gr-fec/python/fec/polar/channel_construction_bsc.py @@ -18,9 +18,39 @@ # Boston, MA 02110-1301, USA. # -import numpy as np +''' +Based on 2 papers: +[1] Ido Tal, Alexander Vardy: 'How To Construct Polar Codes', 2013 +for an in-depth description of a widely used algorithm for channel construction. + +[2] Harish Vangala, Emanuele Viterbo, Yi Hong: 'A Comparative Study of Polar Code Constructions for the AWGN Channel', 2015 +for an overview of different approaches +''' + + +from scipy.optimize import fsolve +from scipy.special import erfc from helper_functions import * import matplotlib.pyplot as plt +from channel_construction_bec import bhattacharyya_bounds + + +def bsc_channel(p): + ''' + binary symmetric channel (BSC) + output alphabet Y = {0, 1} and + W(0|0) = W(1|1) and W(1|0) = W(0|1) + + this function returns a prob's vector for a BSC + p denotes an erroneous transistion + ''' + if not (p >= 0.0 and p <= 1.0): + print "given p is out of range!" + return np.array([], dtype=float) + + # 0 -> 0, 0 -> 1, 1 -> 0, 1 -> 1 + W = np.array([[1 - p, p], [p, 1 - p]], dtype=float) + return W def get_Bn(n): @@ -73,116 +103,237 @@ def mutual_information(w): return i -def bhattacharyya_parameter(w): - '''bhattacharyya parameter is a measure of similarity between two prob. distributions''' - # sum over all y e Y for sqrt( W(y|0) * W(y|1) ) - dim = np.shape(w) - ydim = dim[0] - xdim = dim[1] - z = 0.0 - for y in range(ydim): - z += np.sqrt(w[y][0] * w[y][1]) - # need all +def solver_equation(val, s): + cw_lambda = codeword_lambda_callable(s) + ic_lambda = instantanious_capacity_callable() + return lambda y: ic_lambda(cw_lambda(y)) - val + + +def solve_capacity(a, s): + eq = solver_equation(a, s) + res = fsolve(eq, 1) + return np.abs(res[0]) # only positive values needed. + + +def codeword_lambda_callable(s): + return lambda y: np.exp(-2 * y * np.sqrt(2 * s)) + + +def codeword_lambda(y, s): + return codeword_lambda_callable(s)(y) + + +def instantanious_capacity_callable(): + return lambda x : 1 - np.log2(1 + x) + (x * np.log2(x) / (1 + x)) + + +def instantanious_capacity(x): + return instantanious_capacity_callable()(x) + + +def q_function(x): + # Q(x) = (1 / sqrt(2 * pi) ) * integral (x to inf) exp(- x ^ 2 / 2) dx + return .5 * erfc(x / np.sqrt(2)) + + +def discretize_awgn(mu, design_snr): + ''' + needed for Binary-AWGN channels. + in [1] described in Section VI + in [2] described as a function of the same name. + in both cases reduce infinite output alphabet to a finite output alphabet of a given channel. + idea: + 1. instantaneous capacity C(x) in interval [0, 1] + 2. split into mu intervals. + 3. find corresponding output alphabet values y of likelihood ratio function lambda(y) inserted into C(x) + 4. Calculate probability for each value given that a '0' or '1' is was transmitted. + ''' + s = 10 ** (design_snr / 10) + a = np.zeros(mu + 1, dtype=float) + a[-1] = np.inf + for i in range(1, mu): + a[i] = solve_capacity(1. * i / mu, s) + + factor = np.sqrt(2 * s) + tpm = np.zeros((2, mu)) + for j in range(mu): + tpm[0][j] = q_function(factor + a[j]) - q_function(factor + a[j + 1]) + tpm[1][j] = q_function(-1. * factor + a[j]) - q_function(-1. * factor + a[j + 1]) + return tpm + + +def instant_capacity_delta_callable(): + return lambda a, b: -1. * (a + b) * np.log2((a + b) / 2) + a * np.log2(a) + b * np.log2(b) + + +def capacity_delta_callable(): + c = instant_capacity_delta_callable() + return lambda a, b, at, bt: c(a, b) + c(at, bt) - c(a + at, b + bt) + + +def quantize_to_size(tpm, mu): + # This is a degrading merge, compare [1] + calculate_delta_I = capacity_delta_callable() + L = np.shape(tpm)[1] + if not mu < L: + print('WARNING: This channel gets too small!') + + # lambda works on vectors just fine. Use Numpy vector awesomeness. + delta_i_vec = calculate_delta_I(tpm[0, 0:-1], tpm[1, 0:-1], tpm[0, 1:], tpm[1, 1:]) + + for i in range(L - mu): + d = np.argmin(delta_i_vec) + ap = tpm[0, d] + tpm[0, d + 1] + bp = tpm[1, d] + tpm[1, d + 1] + if d > 0: + delta_i_vec[d - 1] = calculate_delta_I(tpm[0, d - 1], tpm[1, d - 1], ap, bp) + if d < delta_i_vec.size - 1: + delta_i_vec[d + 1] = calculate_delta_I(ap, bp, tpm[0, d + 1], tpm[1, d + 1]) + delta_i_vec = np.delete(delta_i_vec, d) + tpm = np.delete(tpm, d, axis=1) + tpm[0, d] = ap + tpm[1, d] = bp + return tpm + + +def upper_bound_z_params(z, block_size, design_snr): + upper_bound = bhattacharyya_bounds(design_snr, block_size) + z = np.minimum(z, upper_bound) return z -def w_transition_prob(y, u, p): - return p[y == u] - # return 1 - p if y == u else p - -# @profile -def calculate_joint_transition_probability(N, y, x, transition_probs): - single_ws = np.empty(N) - single_ws[y == x] = transition_probs[True] - single_ws[y != x] = transition_probs[False] - return np.prod(single_ws) - - -# @profile -def w_split_prob(y, u, G, transition_probs): - ''' Calculate channel splitting probabilities. ''' - N = len(y) # number of combined channels - df = N - len(u) # degrees of freedom. - prob = 0.0 - for uf in range(2 ** df): - utemp = unpack_byte(np.array([uf, ]), df) - ub = np.concatenate((u, utemp)) - x = np.dot(ub, G) % 2 - true_num = np.sum(y == x) - false_num = N - true_num - w = (transition_probs[True] ** true_num) * (transition_probs[False] ** false_num) - # w = calculate_joint_transition_probability(N, y, x, transition_probs) - prob += w - divider = 1.0 / (2 ** (N - 1)) - return divider * prob - -# @profile -def wn_split_channel(N, p): - G = get_Gn(N) - y = np.zeros((N, ), dtype=np.uint8) - n = 1 - u = np.zeros((n + 1, ), dtype=np.uint8) - transition_probs = np.array([p, 1 - p], dtype=float) - - z_params = [] - c_params = [] - for w in range(N): - nentries = (2 ** N) * (2 ** w) - print "for w=", w, " nentries=", nentries - w_probs = np.zeros((nentries, 2), dtype=float) - for y in range(2 ** N): - yb = unpack_byte(np.array([y, ]), N) - for u in range(2 ** (w + 1)): - ub = unpack_byte(np.array([u, ]), w + 1) - wp = w_split_prob(yb, ub, G, transition_probs) - ufixed = ub[0:-1] - yindex = y * (2 ** w) + pack_byte(ufixed) - uindex = ub[-1] - w_probs[yindex][uindex] = wp - - z = bhattacharyya_parameter(w_probs) - z_params.append(z) - c = mutual_information(w_probs) - c_params.append(c) - print "W=", w, "Z=", z, "capacity=", c - - return z_params, c_params - - -def calculate_z_param(x): - # variables etc taken from paper bei Ido Tal et al. - # name there is f(x) - # x is the cross over probability of a BSC. - return 2 * np.sqrt(x * (1 - x)) - - -def calculate_capacity(x): - # in paper it is called g(x) - return -1. * x * np.log(x) - (1 - x) * np.log(1 - x) - - -def splitting_masses_algorithm(n, k): - m = 2 ** n - p0 = 1.0 / m - mass_vec +def tal_vardy_tpm_algorithm(block_size, design_snr, mu): + block_power = power_of_2_int(block_size) + channels = np.zeros((block_size, 2, mu)) + channels[0] = discretize_awgn(mu, design_snr) * 2 + + print('Constructing polar code with Tal-Vardy algorithm') + print('(block_size = {0}, design SNR = {1}, mu = {2}'.format(block_size, design_snr, mu)) + show_progress_bar(0, block_size) + for j in range(0, block_power): + u = 2 ** j + for t in range(u): + show_progress_bar(u + t, block_size) + # print("(u={0}, t={1}) = {2}".format(u, t, u + t)) + ch1 = upper_convolve(channels[t], mu) + ch2 = lower_convolve(channels[t], mu) + channels[t] = quantize_to_size(ch1, mu) + channels[u + t] = quantize_to_size(ch2, mu) + + z = np.zeros(block_size) + for i in range(block_size): + # z[i] = np.sum(channels[i][1]) + z[i] = bhattacharyya_parameter(channels[i]) + + z = z[bit_reverse_vector(np.arange(block_size), block_power)] + z = upper_bound_z_params(z, block_size, design_snr) + show_progress_bar(block_size, block_size) + print('') + print('channel construction DONE') + return z + + +def merge_lr_based(q, mu): + lrs = q[0] / q[1] + vals, indices, inv_indices = np.unique(lrs, return_index=True, return_inverse=True) + # compare [1] (20). Ordering of representatives according to LRs. + temp = np.zeros((2, len(indices)), dtype=float) + if vals.size < mu: + return q + for i in range(len(indices)): + merge_pos = np.where(inv_indices == i)[0] + sum_items = q[:, merge_pos] + if merge_pos.size > 1: + sum_items = np.sum(q[:, merge_pos], axis=1) + temp[0, i] = sum_items[0] + temp[1, i] = sum_items[1] + return temp + + +def upper_convolve(tpm, mu): + q = np.zeros((2, mu ** 2)) + idx = -1 + for i in range(mu): + idx += 1 + q[0, idx] = (tpm[0, i] ** 2 + tpm[1, i] ** 2) / 2 + q[1, idx] = tpm[0, i] * tpm[1, i] + for j in range(i + 1, mu): + idx += 1 + q[0, idx] = tpm[0, i] * tpm[0, j] + tpm[1, i] * tpm[1, j] + q[1, idx] = tpm[0, i] * tpm[1, j] + tpm[1, i] * tpm[0, j] + if q[0, idx] < q[1, idx]: + q[0, idx], q[1, idx] = swap_values(q[0, idx], q[1, idx]) + + idx += 1 + q = np.delete(q, np.arange(idx, np.shape(q)[1]), axis=1) + q = merge_lr_based(q, mu) + q = normalize_q(q, tpm) + return q + + +def lower_convolve(tpm, mu): + q = np.zeros((2, mu * (mu + 1))) + idx = -1 + for i in range(0, mu): + idx += 1 + q[0, idx] = (tpm[0, i] ** 2) / 2 + q[1, idx] = (tpm[1, i] ** 2) / 2 + if q[0, idx] < q[1, idx]: + q[0, idx], q[1, idx] = swap_values(q[0, idx], q[1, idx]) + idx += 1 + q[0, idx] = tpm[0, i] * tpm[1, i] + q[1, idx] = q[0, idx] + + for j in range(i + 1, mu): + idx += 1 + q[0, idx] = tpm[0, i] * tpm[0, j] + q[1, idx] = tpm[1, i] * tpm[1, j] + if q[0, idx] < q[1, idx]: + q[0, idx], q[1, idx] = swap_values(q[0, idx], q[1, idx]) + idx += 1 + q[0, idx] = tpm[0, i] * tpm[1, j] + q[1, idx] = tpm[1, i] * tpm[0, j] + if q[0, idx] < q[1, idx]: + q[0, idx], q[1, idx] = swap_values(q[0, idx], q[1, idx]) + idx += 1 + q = np.delete(q, np.arange(idx, np.shape(q)[1]), axis=1) + q = merge_lr_based(q, mu) + q = normalize_q(q, tpm) + return q + + +def swap_values(first, second): + return second, first + + +def normalize_q(q, tpm): + original_factor = np.sum(tpm) + next_factor = np.sum(q) + factor = original_factor / next_factor + return q * factor def main(): print 'channel construction BSC main' - n = 3 + n = 8 m = 2 ** n k = m // 2 - eta = 0.3 - p = 0.1 - # z, c = wn_split_channel(m, p) - # print(z) - # print(c) + design_snr = 0.5 + mu = 32 + + + z_params = tal_vardy_tpm_algorithm(m, design_snr, mu) + plt.plot(z_params) + plt.show() + + # q = discretize_awgn(mu, design_snr) - u = np.zeros(m, dtype=bool) - G = get_Gn(m).astype(dtype=bool) - print G - print np.dot(u, G) + # print('discretized:', np.sum(q)) + # qu = upper_convolve(q, mu) + # print('upper_convolve:', np.sum(qu)) + # q0 = lower_convolve(q, mu) + # print('lower_convolve:', np.sum(q0)) if __name__ == '__main__': diff --git a/gr-fec/python/fec/polar/helper_functions.py b/gr-fec/python/fec/polar/helper_functions.py index 213f3cb7c0..e93fa9a507 100644 --- a/gr-fec/python/fec/polar/helper_functions.py +++ b/gr-fec/python/fec/polar/helper_functions.py @@ -19,7 +19,11 @@ # import numpy as np -from channel_construction_bec import get_bec_frozen_indices +import time, sys + + +def power_of_2_int(num): + return int(np.log2(num)) def is_power_of_two(num): @@ -71,28 +75,43 @@ def pack_byte(bits): return res -def get_frozen_bit_positions(directory, n, k, p): - import glob, os - if not os.getcwd().endswith(directory): - 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 get_bec_frozen_indices(n, k, p) +def show_progress_bar(ndone, ntotal): + nchars = 50 + + fract = (1. * ndone / ntotal) + percentage = 100. * fract + ndone_chars = int(nchars * fract) + nundone_chars = nchars - ndone_chars + sys.stdout.write('\r[{0}{1}] {2:5.2f}% ({3} / {4})'.format('=' * ndone_chars, ' ' * nundone_chars, percentage, ndone, ntotal)) + + + +def mutual_information(w): + ''' + calculate mutual information I(W) + I(W) = sum over y e Y ( sum over x e X ( ... ) ) + .5 W(y|x) log frac { W(y|x) }{ .5 W(y|0) + .5 W(y|1) } + ''' + ydim, xdim = np.shape(w) + i = 0.0 + for y in range(ydim): + for x in range(xdim): + v = w[y][x] * np.log2(w[y][x] / (0.5 * w[y][0] + 0.5 * w[y][1])) + i += v + i /= 2.0 + return i + + +def bhattacharyya_parameter(w): + '''bhattacharyya parameter is a measure of similarity between two prob. distributions''' + # sum over all y e Y for sqrt( W(y|0) * W(y|1) ) + dim = np.shape(w) + ydim = dim[0] + z = 0.0 + for y in range(ydim): + z += np.sqrt(w[0, y] * w[1, y]) + # need all + return z def main(): @@ -110,5 +129,14 @@ def main(): print(np.arange(16)) print bit_reverse_vector(np.arange(16), 4) + ntotal = 99 + for i in range(ntotal): + show_progress_bar(i, ntotal) + time.sleep(0.1) + + # sys.stdout.write('Hello') + # time.sleep(1) + # sys.stdout.write('\rMomy ') + if __name__ == '__main__': main() diff --git a/gr-fec/python/fec/polar/polar_channel_construction b/gr-fec/python/fec/polar/polar_channel_construction new file mode 100644 index 0000000000..b69ad3bbfb --- /dev/null +++ b/gr-fec/python/fec/polar/polar_channel_construction @@ -0,0 +1,72 @@ +#!/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. +# +""" A tool for POLAR code channel construction.""" + +from optparse import OptionParser +import gnuradio.fec.polar as cc + + +def setup_parser(): + """ Init the option parser. If derived classes need to add options, + override this and call the parent function. """ + parser = OptionParser(add_help_option=False) + parser.usage = '%prog [blocksize] [designsnr] [mu]' + + parser.add_option("-h", "--help", action="help", help="Displays this help message.") + + parser.add_option("-c", "--channel", action="store", type="string", dest="channel", help="specify channel, currently BEC or BSC (default='BEC')", default='BEC') + parser.add_option("-b", "--blocksize", action="store", type="int", dest="block_size", help="specify block size of polar code (default=16)", default=16) + parser.add_option("-s", "--desgin-snr", action="store", type="float", dest="design_snr", help="specify design SNR of polar code (default=0.0)", default=0.0) + parser.add_option("-k", "--mu", action="store", type="int", dest="mu", help="specify block size of polar code (default=2)", default=2) + + return parser + + +def main(): + """ Here we go. Parse command, choose class and run. """ + print('POLAR code channel constructor commandline tool') + parser = setup_parser() + (options, args) = parser.parse_args() + + channel = str(options.channel) + block_size = int(options.block_size) + design_snr = float(options.design_snr) + mu = int(options.mu) + + if len(args) > 0: + channel = str(args[0]) + if len(args) > 1: + block_size = int(args[1]) + if len(args) > 2: + design_snr = float(args[2]) + if len(args) == 4: + mu = int(args[3]) + + z_params = cc.get_z_params(False, channel, block_size, design_snr, mu) + print(z_params) + + +if __name__ == '__main__': + try: + main() + except KeyboardInterrupt: + pass
\ No newline at end of file diff --git a/gr-fec/python/fec/polar/polar_code.py b/gr-fec/python/fec/polar/polar_code.py deleted file mode 100644 index f263c6d056..0000000000 --- a/gr-fec/python/fec/polar/polar_code.py +++ /dev/null @@ -1,493 +0,0 @@ -#!/usr/bin/env python - -import numpy as np -import matplotlib.pyplot as plt - -from encoder import PolarEncoder as enc - -# input alphabet X is always {0,1} -# output alphabet is arbitrary -# transition probabilities are arbitrary W(y|x) - - -def bit_reverse(value, n): - # is this really missing in NumPy??? - bits = np.zeros(n, type(value)) - for index in range(n): - mask = 1 - mask = np.left_shift(mask, index) - bit = np.bitwise_and(value, mask) - bit = np.right_shift(bit, index) - bits[index] = bit - bits = bits[::-1] - result = 0 - for index, bit in enumerate(bits): - bit = np.left_shift(bit, index) - result += bit - return result - - -def get_Bn(n): - # this is a bit reversal matrix. - lw = int(np.log2(n)) # number of used bits - indexes = [bit_reverse(i, lw) for i in range(n)] - Bn = np.zeros((n, n), type(n)) - for i, index in enumerate(indexes): - Bn[i][index] = 1 - return Bn - - -def get_Fn(n): - # this matrix defines the actual channel combining. - if n == 1: - return np.array([1, ]) - F2 = np.array([[1, 0], [1, 1]], np.int) - nump = int(np.log2(n)) - 1 # number of Kronecker products to calculate - Fn = F2 - for i in range(nump): - Fn = np.kron(Fn, F2) - return Fn - -def get_Gn(n): - # this matrix is called generator matrix - if not is_power_of_2(n): - print "invalid input" - return None - if n == 1: - return np.array([1, ]) - Bn = get_Bn(n) - Fn = get_Fn(n) - Gn = np.dot(Bn, Fn) - return Gn - - -def odd_rec(iwn): - return iwn ** 2 - - -def even_rec(iwn): - return 2 * iwn - iwn ** 2 - - -def calc_one_recursion(iw0): - iw1 = np.zeros(2 * len(iw0)) # double values - for i in range(len(iw0)): - # careful indices screw you because paper is '1' based :( - iw1[2 * i] = odd_rec(iw0[i]) - iw1[2 * i + 1] = even_rec(iw0[i]) - return iw1 - - -def calculate_bec_channel_capacities(eta, n): - iw = 1 - eta # holds for BEC as stated in paper - lw = int(np.log2(n)) - iw = [iw, ] - for i in range(lw): - iw = calc_one_recursion(iw) - return iw - - -def bsc_channel(p): - ''' - binary symmetric channel (BSC) - output alphabet Y = {0, 1} and - W(0|0) = W(1|1) and W(1|0) = W(0|1) - - this function returns a prob's vector for a BSC - p denotes an erroneous transistion - ''' - if not (p >= 0.0 and p <= 1.0): - print "given p is out of range!" - return () - - # 0 -> 0, 0 -> 1, 1 -> 0, 1 -> 1 - W = np.array([[1 - p, p], [p, 1 - p]]) - return W - - -def bec_channel(eta): - ''' - binary erasure channel (BEC) - for each y e Y - W(y|0) * W(y|1) = 0 or W(y|0) = W(y|1) - transistions are 1 -> 1 or 0 -> 0 or {0, 1} -> ? (erased symbol) - ''' - print eta - - # looks like BSC but should be interpreted differently. - W = (1 - eta, eta, 1 - eta) - return W - - -def is_power_of_2(num): - if type(num) != int: - return False # make sure we only compute integers. - return num != 0 and ((num & (num - 1)) == 0) - - -def combine_W2(u): - # This function applies the channel combination for W2 - x1 = (u[0] + u[1]) % 2 - x2 = (u[1]) - return np.array([x1, x2], np.int) - - -def combine_W4(u): - im = np.concatenate((combine_W2(u[0:2]), combine_W2(u[2:4]))) - print "combine_W4.im = ", im - swappy = im[1] - im[1] = im[2] - im[2] = swappy - print "combine_W4.reverse_shuffled = ", im - - return np.concatenate((combine_W2(im[0:2]), combine_W2(im[2:4]))) - - -def combine_Wn(u): - '''Combine vector u for encoding. It's described in the "Channel combining" section''' - # will throw error if len(u) isn't a power of 2! - n = len(u) - G = get_Gn(n) - return np.dot(u, G) % 2 - - -def unpack_byte(byte, nactive): - if np.amin(byte) < 0 or np.amax(byte) > 255: - return None - if not byte.dtype == np.uint8: - byte = byte.astype(np.uint8) - if nactive == 0: - return np.array([], dtype=np.uint8) - return np.unpackbits(byte)[-nactive:] - - -def pack_byte(bits): - if len(bits) == 0: - return 0 - if np.amin(bits) < 0 or np.amax(bits) > 1: # only '1' and '0' in bits array allowed! - return None - bits = np.concatenate((np.zeros(8 - len(bits), dtype=np.uint8), bits)) - res = np.packbits(bits)[0] - return res - - -def calculate_conditional_prob(y, u, channel): - # y and u same size and 1d! - # channel 2 x 2 matrix! - x1 = (u[0] + u[1]) % 2 - s = 0 if y[0] == x1 else 1 - # print "W(", y[0], "|", u[0], "+", u[1], "=", s, ") =", channel[y[0]][x1] - w112 = channel[y[0]][x1] - w22 = channel[y[1]][u[1]] - return w112 * w22 - - -def calculate_w2_probs(): - w0 = np.array([[0.9, 0.1], [0.1, 0.9]]) - print w0 - - w2 = np.zeros((4, 4), dtype=float) - - print "W(y1|u1+u2)" - for y in range(4): - ybits = unpack_byte(np.array([y, ]), 2) - for u in range(4): - ubits = unpack_byte(np.array([u, ]), 2) - prob = calculate_conditional_prob(ybits, ubits, w0) - w2[y][u] = prob - # print "W(y1,y2|u1,u2) =", prob - return w2 - - -def get_prob(y, u, channel): - return channel[y][u] - - -def get_wn_prob(y, u, channel): - x = combine_Wn(u) - result = 1 - for i in range(len(x)): - result *= get_prob(y[i], x[i], channel) - return result - - -def calculate_Wn_probs(n, channel): - # print "calculate_wn_probs" - ncomb = 2 ** n - wn = np.ones((ncomb, ncomb), dtype=float) - for y in range(ncomb): - ybits = unpack_byte(np.array([y, ]), n) - for u in range(ncomb): - ubits = unpack_byte(np.array([u, ]), n) - xbits = combine_Wn(ubits) - wn[y][u] = get_wn_prob(ybits, ubits, channel) - return wn - - -def calculate_channel_splitting_probs(wn, n): - print wn - - wi = np.zeros((n, 2 ** n, 2 ** n), dtype=float) - divider = (1.0 / (2 ** (n - 1))) - for i in range(n): - for y in range(2 ** n): - ybits = unpack_byte(np.array([y, ]), n) - print - for u in range(2 ** n): - ubits = unpack_byte(np.array([u, ]), n) - usc = ubits[0:i] - u = ubits[i] - usum = ubits[i+1:] - fixed_pu = np.append(usc, u) - - my_iter = [] - if len(usum) == 0: - my_iter.append(np.append(np.zeros(8 - len(fixed_pu), dtype=np.uint8), fixed_pu)) - else: - uiter = np.arange(2 ** len(usum), dtype=np.uint8) - for ui in uiter: - element = unpack_byte(ui, len(usum)) - item = np.append(fixed_pu, element) - item = np.append(np.zeros(8 - len(item), dtype=np.uint8), item) - my_iter.append(item) - my_iter = np.array(my_iter) - - prob_sum = 0 - for item in my_iter: - upos = np.packbits(item) - # print "y=", np.binary_repr(y, n), "item=", item, "u=", np.binary_repr(upos, n) - wni = wn[y][upos] - prob_sum += wni - prob_sum *= divider - - print "W[{5}]({0},{1},{2}|{3}) = {4}".format(ybits[0], ybits[1], usc, u, prob_sum, i) - - # print "i=", i, "y=", np.binary_repr(y, n), " fixed=", fixed_pu, "usum=", usum, " WN(i) =", prob_sum - wi[i][y][u] = prob_sum - - for i in range(n): - print - for y in range(2 ** n): - ybits = unpack_byte(np.array([y, ]), n) - for u in range(2 ** n): - - print "W[{}] ({},{}|{})".format(i, ybits[0], ybits[1], u) - - - - return wi - - - -def mutual_information(w): - ''' - calculate mutual information I(W) - I(W) = sum over y e Y ( sum over x e X ( ... ) ) - .5 W(y|x) log frac { W(y|x) }{ .5 W(y|0) + .5 W(y|1) } - ''' - ydim, xdim = np.shape(w) - i = 0.0 - for y in range(ydim): - for x in range(xdim): - v = w[y][x] * np.log2(w[y][x] / (0.5 * w[y][0] + 0.5 * w[y][1])) - i += v - i /= 2.0 - return i - - -def capacity(w): - ''' - find supremum I(W) of a channel. - ''' - return w - - -def bhattacharyya_parameter(w): - '''bhattacharyya parameter is a measure of similarity between two prob. distributions''' - # sum over all y e Y for sqrt( W(y|0) * W(y|1) ) - dim = np.shape(w) - ydim = dim[0] - xdim = dim[1] - z = 0.0 - for y in range(ydim): - z += np.sqrt(w[y][0] * w[y][1]) - # need all - return z - - -def w_transition_prob(y, u, p): - return 1 - p if y == u else p - - -def w_split_prob(y, u, G, p): - ''' Calculate channel splitting probabilities. ''' - N = len(y) # number of combined channels - df = N - len(u) # degrees of freedom. - prob = 0.0 - for uf in range(2 ** df): - utemp = unpack_byte(np.array([uf, ]), df) - ub = np.concatenate((u, utemp)) - # print "y=", y, "\tu=", ub - x = np.dot(ub, G) % 2 - # print "x=", x - w = 1.0 - for i in range(N): - w *= w_transition_prob(y[i], x[i], p) - # print "for u1=", uf, "prob=", w - prob += w - divider = 1.0 / (2 ** (N - 1)) - return divider * prob - - -def wn_split_channel(N, p): - G = get_Gn(N) - y = np.zeros((N, ), dtype=np.uint8) - n = 1 - u = np.zeros((n + 1, ), dtype=np.uint8) - - pn = w_split_prob(y, u, G, p) - # print "pn=", pn - z_params = [] - c_params = [] - for w in range(N): - nentries = (2 ** N) * (2 ** w) - print "for w=", w, " nentries=", nentries - w_probs = np.zeros((nentries, 2), dtype=float) - for y in range(2 ** N): - yb = unpack_byte(np.array([y, ]), N) - # print "\n\nyb", yb - for u in range(2 ** (w + 1)): - ub = unpack_byte(np.array([u, ]), w + 1) - # print "ub", ub - wp = w_split_prob(yb, ub, G, p) - ufixed = ub[0:-1] - yindex = y * (2 ** w) + pack_byte(ufixed) - uindex = ub[-1] - # print "y=", y, "ub", u, " prob=", wp, "index=[", yindex, ", ", uindex, "]" - w_probs[yindex][uindex] = wp - print "\n", np.sum(w_probs, axis=0) - z = bhattacharyya_parameter(w_probs) - z_params.append(z) - c = mutual_information(w_probs) - c_params.append(c) - print "W=", w, "Z=", z, "capacity=", c - - return z_params, c_params - - -def wminus(y0, y1, u0, p): - prob = 0.0 - for i in range(2): - # print y0, y1, u0, i - u0u1 = (i + u0) % 2 - w0 = w_transition_prob(y0, u0u1, p) - w1 = w_transition_prob(y1, i, p) - # print "w0=", w0, "\tw1=", w1 - prob += w0 * w1 - prob *= 0.5 - return prob - - -def wplus(y0, y1, u0, u1, p): - u0u1 = (u0 + u1) % 2 - w0 = w_transition_prob(y0, u0u1, p) - w1 = w_transition_prob(y1, u1, p) - return 0.5 * w0 * w1 - - -def w2_split_channel(p): - - wm_probs = np.zeros((4, 2), dtype=float) - for y0 in range(2): - for y1 in range(2): - for u0 in range(2): - wm = wminus(y0, y1, u0, p) - wm_probs[y0 * 2 + y1][u0] = wm - - print wm_probs - print "W- Z parameter=", bhattacharyya_parameter(wm_probs) - print "I(W-)=", mutual_information(wm_probs) - - chan_prob = 0.0 - wp_probs = np.zeros((8, 2), dtype=float) - for y0 in range(2): - for y1 in range(2): - for u0 in range(2): - for u1 in range(2): - wp = wplus(y0, y1, u0, u1, p) - wp_probs[4 * y0 + 2 * y1 + u0][u1] = wp - - print wp_probs - print "W+ Z parameter=", bhattacharyya_parameter(wp_probs) - print "I(W+)=", mutual_information(wp_probs) - - -def plot_channel(probs, p, name): - nc = len(probs) - plt.plot(probs) - plt.grid() - plt.xlim((0, nc - 1)) - plt.ylim((0.0, 1.0)) - plt.xlabel('channel') - plt.ylabel('capacity') - - fname = name, '_', p, '_', nc - print fname - fname = ''.join(str(n) for n in fname) - print fname - fname = fname.replace('.', '_') - print fname - fname = ''.join((fname, '.pdf')) - print fname - plt.savefig(fname) - # plt.show() - - -def main(): - np.set_printoptions(precision=4, linewidth=150) - print "POLAR code!" - w2 = calculate_w2_probs() - print w2 - - p = 0.1 - n = 2 - wn = calculate_Wn_probs(n, bsc_channel(p)) - - wi = calculate_channel_splitting_probs(wn, n) - - w0 = bsc_channel(p) - print w0 - iw = mutual_information(w0) - print "I(W)=", iw - print 1 - (p * np.log2(1.0 / p) + (1 - p) * np.log2(1.0 / (1 - p))) - - print "Z param call" - bhattacharyya_parameter(w0) - - print "old vs new encoder" - - p = 0.1 - w2_split_channel(p) - z, c = wn_split_channel(4, p) - - eta = 0.3 - nc = 1024 - probs = calculate_bec_channel_capacities(eta, nc) - # plot_channel(probs, eta, 'bec_capacity') - # plot_channel(c, p, 'bsc_capacity') - - nt = 2 ** 5 - - - fG = get_Gn(nt) - # print fG - encoder = enc(nt, 4, np.arange(nt - 4, dtype=int)) - # print encoder.get_gn() - comp = np.equal(fG, encoder.get_gn()) - - print "is equal?", np.all(comp) - - - -if __name__ == '__main__': - main() diff --git a/gr-fec/python/fec/qa_polar_decoder_sc.py b/gr-fec/python/fec/qa_polar_decoder_sc.py index f26bf9a91a..966a9f169a 100644 --- a/gr-fec/python/fec/qa_polar_decoder_sc.py +++ b/gr-fec/python/fec/qa_polar_decoder_sc.py @@ -31,7 +31,7 @@ from extended_encoder import extended_encoder from extended_decoder import extended_decoder from polar.encoder import PolarEncoder from polar.decoder import PolarDecoder -from polar.helper_functions import get_frozen_bit_positions +import polar.channel_construction as cc # from polar.helper_functions import bit_reverse_vector # print('PID:', os.getpid()) @@ -66,7 +66,7 @@ class test_polar_decoder_sc(gr_unittest.TestCase): block_size = 2 ** block_power num_info_bits = 2 ** (block_power - 1) 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_positions = cc.frozen_bit_positions(block_size, num_info_bits, 0.0) frozen_bit_values = np.array([0] * num_frozen_bits,) print frozen_bit_positions @@ -77,7 +77,7 @@ class test_polar_decoder_sc(gr_unittest.TestCase): encoder = PolarEncoder(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values) data = encoder.encode(bits) # data = np.array([0, 1, 1, 0, 1, 0, 1, 0], dtype=int) - gr_data = -2.0 * data + 1.0 + gr_data = 2.0 * data - 1.0 polar_decoder = fec.polar_decoder_sc.make(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values, is_packed) src = blocks.vector_source_f(gr_data, False) @@ -106,7 +106,7 @@ class test_polar_decoder_sc(gr_unittest.TestCase): block_size = 2 ** block_power num_info_bits = 2 ** (block_power - 1) 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_positions = cc.frozen_bit_positions(block_size, num_info_bits, 0.0) frozen_bit_values = np.array([0] * num_frozen_bits,) print frozen_bit_positions @@ -124,7 +124,7 @@ class test_polar_decoder_sc(gr_unittest.TestCase): # bits = np.random.randint(2, size=num_info_bits) # data = encoder.encode(bits) # data = np.array([0, 1, 1, 0, 1, 0, 1, 0], dtype=int) - gr_data = -2.0 * data + 1.0 + gr_data = 2.0 * data - 1.0 polar_decoder = fec.polar_decoder_sc.make(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values, is_packed) src = blocks.vector_source_f(gr_data, False) diff --git a/gr-fec/python/fec/qa_polar_decoder_sc_list.py b/gr-fec/python/fec/qa_polar_decoder_sc_list.py index f698a4e01c..3aefd0f478 100644 --- a/gr-fec/python/fec/qa_polar_decoder_sc_list.py +++ b/gr-fec/python/fec/qa_polar_decoder_sc_list.py @@ -29,12 +29,13 @@ from extended_encoder import extended_encoder from extended_decoder import extended_decoder from polar.encoder import PolarEncoder from polar.decoder import PolarDecoder -from polar.helper_functions import get_frozen_bit_positions -# from polar.helper_functions import bit_reverse_vector -# +import polar.channel_construction as cc + + # print('PID:', os.getpid()) # raw_input('tell me smth') + class test_polar_decoder_sc_list(gr_unittest.TestCase): def setUp(self): @@ -66,7 +67,7 @@ class test_polar_decoder_sc_list(gr_unittest.TestCase): num_info_bits = 2 ** (expo - 1) max_list_size = 2 ** (expo - 2) 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_positions = cc.frozen_bit_positions(block_size, num_info_bits, 0.0) frozen_bit_values = np.array([0] * num_frozen_bits,) print(frozen_bit_positions) @@ -78,7 +79,7 @@ class test_polar_decoder_sc_list(gr_unittest.TestCase): encoder = PolarEncoder(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values) data = encoder.encode(bits) # data = np.array([0, 1, 1, 0, 1, 0, 1, 0], dtype=int) - gr_data = -2.0 * data + 1.0 + gr_data = 2.0 * data - 1.0 polar_decoder = fec.polar_decoder_sc_list.make(max_list_size, block_size, num_info_bits, frozen_bit_positions, frozen_bit_values, is_packed) src = blocks.vector_source_f(gr_data, False) @@ -109,7 +110,7 @@ class test_polar_decoder_sc_list(gr_unittest.TestCase): num_info_bits = 2 ** (expo - 1) max_list_size = 2 ** (expo - 2) 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_positions = cc.frozen_bit_positions(block_size, num_info_bits, 0.0) frozen_bit_values = np.array([0] * num_frozen_bits,) print(frozen_bit_positions) @@ -127,7 +128,7 @@ class test_polar_decoder_sc_list(gr_unittest.TestCase): # bits = np.ones(num_info_bits, dtype=int) # data = encoder.encode(bits) # data = np.array([0, 1, 1, 0, 1, 0, 1, 0], dtype=int) - gr_data = -2.0 * data + 1.0 + gr_data = 2.0 * data - 1.0 polar_decoder = fec.polar_decoder_sc_list.make(max_list_size, block_size, num_info_bits, frozen_bit_positions, frozen_bit_values, is_packed) src = blocks.vector_source_f(gr_data, False) diff --git a/gr-fec/python/fec/qa_polar_encoder.py b/gr-fec/python/fec/qa_polar_encoder.py index 4af193e2d4..b4f26e4017 100644 --- a/gr-fec/python/fec/qa_polar_encoder.py +++ b/gr-fec/python/fec/qa_polar_encoder.py @@ -26,7 +26,7 @@ import numpy as np from extended_encoder import extended_encoder from polar.encoder import PolarEncoder -from polar.helper_functions import get_frozen_bit_positions +import polar.channel_construction as cc class test_polar_encoder(gr_unittest.TestCase): @@ -40,7 +40,7 @@ class test_polar_encoder(gr_unittest.TestCase): def test_001_setup(self): block_size = 16 num_info_bits = 8 - frozen_bit_positions = np.arange(block_size - num_info_bits) + frozen_bit_positions = cc.frozen_bit_positions(block_size, num_info_bits, 0.0) frozen_bit_values = np.array([],) polar_encoder = fec.polar_encoder.make(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values) @@ -54,7 +54,7 @@ class test_polar_encoder(gr_unittest.TestCase): 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_positions = cc.frozen_bit_positions(block_size, num_info_bits, 0.0) frozen_bit_values = np.array([0] * num_frozen_bits,) python_encoder = PolarEncoder(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values) @@ -83,7 +83,7 @@ class test_polar_encoder(gr_unittest.TestCase): 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_positions = cc.frozen_bit_positions(block_size, num_info_bits, 0.0) frozen_bit_values = np.array([0] * num_frozen_bits,) python_encoder = PolarEncoder(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values) |