-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlookups.scala
159 lines (132 loc) · 6.47 KB
/
lookups.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Süleyman Savas, 2016-12-16
// Halmstad University
package SquareRoot
import chisel3._
class lookupL() extends Module {
val io = IO(new Bundle{
val addr = Input(UInt(width = 6))
val out = Output(UInt(width = 28))
})
//Let's prepare the lookup tables
val coeffL = Vec(
"b1100000000000000001110101011".U, "b1011110111001101001000111101".U,
"b1011101110110011000011001011".U, "b1011100110101111110010011111".U,
"b1011011111000001100111100110".U, "b1011010111100110111110111101".U,
"b1011010000011110011111110010".U, "b1011001001100110111010000101".U,
"b1011000010111111000110011011".U, "b1010111100100110000011100010".U,
"b1010110110011010110110001111".U, "b1010110000011100101001001111".U,
"b1010101010101010101011010010".U, "b1010100101000100001111100011".U,
"b1010011111101000101100100001".U, "b1010011010010111011100111101".U,
"b1010010101001111111101100100".U, "b1010010000010001101110001111".U,
"b1010001011011100010001000100".U, "b1010000110101111001010010111".U,
"b1010000010001010000000011001".U, "b1001111101101100011011001101".U,
"b1001111001010110000100100001".U, "b1001110101000110100111011101".U,
"b1001110000111101110000100010".U, "b1001101100111011001101100000".U,
"b1001101000111110101101010000".U, "b1001100101000111111111101101".U,
"b1001100001010110110101101111".U, "b1001011101101011000001001001".U,
"b1001011010000100010100011111".U, "b1001010110100010100011001010".U,
"b1001010011000101100001001011".U, "b1001001111101101000011010000".U,
"b1001001100011000111110101101".U, "b1001001001001001001001011001".U,
"b1001000101111101011001101110".U, "b1001000010110101100110100101".U,
"b1000111111110001100111010011".U, "b1000111100110001010011101010".U,
"b1000111001110100100011110011".U, "b1000110110111011010000010011".U,
"b1000110100000101010010000011".U, "b1000110001010010100010001111".U,
"b1000101110100010111010011100".U, "b1000101011110110010100011100".U,
"b1000101001001100101010010111".U, "b1000100110100101110110100100".U,
"b1000100100000001110011101000".U, "b1000100001100000011100011001".U,
"b1000011111000001101011111010".U, "b1000011100100101011101011100".U,
"b1000011010001011101100011010".U, "b1000010111110100010100011100".U,
"b1000010101011111010001010111".U, "b1000010011001100011111001001".U,
"b1000010000111011111001111000".U, "b1000001110101101011101111001".U,
"b1000001100100001000111100101".U, "b1000001010010110110011011101".U,
"b1000001000001110011110010001".U, "b1000000110001000000100110001".U,
"b1000000100000011100011111000".U, "b1000000010000000111000101001".U
)
//val data = Reg(init = coeffL(io.addr), next = coeffL(io.addr))
//io.out := data
io.out := coeffL(io.addr)
}
class lookupJ() extends Module {
val io = IO(new Bundle{
val addr = Input(UInt(width = 6))
val out = Output(UInt(width = 22))
})
//Let's prepare the lookup tables
val coeffJ = Vec(
"b1000111111110011111101".U, "b1000100101111110001001".U,
"b1000001110001101111010".U, "b0111111000010011110100".U,
"b0111100100000010101010".U, "b0111010001001111001100".U,
"b0110111111101111101100".U, "b0110101111011011101111".U,
"b0110100000001100000000".U, "b0110010001111010000110".U,
"b0110000100100000011001".U, "b0101110111111001111001".U,
"b0101101100000010001111".U, "b0101100000110101011111".U,
"b0101010110010000001011".U, "b0101001100001111001010".U,
"b0101000010101111101010".U, "b0100111001101111001001".U,
"b0100110001001011010110".U, "b0100101001000010001101".U,
"b0100100001010001110111".U, "b0100011001111000100110".U,
"b0100010010110100111001".U, "b0100001100000101010101".U,
"b0100000101101000100110".U, "b0011111111011101100010".U,
"b0011111001100011000011".U, "b0011110011111000001000".U,
"b0011101110011011110111".U, "b0011101001001101011010".U,
"b0011100100001011111101".U, "b0011011111010110110010".U,
"b0011011010101101001111".U, "b0011010110001110101010".U,
"b0011010001111010011111".U, "b0011001101110000001011".U,
"b0011001001101111001101".U, "b0011000101110111001000".U,
"b0011000010000111011111".U, "b0010111110011111110111".U,
"b0010111010111111111000".U, "b0010110111100111001011".U,
"b0010110100010101011001".U, "b0010110001001010010000".U,
"b0010101110000101011010".U, "b0010101011000110100111".U,
"b0010101000001101100101".U, "b0010100101011010000100".U,
"b0010100010101011110101".U, "b0010100000000010101010".U,
"b0010011101011110010101".U, "b0010011010111110101010".U,
"b0010011000100011011100".U, "b0010010110001100100000".U,
"b0010010011111001101011".U, "b0010010001101010110011".U,
"b0010001111011111101110".U, "b0010001101011000010010".U,
"b0010001011010100011000".U, "b0010001001010011110110".U,
"b0010000111010110100101".U, "b0010000101011100011100".U,
"b0010000011100101010110".U, "b0010000001110001001010".U
)
io.out := coeffJ(io.addr)
}
class lookupC() extends Module {
val io = IO(new Bundle{
val addr = Input(UInt(width = 6))
val out = Output(UInt(width = 16))
})
//Let's prepare the lookup tables
val coeffC = Vec(
"b1100111011011100".U, "b1011111000100100".U,
"b1010111101011100".U, "b1010001000111010".U,
"b1001011010000010".U, "b1000110000000000".U,
"b1000001010001101".U, "b0111101000000100".U,
"b0111001001001000".U, "b0110101101000001".U,
"b0110010011011000".U, "b0101111011111101".U,
"b0101100110011111".U, "b0101010010110001".U,
"b0101000000100110".U, "b0100101111110101".U,
"b0100100000010101".U, "b0100010001111110".U,
"b0100000100101001".U, "b0011111000001111".U,
"b0011101100101100".U, "b0011100001111010".U,
"b0011010111110101".U, "b0011001110011010".U,
"b0011000101100101".U, "b0010111101010010".U,
"b0010110101100000".U, "b0010101110001011".U,
"b0010100111010001".U, "b0010100000110000".U,
"b0010011010100111".U, "b0010010100110011".U,
"b0010001111010100".U, "b0010001010000111".U,
"b0010000101001100".U, "b0010000000100000".U,
"b0001111100000100".U, "b0001110111110110".U,
"b0001110011110101".U, "b0001110000000001".U,
"b0001101100011000".U, "b0001101000111010".U,
"b0001100101100110".U, "b0001100010011100".U,
"b0001011111011011".U, "b0001011100100010".U,
"b0001011001110001".U, "b0001010111001000".U,
"b0001010100100110".U, "b0001010010001011".U,
"b0001001111110111".U, "b0001001101101000".U,
"b0001001011011111".U, "b0001001001011011".U,
"b0001000111011101".U, "b0001000101100011".U,
"b0001000011101110".U, "b0001000001111110".U,
"b0001000000010010".U, "b0000111110101001".U,
"b0000111101000101".U, "b0000111011100100".U,
"b0000111010000111".U, "b0000111000101100".U
)
io.out := coeffC(io.addr)
}