1 | ///////////////////////////////////////////////////////////////////// |
---|
2 | //// //// |
---|
3 | //// WISHBONE Connection Bus Top Level //// |
---|
4 | //// //// |
---|
5 | //// //// |
---|
6 | //// Author: Johny Chi //// |
---|
7 | //// [email protected] //// |
---|
8 | //// //// |
---|
9 | //// //// |
---|
10 | //// //// |
---|
11 | ///////////////////////////////////////////////////////////////////// |
---|
12 | //// //// |
---|
13 | //// Copyright (C) 2000 Authors and OPENCORES.ORG //// |
---|
14 | //// //// |
---|
15 | //// This source file may be used and distributed without //// |
---|
16 | //// restriction provided that this copyright statement is not //// |
---|
17 | //// removed from the file and that any derivative work contains //// |
---|
18 | //// the original copyright notice and the associated disclaimer. //// |
---|
19 | //// //// |
---|
20 | //// This source file is free software; you can redistribute it //// |
---|
21 | //// and/or modify it under the terms of the GNU Lesser General //// |
---|
22 | //// Public License as published by the Free Software Foundation; //// |
---|
23 | //// either version 2.1 of the License, or (at your option) any //// |
---|
24 | //// later version. //// |
---|
25 | //// //// |
---|
26 | //// This source is distributed in the hope that it will be //// |
---|
27 | //// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
---|
28 | //// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
---|
29 | //// PURPOSE. See the GNU Lesser General Public License for more //// |
---|
30 | //// details. //// |
---|
31 | //// //// |
---|
32 | //// You should have received a copy of the GNU Lesser General //// |
---|
33 | //// Public License along with this source; if not, download it //// |
---|
34 | //// from http://www.opencores.org/lgpl.shtml //// |
---|
35 | //// //// |
---|
36 | ////////////////////////////////////////////////////////////////////// |
---|
37 | // |
---|
38 | // Description |
---|
39 | // 1. Up to 8 masters and 8 slaves share bus Wishbone connection |
---|
40 | // 2. no priorty arbitor , 8 masters are processed in a round |
---|
41 | // robin way, |
---|
42 | // 3. if WB_USE_TRISTATE was defined, the share bus is a tristate |
---|
43 | // bus, and use less logic resource. |
---|
44 | // 4. wb_conbus was synthesis to XC2S100-5-PQ208 using synplify, |
---|
45 | // Max speed >60M , and 374 SLICE if using Multiplexor bus |
---|
46 | // or 150 SLICE if using tri-state bus. |
---|
47 | // |
---|
48 | `include "wb_conbus_defines.v" |
---|
49 | `define dw 64 // Data bus Width |
---|
50 | `define aw 64 // Address bus Width |
---|
51 | `define sw `dw / 8 // Number of Select Lines |
---|
52 | `define mbusw `aw + `sw + `dw +4 //address width + byte select width + dat width + cyc + we + stb +cab , input from master interface |
---|
53 | `define sbusw 3 // ack + err + rty, input from slave interface |
---|
54 | `define mselectw 8 // number of masters |
---|
55 | `define sselectw 8 // number of slavers |
---|
56 | |
---|
57 | //`define WB_USE_TRISTATE |
---|
58 | |
---|
59 | |
---|
60 | module wb_conbus_top( |
---|
61 | clk_i, rst_i, |
---|
62 | |
---|
63 | // Master 0 Interface |
---|
64 | m0_dat_i, m0_dat_o, m0_adr_i, m0_sel_i, m0_we_i, m0_cyc_i, |
---|
65 | m0_stb_i, m0_ack_o, m0_err_o, m0_rty_o, m0_cab_i, |
---|
66 | |
---|
67 | // Master 1 Interface |
---|
68 | m1_dat_i, m1_dat_o, m1_adr_i, m1_sel_i, m1_we_i, m1_cyc_i, |
---|
69 | m1_stb_i, m1_ack_o, m1_err_o, m1_rty_o, m1_cab_i, |
---|
70 | |
---|
71 | // Master 2 Interface |
---|
72 | m2_dat_i, m2_dat_o, m2_adr_i, m2_sel_i, m2_we_i, m2_cyc_i, |
---|
73 | m2_stb_i, m2_ack_o, m2_err_o, m2_rty_o, m2_cab_i, |
---|
74 | |
---|
75 | // Master 3 Interface |
---|
76 | m3_dat_i, m3_dat_o, m3_adr_i, m3_sel_i, m3_we_i, m3_cyc_i, |
---|
77 | m3_stb_i, m3_ack_o, m3_err_o, m3_rty_o, m3_cab_i, |
---|
78 | |
---|
79 | // Master 4 Interface |
---|
80 | m4_dat_i, m4_dat_o, m4_adr_i, m4_sel_i, m4_we_i, m4_cyc_i, |
---|
81 | m4_stb_i, m4_ack_o, m4_err_o, m4_rty_o, m4_cab_i, |
---|
82 | |
---|
83 | // Master 5 Interface |
---|
84 | m5_dat_i, m5_dat_o, m5_adr_i, m5_sel_i, m5_we_i, m5_cyc_i, |
---|
85 | m5_stb_i, m5_ack_o, m5_err_o, m5_rty_o, m5_cab_i, |
---|
86 | |
---|
87 | // Master 6 Interface |
---|
88 | m6_dat_i, m6_dat_o, m6_adr_i, m6_sel_i, m6_we_i, m6_cyc_i, |
---|
89 | m6_stb_i, m6_ack_o, m6_err_o, m6_rty_o, m6_cab_i, |
---|
90 | |
---|
91 | // Master 7 Interface |
---|
92 | m7_dat_i, m7_dat_o, m7_adr_i, m7_sel_i, m7_we_i, m7_cyc_i, |
---|
93 | m7_stb_i, m7_ack_o, m7_err_o, m7_rty_o, m7_cab_i, |
---|
94 | |
---|
95 | // Slave 0 Interface |
---|
96 | s0_dat_i, s0_dat_o, s0_adr_o, s0_sel_o, s0_we_o, s0_cyc_o, |
---|
97 | s0_stb_o, s0_ack_i, s0_err_i, s0_rty_i, s0_cab_o, |
---|
98 | |
---|
99 | // Slave 1 Interface |
---|
100 | s1_dat_i, s1_dat_o, s1_adr_o, s1_sel_o, s1_we_o, s1_cyc_o, |
---|
101 | s1_stb_o, s1_ack_i, s1_err_i, s1_rty_i, s1_cab_o, |
---|
102 | |
---|
103 | // Slave 2 Interface |
---|
104 | s2_dat_i, s2_dat_o, s2_adr_o, s2_sel_o, s2_we_o, s2_cyc_o, |
---|
105 | s2_stb_o, s2_ack_i, s2_err_i, s2_rty_i, s2_cab_o, |
---|
106 | |
---|
107 | // Slave 3 Interface |
---|
108 | s3_dat_i, s3_dat_o, s3_adr_o, s3_sel_o, s3_we_o, s3_cyc_o, |
---|
109 | s3_stb_o, s3_ack_i, s3_err_i, s3_rty_i, s3_cab_o, |
---|
110 | |
---|
111 | // Slave 4 Interface |
---|
112 | s4_dat_i, s4_dat_o, s4_adr_o, s4_sel_o, s4_we_o, s4_cyc_o, |
---|
113 | s4_stb_o, s4_ack_i, s4_err_i, s4_rty_i, s4_cab_o, |
---|
114 | |
---|
115 | // Slave 5 Interface |
---|
116 | s5_dat_i, s5_dat_o, s5_adr_o, s5_sel_o, s5_we_o, s5_cyc_o, |
---|
117 | s5_stb_o, s5_ack_i, s5_err_i, s5_rty_i, s5_cab_o, |
---|
118 | |
---|
119 | // Slave 6 Interface |
---|
120 | s6_dat_i, s6_dat_o, s6_adr_o, s6_sel_o, s6_we_o, s6_cyc_o, |
---|
121 | s6_stb_o, s6_ack_i, s6_err_i, s6_rty_i, s6_cab_o, |
---|
122 | |
---|
123 | // Slave 7 Interface |
---|
124 | s7_dat_i, s7_dat_o, s7_adr_o, s7_sel_o, s7_we_o, s7_cyc_o, |
---|
125 | s7_stb_o, s7_ack_i, s7_err_i, s7_rty_i, s7_cab_o |
---|
126 | |
---|
127 | ); |
---|
128 | |
---|
129 | //////////////////////////////////////////////////////////////////// |
---|
130 | // |
---|
131 | // Module Parameters |
---|
132 | // |
---|
133 | |
---|
134 | |
---|
135 | // address for DDR from 0x0 to 0x7fffffff_ffffffff (64'h00000000_00000000 to 64'h7fffffff_ffffffff) |
---|
136 | parameter s0_addr_w = 1 ; // slave 0 address decode width |
---|
137 | parameter s0_addr = 1'b0; // slave 0 address |
---|
138 | |
---|
139 | //PCX request on 800000ff_f0000020 |
---|
140 | //address for a 32MB flash from 0x800000ff_f0000000 to 0x800000ff_f07fffff |
---|
141 | //Check address_w |
---|
142 | // 32 MB --> 8 MW X32 bits --> 2^23 --> addr_w=64-23=41 |
---|
143 | parameter s1_addr_w = 41 ; // slave 1 address decode width |
---|
144 | parameter s1_addr = {40'h800000FFF0,1'b0}; // slave 1 address |
---|
145 | |
---|
146 | parameter s2_addr_w = 56 ; |
---|
147 | parameter s2_addr = {56'h800000FFF0C2C1}; // slave 2 address |
---|
148 | parameter s3_addr_w = 60 ; |
---|
149 | parameter s3_addr = {60'h800000FFF0C2C00}; // slave 3 address |
---|
150 | parameter s4_addr_w = 37 ; |
---|
151 | parameter s4_addr = {36'h800000FFF,1'b1}; // slave 4 address |
---|
152 | parameter s5_addr_w = 60 ; |
---|
153 | parameter s5_addr = {60'h400000F00000000}; // slave 5 address |
---|
154 | parameter s6_addr_w = 60 ; |
---|
155 | parameter s6_addr = {60'h500000F00000000}; // slave 6 address |
---|
156 | parameter s7_addr_w = 60 ; |
---|
157 | parameter s7_addr = {60'h600000F00000000}; // slave 7 address |
---|
158 | |
---|
159 | |
---|
160 | //////////////////////////////////////////////////////////////////// |
---|
161 | // |
---|
162 | // Module IOs |
---|
163 | // |
---|
164 | |
---|
165 | input clk_i, rst_i; |
---|
166 | |
---|
167 | // Master 0 Interface |
---|
168 | input [`dw-1:0] m0_dat_i; |
---|
169 | output [`dw-1:0] m0_dat_o; |
---|
170 | input [`aw-1:0] m0_adr_i; |
---|
171 | input [`sw-1:0] m0_sel_i; |
---|
172 | input m0_we_i; |
---|
173 | input m0_cyc_i; |
---|
174 | input m0_stb_i; |
---|
175 | input m0_cab_i; |
---|
176 | output m0_ack_o; |
---|
177 | output m0_err_o; |
---|
178 | output m0_rty_o; |
---|
179 | |
---|
180 | // Master 1 Interface |
---|
181 | input [`dw-1:0] m1_dat_i; |
---|
182 | output [`dw-1:0] m1_dat_o; |
---|
183 | input [`aw-1:0] m1_adr_i; |
---|
184 | input [`sw-1:0] m1_sel_i; |
---|
185 | input m1_we_i; |
---|
186 | input m1_cyc_i; |
---|
187 | input m1_stb_i; |
---|
188 | input m1_cab_i; |
---|
189 | output m1_ack_o; |
---|
190 | output m1_err_o; |
---|
191 | output m1_rty_o; |
---|
192 | |
---|
193 | // Master 2 Interface |
---|
194 | input [`dw-1:0] m2_dat_i; |
---|
195 | output [`dw-1:0] m2_dat_o; |
---|
196 | input [`aw-1:0] m2_adr_i; |
---|
197 | input [`sw-1:0] m2_sel_i; |
---|
198 | input m2_we_i; |
---|
199 | input m2_cyc_i; |
---|
200 | input m2_stb_i; |
---|
201 | input m2_cab_i; |
---|
202 | output m2_ack_o; |
---|
203 | output m2_err_o; |
---|
204 | output m2_rty_o; |
---|
205 | |
---|
206 | // Master 3 Interface |
---|
207 | input [`dw-1:0] m3_dat_i; |
---|
208 | output [`dw-1:0] m3_dat_o; |
---|
209 | input [`aw-1:0] m3_adr_i; |
---|
210 | input [`sw-1:0] m3_sel_i; |
---|
211 | input m3_we_i; |
---|
212 | input m3_cyc_i; |
---|
213 | input m3_stb_i; |
---|
214 | input m3_cab_i; |
---|
215 | output m3_ack_o; |
---|
216 | output m3_err_o; |
---|
217 | output m3_rty_o; |
---|
218 | |
---|
219 | // Master 4 Interface |
---|
220 | input [`dw-1:0] m4_dat_i; |
---|
221 | output [`dw-1:0] m4_dat_o; |
---|
222 | input [`aw-1:0] m4_adr_i; |
---|
223 | input [`sw-1:0] m4_sel_i; |
---|
224 | input m4_we_i; |
---|
225 | input m4_cyc_i; |
---|
226 | input m4_stb_i; |
---|
227 | input m4_cab_i; |
---|
228 | output m4_ack_o; |
---|
229 | output m4_err_o; |
---|
230 | output m4_rty_o; |
---|
231 | |
---|
232 | // Master 5 Interface |
---|
233 | input [`dw-1:0] m5_dat_i; |
---|
234 | output [`dw-1:0] m5_dat_o; |
---|
235 | input [`aw-1:0] m5_adr_i; |
---|
236 | input [`sw-1:0] m5_sel_i; |
---|
237 | input m5_we_i; |
---|
238 | input m5_cyc_i; |
---|
239 | input m5_stb_i; |
---|
240 | input m5_cab_i; |
---|
241 | output m5_ack_o; |
---|
242 | output m5_err_o; |
---|
243 | output m5_rty_o; |
---|
244 | |
---|
245 | // Master 6 Interface |
---|
246 | input [`dw-1:0] m6_dat_i; |
---|
247 | output [`dw-1:0] m6_dat_o; |
---|
248 | input [`aw-1:0] m6_adr_i; |
---|
249 | input [`sw-1:0] m6_sel_i; |
---|
250 | input m6_we_i; |
---|
251 | input m6_cyc_i; |
---|
252 | input m6_stb_i; |
---|
253 | input m6_cab_i; |
---|
254 | output m6_ack_o; |
---|
255 | output m6_err_o; |
---|
256 | output m6_rty_o; |
---|
257 | |
---|
258 | // Master 7 Interface |
---|
259 | input [`dw-1:0] m7_dat_i; |
---|
260 | output [`dw-1:0] m7_dat_o; |
---|
261 | input [`aw-1:0] m7_adr_i; |
---|
262 | input [`sw-1:0] m7_sel_i; |
---|
263 | input m7_we_i; |
---|
264 | input m7_cyc_i; |
---|
265 | input m7_stb_i; |
---|
266 | input m7_cab_i; |
---|
267 | output m7_ack_o; |
---|
268 | output m7_err_o; |
---|
269 | output m7_rty_o; |
---|
270 | |
---|
271 | // Slave 0 Interface |
---|
272 | input [`dw-1:0] s0_dat_i; |
---|
273 | output [`dw-1:0] s0_dat_o; |
---|
274 | output [`aw-1:0] s0_adr_o; |
---|
275 | output [`sw-1:0] s0_sel_o; |
---|
276 | output s0_we_o; |
---|
277 | output s0_cyc_o; |
---|
278 | output s0_stb_o; |
---|
279 | output s0_cab_o; |
---|
280 | input s0_ack_i; |
---|
281 | input s0_err_i; |
---|
282 | input s0_rty_i; |
---|
283 | |
---|
284 | // Slave 1 Interface |
---|
285 | input [`dw-1:0] s1_dat_i; |
---|
286 | output [`dw-1:0] s1_dat_o; |
---|
287 | output [`aw-1:0] s1_adr_o; |
---|
288 | output [`sw-1:0] s1_sel_o; |
---|
289 | output s1_we_o; |
---|
290 | output s1_cyc_o; |
---|
291 | output s1_stb_o; |
---|
292 | output s1_cab_o; |
---|
293 | input s1_ack_i; |
---|
294 | input s1_err_i; |
---|
295 | input s1_rty_i; |
---|
296 | |
---|
297 | // Slave 2 Interface |
---|
298 | input [`dw-1:0] s2_dat_i; |
---|
299 | output [`dw-1:0] s2_dat_o; |
---|
300 | output [`aw-1:0] s2_adr_o; |
---|
301 | output [`sw-1:0] s2_sel_o; |
---|
302 | output s2_we_o; |
---|
303 | output s2_cyc_o; |
---|
304 | output s2_stb_o; |
---|
305 | output s2_cab_o; |
---|
306 | input s2_ack_i; |
---|
307 | input s2_err_i; |
---|
308 | input s2_rty_i; |
---|
309 | |
---|
310 | // Slave 3 Interface |
---|
311 | input [`dw-1:0] s3_dat_i; |
---|
312 | output [`dw-1:0] s3_dat_o; |
---|
313 | output [`aw-1:0] s3_adr_o; |
---|
314 | output [`sw-1:0] s3_sel_o; |
---|
315 | output s3_we_o; |
---|
316 | output s3_cyc_o; |
---|
317 | output s3_stb_o; |
---|
318 | output s3_cab_o; |
---|
319 | input s3_ack_i; |
---|
320 | input s3_err_i; |
---|
321 | input s3_rty_i; |
---|
322 | |
---|
323 | // Slave 4 Interface |
---|
324 | input [`dw-1:0] s4_dat_i; |
---|
325 | output [`dw-1:0] s4_dat_o; |
---|
326 | output [`aw-1:0] s4_adr_o; |
---|
327 | output [`sw-1:0] s4_sel_o; |
---|
328 | output s4_we_o; |
---|
329 | output s4_cyc_o; |
---|
330 | output s4_stb_o; |
---|
331 | output s4_cab_o; |
---|
332 | input s4_ack_i; |
---|
333 | input s4_err_i; |
---|
334 | input s4_rty_i; |
---|
335 | |
---|
336 | // Slave 5 Interface |
---|
337 | input [`dw-1:0] s5_dat_i; |
---|
338 | output [`dw-1:0] s5_dat_o; |
---|
339 | output [`aw-1:0] s5_adr_o; |
---|
340 | output [`sw-1:0] s5_sel_o; |
---|
341 | output s5_we_o; |
---|
342 | output s5_cyc_o; |
---|
343 | output s5_stb_o; |
---|
344 | output s5_cab_o; |
---|
345 | input s5_ack_i; |
---|
346 | input s5_err_i; |
---|
347 | input s5_rty_i; |
---|
348 | |
---|
349 | // Slave 6 Interface |
---|
350 | input [`dw-1:0] s6_dat_i; |
---|
351 | output [`dw-1:0] s6_dat_o; |
---|
352 | output [`aw-1:0] s6_adr_o; |
---|
353 | output [`sw-1:0] s6_sel_o; |
---|
354 | output s6_we_o; |
---|
355 | output s6_cyc_o; |
---|
356 | output s6_stb_o; |
---|
357 | output s6_cab_o; |
---|
358 | input s6_ack_i; |
---|
359 | input s6_err_i; |
---|
360 | input s6_rty_i; |
---|
361 | |
---|
362 | // Slave 7 Interface |
---|
363 | input [`dw-1:0] s7_dat_i; |
---|
364 | output [`dw-1:0] s7_dat_o; |
---|
365 | output [`aw-1:0] s7_adr_o; |
---|
366 | output [`sw-1:0] s7_sel_o; |
---|
367 | output s7_we_o; |
---|
368 | output s7_cyc_o; |
---|
369 | output s7_stb_o; |
---|
370 | output s7_cab_o; |
---|
371 | input s7_ack_i; |
---|
372 | input s7_err_i; |
---|
373 | input s7_rty_i; |
---|
374 | |
---|
375 | |
---|
376 | //////////////////////////////////////////////////////////////////// |
---|
377 | // |
---|
378 | // Local wires |
---|
379 | // |
---|
380 | |
---|
381 | wire [`mselectw -1:0] i_gnt_arb; |
---|
382 | wire [2:0] gnt; |
---|
383 | reg [`sselectw -1:0] i_ssel_dec; |
---|
384 | `ifdef WB_USE_TRISTATE |
---|
385 | wire [`mbusw -1:0] i_bus_m; |
---|
386 | `else |
---|
387 | reg [`mbusw -1:0] i_bus_m; // internal share bus, master data and control to slave |
---|
388 | `endif |
---|
389 | wire [`dw -1:0] i_dat_s; // internal share bus , slave data to master |
---|
390 | wire [`sbusw -1:0] i_bus_s; // internal share bus , slave control to master |
---|
391 | |
---|
392 | |
---|
393 | |
---|
394 | //////////////////////////////////////////////////////////////////// |
---|
395 | // |
---|
396 | // Master output Interfaces |
---|
397 | // |
---|
398 | |
---|
399 | // master0 |
---|
400 | assign m0_dat_o = i_dat_s; |
---|
401 | assign {m0_ack_o, m0_err_o, m0_rty_o} = i_bus_s & {3{i_gnt_arb[0]}}; |
---|
402 | |
---|
403 | // master1 |
---|
404 | assign m1_dat_o = i_dat_s; |
---|
405 | assign {m1_ack_o, m1_err_o, m1_rty_o} = i_bus_s & {3{i_gnt_arb[1]}}; |
---|
406 | |
---|
407 | // master2 |
---|
408 | |
---|
409 | assign m2_dat_o = i_dat_s; |
---|
410 | assign {m2_ack_o, m2_err_o, m2_rty_o} = i_bus_s & {3{i_gnt_arb[2]}}; |
---|
411 | |
---|
412 | // master3 |
---|
413 | |
---|
414 | assign m3_dat_o = i_dat_s; |
---|
415 | assign {m3_ack_o, m3_err_o, m3_rty_o} = i_bus_s & {3{i_gnt_arb[3]}}; |
---|
416 | |
---|
417 | // master4 |
---|
418 | |
---|
419 | assign m4_dat_o = i_dat_s; |
---|
420 | assign {m4_ack_o, m4_err_o, m4_rty_o} = i_bus_s & {3{i_gnt_arb[4]}}; |
---|
421 | |
---|
422 | // master5 |
---|
423 | |
---|
424 | assign m5_dat_o = i_dat_s; |
---|
425 | assign {m5_ack_o, m5_err_o, m5_rty_o} = i_bus_s & {3{i_gnt_arb[5]}}; |
---|
426 | |
---|
427 | // master6 |
---|
428 | |
---|
429 | assign m6_dat_o = i_dat_s; |
---|
430 | assign {m6_ack_o, m6_err_o, m6_rty_o} = i_bus_s & {3{i_gnt_arb[6]}}; |
---|
431 | |
---|
432 | // master7 |
---|
433 | |
---|
434 | assign m7_dat_o = i_dat_s; |
---|
435 | assign {m7_ack_o, m7_err_o, m7_rty_o} = i_bus_s & {3{i_gnt_arb[7]}}; |
---|
436 | |
---|
437 | |
---|
438 | assign i_bus_s = {s0_ack_i | s1_ack_i | s2_ack_i | s3_ack_i | s4_ack_i | s5_ack_i | s6_ack_i | s7_ack_i , |
---|
439 | s0_err_i | s1_err_i | s2_err_i | s3_err_i | s4_err_i | s5_err_i | s6_err_i | s7_err_i , |
---|
440 | s0_rty_i | s1_rty_i | s2_rty_i | s3_rty_i | s4_rty_i | s5_rty_i | s6_rty_i | s7_rty_i }; |
---|
441 | |
---|
442 | //////////////////////////////// |
---|
443 | // Slave output interface |
---|
444 | // |
---|
445 | // slave0 |
---|
446 | assign {s0_adr_o, s0_sel_o, s0_dat_o, s0_we_o, s0_cab_o,s0_cyc_o} = i_bus_m[`mbusw -1:1]; |
---|
447 | assign s0_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[0]; // stb_o = cyc_i & stb_i & i_ssel_dec |
---|
448 | |
---|
449 | // slave1 |
---|
450 | |
---|
451 | assign {s1_adr_o, s1_sel_o, s1_dat_o, s1_we_o, s1_cab_o, s1_cyc_o} = i_bus_m[`mbusw -1:1]; |
---|
452 | assign s1_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[1]; |
---|
453 | |
---|
454 | // slave2 |
---|
455 | |
---|
456 | assign {s2_adr_o, s2_sel_o, s2_dat_o, s2_we_o, s2_cab_o, s2_cyc_o} = i_bus_m[`mbusw -1:1]; |
---|
457 | assign s2_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[2]; |
---|
458 | |
---|
459 | // slave3 |
---|
460 | |
---|
461 | assign {s3_adr_o, s3_sel_o, s3_dat_o, s3_we_o, s3_cab_o, s3_cyc_o} = i_bus_m[`mbusw -1:1]; |
---|
462 | assign s3_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[3]; |
---|
463 | |
---|
464 | // slave4 |
---|
465 | |
---|
466 | assign {s4_adr_o, s4_sel_o, s4_dat_o, s4_we_o, s4_cab_o, s4_cyc_o} = i_bus_m[`mbusw -1:1]; |
---|
467 | assign s4_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[4]; |
---|
468 | |
---|
469 | // slave5 |
---|
470 | |
---|
471 | assign {s5_adr_o, s5_sel_o, s5_dat_o, s5_we_o, s5_cab_o, s5_cyc_o} = i_bus_m[`mbusw -1:1]; |
---|
472 | assign s5_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[5]; |
---|
473 | |
---|
474 | // slave6 |
---|
475 | |
---|
476 | assign {s6_adr_o, s6_sel_o, s6_dat_o, s6_we_o, s6_cab_o, s6_cyc_o} = i_bus_m[`mbusw -1:1]; |
---|
477 | assign s6_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[6]; |
---|
478 | |
---|
479 | // slave7 |
---|
480 | |
---|
481 | assign {s7_adr_o, s7_sel_o, s7_dat_o, s7_we_o, s7_cab_o, s7_cyc_o} = i_bus_m[`mbusw -1:1]; |
---|
482 | assign s7_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[7]; |
---|
483 | |
---|
484 | /////////////////////////////////////// |
---|
485 | // Master and Slave input interface |
---|
486 | // |
---|
487 | |
---|
488 | `ifdef WB_USE_TRISTATE |
---|
489 | // input from master interface |
---|
490 | assign i_bus_m = i_gnt_arb[0] ? {m0_adr_i, m0_sel_i, m0_dat_i, m0_we_i, m0_cab_i, m0_cyc_i, m0_stb_i} : 72'bz ; |
---|
491 | assign i_bus_m = i_gnt_arb[1] ? {m1_adr_i, m1_sel_i, m1_dat_i, m1_we_i, m1_cab_i,m1_cyc_i, m1_stb_i} : 72'bz ; |
---|
492 | assign i_bus_m = i_gnt_arb[2] ? {m2_adr_i, m2_sel_i, m2_dat_i, m2_we_i, m2_cab_i, m2_cyc_i, m2_stb_i} : 72'bz ; |
---|
493 | assign i_bus_m = i_gnt_arb[3] ? {m3_adr_i, m3_sel_i, m3_dat_i, m3_we_i, m3_cab_i, m3_cyc_i, m3_stb_i} : 72'bz ; |
---|
494 | assign i_bus_m = i_gnt_arb[4] ? {m4_adr_i, m4_sel_i, m4_dat_i, m4_we_i, m4_cab_i, m4_cyc_i, m4_stb_i} : 72'bz ; |
---|
495 | assign i_bus_m = i_gnt_arb[5] ? {m5_adr_i, m5_sel_i, m5_dat_i, m5_we_i, m5_cab_i, m5_cyc_i, m5_stb_i} : 72'bz ; |
---|
496 | assign i_bus_m = i_gnt_arb[6] ? {m6_adr_i, m6_sel_i, m6_dat_i, m6_we_i, m6_cab_i, m6_cyc_i, m6_stb_i} : 72'bz ; |
---|
497 | assign i_bus_m = i_gnt_arb[7] ? {m7_adr_i, m7_sel_i, m7_dat_i, m7_we_i, m7_cab_i, m7_cyc_i,m7_stb_i} : 72'bz ; |
---|
498 | // input from slave interface |
---|
499 | assign i_dat_s = i_ssel_dec[0] ? s0_dat_i: 32'bz; |
---|
500 | assign i_dat_s = i_ssel_dec[1] ? s1_dat_i: 32'bz; |
---|
501 | assign i_dat_s = i_ssel_dec[2] ? s2_dat_i: 32'bz; |
---|
502 | assign i_dat_s = i_ssel_dec[3] ? s3_dat_i: 32'bz; |
---|
503 | assign i_dat_s = i_ssel_dec[4] ? s4_dat_i: 32'bz; |
---|
504 | assign i_dat_s = i_ssel_dec[5] ? s5_dat_i: 32'bz; |
---|
505 | assign i_dat_s = i_ssel_dec[6] ? s6_dat_i: 32'bz; |
---|
506 | assign i_dat_s = i_ssel_dec[7] ? s7_dat_i: 32'bz; |
---|
507 | |
---|
508 | `else |
---|
509 | |
---|
510 | always @(gnt , m0_adr_i, m0_sel_i, m0_dat_i, m0_we_i, m0_cab_i, m0_cyc_i,m0_stb_i, |
---|
511 | m1_adr_i, m1_sel_i, m1_dat_i, m1_we_i, m1_cab_i, m1_cyc_i,m1_stb_i, |
---|
512 | m2_adr_i, m2_sel_i, m2_dat_i, m2_we_i, m2_cab_i, m2_cyc_i,m2_stb_i, |
---|
513 | m3_adr_i, m3_sel_i, m3_dat_i, m3_we_i, m3_cab_i, m3_cyc_i,m3_stb_i, |
---|
514 | m4_adr_i, m4_sel_i, m4_dat_i, m4_we_i, m4_cab_i, m4_cyc_i,m4_stb_i, |
---|
515 | m5_adr_i, m5_sel_i, m5_dat_i, m5_we_i, m5_cab_i, m5_cyc_i,m5_stb_i, |
---|
516 | m6_adr_i, m6_sel_i, m6_dat_i, m6_we_i, m6_cab_i, m6_cyc_i,m6_stb_i, |
---|
517 | m7_adr_i, m7_sel_i, m7_dat_i, m7_we_i, m7_cab_i, m7_cyc_i,m7_stb_i) |
---|
518 | case(gnt) |
---|
519 | 3'h0: i_bus_m = {m0_adr_i, m0_sel_i, m0_dat_i, m0_we_i, m0_cab_i, m0_cyc_i,m0_stb_i}; |
---|
520 | 3'h1: i_bus_m = {m1_adr_i, m1_sel_i, m1_dat_i, m1_we_i, m1_cab_i, m1_cyc_i,m1_stb_i}; |
---|
521 | 3'h2: i_bus_m = {m2_adr_i, m2_sel_i, m2_dat_i, m2_we_i, m2_cab_i, m2_cyc_i,m2_stb_i}; |
---|
522 | 3'h3: i_bus_m = {m3_adr_i, m3_sel_i, m3_dat_i, m3_we_i, m3_cab_i, m3_cyc_i,m3_stb_i}; |
---|
523 | 3'h4: i_bus_m = {m4_adr_i, m4_sel_i, m4_dat_i, m4_we_i, m4_cab_i, m4_cyc_i,m4_stb_i}; |
---|
524 | 3'h5: i_bus_m = {m5_adr_i, m5_sel_i, m5_dat_i, m5_we_i, m5_cab_i, m5_cyc_i,m5_stb_i}; |
---|
525 | 3'h6: i_bus_m = {m6_adr_i, m6_sel_i, m6_dat_i, m6_we_i, m6_cab_i, m6_cyc_i,m6_stb_i}; |
---|
526 | 3'h7: i_bus_m = {m7_adr_i, m7_sel_i, m7_dat_i, m7_we_i, m7_cab_i, m7_cyc_i,m7_stb_i}; |
---|
527 | default:i_bus_m = 72'b0;//{m0_adr_i, m0_sel_i, m0_dat_i, m0_we_i, m0_cab_i, m0_cyc_i,m0_stb_i}; |
---|
528 | endcase |
---|
529 | |
---|
530 | assign i_dat_s = i_ssel_dec[0] ? s0_dat_i : |
---|
531 | i_ssel_dec[1] ? s1_dat_i : |
---|
532 | i_ssel_dec[2] ? s2_dat_i : |
---|
533 | i_ssel_dec[3] ? s3_dat_i : |
---|
534 | i_ssel_dec[4] ? s4_dat_i : |
---|
535 | i_ssel_dec[5] ? s5_dat_i : |
---|
536 | i_ssel_dec[6] ? s6_dat_i : |
---|
537 | i_ssel_dec[7] ? s7_dat_i : {`dw{1'b0}}; |
---|
538 | `endif |
---|
539 | // |
---|
540 | // arbitor |
---|
541 | // |
---|
542 | assign i_gnt_arb[0] = (gnt == 3'd0); |
---|
543 | assign i_gnt_arb[1] = (gnt == 3'd1); |
---|
544 | assign i_gnt_arb[2] = (gnt == 3'd2); |
---|
545 | assign i_gnt_arb[3] = (gnt == 3'd3); |
---|
546 | assign i_gnt_arb[4] = (gnt == 3'd4); |
---|
547 | assign i_gnt_arb[5] = (gnt == 3'd5); |
---|
548 | assign i_gnt_arb[6] = (gnt == 3'd6); |
---|
549 | assign i_gnt_arb[7] = (gnt == 3'd7); |
---|
550 | |
---|
551 | wb_conbus_arb wb_conbus_arb( |
---|
552 | .clk(clk_i), |
---|
553 | .rst(rst_i), |
---|
554 | .req({ m7_cyc_i, |
---|
555 | m6_cyc_i, |
---|
556 | m5_cyc_i, |
---|
557 | m4_cyc_i, |
---|
558 | m3_cyc_i, |
---|
559 | m2_cyc_i, |
---|
560 | m1_cyc_i, |
---|
561 | m0_cyc_i}), |
---|
562 | .gnt(gnt) |
---|
563 | ); |
---|
564 | |
---|
565 | ////////////////////////////////// |
---|
566 | // address decode logic |
---|
567 | // |
---|
568 | wire [7:0] m0_ssel_dec, m1_ssel_dec, m2_ssel_dec, m3_ssel_dec, m4_ssel_dec, m5_ssel_dec, m6_ssel_dec, m7_ssel_dec; |
---|
569 | always @(gnt, m0_ssel_dec, m1_ssel_dec, m2_ssel_dec, m3_ssel_dec, m4_ssel_dec, m5_ssel_dec, m6_ssel_dec, m7_ssel_dec) |
---|
570 | case(gnt) |
---|
571 | 3'h0: i_ssel_dec = m0_ssel_dec; |
---|
572 | 3'h1: i_ssel_dec = m1_ssel_dec; |
---|
573 | 3'h2: i_ssel_dec = m2_ssel_dec; |
---|
574 | 3'h3: i_ssel_dec = m3_ssel_dec; |
---|
575 | 3'h4: i_ssel_dec = m4_ssel_dec; |
---|
576 | 3'h5: i_ssel_dec = m5_ssel_dec; |
---|
577 | 3'h6: i_ssel_dec = m6_ssel_dec; |
---|
578 | 3'h7: i_ssel_dec = m7_ssel_dec; |
---|
579 | default: i_ssel_dec = 7'b0; |
---|
580 | endcase |
---|
581 | // |
---|
582 | // decode all master address before arbitor for running faster |
---|
583 | // |
---|
584 | assign m0_ssel_dec[0] = (m0_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
585 | assign m0_ssel_dec[1] = (m0_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
586 | assign m0_ssel_dec[2] = (m0_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
587 | assign m0_ssel_dec[3] = (m0_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
588 | assign m0_ssel_dec[4] = (m0_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
589 | assign m0_ssel_dec[5] = (m0_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
590 | assign m0_ssel_dec[6] = (m0_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
591 | assign m0_ssel_dec[7] = (m0_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
592 | |
---|
593 | assign m1_ssel_dec[0] = (m1_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
594 | assign m1_ssel_dec[1] = (m1_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
595 | assign m1_ssel_dec[2] = (m1_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
596 | assign m1_ssel_dec[3] = (m1_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
597 | assign m1_ssel_dec[4] = (m1_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
598 | assign m1_ssel_dec[5] = (m1_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
599 | assign m1_ssel_dec[6] = (m1_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
600 | assign m1_ssel_dec[7] = (m1_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
601 | |
---|
602 | assign m2_ssel_dec[0] = (m2_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
603 | assign m2_ssel_dec[1] = (m2_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
604 | assign m2_ssel_dec[2] = (m2_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
605 | assign m2_ssel_dec[3] = (m2_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
606 | assign m2_ssel_dec[4] = (m2_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
607 | assign m2_ssel_dec[5] = (m2_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
608 | assign m2_ssel_dec[6] = (m2_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
609 | assign m2_ssel_dec[7] = (m2_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
610 | |
---|
611 | assign m3_ssel_dec[0] = (m3_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
612 | assign m3_ssel_dec[1] = (m3_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
613 | assign m3_ssel_dec[2] = (m3_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
614 | assign m3_ssel_dec[3] = (m3_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
615 | assign m3_ssel_dec[4] = (m3_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
616 | assign m3_ssel_dec[5] = (m3_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
617 | assign m3_ssel_dec[6] = (m3_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
618 | assign m3_ssel_dec[7] = (m3_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
619 | |
---|
620 | assign m4_ssel_dec[0] = (m4_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
621 | assign m4_ssel_dec[1] = (m4_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
622 | assign m4_ssel_dec[2] = (m4_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
623 | assign m4_ssel_dec[3] = (m4_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
624 | assign m4_ssel_dec[4] = (m4_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
625 | assign m4_ssel_dec[5] = (m4_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
626 | assign m4_ssel_dec[6] = (m4_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
627 | assign m4_ssel_dec[7] = (m4_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
628 | |
---|
629 | assign m5_ssel_dec[0] = (m5_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
630 | assign m5_ssel_dec[1] = (m5_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
631 | assign m5_ssel_dec[2] = (m5_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
632 | assign m5_ssel_dec[3] = (m5_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
633 | assign m5_ssel_dec[4] = (m5_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
634 | assign m5_ssel_dec[5] = (m5_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
635 | assign m5_ssel_dec[6] = (m5_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
636 | assign m5_ssel_dec[7] = (m5_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
637 | |
---|
638 | assign m6_ssel_dec[0] = (m6_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
639 | assign m6_ssel_dec[1] = (m6_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
640 | assign m6_ssel_dec[2] = (m6_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
641 | assign m6_ssel_dec[3] = (m6_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
642 | assign m6_ssel_dec[4] = (m6_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
643 | assign m6_ssel_dec[5] = (m6_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
644 | assign m6_ssel_dec[6] = (m6_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
645 | assign m6_ssel_dec[7] = (m6_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
646 | |
---|
647 | assign m7_ssel_dec[0] = (m7_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
648 | assign m7_ssel_dec[1] = (m7_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
649 | assign m7_ssel_dec[2] = (m7_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
650 | assign m7_ssel_dec[3] = (m7_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
651 | assign m7_ssel_dec[4] = (m7_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
652 | assign m7_ssel_dec[5] = (m7_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
653 | assign m7_ssel_dec[6] = (m7_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
654 | assign m7_ssel_dec[7] = (m7_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
655 | |
---|
656 | //assign i_ssel_dec[0] = (i_bus_m[`mbusw -1 : `mbusw - s0_addr_w ] == s0_addr); |
---|
657 | //assign i_ssel_dec[1] = (i_bus_m[`mbusw -1 : `mbusw - s1_addr_w ] == s1_addr); |
---|
658 | //assign i_ssel_dec[2] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s2_addr); |
---|
659 | //assign i_ssel_dec[3] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s3_addr); |
---|
660 | //assign i_ssel_dec[4] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s4_addr); |
---|
661 | //assign i_ssel_dec[5] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s5_addr); |
---|
662 | //assign i_ssel_dec[6] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s6_addr); |
---|
663 | //assign i_ssel_dec[7] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s7_addr); |
---|
664 | |
---|
665 | |
---|
666 | endmodule |
---|
667 | |
---|