1 |
7 |
dbrochart |
######################################################################
|
2 |
|
|
#### ####
|
3 |
|
|
#### acs.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 selec import accDistSel, stateSel
|
44 |
|
|
from misc import opposite, delayer, mux8, mux4, sub
|
45 |
|
|
from distances import distances, accDist
|
46 |
|
|
from myhdl import Signal, instances, intbv
|
47 |
|
|
|
48 |
|
|
def acs(clk, rst, a, b, y1, y2, z, selStateL, selDistL, selState, stateDist, weight, q = 8, l = 20, n = 4, r = 5):
|
49 |
|
|
""" Add-Compare-Select top level.
|
50 |
|
|
|
51 |
|
|
q -- accumulated distance width
|
52 |
|
|
l -- first trellis length
|
53 |
|
|
n -- received decoder signal width
|
54 |
|
|
r -- extrinsic information width
|
55 |
|
|
clk, rst -- in : clock and negative reset
|
56 |
|
|
a, b, y1, y2 -- in : received decoder signals
|
57 |
|
|
z -- in : extrinsic information
|
58 |
|
|
selStateL -- in : selected state at t = L
|
59 |
|
|
selDistL -- in : selected transition at selStateL
|
60 |
|
|
selState -- out : selected state
|
61 |
|
|
stateDist -- out : selected accumulated distances (per state)
|
62 |
|
|
weight -- out : four weights sorted by transition code
|
63 |
|
|
|
64 |
|
|
"""
|
65 |
|
|
from2to = [0, 25, 6, 31, 8, 17, 14, 23, 20, 13, 18, 11, 28, 5, 26, 3, 4, 29, 2, 27, 12, 21, 10, 19, 16, 9, 22, 15, 24, 1, 30, 7]
|
66 |
|
|
distance16 = [Signal(intbv(0, 0, 4*(2**(n-1))+(2**r))) for i in range(16)]
|
67 |
|
|
accDist8 = [Signal(intbv(0, 0, 2**q)) for i in range(8)]
|
68 |
|
|
accDist32 = [Signal(intbv(0, 0, 2**q)) for i in range(32)]
|
69 |
|
|
accDistDel32 = [[Signal(intbv(0, 0, 2**q)) for i in range(4)] for j in range(8)]
|
70 |
|
|
accDistDel4 = [Signal(intbv(0, 0, 2**q)) for i in range(4)]
|
71 |
|
|
selAccDistL = Signal(intbv(0, 0, 2**q))
|
72 |
|
|
delayer_i = [None for i in range(32)]
|
73 |
|
|
distances_i0 = distances(a, b, y1, y2, z, distance16)
|
74 |
|
|
accDist_i0 = accDist(clk, rst, accDist8, distance16, accDist32, q)
|
75 |
|
|
for i in range(8):
|
76 |
|
|
for j in range(4):
|
77 |
|
|
delayer_i[i * 4 + j] = delayer(clk, rst, accDist32[from2to[i * 4 + j]], accDistDel32[i][j], l - 1, 0, 2**(q+1))
|
78 |
|
|
mux8_i0 = mux8(accDistDel32[0], accDistDel32[1], accDistDel32[2], accDistDel32[3], accDistDel32[4], accDistDel32[5], accDistDel32[6], accDistDel32[7], selStateL, accDistDel4)
|
79 |
|
|
mux4_i0 = mux4(accDistDel4[0], accDistDel4[1], accDistDel4[2], accDistDel4[3], selDistL, selAccDistL)
|
80 |
|
|
sub_i0 = sub(accDistDel4[0], selAccDistL, weight[0])
|
81 |
|
|
sub_i1 = sub(accDistDel4[1], selAccDistL, weight[1])
|
82 |
|
|
sub_i2 = sub(accDistDel4[2], selAccDistL, weight[2])
|
83 |
|
|
sub_i3 = sub(accDistDel4[3], selAccDistL, weight[3])
|
84 |
|
|
accDistSel_i0 = accDistSel(accDist32, stateDist, accDist8, q)
|
85 |
|
|
stateSel_i0 = stateSel(accDist8, selState, q)
|
86 |
|
|
|
87 |
|
|
return distances_i0, accDist_i0, mux8_i0, mux4_i0, sub_i0, sub_i1, sub_i2, sub_i3, accDistSel_i0, stateSel_i0, delayer_i
|