-
Notifications
You must be signed in to change notification settings - Fork 4
/
tt_top.v
280 lines (240 loc) · 5.41 KB
/
tt_top.v
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
/*
* tt_top.v
*
* Top level
*
* Copyright (c) 2023 Sylvain Munaut <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/
`default_nettype none
`include "tt_defs.vh"
module tt_top #(
parameter integer N_PADS = 44,
parameter integer G_X = `TT_G_X,
parameter integer G_Y = `TT_G_Y,
parameter integer N_AE = `TT_N_AE,
parameter integer N_AU = `TT_N_AU,
parameter integer N_IO = `TT_N_IO,
parameter integer N_O = `TT_N_O,
parameter integer N_I = `TT_N_I,
parameter [G_Y-1:0] MUX_MASK = `TT_MUX_MASK
)(
// Power
`ifdef USE_POWER_PINS
input wire VDPWR,
input wire VAPWR,
input wire VGND,
`endif
// IOs
inout wire [N_PADS-1:0] io_ana,
input wire [N_PADS-1:0] io_in,
output wire [N_PADS-1:0] io_out,
output wire [N_PADS-1:0] io_oeb,
// Convenient constants for top-level tie-offs
output wire k_zero,
output wire k_one
);
localparam integer S_OW = N_O + N_IO * 2 + 2;
localparam integer S_IW = N_I + N_IO + 9 + 1 + 2;
localparam integer U_OW = N_O + N_IO * 2;
localparam integer U_IW = N_I + N_IO;
// Signals
// -------
// Pads
wire [5:0] pad_ctl_in;
wire [5:0] pad_ctl_out;
wire [5:0] pad_ctl_oe_n;
wire [N_IO-1:0] pad_uio_in;
wire [N_IO-1:0] pad_uio_out;
wire [N_IO-1:0] pad_uio_oe_n;
wire [N_O-1:0] pad_uo_in;
wire [N_O-1:0] pad_uo_out;
wire [N_O-1:0] pad_uo_oe_n;
wire [N_I-1:0] pad_ui_in;
wire [N_I-1:0] pad_ui_out;
wire [N_I-1:0] pad_ui_oe_n;
wire [N_AE-1:0] pad_ana_in;
wire [N_AE-1:0] pad_ana_out;
wire [N_AE-1:0] pad_ana_oe_n;
wire [N_AE-1:0] pad_ana_analog;
// Vertical spine
wire [S_OW-1:0] spine_top_ow;
wire [S_IW-1:0] spine_top_iw;
wire [S_OW-1:0] spine_bot_ow;
wire [S_IW-1:0] spine_bot_iw;
// Control signals
wire ctrl_sel_rst_n;
wire ctrl_sel_inc;
wire ctrl_ena;
// Pad connections
// ---------------
// Split in groups
assign {
pad_ctl_in,
pad_ana_in[11:6],
pad_uo_in,
pad_uio_in,
pad_ui_in[1], // u_rst
pad_ui_in[0], // u_clk
pad_ui_in[9],
pad_ana_in[5:0],
pad_ui_in[8:2]
} = io_in;
assign io_out = {
pad_ctl_out,
pad_ana_out[11:6],
pad_uo_out,
pad_uio_out,
pad_ui_out[1], // u_rst
pad_ui_out[0], // u_clk
pad_ui_out[9],
pad_ana_out[5:0],
pad_ui_out[8:2]
};
assign io_oeb = {
pad_ctl_oe_n,
pad_ana_oe_n[11:6],
pad_uo_oe_n,
pad_uio_oe_n,
pad_ui_oe_n[1], // u_rst
pad_ui_oe_n[0], // u_clk
pad_ui_oe_n[9],
pad_ana_oe_n[5:0],
pad_ui_oe_n[8:2]
};
assign pad_ana_analog = {
io_ana[37:32],
io_ana[12:7]
};
// Tie-offs
// Control
assign pad_ctl_oe_n = { 6{k_one} };
assign pad_ctl_out = { 6{k_one} };
assign ctrl_sel_rst_n = pad_ctl_in[2];
assign ctrl_sel_inc = pad_ctl_in[1];
assign ctrl_ena = pad_ctl_in[0];
// Output enables
assign pad_uo_oe_n = { N_O{k_zero} };
assign pad_ui_oe_n = { N_I{k_one} };
assign pad_ana_oe_n = { N_AE{k_one} };
// Output signal
assign pad_ui_out = { N_I{k_one} };
assign pad_ana_out = { N_AE{k_one} };
// Controller
// ----------
(* blackbox *)
tt_ctrl
`ifdef SIM
#(
.N_I (N_I),
.N_O (N_O),
.N_IO (N_IO)
)
`endif
ctrl_I (
`ifdef USE_POWER_PINS
.VPWR (VDPWR),
.VGND (VGND),
`endif
.pad_uio_in (pad_uio_in),
.pad_uio_out (pad_uio_out),
.pad_uio_oe_n (pad_uio_oe_n),
.pad_uo_out (pad_uo_out),
.pad_ui_in (pad_ui_in),
.spine_top_ow (spine_top_ow),
.spine_top_iw (spine_top_iw),
.spine_bot_ow (spine_bot_ow),
.spine_bot_iw (spine_bot_iw),
.ctrl_sel_rst_n (ctrl_sel_rst_n),
.ctrl_sel_inc (ctrl_sel_inc),
.ctrl_ena (ctrl_ena),
.k_one (k_one),
.k_zero (k_zero)
);
// Branches
// --------
genvar i, j;
for (i=0; i<G_Y; i=i+1)
begin : branch
if (~MUX_MASK[i])
begin : check_mask
// Signals
wire [S_OW-1:0] l_spine_ow;
wire [S_IW-1:0] l_spine_iw;
wire [(U_OW*G_X)-1:0] l_um_ow;
wire [(U_IW*G_X)-1:0] l_um_iw;
wire [ G_X -1:0] l_um_ena;
wire [ G_X -1:0] l_um_k_zero;
wire [ G_X -1:0] l_um_pg_ena;
wire [3:0] l_addr;
wire l_k_one;
wire l_k_zero;
// Spine connection
if (i & 1) begin
assign spine_top_ow = l_spine_ow;
assign l_spine_iw = spine_top_iw;
end else begin
assign spine_bot_ow = l_spine_ow;
assign l_spine_iw = spine_bot_iw;
end
// Branch Mux
(* blackbox *)
tt_mux
`ifdef SIM
#(
.N_UM (G_X),
.N_I (N_I),
.N_O (N_O),
.N_IO (N_IO)
)
`endif
mux_I (
`ifdef USE_POWER_PINS
.VPWR (VDPWR),
.VGND (VGND),
`endif
.um_ow (l_um_ow),
.um_iw (l_um_iw),
.um_ena (l_um_ena),
.um_k_zero (l_um_k_zero),
.um_pg_ena (l_um_pg_ena),
.spine_ow (l_spine_ow),
.spine_iw (l_spine_iw),
.addr (l_addr),
.k_one (l_k_one),
.k_zero (l_k_zero)
);
// Branch address tie-offs
for (j=0; j<4; j=j+1)
if (i & (2<<j))
assign l_addr[j] = l_k_one;
else
assign l_addr[j] = l_k_zero;
// Branch User modules
for (j=0; j<G_X; j=j+1)
begin : block
tt_user_module #(
.MUX_ID (i),
.BLK_ID (j),
.N_AE (N_AE),
.N_AU (N_AU),
.N_I (N_I),
.N_O (N_O),
.N_IO (N_IO)
) um_I (
`ifdef USE_POWER_PINS
.VDPWR (VDPWR),
.VAPWR (VAPWR),
.VGND (VGND),
`endif
.ana (pad_ana_analog),
.ow (l_um_ow[j*U_OW+:U_OW]),
.iw (l_um_iw[j*U_IW+:U_IW]),
.ena (l_um_ena[j]),
.k_zero (l_um_k_zero[j]),
.pg_ena (l_um_pg_ena[j])
);
end
end
end
endmodule // tt_top