diff options
Diffstat (limited to 'gr-trellis')
36 files changed, 1006 insertions, 1578 deletions
diff --git a/gr-trellis/docs/make_numbered_listing.py b/gr-trellis/docs/make_numbered_listing.py index c295dc8763..09a82cfaa4 100755..100644 --- a/gr-trellis/docs/make_numbered_listing.py +++ b/gr-trellis/docs/make_numbered_listing.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import unicode_literals import sys import os, os.path from optparse import OptionParser diff --git a/gr-trellis/docs/test_tcm.py b/gr-trellis/docs/test_tcm.py index 61ab00f1c8..e9a0ba59eb 100644 --- a/gr-trellis/docs/test_tcm.py +++ b/gr-trellis/docs/test_tcm.py @@ -1,5 +1,8 @@ #!/usr/bin/env python +from __future__ import print_function +from __future__ import division +from __future__ import unicode_literals from gnuradio import gr from gnuradio import audio from gnuradio import trellis, digital, blocks @@ -20,14 +23,14 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): # TX src = blocks.lfsr_32k_source_s() - src_head = blocks.head (gr.sizeof_short,Kb/16) # packet size in shorts + src_head = blocks.head (gr.sizeof_short,Kb / 16) # packet size in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality enc = trellis.encoder_ss(f,0) # initial state = 0 mod = digital.chunks_to_symbols_sf(constellation,dimensionality) # CHANNEL add = blocks.add_ff() - noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) + noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0 / 2),seed) # RX metrics = trellis.metrics_f(f.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi @@ -67,31 +70,31 @@ def main(args): # system parameters f=trellis.fsm(fname) # get the FSM specification from a file Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) - bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps + bitspersymbol = int(round(math.log(f.I()) / math.log(2))) # bits per FSM input symbol + K=Kb / bitspersymbol # packet size in trellis steps modulation = fsm_utils.psk4 # see fsm_utlis.py for available predefined modulations dimensionality = modulation[0] constellation = modulation[1] - if len(constellation)/dimensionality != f.O(): + if len(constellation) / dimensionality != f.O(): sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') sys.exit (1) # calculate average symbol energy Es = 0 for i in range(len(constellation)): Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # noise variance + Es = Es / (old_div(len(constellation,dimensionality))) + N0=Es / pow(10.0,old_div(esn0_db,10.0)); # noise variance tot_s=0 terr_s=0 for i in range(rep): - (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,constellation,N0,-long(666+i)) # run experiment with different seed to get different noise realizations + (s,e)=run_test(f,Kb,bitspersymbol,K,dimensionality,constellation,N0,-int(666+i)) # run experiment with different seed to get different noise realizations tot_s=tot_s+s terr_s=terr_s+e if (i%100==0): - print i,s,e,tot_s,terr_s, '%e' % ((1.0*terr_s)/tot_s) + print(i,s,e,tot_s,terr_s, '%e' % ((1.0*terr_s) / tot_s)) # estimate of the (short) error rate - print tot_s,terr_s, '%e' % ((1.0*terr_s)/tot_s) + print(tot_s,terr_s, '%e' % ((1.0*terr_s) / tot_s)) if __name__ == '__main__': diff --git a/gr-trellis/docs/test_viterbi_equalization1.py b/gr-trellis/docs/test_viterbi_equalization1.py index c1a831d0bb..95cb119edf 100755..100644 --- a/gr-trellis/docs/test_viterbi_equalization1.py +++ b/gr-trellis/docs/test_viterbi_equalization1.py @@ -1,5 +1,8 @@ #!/usr/bin/env python +from __future__ import print_function +from __future__ import division +from __future__ import unicode_literals from gnuradio import gr from gnuradio import audio from gnuradio import trellis, digital, filter, blocks @@ -34,7 +37,7 @@ def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constel # CHANNEL isi = filter.fir_filter_fff(1,channel) add = blocks.add_ff() - noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) + noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0 / 2),seed) # RX skip = blocks.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols @@ -78,14 +81,14 @@ def main(args): modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations channel = fsm_utils.c_channel # see fsm_utlis.py for available predefined test channels f=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically - bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps + bitspersymbol = int(round(math.log(f.I()) / math.log(2))) # bits per FSM input symbol + K=Kb / bitspersymbol # packet size in trellis steps tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1) dimensionality = tot_channel[0] tot_constellation = tot_channel[1] - N0=pow(10.0,-esn0_db/10.0); # noise variance - if len(tot_constellation)/dimensionality != f.O(): + N0=pow(10.0,-esn0_db / 10.0); # noise variance + if len(tot_constellation) / dimensionality != f.O(): sys.stderr.write ('Incompatible FSM output cardinality and lookup table size.\n') sys.exit (1) @@ -94,14 +97,14 @@ def main(args): terr_p=0 # total number of packets in error for i in range(rep): - (s,e)=run_test(f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,N0,-long(666+i)) # run experiment with different seed to get different data and noise realizations + (s,e)=run_test(f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,N0,-int(666+i)) # run experiment with different seed to get different data and noise realizations tot_s=tot_s+s terr_s=terr_s+e terr_p=terr_p+(terr_s!=0) if ((i+1)%100==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + print(i+1,terr_p, '%.2e' % ((1.0*terr_p) / (i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s) / tot_s)) # estimate of the (short or symbol) error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s)/tot_s) + print(rep,terr_p, '%.2e' % ((1.0*terr_p) / (i+1)),tot_s,terr_s, '%.2e' % ((1.0*terr_s) / tot_s)) if __name__ == '__main__': diff --git a/gr-trellis/examples/python/test_tcm.py b/gr-trellis/examples/python/test_tcm.py index dfc565616e..e2eb87fcd7 100755..100644 --- a/gr-trellis/examples/python/test_tcm.py +++ b/gr-trellis/examples/python/test_tcm.py @@ -1,5 +1,8 @@ #!/usr/bin/env python +from __future__ import print_function +from __future__ import division +from __future__ import unicode_literals from gnuradio import gr from gnuradio import trellis, digital, blocks from gnuradio import eng_notation @@ -33,7 +36,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): # CHANNEL add = blocks.add_ff() - noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),long(seed)) + noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0 / 2),int(seed)) # RX va = trellis.viterbi_combined_fs(f,K,0,0,dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # Put -1 if the Initial/Final states are not set. @@ -56,7 +59,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): #print "final state = " , enc.ST() if len(dst.data()) != len(packet): - print "Error: not enough data:", len(dst.data()), len(packet) + print("Error: not enough data:", len(dst.data()), len(packet)) ntotal=len(packet) nwrong = sum(abs(packet-numpy.array(dst.data()))); return (ntotal,nwrong,abs(packet-numpy.array(dst.data()))) @@ -73,7 +76,7 @@ def main(): (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() - raise SystemExit, 1 + raise SystemExit(1) fname=options.fsm_file esn0_db=float(options.esn0) @@ -84,20 +87,20 @@ def main(): # alternatively you can specify the fsm from its generator matrix #f=trellis.fsm(1,2,[5,7]) Kb=1024*16 # packet size in bits (make it multiple of 16 so it can be packed in a short) - bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol - K=Kb/bitspersymbol # packet size in trellis steps + bitspersymbol = int(round(math.log(f.I()) / math.log(2))) # bits per FSM input symbol + K=Kb / bitspersymbol # packet size in trellis steps modulation = fsm_utils.psk4 # see fsm_utlis.py for available predefined modulations dimensionality = modulation[0] constellation = modulation[1] - if len(constellation)/dimensionality != f.O(): + if len(constellation) / dimensionality != f.O(): sys.stderr.write ('Incompatible FSM output cardinality and modulation size.\n') sys.exit (1) # calculate average symbol energy Es = 0 for i in range(len(constellation)): Es = Es + constellation[i]**2 - Es = Es / (len(constellation)/dimensionality) - N0=Es/pow(10.0,esn0_db/10.0); # calculate noise variance + Es = Es / (old_div(len(constellation,dimensionality))) + N0=Es / pow(10.0,old_div(esn0_db,10.0)); # calculate noise variance tot_b=0 # total number of transmitted bits terr_b=0 # total number of bits in error @@ -108,14 +111,14 @@ def main(): terr_b=terr_b+e terr_p=terr_p+(e!=0) if ((i+1)%100==0) : # display progress - print i+1,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_b,terr_b, '%.2e' % ((1.0*terr_b)/tot_b) + print(i+1,terr_p, '%.2e' % ((1.0*terr_p) / (i+1)),tot_b,terr_b, '%.2e' % ((1.0*terr_b) / tot_b)) if e!=0: - print "rep=",i, e + print("rep=",i, e) for k in range(Kb): if pattern[k]!=0: - print k + print(k) # estimate of the bit error rate - print rep,terr_p, '%.2e' % ((1.0*terr_p)/(i+1)),tot_b,terr_b, '%.2e' % ((1.0*terr_b)/tot_b) + print(rep,terr_p, '%.2e' % ((1.0*terr_p) / (i+1)),tot_b,terr_b, '%.2e' % ((1.0*terr_b) / tot_b)) diff --git a/gr-trellis/grc/CMakeLists.txt b/gr-trellis/grc/CMakeLists.txt index 9fbadd50d8..f727da92d4 100644 --- a/gr-trellis/grc/CMakeLists.txt +++ b/gr-trellis/grc/CMakeLists.txt @@ -18,18 +18,18 @@ # Boston, MA 02110-1301, USA. install(FILES - trellis_encoder_xx.xml - trellis_siso_combined_f.xml - trellis_viterbi_x.xml - trellis_metrics_x.xml - trellis_siso_f.xml - trellis_permutation.xml - trellis_viterbi_combined_xx.xml - trellis_sccc_encoder_xx.xml - trellis_sccc_decoder_x.xml - trellis_sccc_decoder_combined_xx.xml - trellis_pccc_encoder_xx.xml - trellis_pccc_decoder_x.xml - trellis_pccc_decoder_combined_xx.xml + trellis_encoder_xx.block.yml + trellis_siso_combined_f.block.yml + trellis_viterbi_x.block.yml + trellis_metrics_x.block.yml + trellis_siso_f.block.yml + trellis_permutation.block.yml + trellis_viterbi_combined_xx.block.yml + trellis_sccc_encoder_xx.block.yml + trellis_sccc_decoder_x.block.yml + trellis_sccc_decoder_combined_xx.block.yml + trellis_pccc_encoder_xx.block.yml + trellis_pccc_decoder_x.block.yml + trellis_pccc_decoder_combined_xx.block.yml DESTINATION ${GRC_BLOCKS_DIR} ) diff --git a/gr-trellis/grc/trellis_encoder_xx.block.yml b/gr-trellis/grc/trellis_encoder_xx.block.yml new file mode 100644 index 0000000000..d437c16119 --- /dev/null +++ b/gr-trellis/grc/trellis_encoder_xx.block.yml @@ -0,0 +1,59 @@ +id: trellis_encoder_xx +label: Trellis Encoder +category: '[Core]/Trellis Coding' + +parameters: +- id: type + label: Type + dtype: enum + options: [bb, bs, bi, ss, si, ii] + option_labels: [Byte->Byte, Byte->Short, Byte->Int, Short->Short, Short->Int, + Int->Int] + option_attributes: + input: [byte, byte, byte, short, short, int] + output: [byte, short, int, short, int, int] + hide: part +- id: fsm_args + label: FSM Args + dtype: raw +- id: init_state + label: Initial State + dtype: int + default: '0' +- id: blockwise + label: Blockwise + dtype: enum + default: 'False' + options: ['True', 'False'] + option_labels: ['On', 'Off'] + hide: part +- id: blocklength + label: Block length + dtype: int + default: '0' + hide: ${ ('none' if blockwise == 'True' else 'all') } + +inputs: +- domain: stream + dtype: ${ type.input } + +outputs: +- domain: stream + dtype: ${ type.output } + +asserts: +- ${ (isinstance(eval(""" fsm_args """[1:-1], locals(),globals()), str) and open(fsm_args).close()) or True } + +templates: + imports: from gnuradio import trellis + make: ' trellis.encoder_${type}(trellis.fsm(${fsm_args}), ${init_state}, ${blocklength}) + if ${blockwise} else trellis.encoder_${type}(trellis.fsm(${fsm_args}), ${init_state}) ' + callbacks: + - set_FSM(trellis.fsm(${fsm_args})) + - set_ST(${init_state}) + - set_K(${blocklength}) + +documentation: |- + The fsm arguments are passed directly to the trellis.fsm() constructor. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_encoder_xx.xml b/gr-trellis/grc/trellis_encoder_xx.xml deleted file mode 100644 index ab7d5226e9..0000000000 --- a/gr-trellis/grc/trellis_encoder_xx.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Trellis Encoder -################################################### - --> - -<block> - <name>Trellis Encoder</name> - <key>trellis_encoder_xx</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis</import> - <make> trellis.encoder_$(type)(trellis.fsm($fsm_args), $init_state, $blocklength) if $blockwise else trellis.encoder_$(type)(trellis.fsm($fsm_args), $init_state) </make> - <callback>set_FSM(trellis.fsm($fsm_args))</callback> - <callback>set_ST($init_state)</callback> - <callback>set_K($blocklength)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Byte->Byte</name> - <key>bb</key> - <opt>input:byte</opt> - <opt>output:byte</opt> - </option> - <option> - <name>Byte->Short</name> - <key>bs</key> - <opt>input:byte</opt> - <opt>output:short</opt> - </option> - <option> - <name>Byte->Int</name> - <key>bi</key> - <opt>input:byte</opt> - <opt>output:int</opt> - </option> - <option> - <name>Short->Short</name> - <key>ss</key> - <opt>input:short</opt> - <opt>output:short</opt> - </option> - <option> - <name>Short->Int</name> - <key>si</key> - <opt>input:short</opt> - <opt>output:int</opt> - </option> - <option> - <name>Int->Int</name> - <key>ii</key> - <opt>input:int</opt> - <opt>output:int</opt> - </option> - </param> - <param> - <name>FSM Args</name> - <key>fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Initial State</name> - <key>init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Blockwise</name> - <key>blockwise</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>On</name> - <key>True</key> - </option> - <option> - <name>Off</name> - <key>False</key> - </option> - </param> - <param> - <name>Block length</name> - <key>blocklength</key> - <value>0</value> - <type>int</type> - <hide>#if $blockwise() == 'True' then 'none' else 'all'#</hide> - </param> - <check>(isinstance(eval(""" $fsm_args """[1:-1], locals(),globals()), str) and open($fsm_args).close()) or True</check> - <sink> - <name>in</name> - <type>$type.input</type> - </sink> - <source> - <name>out</name> - <type>$type.output</type> - </source> - <doc> -The fsm arguments are passed directly to the trellis.fsm() constructor. - </doc> -</block> diff --git a/gr-trellis/grc/trellis_metrics_x.block.yml b/gr-trellis/grc/trellis_metrics_x.block.yml new file mode 100644 index 0000000000..e4559ea15c --- /dev/null +++ b/gr-trellis/grc/trellis_metrics_x.block.yml @@ -0,0 +1,50 @@ +id: trellis_metrics_x +label: Trellis Metrics +category: '[Core]/Trellis Coding' + +parameters: +- id: type + label: Type + dtype: enum + options: [c, f, i, s] + option_labels: [Complex, Float, Int, Short] + option_attributes: + io: [complex, float, int, short] + table: [complex_vector, real_vector, int_vector, int_vector] + hide: part +- id: card + label: Output Cardinality + dtype: int +- id: dim + label: Dimensionality + dtype: int +- id: table + label: Constellation + dtype: ${ type.table } +- id: metric_type + label: Metric Type + dtype: enum + options: [digital.TRELLIS_EUCLIDEAN, digital.TRELLIS_HARD_SYMBOL, digital.TRELLIS_HARD_BIT] + option_labels: [Euclidean, Hard Symbol, Hard Bit] + +inputs: +- domain: stream + dtype: ${ type.io } + +outputs: +- domain: stream + dtype: float + +templates: + imports: from gnuradio import trellis, digital + make: trellis.metrics_${type}(${card}, ${dim}, ${table}, ${metric_type}) + callbacks: + - set_O(${card}) + - set_D(${dim}) + - set_TYPE(${metric_type}) + - set_TABLE(${table}) + +documentation: |- + Generate metrics required for Viterbi or SISO algorithms. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_metrics_x.xml b/gr-trellis/grc/trellis_metrics_x.xml deleted file mode 100644 index 15e7338098..0000000000 --- a/gr-trellis/grc/trellis_metrics_x.xml +++ /dev/null @@ -1,91 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Trellis Metrics -################################################### - --> - - -<block> - <name>Trellis Metrics</name> - <key>trellis_metrics_x</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis, digital</import> - <make>trellis.metrics_$(type)($card, $dim, $table, $metric_type)</make> - <callback>set_O($card)</callback> - <callback>set_D($dim)</callback> - <callback>set_TYPE($metric_type)</callback> - <callback>set_TABLE($table)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>c</key> - <opt>io:complex</opt> - <opt>table:complex_vector</opt> - </option> - <option> - <name>Float</name> - <key>f</key> - <opt>io:float</opt> - <opt>table:real_vector</opt> - </option> - <option> - <name>Int</name> - <key>i</key> - <opt>io:int</opt> - <opt>table:int_vector</opt> - </option> - <option> - <name>Short</name> - <key>s</key> - <opt>io:short</opt> - <opt>table:int_vector</opt> - </option> - </param> - <param> - <name>Output Cardinality</name> - <key>card</key> - <type>int</type> - </param> - <param> - <name>Dimensionality</name> - <key>dim</key> - <type>int</type> - </param> - <param> - <name>Constellation</name> - <key>table</key> - <type>$type.table</type> - </param> - <param> - <name>Metric Type</name> - <key>metric_type</key> - <type>enum</type> - <option> - <name>Euclidean</name> - <key>digital.TRELLIS_EUCLIDEAN</key> - </option> - <option> - <name>Hard Symbol</name> - <key>digital.TRELLIS_HARD_SYMBOL</key> - </option> - <option> - <name>Hard Bit</name> - <key>digital.TRELLIS_HARD_BIT</key> - </option> - </param> - <sink> - <name>in</name> - <type>$type.io</type> - </sink> - <source> - <name>out</name> - <type>float</type> - </source> - <doc> -Generate metrics required for Viterbi or SISO algorithms. - </doc> -</block> diff --git a/gr-trellis/grc/trellis_pccc_decoder_combined_xx.block.yml b/gr-trellis/grc/trellis_pccc_decoder_combined_xx.block.yml new file mode 100644 index 0000000000..dbfe1ec31d --- /dev/null +++ b/gr-trellis/grc/trellis_pccc_decoder_combined_xx.block.yml @@ -0,0 +1,102 @@ +id: trellis_pccc_decoder_combined_xx +label: PCCC Decoder Combo +category: '[Core]/Trellis Coding' + +parameters: +- id: type + label: Input Type + dtype: enum + options: [c, f] + option_labels: [Complex, Float] + option_attributes: + io: [complex, float] + table: [complex_vector, real_vector] + hide: part +- id: out_type + label: Output Type + dtype: enum + options: [i, s, b] + option_labels: [Int, Short, Byte] + option_attributes: + io: [int, short, byte] + hide: part +- id: o_fsm_args + label: FSM 1 + dtype: raw +- id: o_init_state + label: Initial State 1 + dtype: int + default: '0' +- id: o_final_state + label: Final State 1 + dtype: int + default: '-1' +- id: i_fsm_args + label: FSM 2 + dtype: raw +- id: i_init_state + label: Initial State 2 + dtype: int + default: '0' +- id: i_final_state + label: Final State 2 + dtype: int + default: '-1' +- id: interleaver + label: Interleaver + dtype: raw +- id: block_size + label: Block Size + dtype: int +- id: iterations + label: Iterations + dtype: int + default: '10' +- id: dim + label: Dimensionality + dtype: int +- id: table + label: Constellation + dtype: ${ type.table } +- id: metric_type + label: Metric Type + dtype: enum + options: [digital.TRELLIS_EUCLIDEAN, digital.TRELLIS_HARD_SYMBOL, digital.TRELLIS_HARD_BIT] + option_labels: [Euclidean, Hard Symbol, Hard Bit] +- id: siso_type + label: SISO Type + dtype: enum + options: [trellis.TRELLIS_MIN_SUM, trellis.TRELLIS_SUM_PRODUCT] + option_labels: [Min Sum, Sum Product] +- id: scaling + label: Scaling + dtype: real + default: '1.0' + +inputs: +- domain: stream + dtype: ${ type.io } + +outputs: +- domain: stream + dtype: ${ out_type.io } + +asserts: +- ${ (isinstance(eval(""" o_fsm_args """[1:-1], locals(),globals()), str) and open(o_fsm_args).close()) or True } +- ${ (isinstance(eval(""" i_fsm_args """[1:-1], locals(),globals()), str) and open(i_fsm_args).close()) or True } + +templates: + imports: from gnuradio import trellis, digital + make: "trellis.pccc_decoder_combined_${type}${out_type}(\n trellis.fsm(${o_fsm_args}),\ + \ ${o_init_state}, ${o_final_state},\n trellis.fsm(${i_fsm_args}), ${i_init_state},\ + \ ${i_final_state},\n trellis.interleaver(${interleaver}),\n ${block_size},\n\ + \ ${iterations},\n ${siso_type},\n ${dim}, ${table}, ${metric_type},\n\ + \ ${scaling})\n " + callbacks: + - set_scaling(${scaling}) + +documentation: |- + PCCC turbo Decoder combined with metric calculation. + The fsm arguments are passed directly to the trellis.fsm() constructor. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_pccc_decoder_combined_xx.xml b/gr-trellis/grc/trellis_pccc_decoder_combined_xx.xml deleted file mode 100644 index 7bb38db893..0000000000 --- a/gr-trellis/grc/trellis_pccc_decoder_combined_xx.xml +++ /dev/null @@ -1,172 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -## PCCC Decoder Combined -################################################### - --> - - -<block> - <name>PCCC Decoder Combo</name> - <key>trellis_pccc_decoder_combined_xx</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis, digital</import> - <make>trellis.pccc_decoder_combined_$(type)$(out_type)( - trellis.fsm($o_fsm_args), $o_init_state, $o_final_state, - trellis.fsm($i_fsm_args), $i_init_state, $i_final_state, - trellis.interleaver($interleaver), - $block_size, - $iterations, - $siso_type, - $dim, $table, $metric_type, - $scaling) - </make> - <callback>set_scaling($scaling)</callback> - <param> - <name>Input Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>c</key> - <opt>io:complex</opt> - <opt>table:complex_vector</opt> - </option> - <option> - <name>Float</name> - <key>f</key> - <opt>io:float</opt> - <opt>table:real_vector</opt> - </option> - </param> - <param> - <name>Output Type</name> - <key>out_type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>i</key> - <opt>io:int</opt> - </option> - <option> - <name>Short</name> - <key>s</key> - <opt>io:short</opt> - </option> - <option> - <name>Byte</name> - <key>b</key> - <opt>io:byte</opt> - </option> - </param> - <param> - <name>FSM 1</name> - <key>o_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Initial State 1</name> - <key>o_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Final State 1</name> - <key>o_final_state</key> - <value>-1</value> - <type>int</type> - </param> - <param> - <name>FSM 2</name> - <key>i_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Initial State 2</name> - <key>i_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Final State 2</name> - <key>i_final_state</key> - <value>-1</value> - <type>int</type> - </param> - <param> - <name>Interleaver</name> - <key>interleaver</key> - <type>raw</type> - </param> - <param> - <name>Block Size</name> - <key>block_size</key> - <type>int</type> - </param> - <param> - <name>Iterations</name> - <key>iterations</key> - <value>10</value> - <type>int</type> - </param> - <param> - <name>Dimensionality</name> - <key>dim</key> - <type>int</type> - </param> - <param> - <name>Constellation</name> - <key>table</key> - <type>$type.table</type> - </param> - <param> - <name>Metric Type</name> - <key>metric_type</key> - <type>enum</type> - <option> - <name>Euclidean</name> - <key>digital.TRELLIS_EUCLIDEAN</key> - </option> - <option> - <name>Hard Symbol</name> - <key>digital.TRELLIS_HARD_SYMBOL</key> - </option> - <option> - <name>Hard Bit</name> - <key>digital.TRELLIS_HARD_BIT</key> - </option> - </param> - <param> - <name>SISO Type</name> - <key>siso_type</key> - <type>enum</type> - <option> - <name>Min Sum</name> - <key>trellis.TRELLIS_MIN_SUM</key> - </option> - <option> - <name>Sum Product</name> - <key>trellis.TRELLIS_SUM_PRODUCT</key> - </option> - </param> - <param> - <name>Scaling</name> - <key>scaling</key> - <value>1.0</value> - <type>real</type> - </param> - <check>(isinstance(eval(""" $o_fsm_args """[1:-1], locals(),globals()), str) and open($o_fsm_args).close()) or True</check> - <check>(isinstance(eval(""" $i_fsm_args """[1:-1], locals(),globals()), str) and open($i_fsm_args).close()) or True </check> - <sink> - <name>in</name> - <type>$type.io</type> - </sink> - <source> - <name>out</name> - <type>$out_type.io</type> - </source> - <doc> -PCCC turbo Decoder combined with metric calculation. -The fsm arguments are passed directly to the trellis.fsm() constructor. - </doc> -</block> diff --git a/gr-trellis/grc/trellis_pccc_decoder_x.block.yml b/gr-trellis/grc/trellis_pccc_decoder_x.block.yml new file mode 100644 index 0000000000..f49ec91a70 --- /dev/null +++ b/gr-trellis/grc/trellis_pccc_decoder_x.block.yml @@ -0,0 +1,75 @@ +id: trellis_pccc_decoder_x +label: PCCC Decoder +category: '[Core]/Trellis Coding' + +parameters: +- id: out_type + label: Output Type + dtype: enum + options: [i, s, b] + option_labels: [Int, Short, Byte] + option_attributes: + io: [int, short, byte] + hide: part +- id: o_fsm_args + label: FSM 1 + dtype: raw +- id: o_init_state + label: Initial State 1 + dtype: int + default: '0' +- id: o_final_state + label: Final State 1 + dtype: int + default: '-1' +- id: i_fsm_args + label: FSM 2 + dtype: raw +- id: i_init_state + label: Initial State 2 + dtype: int + default: '0' +- id: i_final_state + label: Final State 2 + dtype: int + default: '-1' +- id: interleaver + label: Interleaver + dtype: raw +- id: block_size + label: Block Size + dtype: int +- id: iterations + label: Iterations + dtype: int + default: '10' +- id: siso_type + label: SISO Type + dtype: enum + options: [trellis.TRELLIS_MIN_SUM, trellis.TRELLIS_SUM_PRODUCT] + option_labels: [Min Sum, Sum Product] + +inputs: +- domain: stream + dtype: float + +outputs: +- domain: stream + dtype: ${ out_type.io } + +asserts: +- ${ (isinstance(eval(""" o_fsm_args """[1:-1], locals(),globals()), str) and open(o_fsm_args).close()) or True } +- ${ (isinstance(eval(""" i_fsm_args """[1:-1], locals(),globals()), str) and open(i_fsm_args).close()) or True } + +templates: + imports: from gnuradio import trellis + make: "trellis.pccc_decoder_${out_type}(\n trellis.fsm(${o_fsm_args}), ${o_init_state},\ + \ ${o_final_state},\n trellis.fsm(${i_fsm_args}), ${i_init_state}, ${i_final_state},\n\ + \ trellis.interleaver(${interleaver}),\n ${block_size},\n ${iterations},\n\ + \ ${siso_type})\n " + +documentation: |- + PCCC turbo Decoder. + The fsm and interleaver arguments are passed directly to the trellis.fsm() and trellis.interleaver() constructors. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_pccc_decoder_x.xml b/gr-trellis/grc/trellis_pccc_decoder_x.xml deleted file mode 100644 index 08d1f526af..0000000000 --- a/gr-trellis/grc/trellis_pccc_decoder_x.xml +++ /dev/null @@ -1,119 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -## PCCC Decoder -################################################### - --> - - -<block> - <name>PCCC Decoder</name> - <key>trellis_pccc_decoder_x</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis</import> - <make>trellis.pccc_decoder_$(out_type)( - trellis.fsm($o_fsm_args), $o_init_state, $o_final_state, - trellis.fsm($i_fsm_args), $i_init_state, $i_final_state, - trellis.interleaver($interleaver), - $block_size, - $iterations, - $siso_type) - </make> - <param> - <name>Output Type</name> - <key>out_type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>i</key> - <opt>io:int</opt> - </option> - <option> - <name>Short</name> - <key>s</key> - <opt>io:short</opt> - </option> - <option> - <name>Byte</name> - <key>b</key> - <opt>io:byte</opt> - </option> - </param> - <param> - <name>FSM 1</name> - <key>o_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Initial State 1</name> - <key>o_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Final State 1</name> - <key>o_final_state</key> - <value>-1</value> - <type>int</type> - </param> - <param> - <name>FSM 2</name> - <key>i_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Initial State 2</name> - <key>i_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Final State 2</name> - <key>i_final_state</key> - <value>-1</value> - <type>int</type> - </param> - <param> - <name>Interleaver</name> - <key>interleaver</key> - <type>raw</type> - </param> - <param> - <name>Block Size</name> - <key>block_size</key> - <type>int</type> - </param> - <param> - <name>Iterations</name> - <key>iterations</key> - <value>10</value> - <type>int</type> - </param> - <param> - <name>SISO Type</name> - <key>siso_type</key> - <type>enum</type> - <option> - <name>Min Sum</name> - <key>trellis.TRELLIS_MIN_SUM</key> - </option> - <option> - <name>Sum Product</name> - <key>trellis.TRELLIS_SUM_PRODUCT</key> - </option> - </param> - <check>(isinstance(eval(""" $o_fsm_args """[1:-1], locals(),globals()), str) and open($o_fsm_args).close()) or True</check> - <check>(isinstance(eval(""" $i_fsm_args """[1:-1], locals(),globals()), str) and open($i_fsm_args).close()) or True </check> - <sink> - <name>in</name> - <type>float</type> - </sink> - <source> - <name>out</name> - <type>$out_type.io</type> - </source> - <doc> -PCCC turbo Decoder. -The fsm and interleaver arguments are passed directly to the trellis.fsm() and trellis.interleaver() constructors. - </doc> -</block> diff --git a/gr-trellis/grc/trellis_pccc_encoder_xx.block.yml b/gr-trellis/grc/trellis_pccc_encoder_xx.block.yml new file mode 100644 index 0000000000..4bc2f10b3b --- /dev/null +++ b/gr-trellis/grc/trellis_pccc_encoder_xx.block.yml @@ -0,0 +1,58 @@ +id: trellis_pccc_encoder_xx +label: PCCC Encoder +category: '[Core]/Trellis Coding' + +parameters: +- id: type + label: Type + dtype: enum + options: [bb, bs, bi, ss, si, ii] + option_labels: [Byte->Byte, Byte->Short, Byte->Int, Short->Short, Short->Int, + Int->Int] + option_attributes: + input: [byte, byte, byte, short, short, int] + output: [byte, short, int, short, int, int] + hide: part +- id: o_fsm_args + label: FSM 1 + dtype: raw +- id: o_init_state + label: Initial State 1 + dtype: int + default: '0' +- id: i_fsm_args + label: FSM 2 + dtype: raw +- id: i_init_state + label: Initial State 2 + dtype: int + default: '0' +- id: interleaver_args + label: Interleaver + dtype: raw +- id: bl + label: Blocklength + dtype: int + +inputs: +- domain: stream + dtype: ${ type.input } + +outputs: +- domain: stream + dtype: ${ type.output } + +asserts: +- ${ (isinstance(eval(""" o_fsm_args """[1:-1], locals(),globals()), str) and open(o_fsm_args).close()) or True } +- ${ (isinstance(eval(""" i_fsm_args """[1:-1], locals(),globals()), str) and open(i_fsm_args).close()) or True } + +templates: + imports: from gnuradio import trellis + make: trellis.pccc_encoder_${type}(trellis.fsm(${o_fsm_args}), ${o_init_state}, + trellis.fsm(${i_fsm_args}), ${i_init_state}, trellis.interleaver(${interleaver_args}), + ${bl}) + +documentation: |- + The fsm and interleaver arguments are passed directly to the trellis.fsm() and trellis.interleaver() constructors. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_pccc_encoder_xx.xml b/gr-trellis/grc/trellis_pccc_encoder_xx.xml deleted file mode 100644 index 85348e6e9b..0000000000 --- a/gr-trellis/grc/trellis_pccc_encoder_xx.xml +++ /dev/null @@ -1,100 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -## PCCC Encoder -################################################### - --> - -<block> - <name>PCCC Encoder</name> - <key>trellis_pccc_encoder_xx</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis</import> - <make>trellis.pccc_encoder_$(type)(trellis.fsm($o_fsm_args), $o_init_state, trellis.fsm($i_fsm_args), $i_init_state, trellis.interleaver($interleaver_args), $bl)</make> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Byte->Byte</name> - <key>bb</key> - <opt>input:byte</opt> - <opt>output:byte</opt> - </option> - <option> - <name>Byte->Short</name> - <key>bs</key> - <opt>input:byte</opt> - <opt>output:short</opt> - </option> - <option> - <name>Byte->Int</name> - <key>bi</key> - <opt>input:byte</opt> - <opt>output:int</opt> - </option> - <option> - <name>Short->Short</name> - <key>ss</key> - <opt>input:short</opt> - <opt>output:short</opt> - </option> - <option> - <name>Short->Int</name> - <key>si</key> - <opt>input:short</opt> - <opt>output:int</opt> - </option> - <option> - <name>Int->Int</name> - <key>ii</key> - <opt>input:int</opt> - <opt>output:int</opt> - </option> - </param> - <param> - <name>FSM 1</name> - <key>o_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Initial State 1</name> - <key>o_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>FSM 2</name> - <key>i_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Initial State 2</name> - <key>i_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Interleaver</name> - <key>interleaver_args</key> - <type>raw</type> - </param> - <param> - <name>Blocklength</name> - <key>bl</key> - <type>int</type> - </param> - <check>(isinstance(eval(""" $o_fsm_args """[1:-1], locals(),globals()), str) and open($o_fsm_args).close()) or True</check> - <check>(isinstance(eval(""" $i_fsm_args """[1:-1], locals(),globals()), str) and open($i_fsm_args).close()) or True </check> - <sink> - <name>in</name> - <type>$type.input</type> - </sink> - <source> - <name>out</name> - <type>$type.output</type> - </source> - <doc> -The fsm and interleaver arguments are passed directly to the trellis.fsm() and trellis.interleaver() constructors. - </doc> -</block> diff --git a/gr-trellis/grc/trellis_permutation.block.yml b/gr-trellis/grc/trellis_permutation.block.yml new file mode 100644 index 0000000000..2dba671448 --- /dev/null +++ b/gr-trellis/grc/trellis_permutation.block.yml @@ -0,0 +1,54 @@ +id: trellis_permutation +label: Trellis Permutation +category: '[Core]/Trellis Coding' + +parameters: +- id: type + label: Type + dtype: enum + options: [complex, float, int, short, byte] + option_attributes: + size: [gr.sizeof_gr_complex, gr.sizeof_float, gr.sizeof_int, gr.sizeof_short, + gr.sizeof_char] + hide: part +- id: interleaver_size + label: Interleaver Size + dtype: int +- id: table + label: Table + dtype: int_vector +- id: syms_per_block + label: Symbols per Block + dtype: int +- id: vlen + label: Vec Length + dtype: int + default: '1' + hide: ${ 'part' if vlen == 1 else 'none' } + +inputs: +- domain: stream + dtype: ${ type } + vlen: ${ vlen } + +outputs: +- domain: stream + dtype: ${ type } + vlen: ${ vlen } + +asserts: +- ${ vlen > 0 } + +templates: + imports: from gnuradio import trellis + make: trellis.permutation(${interleaver_size}, ${table}, ${syms_per_block}, ${type.size}*${vlen}) + callbacks: + - set_K(${interleaver_size}) + - set_TABLE(${table}) + - set_SYMS_PER_BLOCK(${syms_per_block}) + +documentation: |- + Interleaver size is given in blocks. + One Symbol = (in/out type) * (vector length) + +file_format: 1 diff --git a/gr-trellis/grc/trellis_permutation.xml b/gr-trellis/grc/trellis_permutation.xml deleted file mode 100644 index 99eb2d291c..0000000000 --- a/gr-trellis/grc/trellis_permutation.xml +++ /dev/null @@ -1,85 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Trellis Permutation -################################################### - --> - - -<block> - <name>Trellis Permutation</name> - <key>trellis_permutation</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis</import> - <make>trellis.permutation($interleaver_size, $table, $syms_per_block, $type.size*$vlen)</make> - <callback>set_K($interleaver_size)</callback> - <callback>set_TABLE($table)</callback> - <callback>set_SYMS_PER_BLOCK($syms_per_block)</callback> - - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Interleaver Size</name> - <key>interleaver_size</key> - <type>int</type> - </param> - <param> - <name>Table</name> - <key>table</key> - <type>int_vector</type> - </param> - <param> - <name>Symbols per Block</name> - <key>syms_per_block</key> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> - <doc> -Interleaver size is given in blocks. -One Symbol = (in/out type) * (vector length) - </doc> -</block> diff --git a/gr-trellis/grc/trellis_sccc_decoder_combined_xx.block.yml b/gr-trellis/grc/trellis_sccc_decoder_combined_xx.block.yml new file mode 100644 index 0000000000..441d9593b8 --- /dev/null +++ b/gr-trellis/grc/trellis_sccc_decoder_combined_xx.block.yml @@ -0,0 +1,102 @@ +id: trellis_sccc_decoder_combined_xx +label: SCCC Decoder Combo +category: '[Core]/Trellis Coding' + +parameters: +- id: type + label: Input Type + dtype: enum + options: [c, f] + option_labels: [Complex, Float] + option_attributes: + io: [complex, float] + table: [complex_vector, real_vector] + hide: part +- id: out_type + label: Output Type + dtype: enum + options: [i, s, b] + option_labels: [Int, Short, Byte] + option_attributes: + io: [int, short, byte] + hide: part +- id: o_fsm_args + label: Outer FSM + dtype: raw +- id: o_init_state + label: Outer Initial State + dtype: int + default: '0' +- id: o_final_state + label: Outer Final State + dtype: int + default: '-1' +- id: i_fsm_args + label: Inner FSM + dtype: raw +- id: i_init_state + label: Inner Initial State + dtype: int + default: '0' +- id: i_final_state + label: Inner Final State + dtype: int + default: '-1' +- id: interleaver + label: Interleaver + dtype: raw +- id: block_size + label: Block Size + dtype: int +- id: iterations + label: Iterations + dtype: int + default: '10' +- id: dim + label: Dimensionality + dtype: int +- id: table + label: Constellation + dtype: ${ type.table } +- id: metric_type + label: Metric Type + dtype: enum + options: [digital.TRELLIS_EUCLIDEAN, digital.TRELLIS_HARD_SYMBOL, digital.TRELLIS_HARD_BIT] + option_labels: [Euclidean, Hard Symbol, Hard Bit] +- id: siso_type + label: SISO Type + dtype: enum + options: [trellis.TRELLIS_MIN_SUM, trellis.TRELLIS_SUM_PRODUCT] + option_labels: [Min Sum, Sum Product] +- id: scaling + label: Scaling + dtype: real + default: '1.0' + +inputs: +- domain: stream + dtype: ${ type.io } + +outputs: +- domain: stream + dtype: ${ out_type.io } + +asserts: +- ${ (isinstance(eval(""" o_fsm_args """[1:-1], locals(),globals()), str) and open(o_fsm_args).close()) or True } +- ${ (isinstance(eval(""" i_fsm_args """[1:-1], locals(),globals()), str) and open(i_fsm_args).close()) or True } + +templates: + imports: from gnuradio import trellis, digital + make: "trellis.sccc_decoder_combined_${type}${out_type}(\n trellis.fsm(${o_fsm_args}),\ + \ ${o_init_state}, ${o_final_state},\n trellis.fsm(${i_fsm_args}), ${i_init_state},\ + \ ${i_final_state},\n trellis.interleaver(${interleaver}),\n ${block_size},\n\ + \ ${iterations},\n ${siso_type},\n ${dim}, ${table},\ + \ ${metric_type},\n ${scaling})\n " + callbacks: + - set_scaling(${scaling}) + +documentation: |- + SCCC turbo Decoder combined with metric calculation. + The fsm arguments are passed directly to the trellis.fsm() constructor. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_sccc_decoder_combined_xx.xml b/gr-trellis/grc/trellis_sccc_decoder_combined_xx.xml deleted file mode 100644 index 79be0b8b5d..0000000000 --- a/gr-trellis/grc/trellis_sccc_decoder_combined_xx.xml +++ /dev/null @@ -1,172 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -## SCCC Decoder Combined -################################################### - --> - - -<block> - <name>SCCC Decoder Combo</name> - <key>trellis_sccc_decoder_combined_xx</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis, digital</import> - <make>trellis.sccc_decoder_combined_$(type)$(out_type)( - trellis.fsm($o_fsm_args), $o_init_state, $o_final_state, - trellis.fsm($i_fsm_args), $i_init_state, $i_final_state, - trellis.interleaver($interleaver), - $block_size, - $iterations, - $siso_type, - $dim, $table, $metric_type, - $scaling) - </make> - <callback>set_scaling($scaling)</callback> - <param> - <name>Input Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>c</key> - <opt>io:complex</opt> - <opt>table:complex_vector</opt> - </option> - <option> - <name>Float</name> - <key>f</key> - <opt>io:float</opt> - <opt>table:real_vector</opt> - </option> - </param> - <param> - <name>Output Type</name> - <key>out_type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>i</key> - <opt>io:int</opt> - </option> - <option> - <name>Short</name> - <key>s</key> - <opt>io:short</opt> - </option> - <option> - <name>Byte</name> - <key>b</key> - <opt>io:byte</opt> - </option> - </param> - <param> - <name>Outer FSM</name> - <key>o_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Outer Initial State</name> - <key>o_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Outer Final State</name> - <key>o_final_state</key> - <value>-1</value> - <type>int</type> - </param> - <param> - <name>Inner FSM</name> - <key>i_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Inner Initial State</name> - <key>i_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Inner Final State</name> - <key>i_final_state</key> - <value>-1</value> - <type>int</type> - </param> - <param> - <name>Interleaver</name> - <key>interleaver</key> - <type>raw</type> - </param> - <param> - <name>Block Size</name> - <key>block_size</key> - <type>int</type> - </param> - <param> - <name>Iterations</name> - <key>iterations</key> - <value>10</value> - <type>int</type> - </param> - <param> - <name>Dimensionality</name> - <key>dim</key> - <type>int</type> - </param> - <param> - <name>Constellation</name> - <key>table</key> - <type>$type.table</type> - </param> - <param> - <name>Metric Type</name> - <key>metric_type</key> - <type>enum</type> - <option> - <name>Euclidean</name> - <key>digital.TRELLIS_EUCLIDEAN</key> - </option> - <option> - <name>Hard Symbol</name> - <key>digital.TRELLIS_HARD_SYMBOL</key> - </option> - <option> - <name>Hard Bit</name> - <key>digital.TRELLIS_HARD_BIT</key> - </option> - </param> - <param> - <name>SISO Type</name> - <key>siso_type</key> - <type>enum</type> - <option> - <name>Min Sum</name> - <key>trellis.TRELLIS_MIN_SUM</key> - </option> - <option> - <name>Sum Product</name> - <key>trellis.TRELLIS_SUM_PRODUCT</key> - </option> - </param> - <param> - <name>Scaling</name> - <key>scaling</key> - <value>1.0</value> - <type>real</type> - </param> - <check>(isinstance(eval(""" $o_fsm_args """[1:-1], locals(),globals()), str) and open($o_fsm_args).close()) or True</check> - <check>(isinstance(eval(""" $i_fsm_args """[1:-1], locals(),globals()), str) and open($i_fsm_args).close()) or True </check> - <sink> - <name>in</name> - <type>$type.io</type> - </sink> - <source> - <name>out</name> - <type>$out_type.io</type> - </source> - <doc> -SCCC turbo Decoder combined with metric calculation. -The fsm arguments are passed directly to the trellis.fsm() constructor. - </doc> -</block> diff --git a/gr-trellis/grc/trellis_sccc_decoder_x.block.yml b/gr-trellis/grc/trellis_sccc_decoder_x.block.yml new file mode 100644 index 0000000000..794115d48a --- /dev/null +++ b/gr-trellis/grc/trellis_sccc_decoder_x.block.yml @@ -0,0 +1,75 @@ +id: trellis_sccc_decoder_x +label: SCCC Decoder +category: '[Core]/Trellis Coding' + +parameters: +- id: out_type + label: Output Type + dtype: enum + options: [i, s, b] + option_labels: [Int, Short, Byte] + option_attributes: + io: [int, short, byte] + hide: part +- id: o_fsm_args + label: Outer FSM + dtype: raw +- id: o_init_state + label: Outer Initial State + dtype: int + default: '0' +- id: o_final_state + label: Outer Final State + dtype: int + default: '-1' +- id: i_fsm_args + label: Inner FSM + dtype: raw +- id: i_init_state + label: Inner Initial State + dtype: int + default: '0' +- id: i_final_state + label: Inner Final State + dtype: int + default: '-1' +- id: interleaver + label: Interleaver + dtype: raw +- id: block_size + label: Block Size + dtype: int +- id: iterations + label: Iterations + dtype: int + default: '10' +- id: siso_type + label: SISO Type + dtype: enum + options: [trellis.TRELLIS_MIN_SUM, trellis.TRELLIS_SUM_PRODUCT] + option_labels: [Min Sum, Sum Product] + +inputs: +- domain: stream + dtype: float + +outputs: +- domain: stream + dtype: ${ out_type.io } + +asserts: +- ${ (isinstance(eval(""" o_fsm_args """[1:-1], locals(),globals()), str) and open(o_fsm_args).close()) or True } +- ${ (isinstance(eval(""" i_fsm_args """[1:-1], locals(),globals()), str) and open(i_fsm_args).close()) or True } + +templates: + imports: from gnuradio import trellis + make: "trellis.sccc_decoder_${out_type}(\n trellis.fsm(${o_fsm_args}), ${o_init_state},\ + \ ${o_final_state},\n trellis.fsm(${i_fsm_args}), ${i_init_state}, ${i_final_state},\n\ + \ trellis.interleaver(${interleaver}),\n ${block_size},\n ${iterations},\n\ + \ ${siso_type})\n " + +documentation: |- + SCCC turbo Decoder. + The fsm and interleaver arguments are passed directly to the trellis.fsm() and trellis.interleaver() constructors. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_sccc_decoder_x.xml b/gr-trellis/grc/trellis_sccc_decoder_x.xml deleted file mode 100644 index 584ff0b0af..0000000000 --- a/gr-trellis/grc/trellis_sccc_decoder_x.xml +++ /dev/null @@ -1,119 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -## SCCC Decoder -################################################### - --> - - -<block> - <name>SCCC Decoder</name> - <key>trellis_sccc_decoder_x</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis</import> - <make>trellis.sccc_decoder_$(out_type)( - trellis.fsm($o_fsm_args), $o_init_state, $o_final_state, - trellis.fsm($i_fsm_args), $i_init_state, $i_final_state, - trellis.interleaver($interleaver), - $block_size, - $iterations, - $siso_type) - </make> - <param> - <name>Output Type</name> - <key>out_type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>i</key> - <opt>io:int</opt> - </option> - <option> - <name>Short</name> - <key>s</key> - <opt>io:short</opt> - </option> - <option> - <name>Byte</name> - <key>b</key> - <opt>io:byte</opt> - </option> - </param> - <param> - <name>Outer FSM</name> - <key>o_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Outer Initial State</name> - <key>o_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Outer Final State</name> - <key>o_final_state</key> - <value>-1</value> - <type>int</type> - </param> - <param> - <name>Inner FSM</name> - <key>i_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Inner Initial State</name> - <key>i_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Inner Final State</name> - <key>i_final_state</key> - <value>-1</value> - <type>int</type> - </param> - <param> - <name>Interleaver</name> - <key>interleaver</key> - <type>raw</type> - </param> - <param> - <name>Block Size</name> - <key>block_size</key> - <type>int</type> - </param> - <param> - <name>Iterations</name> - <key>iterations</key> - <value>10</value> - <type>int</type> - </param> - <param> - <name>SISO Type</name> - <key>siso_type</key> - <type>enum</type> - <option> - <name>Min Sum</name> - <key>trellis.TRELLIS_MIN_SUM</key> - </option> - <option> - <name>Sum Product</name> - <key>trellis.TRELLIS_SUM_PRODUCT</key> - </option> - </param> - <check>(isinstance(eval(""" $o_fsm_args """[1:-1], locals(),globals()), str) and open($o_fsm_args).close()) or True</check> - <check>(isinstance(eval(""" $i_fsm_args """[1:-1], locals(),globals()), str) and open($i_fsm_args).close()) or True </check> - <sink> - <name>in</name> - <type>float</type> - </sink> - <source> - <name>out</name> - <type>$out_type.io</type> - </source> - <doc> -SCCC turbo Decoder. -The fsm and interleaver arguments are passed directly to the trellis.fsm() and trellis.interleaver() constructors. - </doc> -</block> diff --git a/gr-trellis/grc/trellis_sccc_encoder_xx.block.yml b/gr-trellis/grc/trellis_sccc_encoder_xx.block.yml new file mode 100644 index 0000000000..5068af38ff --- /dev/null +++ b/gr-trellis/grc/trellis_sccc_encoder_xx.block.yml @@ -0,0 +1,58 @@ +id: trellis_sccc_encoder_xx +label: SCCC Encoder +category: '[Core]/Trellis Coding' + +parameters: +- id: type + label: Type + dtype: enum + options: [bb, bs, bi, ss, si, ii] + option_labels: [Byte->Byte, Byte->Short, Byte->Int, Short->Short, Short->Int, + Int->Int] + option_attributes: + input: [byte, byte, byte, short, short, int] + output: [byte, short, int, short, int, int] + hide: part +- id: o_fsm_args + label: Outer FSM + dtype: raw +- id: o_init_state + label: Outer Initial State + dtype: int + default: '0' +- id: i_fsm_args + label: Inner FSM + dtype: raw +- id: i_init_state + label: Inner Initial State + dtype: int + default: '0' +- id: interleaver_args + label: Interleaver + dtype: raw +- id: bl + label: Blocklength + dtype: int + +inputs: +- domain: stream + dtype: ${ type.input } + +outputs: +- domain: stream + dtype: ${ type.output } + +asserts: +- ${ (isinstance(eval(""" o_fsm_args """[1:-1], locals(),globals()), str) and open(o_fsm_args).close()) or True } +- ${ (isinstance(eval(""" i_fsm_args """[1:-1], locals(),globals()), str) and open(i_fsm_args).close()) or True } + +templates: + imports: from gnuradio import trellis + make: trellis.sccc_encoder_${type}(trellis.fsm(${o_fsm_args}), ${o_init_state}, + trellis.fsm(${i_fsm_args}), ${i_init_state}, trellis.interleaver(${interleaver_args}), + ${bl}) + +documentation: |- + The fsm and interleaver arguments are passed directly to the trellis.fsm() and trellis.interleaver() constructors. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_sccc_encoder_xx.xml b/gr-trellis/grc/trellis_sccc_encoder_xx.xml deleted file mode 100644 index 7b4ab30c75..0000000000 --- a/gr-trellis/grc/trellis_sccc_encoder_xx.xml +++ /dev/null @@ -1,100 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##SCCC Encoder -################################################### - --> - -<block> - <name>SCCC Encoder</name> - <key>trellis_sccc_encoder_xx</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis</import> - <make>trellis.sccc_encoder_$(type)(trellis.fsm($o_fsm_args), $o_init_state, trellis.fsm($i_fsm_args), $i_init_state, trellis.interleaver($interleaver_args), $bl)</make> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Byte->Byte</name> - <key>bb</key> - <opt>input:byte</opt> - <opt>output:byte</opt> - </option> - <option> - <name>Byte->Short</name> - <key>bs</key> - <opt>input:byte</opt> - <opt>output:short</opt> - </option> - <option> - <name>Byte->Int</name> - <key>bi</key> - <opt>input:byte</opt> - <opt>output:int</opt> - </option> - <option> - <name>Short->Short</name> - <key>ss</key> - <opt>input:short</opt> - <opt>output:short</opt> - </option> - <option> - <name>Short->Int</name> - <key>si</key> - <opt>input:short</opt> - <opt>output:int</opt> - </option> - <option> - <name>Int->Int</name> - <key>ii</key> - <opt>input:int</opt> - <opt>output:int</opt> - </option> - </param> - <param> - <name>Outer FSM</name> - <key>o_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Outer Initial State</name> - <key>o_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Inner FSM</name> - <key>i_fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Inner Initial State</name> - <key>i_init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Interleaver</name> - <key>interleaver_args</key> - <type>raw</type> - </param> - <param> - <name>Blocklength</name> - <key>bl</key> - <type>int</type> - </param> - <check>(isinstance(eval(""" $o_fsm_args """[1:-1], locals(),globals()), str) and open($o_fsm_args).close()) or True</check> - <check>(isinstance(eval(""" $i_fsm_args """[1:-1], locals(),globals()), str) and open($i_fsm_args).close()) or True </check> - <sink> - <name>in</name> - <type>$type.input</type> - </sink> - <source> - <name>out</name> - <type>$type.output</type> - </source> - <doc> -The fsm and interleaver arguments are passed directly to the trellis.fsm() and trellis.interleaver() constructors. - </doc> -</block> diff --git a/gr-trellis/grc/trellis_siso_combined_f.block.yml b/gr-trellis/grc/trellis_siso_combined_f.block.yml new file mode 100644 index 0000000000..0a10dc14d3 --- /dev/null +++ b/gr-trellis/grc/trellis_siso_combined_f.block.yml @@ -0,0 +1,79 @@ +id: trellis_siso_combined_f +label: SISO Combo +category: '[Core]/Trellis Coding' + +parameters: +- id: fsm_args + label: FSM Args + dtype: raw +- id: block_size + label: Block Size + dtype: int +- id: init_state + label: Initial State + dtype: int + default: '0' +- id: final_state + label: Final State + dtype: int + default: '-1' +- id: a_post_in + label: A-posteriori In + dtype: enum + options: ['True', 'False'] + option_labels: ['Yes', 'No'] +- id: a_post_out + label: A-posteriori Out + dtype: enum + options: ['True', 'False'] + option_labels: ['Yes', 'No'] +- id: siso_type + label: SISO Type + dtype: enum + options: [trellis.TRELLIS_MIN_SUM, trellis.TRELLIS_SUM_PRODUCT] + option_labels: [Min Sum, Sum Product] +- id: dim + label: Dimensionality + dtype: int +- id: table + label: Constellation + dtype: real_vector +- id: metric_type + label: Metric Type + dtype: enum + options: [trellis.TRELLIS_EUCLIDEAN, trellis.TRELLIS_HARD_SYMBOL, trellis.TRELLIS_HARD_BIT] + option_labels: [Euclidean, Hard Symbol, Hard Bit] + +inputs: +- label: in_i + domain: stream + dtype: float +- label: in_o + domain: stream + dtype: float + +outputs: +- domain: stream + dtype: float + +templates: + imports: from gnuradio import trellis + make: trellis.siso_combined_f(trellis.fsm(${fsm_args}), ${block_size}, ${init_state}, + ${final_state}, ${a_post_in}, ${a_post_out}, ${siso_type}, ${dim}, ${table}, + ${metric_type}) + callbacks: + - set_FSM(trellis.fsm(${fsm_args})) + - set_K(${block_size}) + - set_S0(${init_state}) + - set_SK(${final_state}) + - set_POSTI(${a_post_in}) + - set_POSTO(${a_post_out}) + - set_SISO_TYPE(${siso_type}) + - set_D(${dim}) + - set_TABLE(${table}) + - set_TYPE(${metric_type}) + +documentation: |- + BCJR Algorithm combined with metric calculation. The fsm arguments are passed directly to the trellis.fsm() constructor. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_siso_combined_f.xml b/gr-trellis/grc/trellis_siso_combined_f.xml deleted file mode 100644 index f8ec9c2d21..0000000000 --- a/gr-trellis/grc/trellis_siso_combined_f.xml +++ /dev/null @@ -1,129 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Trellis SISO Combined -################################################### - --> - - -<block> - <name>SISO Combo</name> - <key>trellis_siso_combined_f</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis</import> - <make>trellis.siso_combined_f(trellis.fsm($fsm_args), $block_size, $init_state, $final_state, $a_post_in, $a_post_out, $siso_type, $dim, $table, $metric_type)</make> - <callback>set_FSM(trellis.fsm($fsm_args))</callback> - <callback>set_K($block_size)</callback> - <callback>set_S0($init_state)</callback> - <callback>set_SK($final_state)</callback> - <callback>set_POSTI($a_post_in)</callback> - <callback>set_POSTO($a_post_out)</callback> - <callback>set_SISO_TYPE($siso_type)</callback> - <callback>set_D($dim)</callback> - <callback>set_TABLE($table)</callback> - <callback>set_TYPE($metric_type)</callback> - <param> - <name>FSM Args</name> - <key>fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Block Size</name> - <key>block_size</key> - <type>int</type> - </param> - <param> - <name>Initial State</name> - <key>init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Final State</name> - <key>final_state</key> - <value>-1</value> - <type>int</type> - </param> - <param> - <name>A-posteriori In</name> - <key>a_post_in</key> - <type>enum</type> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - <param> - <name>A-posteriori Out</name> - <key>a_post_out</key> - <type>enum</type> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - <param> - <name>SISO Type</name> - <key>siso_type</key> - <type>enum</type> - <option> - <name>Min Sum</name> - <key>trellis.TRELLIS_MIN_SUM</key> - </option> - <option> - <name>Sum Product</name> - <key>trellis.TRELLIS_SUM_PRODUCT</key> - </option> - </param> - <param> - <name>Dimensionality</name> - <key>dim</key> - <type>int</type> - </param> - <param> - <name>Constellation</name> - <key>table</key> - <type>real_vector</type> - </param> - <param> - <name>Metric Type</name> - <key>metric_type</key> - <type>enum</type> - <option> - <name>Euclidean</name> - <key>trellis.TRELLIS_EUCLIDEAN</key> - </option> - <option> - <name>Hard Symbol</name> - <key>trellis.TRELLIS_HARD_SYMBOL</key> - </option> - <option> - <name>Hard Bit</name> - <key>trellis.TRELLIS_HARD_BIT</key> - </option> - </param> - <sink> - <name>in_i</name> - <type>float</type> - </sink> - <sink> - <name>in_o</name> - <type>float</type> - </sink> - <source> - <name>out</name> - <type>float</type> - </source> - <doc> -BCJR Algorithm combined with metric calculation. \ -The fsm arguments are passed directly to the trellis.fsm() constructor. - </doc> -</block> diff --git a/gr-trellis/grc/trellis_siso_f.block.yml b/gr-trellis/grc/trellis_siso_f.block.yml new file mode 100644 index 0000000000..5687dee4ea --- /dev/null +++ b/gr-trellis/grc/trellis_siso_f.block.yml @@ -0,0 +1,67 @@ +id: trellis_siso_f +label: SISO +category: '[Core]/Trellis Coding' + +parameters: +- id: fsm_args + label: FSM Args + dtype: raw +- id: block_size + label: Block Size + dtype: int +- id: init_state + label: Initial State + dtype: int + default: '0' +- id: final_state + label: Final State + dtype: int + default: '-1' +- id: a_post_in + label: A-posteriori In + dtype: enum + options: ['True', 'False'] + option_labels: ['Yes', 'No'] +- id: a_post_out + label: A-posteriori Out + dtype: enum + options: ['True', 'False'] + option_labels: ['Yes', 'No'] +- id: siso_type + label: SISO Type + dtype: enum + options: [trellis.TRELLIS_MIN_SUM, trellis.TRELLIS_SUM_PRODUCT] + option_labels: [Min Sum, Sum Product] + +inputs: +- label: priori + domain: stream + dtype: float +- label: prioro + domain: stream + dtype: float + +outputs: +- domain: stream + dtype: float + +asserts: +- ${ (isinstance(eval(""" fsm_args """[1:-1], locals(),globals()), str) and open(fsm_args).close()) or True } + +templates: + imports: from gnuradio import trellis + make: trellis.siso_f(trellis.fsm(${fsm_args}), ${block_size}, ${init_state}, ${final_state}, + ${a_post_in}, ${a_post_out}, ${siso_type}) + callbacks: + - set_FSM(trellis.fsm(${fsm_args})) + - set_K(${block_size}) + - set_S0(${init_state}) + - set_SK(${final_state}) + - set_POSTI(${a_post_in}) + - set_POSTO(${a_post_out}) + - set_SISO_TYPE(${siso_type}) + +documentation: |- + BCJR Algorithm. The fsm arguments are passed directly to the trellis.fsm() constructor. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_siso_f.xml b/gr-trellis/grc/trellis_siso_f.xml deleted file mode 100644 index e121643e3f..0000000000 --- a/gr-trellis/grc/trellis_siso_f.xml +++ /dev/null @@ -1,100 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Trellis SISO -################################################### - --> - - -<block> - <name>SISO</name> - <key>trellis_siso_f</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis</import> - <make>trellis.siso_f(trellis.fsm($fsm_args), $block_size, $init_state, $final_state, $a_post_in, $a_post_out, $siso_type)</make> - <callback>set_FSM(trellis.fsm($fsm_args))</callback> - <callback>set_K($block_size)</callback> - <callback>set_S0($init_state)</callback> - <callback>set_SK($final_state)</callback> - <callback>set_POSTI($a_post_in)</callback> - <callback>set_POSTO($a_post_out)</callback> - <callback>set_SISO_TYPE($siso_type)</callback> - <param> - <name>FSM Args</name> - <key>fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Block Size</name> - <key>block_size</key> - <type>int</type> - </param> - <param> - <name>Initial State</name> - <key>init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Final State</name> - <key>final_state</key> - <value>-1</value> - <type>int</type> - </param> - <param> - <name>A-posteriori In</name> - <key>a_post_in</key> - <type>enum</type> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - <param> - <name>A-posteriori Out</name> - <key>a_post_out</key> - <type>enum</type> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - <param> - <name>SISO Type</name> - <key>siso_type</key> - <type>enum</type> - <option> - <name>Min Sum</name> - <key>trellis.TRELLIS_MIN_SUM</key> - </option> - <option> - <name>Sum Product</name> - <key>trellis.TRELLIS_SUM_PRODUCT</key> - </option> - </param> - <check>(isinstance(eval(""" $fsm_args """[1:-1], locals(),globals()), str) and open($fsm_args).close()) or True</check> - <sink> - <name>priori</name> - <type>float</type> - </sink> - <sink> - <name>prioro</name> - <type>float</type> - </sink> - <source> - <name>out</name> - <type>float</type> - </source> - <doc> -BCJR Algorithm. \ -The fsm arguments are passed directly to the trellis.fsm() constructor. - </doc> -</block> diff --git a/gr-trellis/grc/trellis_viterbi_combined_xx.block.yml b/gr-trellis/grc/trellis_viterbi_combined_xx.block.yml new file mode 100644 index 0000000000..8d1451e2da --- /dev/null +++ b/gr-trellis/grc/trellis_viterbi_combined_xx.block.yml @@ -0,0 +1,76 @@ +id: trellis_viterbi_combined_xx +label: Viterbi Combo +category: '[Core]/Trellis Coding' + +parameters: +- id: type + label: Input Type + dtype: enum + options: [c, f, i, s] + option_labels: [Complex, Float, Int, Short] + option_attributes: + io: [complex, float, int, short] + table: [complex_vector, real_vector, int_vector, int_vector] + hide: part +- id: out_type + label: Output Type + dtype: enum + options: [i, s, b] + option_labels: [Int, Short, Byte] + option_attributes: + io: [int, short, byte] + hide: part +- id: fsm_args + label: FSM Args + dtype: raw +- id: block_size + label: Block Size + dtype: int +- id: init_state + label: Initial State + dtype: int + default: '0' +- id: final_state + label: Final State + dtype: int + default: '-1' +- id: dim + label: Dimensionality + dtype: int +- id: table + label: Constellation + dtype: ${ type.table } +- id: metric_type + label: Metric Type + dtype: enum + options: [digital.TRELLIS_EUCLIDEAN, digital.TRELLIS_HARD_SYMBOL, digital.TRELLIS_HARD_BIT] + option_labels: [Euclidean, Hard Symbol, Hard Bit] + +inputs: +- domain: stream + dtype: ${ type.io } + +outputs: +- domain: stream + dtype: ${ out_type.io } + +asserts: +- ${ (isinstance(eval(""" fsm_args """[1:-1], locals(),globals()), str) and open(fsm_args).close()) or True } + +templates: + imports: from gnuradio import trellis, digital + make: trellis.viterbi_combined_${type}${out_type}(trellis.fsm(${fsm_args}), ${block_size}, + ${init_state}, ${final_state}, ${dim}, ${table}, ${metric_type}) + callbacks: + - set_FSM(trellis.fsm(${fsm_args})) + - set_K(${block_size}) + - set_S0(${init_state}) + - set_SK(${final_state}) + - set_D(${dim}) + - set_TABLE(${table}) + - set_TYPE(${metric_type}) + +documentation: |- + Viterbi Decoder combined with metric calculation. The fsm arguments are passed directly to the trellis.fsm() constructor. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_viterbi_combined_xx.xml b/gr-trellis/grc/trellis_viterbi_combined_xx.xml deleted file mode 100644 index a52e5ed2b5..0000000000 --- a/gr-trellis/grc/trellis_viterbi_combined_xx.xml +++ /dev/null @@ -1,133 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Trellis Viterbi Combined -################################################### - --> - - -<block> - <name>Viterbi Combo</name> - <key>trellis_viterbi_combined_xx</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis, digital</import> - <make>trellis.viterbi_combined_$(type)$(out_type)(trellis.fsm($fsm_args), $block_size, $init_state, $final_state, $dim, $table, $metric_type)</make> - <callback>set_FSM(trellis.fsm($fsm_args))</callback> - <callback>set_K($block_size)</callback> - <callback>set_S0($init_state)</callback> - <callback>set_SK($final_state)</callback> - <callback>set_D($dim)</callback> - <callback>set_TABLE($table)</callback> - <callback>set_TYPE($metric_type)</callback> - <param> - <name>Input Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>c</key> - <opt>io:complex</opt> - <opt>table:complex_vector</opt> - </option> - <option> - <name>Float</name> - <key>f</key> - <opt>io:float</opt> - <opt>table:real_vector</opt> - </option> - <option> - <name>Int</name> - <key>i</key> - <opt>io:int</opt> - <opt>table:int_vector</opt> - </option> - <option> - <name>Short</name> - <key>s</key> - <opt>io:short</opt> - <opt>table:int_vector</opt> - </option> - </param> - <param> - <name>Output Type</name> - <key>out_type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>i</key> - <opt>io:int</opt> - </option> - <option> - <name>Short</name> - <key>s</key> - <opt>io:short</opt> - </option> - <option> - <name>Byte</name> - <key>b</key> - <opt>io:byte</opt> - </option> - </param> - <param> - <name>FSM Args</name> - <key>fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Block Size</name> - <key>block_size</key> - <type>int</type> - </param> - <param> - <name>Initial State</name> - <key>init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Final State</name> - <key>final_state</key> - <value>-1</value> - <type>int</type> - </param> - <param> - <name>Dimensionality</name> - <key>dim</key> - <type>int</type> - </param> - <param> - <name>Constellation</name> - <key>table</key> - <type>$type.table</type> - </param> - <param> - <name>Metric Type</name> - <key>metric_type</key> - <type>enum</type> - <option> - <name>Euclidean</name> - <key>digital.TRELLIS_EUCLIDEAN</key> - </option> - <option> - <name>Hard Symbol</name> - <key>digital.TRELLIS_HARD_SYMBOL</key> - </option> - <option> - <name>Hard Bit</name> - <key>digital.TRELLIS_HARD_BIT</key> - </option> - </param> - <check>(isinstance(eval(""" $fsm_args """[1:-1], locals(),globals()), str) and open($fsm_args).close()) or True</check> - <sink> - <name>in</name> - <type>$type.io</type> - </sink> - <source> - <name>out</name> - <type>$out_type.io</type> - </source> - <doc> -Viterbi Decoder combined with metric calculation. \ -The fsm arguments are passed directly to the trellis.fsm() constructor. - </doc> -</block> diff --git a/gr-trellis/grc/trellis_viterbi_x.block.yml b/gr-trellis/grc/trellis_viterbi_x.block.yml new file mode 100644 index 0000000000..2caa5992e7 --- /dev/null +++ b/gr-trellis/grc/trellis_viterbi_x.block.yml @@ -0,0 +1,53 @@ +id: trellis_viterbi_x +label: Viterbi +category: '[Core]/Trellis Coding' + +parameters: +- id: type + label: Type + dtype: enum + options: [i, s, b] + option_labels: [Int, Short, Byte] + option_attributes: + io: [int, short, byte] + hide: part +- id: fsm_args + label: FSM Args + dtype: raw +- id: block_size + label: Block Size + dtype: int +- id: init_state + label: Initial State + dtype: int + default: '0' +- id: final_state + label: Final State + dtype: int + default: '-1' + +inputs: +- domain: stream + dtype: float + +outputs: +- domain: stream + dtype: ${ type.io } + +asserts: +- ${ (isinstance(eval(""" fsm_args """[1:-1], locals(),globals()), str) and open(fsm_args).close()) or True } + +templates: + imports: from gnuradio import trellis + make: trellis.viterbi_${type}(trellis.fsm(${fsm_args}), ${block_size}, ${init_state}, + ${final_state}) + callbacks: + - set_FSM(trellis.fsm(${fsm_args})) + - set_K(${block_size}) + - set_S0(${init_state}) + - set_SK(${final_state}) + +documentation: |- + Viterbi Decoder. The fsm arguments are passed directly to the trellis.fsm() constructor. + +file_format: 1 diff --git a/gr-trellis/grc/trellis_viterbi_x.xml b/gr-trellis/grc/trellis_viterbi_x.xml deleted file mode 100644 index 21611ee51d..0000000000 --- a/gr-trellis/grc/trellis_viterbi_x.xml +++ /dev/null @@ -1,74 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Trellis Viterbi -################################################### - --> - - -<block> - <name>Viterbi</name> - <key>trellis_viterbi_x</key> - <category>[Core]/Trellis Coding</category> - <import>from gnuradio import trellis</import> - <make>trellis.viterbi_$(type)(trellis.fsm($fsm_args), $block_size, $init_state, $final_state)</make> - <callback>set_FSM(trellis.fsm($fsm_args))</callback> - <callback>set_K($block_size)</callback> - <callback>set_S0($init_state)</callback> - <callback>set_SK($final_state)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Int</name> - <key>i</key> - <opt>io:int</opt> - </option> - <option> - <name>Short</name> - <key>s</key> - <opt>io:short</opt> - </option> - <option> - <name>Byte</name> - <key>b</key> - <opt>io:byte</opt> - </option> - </param> - <param> - <name>FSM Args</name> - <key>fsm_args</key> - <type>raw</type> - </param> - <param> - <name>Block Size</name> - <key>block_size</key> - <type>int</type> - </param> - <param> - <name>Initial State</name> - <key>init_state</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Final State</name> - <key>final_state</key> - <value>-1</value> - <type>int</type> - </param> - <check>(isinstance(eval(""" $fsm_args """[1:-1], locals(),globals()), str) and open($fsm_args).close()) or True</check> - <sink> - <name>in</name> - <type>float</type> - </sink> - <source> - <name>out</name> - <type>$type.io</type> - </source> - <doc> -Viterbi Decoder. \ -The fsm arguments are passed directly to the trellis.fsm() constructor. - </doc> -</block> diff --git a/gr-trellis/python/trellis/CMakeLists.txt b/gr-trellis/python/trellis/CMakeLists.txt index 10fd9d5c0e..94a160b310 100644 --- a/gr-trellis/python/trellis/CMakeLists.txt +++ b/gr-trellis/python/trellis/CMakeLists.txt @@ -44,6 +44,6 @@ if(ENABLE_TESTING) file(GLOB py_qa_test_files "qa_*.py") foreach(py_qa_test_file ${py_qa_test_files}) get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE) - GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) + GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file}) endforeach(py_qa_test_file) endif(ENABLE_TESTING) diff --git a/gr-trellis/python/trellis/__init__.py b/gr-trellis/python/trellis/__init__.py index a6b5ed0038..445a381424 100644 --- a/gr-trellis/python/trellis/__init__.py +++ b/gr-trellis/python/trellis/__init__.py @@ -21,15 +21,16 @@ ''' Blocks and utilities for trellis coding and related. ''' +from __future__ import unicode_literals # The presence of this file turns this directory into a Python package import os try: - from trellis_swig import * + from .trellis_swig import * except ImportError: dirname, filename = os.path.split(os.path.abspath(__file__)) __path__.append(os.path.join(dirname, "..", "..", "swig")) - from trellis_swig import * + from .trellis_swig import * # import any pure python here diff --git a/gr-trellis/python/trellis/fsm_utils.py b/gr-trellis/python/trellis/fsm_utils.py index 72aa1d3660..efc526c0e7 100755..100644 --- a/gr-trellis/python/trellis/fsm_utils.py +++ b/gr-trellis/python/trellis/fsm_utils.py @@ -20,11 +20,13 @@ # Boston, MA 02110-1301, USA. # +from __future__ import print_function +from __future__ import division +from __future__ import unicode_literals -import re import math import sys -import operator + import numpy #from gnuradio import trellis @@ -32,7 +34,7 @@ import numpy try: import scipy.linalg except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." + print("Error: Program requires scipy (see: www.scipy.org).") sys.exit(1) @@ -43,13 +45,13 @@ except ImportError: # to base 'base' (most significant symbol first). ###################################################################### def dec2base(num,base,l): - s=range(l) + s=list(range(l)) n=num for i in range(l): s[l-i-1]=n%base - n=int(n/base) + n=int(n / base) if n!=0: - print 'Number ', num, ' requires more than ', l, 'digits.' + print('Number ', num, ' requires more than ', l, 'digits.') return s @@ -84,9 +86,9 @@ def make_isi_lookup(mod,channel,normalize): for i in range(len(channel)): p = p + channel[i]**2 for i in range(len(channel)): - channel[i] = channel[i]/math.sqrt(p) + channel[i] = channel[i] / math.sqrt(p) - lookup=range(len(constellation)**len(channel)) + lookup=list(range(len(constellation)**len(channel))) for o in range(len(constellation)**len(channel)): ss=dec2base(o,len(constellation),len(channel)) ll=0 @@ -109,11 +111,11 @@ def make_isi_lookup(mod,channel,normalize): ###################################################################### def make_cpm_signals(K,P,M,L,q,frac): - Q=numpy.size(q)/L - h=(1.0*K)/P + Q=numpy.size(q) / L + h=(1.0*K) / P f0=-h*(M-1)/2 dt=0.0; # maybe start at t=0.5 - t=(dt+numpy.arange(0,Q))/Q + t=(dt+numpy.arange(0 / Q),Q) qq=numpy.zeros(Q) for m in range(L): qq=qq + q[m*Q:m*Q+Q] @@ -122,46 +124,46 @@ def make_cpm_signals(K,P,M,L,q,frac): X=(M**L)*P PSI=numpy.empty((X,Q)) for x in range(X): - xv=dec2base(x/P,M,L) + xv=dec2base(x / P,M,L) xv=numpy.append(xv, x%P) qq1=numpy.zeros(Q) for m in range(L): qq1=qq1+xv[m]*q[m*Q:m*Q+Q] psi=2*math.pi*h*xv[-1]+4*math.pi*h*qq1+w - #print psi + #print(psi) PSI[x]=psi PSI = numpy.transpose(PSI) SS=numpy.exp(1j*PSI) # contains all signals as columns - #print SS + #print(SS) # Now we need to orthogonalize the signals F = scipy.linalg.orth(SS) # find an orthonormal basis for SS - #print numpy.dot(numpy.transpose(F.conjugate()),F) # check for orthonormality + #print(numpy.dot(numpy.transpose(F.conjugate()),F) # check for orthonormality) S = numpy.dot(numpy.transpose(F.conjugate()),SS) - #print F - #print S + #print(F) + #print(S) # We only want to keep those dimensions that contain most # of the energy of the overall constellation (eg, frac=0.9 ==> 90%) # evaluate mean energy in each dimension - E=numpy.sum(numpy.absolute(S)**2,axis=1)/Q - E=E/numpy.sum(E) - #print E + E=numpy.sum(numpy.absolute(S)**2, axis=1) / Q + E=E / numpy.sum(E) + #print(E) Es = -numpy.sort(-E) Esi = numpy.argsort(-E) - #print Es - #print Esi + #print(Es) + #print(Esi) Ecum=numpy.cumsum(Es) - #print Ecum + #print(Ecum) v0=numpy.searchsorted(Ecum,frac) N = v0+1 - #print v0 - #print Esi[0:v0+1] + #print(v0) + #print(Esi[0:v0+1]) Ff=numpy.transpose(numpy.transpose(F)[Esi[0:v0+1]]) - #print Ff + #print(Ff) Sf = S[Esi[0:v0+1]] - #print Sf + #print(Sf) return (f0,SS,S,F,Sf,Ff,N) diff --git a/gr-trellis/python/trellis/qa_trellis.py b/gr-trellis/python/trellis/qa_trellis.py index 0ed802a0fd..6d14fefe85 100755..100644 --- a/gr-trellis/python/trellis/qa_trellis.py +++ b/gr-trellis/python/trellis/qa_trellis.py @@ -20,6 +20,8 @@ # Boston, MA 02110-1301, USA. # +from __future__ import division + import math import os @@ -71,7 +73,7 @@ class test_trellis (gr_unittest.TestCase): Runs some coding/decoding tests with a few different FSM specs. """ - for name, args in fsm_args.items(): + for name, args in list(fsm_args.items()): constellation = constells[args[2]] fsms = trellis.fsm(*args) noise = 0.1 @@ -85,7 +87,7 @@ class trellis_tb(gr.top_block): """ A simple top block for use testing gr-trellis. """ - def __init__(self, constellation, f, N0=0.25, seed=-666L): + def __init__(self, constellation, f, N0=0.25, seed=-666): """ constellation - a constellation object used for modulation. f - a finite state machine specification used for coding. @@ -96,14 +98,14 @@ class trellis_tb(gr.top_block): # packet size in bits (make it multiple of 16 so it can be packed in a short) packet_size = 1024*16 # bits per FSM input symbol - bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol + bitspersymbol = int(round(math.log(f.I()) / math.log(2))) # bits per FSM input symbol # packet size in trellis steps - K = packet_size/bitspersymbol + K = packet_size // bitspersymbol # TX src = blocks.lfsr_32k_source_s() # packet size in shorts - src_head = blocks.head(gr.sizeof_short, packet_size/16) + src_head = blocks.head(gr.sizeof_short, packet_size // 16) # unpack shorts to symbols compatible with the FSM input cardinality s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol, gr.GR_MSB_FIRST) # initial FSM state = 0 @@ -112,7 +114,7 @@ class trellis_tb(gr.top_block): # CHANNEL add = blocks.add_cc() - noise = analog.noise_source_c(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) + noise = analog.noise_source_c(analog.GR_GAUSSIAN,math.sqrt(N0 / 2),seed) # RX # data preprocessing to generate metrics for Viterbi diff --git a/gr-trellis/swig/trellis_swig.py.in b/gr-trellis/swig/trellis_swig.py.in index fac5f631e2..f49e04e0a3 100644 --- a/gr-trellis/swig/trellis_swig.py.in +++ b/gr-trellis/swig/trellis_swig.py.in @@ -19,5 +19,7 @@ # Boston, MA 02110-1301, USA. # -from trellis_swig0 import * -from trellis_swig1 import * +from __future__ import absolute_import + +from .trellis_swig0 import * +from .trellis_swig1 import * |