summaryrefslogtreecommitdiff
path: root/gnuradio-examples/python
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-examples/python')
-rw-r--r--gnuradio-examples/python/channel-coding/README21
-rwxr-xr-xgnuradio-examples/python/channel-coding/test_tcm_combined.py4
-rwxr-xr-xgnuradio-examples/python/channel-coding/test_viterbi_equalization1.py12
3 files changed, 22 insertions, 15 deletions
diff --git a/gnuradio-examples/python/channel-coding/README b/gnuradio-examples/python/channel-coding/README
index 2be8c6ba1..7f25b697b 100644
--- a/gnuradio-examples/python/channel-coding/README
+++ b/gnuradio-examples/python/channel-coding/README
@@ -18,8 +18,13 @@ If you just want to see what these programs do, run each of the following:
./test_sccc_soft.py fsm_files/awgn1o2_4.fsm fsm_files/awgn1o2_4_msb.fsm 8.0 100
./test_sccc_turbo.py fsm_files/awgn1o2_4.fsm fsm_files/awgn1o2_4_msb.fsm 5.0 100
+./test_viterbi_equalization.py 12.0 100
+./test_viterbi_equalization1.py 12.0 100
+
+
In your terminal you will see something like this:
+
$ ./test_tcm.py fsm_files/awgn1o2_4.fsm 6.0 1000
100 98 9.80e-01 102400 9 8.79e-05
200 198 9.90e-01 204800 20 9.77e-05
@@ -36,11 +41,11 @@ $ ./test_tcm.py fsm_files/awgn1o2_4.fsm 6.0 1000
which gives you information about the:
number of transmitted packets
number of packets in error
-iestimated packet error rate
-number of transmitted shorts
-number of shorts in error
-estimated (short) error rate
-
-1.10e-03 is the error rate estimate by sending 1000 packets of
-1024 shorts each, using an 1/2 4-state convolutional code and QPSK
-modulation through an AWGN with Es/N0 = 6.0 dB
+estimated packet error rate
+number of transmitted shorts (or symbols, or bits, depending on the specific program)
+number of shorts (or symbols, or bits) in error
+estimated short (or symbol, or bit) error rate
+
+for instance, the final number 1.10e-03 is the error rate estimate by sending 1000
+packets of 1024 shorts each, using an 1/2 4-state convolutional code
+and QPSK modulation through an AWGN with Es/N0 = 6.0 dB
diff --git a/gnuradio-examples/python/channel-coding/test_tcm_combined.py b/gnuradio-examples/python/channel-coding/test_tcm_combined.py
index 37f38ef1a..e286f88f6 100755
--- a/gnuradio-examples/python/channel-coding/test_tcm_combined.py
+++ b/gnuradio-examples/python/channel-coding/test_tcm_combined.py
@@ -13,7 +13,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed):
# TX
src = gr.lfsr_32k_source_s()
- src_head = gr.head (gr.sizeof_short,K/16) # packet size in shorts
+ src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts
s2fsmi = gr.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 = gr.chunks_to_symbols_sf(constellation,dimensionality)
@@ -25,7 +25,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed):
# RX
- va = trellis.viterbi_combined_s(f,dimensionality,constellation,K/bitspersymbol,0,-1,trellis.TRELLIS_EUCLIDEAN) # Put -1 if the Initial/Final states are not set.
+ va = trellis.viterbi_combined_s(f,K,0,-1,dimensionality,constellation,trellis.TRELLIS_EUCLIDEAN) # Put -1 if the Initial/Final states are not set.
fsmi2s = gr.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts
dst = gr.check_lfsr_32k_s();
diff --git a/gnuradio-examples/python/channel-coding/test_viterbi_equalization1.py b/gnuradio-examples/python/channel-coding/test_viterbi_equalization1.py
index 133e550db..8e197cae9 100755
--- a/gnuradio-examples/python/channel-coding/test_viterbi_equalization1.py
+++ b/gnuradio-examples/python/channel-coding/test_viterbi_equalization1.py
@@ -16,6 +16,7 @@ def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constel
# TX
# this for loop is TOO slow in python!!!
packet = [0]*(K+2*L)
+ random.seed(seed)
for i in range(len(packet)):
packet[i] = random.randint(0, 2**bitspersymbol - 1) # random symbols
for i in range(L): # first/last L symbols set to 0
@@ -30,9 +31,10 @@ def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constel
noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed)
# RX
+ skip = gr.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols
#metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,trellis.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi
- #va = trellis.viterbi_s(f,K+2*L,-1,0) # Put -1 if the Initial/Final states are not set. Better if we could skip the first L symbols and start with a 0 state... don't know how to "skip" samples in gnuradio
- va = trellis.viterbi_combined_s(f,dimensionality,tot_constellation,K+2*L,-1,0,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...
+ #va = trellis.viterbi_s(f,K+L,-1,0) # Put -1 if the Initial/Final states are not set.
+ 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...
dst = gr.vector_sink_s()
fg.connect (src,mod)
@@ -40,15 +42,15 @@ def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constel
fg.connect (noise,(add,1))
#fg.connect (add,metrics)
#fg.connect (metrics,va,dst)
- fg.connect (add,va,dst)
+ fg.connect (add,skip,va,dst)
fg.run()
data = dst.data()
- ntotal = len(data) - 2*L
+ ntotal = len(data) - L
nright=0
for i in range(ntotal):
- if packet[i+L]==data[i+L]:
+ if packet[i+L]==data[i]:
nright=nright+1
#else:
#print "Error in ", i