summaryrefslogtreecommitdiff
path: root/gr-trellis/doc/test_viterbi_equalization1.py.xml
diff options
context:
space:
mode:
Diffstat (limited to 'gr-trellis/doc/test_viterbi_equalization1.py.xml')
-rw-r--r--gr-trellis/doc/test_viterbi_equalization1.py.xml36
1 files changed, 18 insertions, 18 deletions
diff --git a/gr-trellis/doc/test_viterbi_equalization1.py.xml b/gr-trellis/doc/test_viterbi_equalization1.py.xml
index a97d04d6e..27605870e 100644
--- a/gr-trellis/doc/test_viterbi_equalization1.py.xml
+++ b/gr-trellis/doc/test_viterbi_equalization1.py.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<programlisting>
1 #!/usr/bin/env python
- 2
+ 2
3 from gnuradio import gr
4 from gnuradio import audio
5 from gnuradio import trellis
@@ -10,11 +10,11 @@
8 import sys
9 import random
10 import fsm_utils
- 11
+ 11
12 def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,N0,seed):
13 tb = gr.top_block ()
14 L = len(channel)
- 15
+ 15
16 # TX
17 # this for loop is TOO slow in python!!!
18 packet = [0]*(K+2*L)
@@ -26,29 +26,29 @@
24 packet[len(packet)-i-1] = 0
25 src = gr.vector_source_s(packet,False)
26 mod = gr.chunks_to_symbols_sf(modulation[1],modulation[0])
- 27
+ 27
28 # CHANNEL
29 isi = gr.fir_filter_fff(1,channel)
30 add = gr.add_ff()
31 noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed)
- 32
+ 32
33 # RX
34 skip = gr.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols
35 #metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,trellis.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi
36 #va = trellis.viterbi_s(f,K+L,0,0) # Put -1 if the Initial/Final states are not set.
37 va = trellis.viterbi_combined_s(f,K+L,0,0,dimensionality,tot_constellation,trellis.TRELLIS_EUCLIDEAN) # using viterbi_combined_s instead of metrics_f/viterbi_s allows larger packet lengths because metrics_f is complaining for not being able to allocate large buffers. This is due to the large f.O() in this application...
38 dst = gr.vector_sink_s()
- 39
+ 39
40 tb.connect (src,mod)
41 tb.connect (mod,isi,(add,0))
42 tb.connect (noise,(add,1))
43 #tb.connect (add,metrics)
44 #tb.connect (metrics,va,dst)
45 tb.connect (add,skip,va,dst)
- 46
+ 46
47 tb.run()
- 48
- 49 data = dst.data()
+ 48
+ 49 data = dst.data()
50 ntotal = len(data) - L
51 nright=0
52 for i in range(ntotal):
@@ -56,10 +56,10 @@
54 nright=nright+1
55 #else:
56 #print &quot;Error in &quot;, i
- 57
+ 57
58 return (ntotal,ntotal-nright)
- 59
- 60
+ 59
+ 60
61 def main(args):
62 nargs = len (args)
63 if nargs == 2:
@@ -68,7 +68,7 @@
66 else:
67 sys.stderr.write (&apos;usage: test_viterbi_equalization1.py Es/No_db repetitions\n&apos;)
68 sys.exit (1)
- 69
+ 69
70 # system parameters
71 Kb=2048 # packet size in bits
72 modulation = fsm_utils.pam4 # see fsm_utlis.py for available predefined modulations
@@ -76,7 +76,7 @@
74 f=trellis.fsm(len(modulation[1]),len(channel)) # generate the FSM automatically
75 bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per FSM input symbol
76 K=Kb/bitspersymbol # packet size in trellis steps
- 77
+ 77
78 tot_channel = fsm_utils.make_isi_lookup(modulation,channel,True) # generate the lookup table (normalize energy to 1)
79 dimensionality = tot_channel[0]
80 tot_constellation = tot_channel[1]
@@ -84,11 +84,11 @@
82 if len(tot_constellation)/dimensionality != f.O():
83 sys.stderr.write (&apos;Incompatible FSM output cardinality and lookup table size.\n&apos;)
84 sys.exit (1)
- 85
+ 85
86 tot_s=0 # total number of transmitted shorts
87 terr_s=0 # total number of shorts in error
88 terr_p=0 # total number of packets in error
- 89
+ 89
90 for i in range(rep):
91 (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
92 tot_s=tot_s+s
@@ -98,8 +98,8 @@
96 print i+1,terr_p, &apos;%.2e&apos; % ((1.0*terr_p)/(i+1)),tot_s,terr_s, &apos;%.2e&apos; % ((1.0*terr_s)/tot_s)
97 # estimate of the (short or symbol) error rate
98 print rep,terr_p, &apos;%.2e&apos; % ((1.0*terr_p)/(i+1)),tot_s,terr_s, &apos;%.2e&apos; % ((1.0*terr_s)/tot_s)
- 99
-100
+ 99
+100
101 if __name__ == &apos;__main__&apos;:
102 main (sys.argv[1:])
</programlisting>