This repository has been archived by the owner on Apr 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnorm2.srp.sv
305 lines (298 loc) · 7.9 KB
/
norm2.srp.sv
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
`default_nettype none
module main (
input wire clk, r_enable, controlArr,
input wire[9:0] init_i_t_a,
input wire signed[63:0] init_acc_t_a,
input wire controlArrWEnable_a,
input wire[9:0] controlArrAddr_a,
output wire signed[26:0] controlArrRData_a,
input wire signed[26:0] controlArrWData_a,
output reg w_enable,
output reg signed[63:0] result
);
reg[4:0] stateR;
reg[4:0] linkreg;
reg[63:0] reg0;
wire[63:0] stationReg0;
reg[63:0] reg1;
wire[63:0] stationReg1;
reg[63:0] reg2;
wire[63:0] stationReg2;
reg[63:0] reg3;
wire[63:0] stationReg3;
reg[63:0] reg4;
wire[63:0] stationReg4;
reg[63:0] reg5;
wire[63:0] stationReg5;
reg[63:0] reg6;
wire[63:0] stationReg6;
reg[63:0] reg7;
wire[63:0] stationReg7;
reg[63:0] reg8;
wire[63:0] stationReg8;
reg[63:0] reg9;
wire[63:0] stationReg9;
reg[63:0] reg10;
wire[63:0] stationReg10;
reg[63:0] reg11;
wire[63:0] stationReg11;
reg[63:0] reg12;
wire[63:0] stationReg12;
reg[63:0] reg13;
wire[63:0] stationReg13;
reg[63:0] reg14;
wire[63:0] stationReg14;
reg[63:0] reg15;
wire[63:0] stationReg15;
wire[9:0] in0_Bin0;
wire[9:0] in1_Bin0;
wire out0_Bin0 = in0_Bin0 == in1_Bin0;
wire[9:0] in0_Bin1;
wire in1_Bin1;
wire[9:0] out0_Bin1 = in0_Bin1 + in1_Bin1;
wire signed[63:0] in0_Bin2;
wire signed[26:0] in1_Bin2;
wire signed[63:0] out0_Bin2 = in0_Bin2 * in1_Bin2;
wire signed[63:0] in0_Bin3;
wire signed[63:0] in1_Bin3;
wire signed[63:0] out0_Bin3 = in0_Bin3 + in1_Bin3;
wire arrWEnable_a;
wire[9:0] arrAddr_a;
wire signed[26:0] arrRData_a;
wire signed[26:0] arrWData_a;
arr_a arr_a(.*);
assign in0_Bin1 =
stateR == 5'd2 ? reg0[9:0] :
stateR == 5'd6 ? reg7[9:0] :
stateR == 5'd12 ? reg10[9:0] :
'x;
assign in1_Bin2 =
stateR == 5'd7 ? {reg9[63], reg9[26:0]} :
stateR == 5'd9 ? {reg9[63], reg9[26:0]} :
stateR == 5'd13 ? {reg14[63], reg14[26:0]} :
stateR == 5'd15 ? {reg14[63], reg14[26:0]} :
'x;
assign in0_Bin0 =
stateR == 5'd1 ? reg0[9:0] :
stateR == 5'd3 ? reg7[9:0] :
stateR == 5'd7 ? reg10[9:0] :
stateR == 5'd13 ? reg6[9:0] :
'x;
assign in0_Bin3 =
stateR == 5'd10 ? reg1 :
stateR == 5'd12 ? reg1 :
stateR == 5'd14 ? reg1 :
stateR == 5'd16 ? reg1 :
'x;
assign in1_Bin3 =
stateR == 5'd10 ? reg13 :
stateR == 5'd12 ? reg13 :
stateR == 5'd14 ? reg13 :
stateR == 5'd16 ? reg9 :
'x;
assign in1_Bin1 =
stateR == 5'd2 ? 1'd1 :
stateR == 5'd6 ? 1'd1 :
stateR == 5'd12 ? 1'd1 :
'x;
assign in0_Bin2 =
stateR == 5'd7 ? reg11 :
stateR == 5'd9 ? reg11 :
stateR == 5'd13 ? reg0 :
stateR == 5'd15 ? reg0 :
'x;
assign in1_Bin0 =
stateR == 5'd1 ? 10'd1000 :
stateR == 5'd3 ? 10'd1000 :
stateR == 5'd7 ? 10'd1000 :
stateR == 5'd13 ? 10'd1000 :
'x;
assign arrWEnable_a =
controlArr ? controlArrWEnable_a :
stateR == 5'd2 ? 1'd0 :
stateR == 5'd3 ? 1'd0 :
stateR == 5'd6 ? 1'd0 :
stateR == 5'd7 ? 1'd0 :
stateR == 5'd12 ? 1'd0 :
stateR == 5'd13 ? 1'd0 :
1'd0;
assign arrAddr_a =
controlArr ? controlArrAddr_a :
stateR == 5'd2 ? reg0[9:0] :
stateR == 5'd3 ? reg0[9:0] :
stateR == 5'd6 ? reg7[9:0] :
stateR == 5'd7 ? reg7[9:0] :
stateR == 5'd12 ? reg10[9:0] :
stateR == 5'd13 ? reg10[9:0] :
'x;
assign arrWData_a =
controlArr ? controlArrWData_a :
'x;
assign controlArrRData_a = controlArr ? arrRData_a : 'x;
assign stationReg0 =
stateR == 5'd12 ? {{37{arrRData_a[26]}}, arrRData_a} :
stateR == 5'd14 ? {{37{arrRData_a[26]}}, arrRData_a} :
reg0;
assign stationReg1 =
stateR == 5'd10 ? out0_Bin3 :
stateR == 5'd12 ? out0_Bin3 :
stateR == 5'd14 ? out0_Bin3 :
reg1;
assign stationReg2 =
reg2;
assign stationReg3 =
reg3;
assign stationReg4 =
reg4;
assign stationReg5 =
reg5;
assign stationReg6 =
stateR == 5'd1 ? {63'd0, out0_Bin0} :
stateR == 5'd12 ? {54'd0, out0_Bin1} :
reg6;
assign stationReg7 =
stateR == 5'd2 ? {54'd0, out0_Bin1} :
reg7;
assign stationReg8 =
stateR == 5'd3 ? {63'd0, out0_Bin0} :
reg8;
assign stationReg9 =
stateR == 5'd3 ? {{37{arrRData_a[26]}}, arrRData_a} :
stateR == 5'd13 ? out0_Bin2 :
stateR == 5'd15 ? out0_Bin2 :
reg9;
assign stationReg10 =
stateR == 5'd6 ? {54'd0, out0_Bin1} :
reg10;
assign stationReg11 =
stateR == 5'd6 ? {{37{arrRData_a[26]}}, arrRData_a} :
stateR == 5'd8 ? {{37{arrRData_a[26]}}, arrRData_a} :
stateR == 5'd13 ? {{37{arrRData_a[26]}}, arrRData_a} :
reg11;
assign stationReg12 =
stateR == 5'd7 ? {63'd0, out0_Bin0} :
reg12;
assign stationReg13 =
stateR == 5'd7 ? out0_Bin2 :
stateR == 5'd9 ? out0_Bin2 :
stateR == 5'd13 ? {63'd0, out0_Bin0} :
reg13;
assign stationReg14 =
stateR == 5'd7 ? {{37{arrRData_a[26]}}, arrRData_a} :
reg14;
assign stationReg15 =
stateR == 5'd16 ? out0_Bin3 :
reg15;
always @(posedge clk) begin
if(r_enable) begin
stateR <= '0;
linkreg <= '1;
w_enable <= 1'd0;
reg0 <= {54'd0, init_i_t_a};
reg1 <= init_acc_t_a;
end else begin
case(stateR)
'1: begin
w_enable <= 1'd1;
result <= reg0;
end
5'd0: stateR <= 5'd1;
5'd1: stateR <= (stationReg6) ? 5'd5 : 5'd2;
5'd2: stateR <= 5'd3;
5'd3: stateR <= (stationReg8) ? 5'd8 : 5'd6;
5'd5: stateR <= linkreg;
5'd6: stateR <= 5'd7;
5'd7: stateR <= (stationReg12) ? 5'd14 : 5'd12;
5'd8: stateR <= 5'd9;
5'd9: stateR <= 5'd10;
5'd10: stateR <= linkreg;
5'd12: stateR <= 5'd13;
5'd13: stateR <= (stationReg13) ? 5'd14 : 5'd12;
5'd14: stateR <= 5'd15;
5'd15: stateR <= 5'd16;
5'd16: stateR <= linkreg;
endcase
case(stateR)
5'd5: reg0 <= stationReg1;
5'd10: reg0 <= stationReg1;
5'd13: reg0 <= stationReg7;
5'd16: reg0 <= stationReg15;
default: reg0 <= stationReg0;
endcase
case(stateR)
5'd13: reg1 <= stationReg1;
default: reg1 <= stationReg1;
endcase
case(stateR)
default: reg2 <= stationReg2;
endcase
case(stateR)
5'd13: reg3 <= stationReg2;
default: reg3 <= stationReg3;
endcase
case(stateR)
default: reg4 <= stationReg4;
endcase
case(stateR)
default: reg5 <= stationReg5;
endcase
case(stateR)
5'd13: reg6 <= stationReg8;
default: reg6 <= stationReg6;
endcase
case(stateR)
5'd13: reg7 <= stationReg10;
default: reg7 <= stationReg7;
endcase
case(stateR)
5'd13: reg8 <= stationReg12;
default: reg8 <= stationReg8;
endcase
case(stateR)
5'd13: reg9 <= stationReg14;
default: reg9 <= stationReg9;
endcase
case(stateR)
5'd13: reg10 <= stationReg6;
default: reg10 <= stationReg10;
endcase
case(stateR)
5'd13: reg11 <= stationReg0;
default: reg11 <= stationReg11;
endcase
case(stateR)
5'd13: reg12 <= stationReg13;
default: reg12 <= stationReg12;
endcase
case(stateR)
5'd13: reg13 <= stationReg9;
default: reg13 <= stationReg13;
endcase
case(stateR)
5'd13: reg14 <= stationReg11;
default: reg14 <= stationReg14;
endcase
case(stateR)
5'd13: reg15 <= stationReg3;
default: reg15 <= stationReg15;
endcase
end
end
endmodule // main
module arr_a (
input wire clk, arrWEnable_a,
input wire[9:0] arrAddr_a,
output wire signed[26:0] arrRData_a,
input wire signed[26:0] arrWData_a
);
reg[9:0] delayedRAddr;
reg signed[26:0] mem [0:1023];
always @(posedge clk) begin
if(arrWEnable_a) begin
mem[arrAddr_a] <= arrWData_a;
end
delayedRAddr <= arrAddr_a;
end
assign arrRData_a = mem[delayedRAddr];
endmodule
`default_nettype wire