OpenCores
URL https://opencores.org/ocsvn/turbocodes/turbocodes/trunk

Subversion Repositories turbocodes

[/] [turbocodes/] [trunk/] [src/] [myhdl/] [launchTurbo.py] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 dbrochart
######################################################################
2
####                                                              ####
3
####  launchTurbo.py                                              ####
4
####                                                              ####
5
####  This file is part of the turbo decoder IP core project      ####
6
####  http://www.opencores.org/projects/turbocodes/               ####
7
####                                                              ####
8
####  Author(s):                                                  ####
9
####      - David Brochart(dbrochart@opencores.org)               ####
10
####                                                              ####
11
####  All additional information is available in the README.txt   ####
12
####  file.                                                       ####
13
####                                                              ####
14
######################################################################
15
####                                                              ####
16
#### Copyright (C) 2005 Authors                                   ####
17
####                                                              ####
18
#### This source file may be used and distributed without         ####
19
#### restriction provided that this copyright statement is not    ####
20
#### removed from the file and that any derivative work contains  ####
21
#### the original copyright notice and the associated disclaimer. ####
22
####                                                              ####
23
#### This source file is free software; you can redistribute it   ####
24
#### and/or modify it under the terms of the GNU Lesser General   ####
25
#### Public License as published by the Free Software Foundation; ####
26
#### either version 2.1 of the License, or (at your option) any   ####
27
#### later version.                                               ####
28
####                                                              ####
29
#### This source is distributed in the hope that it will be       ####
30
#### useful, but WITHOUT ANY WARRANTY; without even the implied   ####
31
#### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ####
32
#### PURPOSE. See the GNU Lesser General Public License for more  ####
33
#### details.                                                     ####
34
####                                                              ####
35
#### You should have received a copy of the GNU Lesser General    ####
36
#### Public License along with this source; if not, download it   ####
37
#### from http://www.opencores.org/lgpl.shtml                     ####
38
####                                                              ####
39
######################################################################
40
 
41
 
42
 
43
from math import sqrt
44
from turboTop import turboTop
45
from args import getArgs
46
from myhdl import Simulation, traceSignals
47
 
48
args    = getArgs('-rate', '-iter', '-vcd', '-time', '-snr', '-help', '-sig', '-ext', '-trel1', '-trel2', '-dist', '-int', '-delay')
49
rate    = args['-rate']
50
vcd     = args['-vcd']
51
time    = args['-time']
52
snr     = args['-snr']
53
help    = args['-help']
54
sig     = args['-sig']
55
ext     = args['-ext']
56
trel1   = args['-trel1']
57
trel2   = args['-trel2']
58
dist    = args['-dist']
59
inter   = args['-int']
60
dela    = args['-delay']
61
iter    = args['-iter']
62
if help == 'on':
63
    print "python launchTurbo.py"
64
    print "    [-help]        : prints this message"
65
    print "    [-iter val]    : number of iterations for the turbo decoding (default: 5)"
66
    print "    [-snr val]     : specifies the signal-to-noise ratio in dB (default: 5.1 dB)"
67
    print "    [-vcd on/off]  : turns on/off the signal logging into a VCD file (default: off)"
68
    print "    [-time val]    : time to run the simulation (default: forever)"
69
    print "    [-sig val]     : number of bits for the quantization of the signals - a, b, y1, y2 (default: 4)"
70
    print "    [-ext val]     : number of bits for the coding of the extrinsic information (default: 5)"
71
    print "    [-trel1 val]   : first trellis' length (default: 24)"
72
    print "    [-trel2 val]   : second trellis' length (default: 12)"
73
    print "    [-dist val]    : number of bits for the coding of the accumulated distances (default: 9)"
74
    print "    [-int val]     : interleaver frame size in bit couples - valid values are 48, 64, 212, 220, 228, 424, 432, 440, 848, 856, 864, 752 (default: 64)"
75
    print "    [-delay val]   : additional delay through the noiser - 0 means the noiser adds 1 clock cycle (default: 0)"
76
    print "    [-rate val]    : code rate (e.g. 13 for rate 1/3) - valid values are 13, 25, 12, 23, 34, 45, 67 (default is 12)"
77
else:
78
    if rate != None:
79
        rate = int(rate)    # code rate (e.g. 13 for rate 1/3)
80
    else:
81
        rate = 12
82
    if iter != None:
83
        it = int(iter)
84
    else:
85
        it = 5  # number of iterations for the turbo decoding
86
    if sig != None:
87
        n = int(sig)
88
    else:
89
        n = 4   # number of bits for the quantization of the signals - a, b, y1, y2
90
    if ext != None:
91
        r = int(ext)
92
    else:
93
        r = 5   # number of bits for the coding of the extrinsic information
94
    if trel1 != None:
95
        l = int(trel1)
96
    else:
97
        l = 24  # first trellis' length
98
    if trel2 != None:
99
        m = int(trel2)
100
    else:
101
        m = 12  # second trellis' length
102
    if dist != None:
103
        q = int(dist)
104
    else:
105
        q = 9   # number of bits for the coding of the accumulated distances
106
    if inter != None:
107
        p = int(inter)
108
    else:
109
        p = 64  # interleaver frame size in bit couples
110
    if dela != None:
111
        d = int(dela) + 1
112
    else:
113
        d = 1   # additional delay through the noiser - 0 means the noiser adds 2 clock cycles
114
    if snr == None:
115
        snr = 5.1   # signal-to-noise ratio in dB
116
    sigma = sqrt(((2 ** (n - 1) - 1) ** 2)/(10 ** (float(snr) / 10)))   # standard deviation of the noise distribution
117
    if time != None:
118
        time = int(time)    # time to run the simulation
119
    else:
120
        time = None
121
    mu = 2**(n - 1) # mean value of the noise distribution (additive noise)
122
    print "Parameters of the simulation:"
123
    print "-----------------------------"
124
    print
125
    print it, "iterations for the turbo decoding"
126
    print n, "bits for the quantization of the signals - a, b, y1, y2"
127
    print r, "bits for the coding of the extrinsic information"
128
    print "The length of the first trellis is", l
129
    print "The length of the second trellis is", m
130
    print q, "bits for the coding of the accumulated distances"
131
    print "The interleaver has a frame size of", p, "bit couples"
132
    print "There is an additional delay through the noiser of", (d - 1), "clock cycle(s) - 0 means the noiser adds 2 clock cycles"
133
    print "The signal-to-noise ratio is", snr, "dB"
134
    print "The code rate is", str(rate)[0], "/", str(rate)[1]
135
    print
136
    print
137
    print
138
    resFile = [None for i in range(it + 1)]
139
    for i in range(it + 1):
140
        resFile[i] = open('./turbo' + str(i) + '.txt', 'w')
141
    if vcd == 'on':
142
        turbo = traceSignals(turboTop, resFile, rate, it, n, r, p, d, mu, sigma, l, m, q)
143
    else:
144
        turbo = turboTop(resFile, rate, it, n, r, p, d, mu, sigma, l, m, q)
145
    sim = Simulation(turbo)
146
    sim.run(time)
147
    for i in range(it + 1):
148
        resFile[i].close

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.