1 | ///////////////////////////////////////////////////////////////////// |
---|
2 | //// //// |
---|
3 | //// WISHBONE Connection Bus Top Level //// |
---|
4 | //// //// |
---|
5 | //// //// |
---|
6 | //// Author: Johny Chi //// |
---|
7 | //// chisuhua@yahoo.com.cn //// |
---|
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 | //ETHERNET |
---|
147 | parameter s2_addr_w = 56 ; |
---|
148 | parameter s2_addr = {56'h800000FFF0C2C1}; // slave 2 address |
---|
149 | |
---|
150 | //UART |
---|
151 | parameter s3_addr_w = 60 ; |
---|
152 | parameter s3_addr = {60'h800000FFF0C2C00}; // slave 3 address |
---|
153 | |
---|
154 | parameter s4_addr_w = 37 ; |
---|
155 | parameter s4_addr = {36'h800000FFF,1'b1}; // slave 4 address |
---|
156 | parameter s5_addr_w = 60 ; |
---|
157 | parameter s5_addr = {60'h400000F00000000}; // slave 5 address |
---|
158 | parameter s6_addr_w = 60 ; |
---|
159 | parameter s6_addr = {60'h500000F00000000}; // slave 6 address |
---|
160 | parameter s7_addr_w = 60 ; |
---|
161 | parameter s7_addr = {60'h600000F00000000}; // slave 7 address |
---|
162 | |
---|
163 | |
---|
164 | //////////////////////////////////////////////////////////////////// |
---|
165 | // |
---|
166 | // Module IOs |
---|
167 | // |
---|
168 | |
---|
169 | input clk_i, rst_i; |
---|
170 | |
---|
171 | // Master 0 Interface |
---|
172 | input [`dw-1:0] m0_dat_i; |
---|
173 | output [`dw-1:0] m0_dat_o; |
---|
174 | input [`aw-1:0] m0_adr_i; |
---|
175 | input [`sw-1:0] m0_sel_i; |
---|
176 | input m0_we_i; |
---|
177 | input m0_cyc_i; |
---|
178 | input m0_stb_i; |
---|
179 | input m0_cab_i; |
---|
180 | output m0_ack_o; |
---|
181 | output m0_err_o; |
---|
182 | output m0_rty_o; |
---|
183 | |
---|
184 | // Master 1 Interface |
---|
185 | input [`dw-1:0] m1_dat_i; |
---|
186 | output [`dw-1:0] m1_dat_o; |
---|
187 | input [`aw-1:0] m1_adr_i; |
---|
188 | input [`sw-1:0] m1_sel_i; |
---|
189 | input m1_we_i; |
---|
190 | input m1_cyc_i; |
---|
191 | input m1_stb_i; |
---|
192 | input m1_cab_i; |
---|
193 | output m1_ack_o; |
---|
194 | output m1_err_o; |
---|
195 | output m1_rty_o; |
---|
196 | |
---|
197 | // Master 2 Interface |
---|
198 | input [`dw-1:0] m2_dat_i; |
---|
199 | output [`dw-1:0] m2_dat_o; |
---|
200 | input [`aw-1:0] m2_adr_i; |
---|
201 | input [`sw-1:0] m2_sel_i; |
---|
202 | input m2_we_i; |
---|
203 | input m2_cyc_i; |
---|
204 | input m2_stb_i; |
---|
205 | input m2_cab_i; |
---|
206 | output m2_ack_o; |
---|
207 | output m2_err_o; |
---|
208 | output m2_rty_o; |
---|
209 | |
---|
210 | // Master 3 Interface |
---|
211 | input [`dw-1:0] m3_dat_i; |
---|
212 | output [`dw-1:0] m3_dat_o; |
---|
213 | input [`aw-1:0] m3_adr_i; |
---|
214 | input [`sw-1:0] m3_sel_i; |
---|
215 | input m3_we_i; |
---|
216 | input m3_cyc_i; |
---|
217 | input m3_stb_i; |
---|
218 | input m3_cab_i; |
---|
219 | output m3_ack_o; |
---|
220 | output m3_err_o; |
---|
221 | output m3_rty_o; |
---|
222 | |
---|
223 | // Master 4 Interface |
---|
224 | input [`dw-1:0] m4_dat_i; |
---|
225 | output [`dw-1:0] m4_dat_o; |
---|
226 | input [`aw-1:0] m4_adr_i; |
---|
227 | input [`sw-1:0] m4_sel_i; |
---|
228 | input m4_we_i; |
---|
229 | input m4_cyc_i; |
---|
230 | input m4_stb_i; |
---|
231 | input m4_cab_i; |
---|
232 | output m4_ack_o; |
---|
233 | output m4_err_o; |
---|
234 | output m4_rty_o; |
---|
235 | |
---|
236 | // Master 5 Interface |
---|
237 | input [`dw-1:0] m5_dat_i; |
---|
238 | output [`dw-1:0] m5_dat_o; |
---|
239 | input [`aw-1:0] m5_adr_i; |
---|
240 | input [`sw-1:0] m5_sel_i; |
---|
241 | input m5_we_i; |
---|
242 | input m5_cyc_i; |
---|
243 | input m5_stb_i; |
---|
244 | input m5_cab_i; |
---|
245 | output m5_ack_o; |
---|
246 | output m5_err_o; |
---|
247 | output m5_rty_o; |
---|
248 | |
---|
249 | // Master 6 Interface |
---|
250 | input [`dw-1:0] m6_dat_i; |
---|
251 | output [`dw-1:0] m6_dat_o; |
---|
252 | input [`aw-1:0] m6_adr_i; |
---|
253 | input [`sw-1:0] m6_sel_i; |
---|
254 | input m6_we_i; |
---|
255 | input m6_cyc_i; |
---|
256 | input m6_stb_i; |
---|
257 | input m6_cab_i; |
---|
258 | output m6_ack_o; |
---|
259 | output m6_err_o; |
---|
260 | output m6_rty_o; |
---|
261 | |
---|
262 | // Master 7 Interface |
---|
263 | input [`dw-1:0] m7_dat_i; |
---|
264 | output [`dw-1:0] m7_dat_o; |
---|
265 | input [`aw-1:0] m7_adr_i; |
---|
266 | input [`sw-1:0] m7_sel_i; |
---|
267 | input m7_we_i; |
---|
268 | input m7_cyc_i; |
---|
269 | input m7_stb_i; |
---|
270 | input m7_cab_i; |
---|
271 | output m7_ack_o; |
---|
272 | output m7_err_o; |
---|
273 | output m7_rty_o; |
---|
274 | |
---|
275 | // Slave 0 Interface |
---|
276 | input [`dw-1:0] s0_dat_i; |
---|
277 | output [`dw-1:0] s0_dat_o; |
---|
278 | output [`aw-1:0] s0_adr_o; |
---|
279 | output [`sw-1:0] s0_sel_o; |
---|
280 | output s0_we_o; |
---|
281 | output s0_cyc_o; |
---|
282 | output s0_stb_o; |
---|
283 | output s0_cab_o; |
---|
284 | input s0_ack_i; |
---|
285 | input s0_err_i; |
---|
286 | input s0_rty_i; |
---|
287 | |
---|
288 | // Slave 1 Interface |
---|
289 | input [`dw-1:0] s1_dat_i; |
---|
290 | output [`dw-1:0] s1_dat_o; |
---|
291 | output [`aw-1:0] s1_adr_o; |
---|
292 | output [`sw-1:0] s1_sel_o; |
---|
293 | output s1_we_o; |
---|
294 | output s1_cyc_o; |
---|
295 | output s1_stb_o; |
---|
296 | output s1_cab_o; |
---|
297 | input s1_ack_i; |
---|
298 | input s1_err_i; |
---|
299 | input s1_rty_i; |
---|
300 | |
---|
301 | // Slave 2 Interface |
---|
302 | input [`dw-1:0] s2_dat_i; |
---|
303 | output [`dw-1:0] s2_dat_o; |
---|
304 | output [`aw-1:0] s2_adr_o; |
---|
305 | output [`sw-1:0] s2_sel_o; |
---|
306 | output s2_we_o; |
---|
307 | output s2_cyc_o; |
---|
308 | output s2_stb_o; |
---|
309 | output s2_cab_o; |
---|
310 | input s2_ack_i; |
---|
311 | input s2_err_i; |
---|
312 | input s2_rty_i; |
---|
313 | |
---|
314 | // Slave 3 Interface |
---|
315 | input [`dw-1:0] s3_dat_i; |
---|
316 | output [`dw-1:0] s3_dat_o; |
---|
317 | output [`aw-1:0] s3_adr_o; |
---|
318 | output [`sw-1:0] s3_sel_o; |
---|
319 | output s3_we_o; |
---|
320 | output s3_cyc_o; |
---|
321 | output s3_stb_o; |
---|
322 | output s3_cab_o; |
---|
323 | input s3_ack_i; |
---|
324 | input s3_err_i; |
---|
325 | input s3_rty_i; |
---|
326 | |
---|
327 | // Slave 4 Interface |
---|
328 | input [`dw-1:0] s4_dat_i; |
---|
329 | output [`dw-1:0] s4_dat_o; |
---|
330 | output [`aw-1:0] s4_adr_o; |
---|
331 | output [`sw-1:0] s4_sel_o; |
---|
332 | output s4_we_o; |
---|
333 | output s4_cyc_o; |
---|
334 | output s4_stb_o; |
---|
335 | output s4_cab_o; |
---|
336 | input s4_ack_i; |
---|
337 | input s4_err_i; |
---|
338 | input s4_rty_i; |
---|
339 | |
---|
340 | // Slave 5 Interface |
---|
341 | input [`dw-1:0] s5_dat_i; |
---|
342 | output [`dw-1:0] s5_dat_o; |
---|
343 | output [`aw-1:0] s5_adr_o; |
---|
344 | output [`sw-1:0] s5_sel_o; |
---|
345 | output s5_we_o; |
---|
346 | output s5_cyc_o; |
---|
347 | output s5_stb_o; |
---|
348 | output s5_cab_o; |
---|
349 | input s5_ack_i; |
---|
350 | input s5_err_i; |
---|
351 | input s5_rty_i; |
---|
352 | |
---|
353 | // Slave 6 Interface |
---|
354 | input [`dw-1:0] s6_dat_i; |
---|
355 | output [`dw-1:0] s6_dat_o; |
---|
356 | output [`aw-1:0] s6_adr_o; |
---|
357 | output [`sw-1:0] s6_sel_o; |
---|
358 | output s6_we_o; |
---|
359 | output s6_cyc_o; |
---|
360 | output s6_stb_o; |
---|
361 | output s6_cab_o; |
---|
362 | input s6_ack_i; |
---|
363 | input s6_err_i; |
---|
364 | input s6_rty_i; |
---|
365 | |
---|
366 | // Slave 7 Interface |
---|
367 | input [`dw-1:0] s7_dat_i; |
---|
368 | output [`dw-1:0] s7_dat_o; |
---|
369 | output [`aw-1:0] s7_adr_o; |
---|
370 | output [`sw-1:0] s7_sel_o; |
---|
371 | output s7_we_o; |
---|
372 | output s7_cyc_o; |
---|
373 | output s7_stb_o; |
---|
374 | output s7_cab_o; |
---|
375 | input s7_ack_i; |
---|
376 | input s7_err_i; |
---|
377 | input s7_rty_i; |
---|
378 | |
---|
379 | |
---|
380 | //////////////////////////////////////////////////////////////////// |
---|
381 | // |
---|
382 | // Local wires |
---|
383 | // |
---|
384 | |
---|
385 | wire [`mselectw -1:0] i_gnt_arb; |
---|
386 | wire [2:0] gnt; |
---|
387 | reg [`sselectw -1:0] i_ssel_dec; |
---|
388 | `ifdef WB_USE_TRISTATE |
---|
389 | wire [`mbusw -1:0] i_bus_m; |
---|
390 | `else |
---|
391 | reg [`mbusw -1:0] i_bus_m; // internal share bus, master data and control to slave |
---|
392 | `endif |
---|
393 | wire [`dw -1:0] i_dat_s; // internal share bus , slave data to master |
---|
394 | wire [`sbusw -1:0] i_bus_s; // internal share bus , slave control to master |
---|
395 | |
---|
396 | |
---|
397 | |
---|
398 | //////////////////////////////////////////////////////////////////// |
---|
399 | // |
---|
400 | // Master output Interfaces |
---|
401 | // |
---|
402 | |
---|
403 | // master0 |
---|
404 | assign m0_dat_o = i_dat_s; |
---|
405 | assign {m0_ack_o, m0_err_o, m0_rty_o} = i_bus_s & {3{i_gnt_arb[0]}}; |
---|
406 | |
---|
407 | // master1 |
---|
408 | assign m1_dat_o = i_dat_s; |
---|
409 | assign {m1_ack_o, m1_err_o, m1_rty_o} = i_bus_s & {3{i_gnt_arb[1]}}; |
---|
410 | |
---|
411 | // master2 |
---|
412 | |
---|
413 | assign m2_dat_o = i_dat_s; |
---|
414 | assign {m2_ack_o, m2_err_o, m2_rty_o} = i_bus_s & {3{i_gnt_arb[2]}}; |
---|
415 | |
---|
416 | // master3 |
---|
417 | |
---|
418 | assign m3_dat_o = i_dat_s; |
---|
419 | assign {m3_ack_o, m3_err_o, m3_rty_o} = i_bus_s & {3{i_gnt_arb[3]}}; |
---|
420 | |
---|
421 | // master4 |
---|
422 | |
---|
423 | assign m4_dat_o = i_dat_s; |
---|
424 | assign {m4_ack_o, m4_err_o, m4_rty_o} = i_bus_s & {3{i_gnt_arb[4]}}; |
---|
425 | |
---|
426 | // master5 |
---|
427 | |
---|
428 | assign m5_dat_o = i_dat_s; |
---|
429 | assign {m5_ack_o, m5_err_o, m5_rty_o} = i_bus_s & {3{i_gnt_arb[5]}}; |
---|
430 | |
---|
431 | // master6 |
---|
432 | |
---|
433 | assign m6_dat_o = i_dat_s; |
---|
434 | assign {m6_ack_o, m6_err_o, m6_rty_o} = i_bus_s & {3{i_gnt_arb[6]}}; |
---|
435 | |
---|
436 | // master7 |
---|
437 | |
---|
438 | assign m7_dat_o = i_dat_s; |
---|
439 | assign {m7_ack_o, m7_err_o, m7_rty_o} = i_bus_s & {3{i_gnt_arb[7]}}; |
---|
440 | |
---|
441 | |
---|
442 | 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 , |
---|
443 | s0_err_i | s1_err_i | s2_err_i | s3_err_i | s4_err_i | s5_err_i | s6_err_i | s7_err_i , |
---|
444 | s0_rty_i | s1_rty_i | s2_rty_i | s3_rty_i | s4_rty_i | s5_rty_i | s6_rty_i | s7_rty_i }; |
---|
445 | |
---|
446 | //////////////////////////////// |
---|
447 | // Slave output interface |
---|
448 | // |
---|
449 | // slave0 |
---|
450 | 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]; |
---|
451 | 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 |
---|
452 | |
---|
453 | // slave1 |
---|
454 | |
---|
455 | 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]; |
---|
456 | assign s1_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[1]; |
---|
457 | |
---|
458 | // slave2 |
---|
459 | |
---|
460 | 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]; |
---|
461 | assign s2_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[2]; |
---|
462 | |
---|
463 | // slave3 |
---|
464 | |
---|
465 | 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]; |
---|
466 | assign s3_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[3]; |
---|
467 | |
---|
468 | // slave4 |
---|
469 | |
---|
470 | 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]; |
---|
471 | assign s4_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[4]; |
---|
472 | |
---|
473 | // slave5 |
---|
474 | |
---|
475 | 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]; |
---|
476 | assign s5_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[5]; |
---|
477 | |
---|
478 | // slave6 |
---|
479 | |
---|
480 | 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]; |
---|
481 | assign s6_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[6]; |
---|
482 | |
---|
483 | // slave7 |
---|
484 | |
---|
485 | 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]; |
---|
486 | assign s7_stb_o = i_bus_m[1] & i_bus_m[0] & i_ssel_dec[7]; |
---|
487 | |
---|
488 | /////////////////////////////////////// |
---|
489 | // Master and Slave input interface |
---|
490 | // |
---|
491 | |
---|
492 | `ifdef WB_USE_TRISTATE |
---|
493 | // input from master interface |
---|
494 | 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 ; |
---|
495 | 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 ; |
---|
496 | 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 ; |
---|
497 | 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 ; |
---|
498 | 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 ; |
---|
499 | 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 ; |
---|
500 | 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 ; |
---|
501 | 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 ; |
---|
502 | // input from slave interface |
---|
503 | assign i_dat_s = i_ssel_dec[0] ? s0_dat_i: 32'bz; |
---|
504 | assign i_dat_s = i_ssel_dec[1] ? s1_dat_i: 32'bz; |
---|
505 | assign i_dat_s = i_ssel_dec[2] ? s2_dat_i: 32'bz; |
---|
506 | assign i_dat_s = i_ssel_dec[3] ? s3_dat_i: 32'bz; |
---|
507 | assign i_dat_s = i_ssel_dec[4] ? s4_dat_i: 32'bz; |
---|
508 | assign i_dat_s = i_ssel_dec[5] ? s5_dat_i: 32'bz; |
---|
509 | assign i_dat_s = i_ssel_dec[6] ? s6_dat_i: 32'bz; |
---|
510 | assign i_dat_s = i_ssel_dec[7] ? s7_dat_i: 32'bz; |
---|
511 | |
---|
512 | `else |
---|
513 | |
---|
514 | always @(gnt , m0_adr_i, m0_sel_i, m0_dat_i, m0_we_i, m0_cab_i, m0_cyc_i,m0_stb_i, |
---|
515 | m1_adr_i, m1_sel_i, m1_dat_i, m1_we_i, m1_cab_i, m1_cyc_i,m1_stb_i, |
---|
516 | m2_adr_i, m2_sel_i, m2_dat_i, m2_we_i, m2_cab_i, m2_cyc_i,m2_stb_i, |
---|
517 | m3_adr_i, m3_sel_i, m3_dat_i, m3_we_i, m3_cab_i, m3_cyc_i,m3_stb_i, |
---|
518 | m4_adr_i, m4_sel_i, m4_dat_i, m4_we_i, m4_cab_i, m4_cyc_i,m4_stb_i, |
---|
519 | m5_adr_i, m5_sel_i, m5_dat_i, m5_we_i, m5_cab_i, m5_cyc_i,m5_stb_i, |
---|
520 | m6_adr_i, m6_sel_i, m6_dat_i, m6_we_i, m6_cab_i, m6_cyc_i,m6_stb_i, |
---|
521 | m7_adr_i, m7_sel_i, m7_dat_i, m7_we_i, m7_cab_i, m7_cyc_i,m7_stb_i) |
---|
522 | case(gnt) |
---|
523 | 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}; |
---|
524 | 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}; |
---|
525 | 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}; |
---|
526 | 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}; |
---|
527 | 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}; |
---|
528 | 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}; |
---|
529 | 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}; |
---|
530 | 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}; |
---|
531 | 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}; |
---|
532 | endcase |
---|
533 | |
---|
534 | assign i_dat_s = i_ssel_dec[0] ? s0_dat_i : |
---|
535 | i_ssel_dec[1] ? s1_dat_i : |
---|
536 | i_ssel_dec[2] ? s2_dat_i : |
---|
537 | i_ssel_dec[3] ? s3_dat_i : |
---|
538 | i_ssel_dec[4] ? s4_dat_i : |
---|
539 | i_ssel_dec[5] ? s5_dat_i : |
---|
540 | i_ssel_dec[6] ? s6_dat_i : |
---|
541 | i_ssel_dec[7] ? s7_dat_i : {`dw{1'b0}}; |
---|
542 | `endif |
---|
543 | // |
---|
544 | // arbitor |
---|
545 | // |
---|
546 | assign i_gnt_arb[0] = (gnt == 3'd0); |
---|
547 | assign i_gnt_arb[1] = (gnt == 3'd1); |
---|
548 | assign i_gnt_arb[2] = (gnt == 3'd2); |
---|
549 | assign i_gnt_arb[3] = (gnt == 3'd3); |
---|
550 | assign i_gnt_arb[4] = (gnt == 3'd4); |
---|
551 | assign i_gnt_arb[5] = (gnt == 3'd5); |
---|
552 | assign i_gnt_arb[6] = (gnt == 3'd6); |
---|
553 | assign i_gnt_arb[7] = (gnt == 3'd7); |
---|
554 | |
---|
555 | wb_conbus_arb wb_conbus_arb( |
---|
556 | .clk(clk_i), |
---|
557 | .rst(rst_i), |
---|
558 | .req({ m7_cyc_i, |
---|
559 | m6_cyc_i, |
---|
560 | m5_cyc_i, |
---|
561 | m4_cyc_i, |
---|
562 | m3_cyc_i, |
---|
563 | m2_cyc_i, |
---|
564 | m1_cyc_i, |
---|
565 | m0_cyc_i}), |
---|
566 | .gnt(gnt) |
---|
567 | ); |
---|
568 | |
---|
569 | ////////////////////////////////// |
---|
570 | // address decode logic |
---|
571 | // |
---|
572 | 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; |
---|
573 | 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) |
---|
574 | case(gnt) |
---|
575 | 3'h0: i_ssel_dec = m0_ssel_dec; |
---|
576 | 3'h1: i_ssel_dec = m1_ssel_dec; |
---|
577 | 3'h2: i_ssel_dec = m2_ssel_dec; |
---|
578 | 3'h3: i_ssel_dec = m3_ssel_dec; |
---|
579 | 3'h4: i_ssel_dec = m4_ssel_dec; |
---|
580 | 3'h5: i_ssel_dec = m5_ssel_dec; |
---|
581 | 3'h6: i_ssel_dec = m6_ssel_dec; |
---|
582 | 3'h7: i_ssel_dec = m7_ssel_dec; |
---|
583 | default: i_ssel_dec = 7'b0; |
---|
584 | endcase |
---|
585 | // |
---|
586 | // decode all master address before arbitor for running faster |
---|
587 | // |
---|
588 | assign m0_ssel_dec[0] = (m0_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
589 | assign m0_ssel_dec[1] = (m0_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
590 | assign m0_ssel_dec[2] = (m0_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
591 | assign m0_ssel_dec[3] = (m0_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
592 | assign m0_ssel_dec[4] = (m0_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
593 | assign m0_ssel_dec[5] = (m0_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
594 | assign m0_ssel_dec[6] = (m0_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
595 | assign m0_ssel_dec[7] = (m0_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
596 | |
---|
597 | assign m1_ssel_dec[0] = (m1_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
598 | assign m1_ssel_dec[1] = (m1_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
599 | assign m1_ssel_dec[2] = (m1_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
600 | assign m1_ssel_dec[3] = (m1_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
601 | assign m1_ssel_dec[4] = (m1_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
602 | assign m1_ssel_dec[5] = (m1_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
603 | assign m1_ssel_dec[6] = (m1_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
604 | assign m1_ssel_dec[7] = (m1_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
605 | |
---|
606 | assign m2_ssel_dec[0] = (m2_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
607 | assign m2_ssel_dec[1] = (m2_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
608 | assign m2_ssel_dec[2] = (m2_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
609 | assign m2_ssel_dec[3] = (m2_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
610 | assign m2_ssel_dec[4] = (m2_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
611 | assign m2_ssel_dec[5] = (m2_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
612 | assign m2_ssel_dec[6] = (m2_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
613 | assign m2_ssel_dec[7] = (m2_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
614 | |
---|
615 | assign m3_ssel_dec[0] = (m3_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
616 | assign m3_ssel_dec[1] = (m3_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
617 | assign m3_ssel_dec[2] = (m3_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
618 | assign m3_ssel_dec[3] = (m3_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
619 | assign m3_ssel_dec[4] = (m3_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
620 | assign m3_ssel_dec[5] = (m3_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
621 | assign m3_ssel_dec[6] = (m3_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
622 | assign m3_ssel_dec[7] = (m3_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
623 | |
---|
624 | assign m4_ssel_dec[0] = (m4_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
625 | assign m4_ssel_dec[1] = (m4_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
626 | assign m4_ssel_dec[2] = (m4_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
627 | assign m4_ssel_dec[3] = (m4_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
628 | assign m4_ssel_dec[4] = (m4_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
629 | assign m4_ssel_dec[5] = (m4_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
630 | assign m4_ssel_dec[6] = (m4_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
631 | assign m4_ssel_dec[7] = (m4_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
632 | |
---|
633 | assign m5_ssel_dec[0] = (m5_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
634 | assign m5_ssel_dec[1] = (m5_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
635 | assign m5_ssel_dec[2] = (m5_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
636 | assign m5_ssel_dec[3] = (m5_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
637 | assign m5_ssel_dec[4] = (m5_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
638 | assign m5_ssel_dec[5] = (m5_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
639 | assign m5_ssel_dec[6] = (m5_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
640 | assign m5_ssel_dec[7] = (m5_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
641 | |
---|
642 | assign m6_ssel_dec[0] = (m6_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
643 | assign m6_ssel_dec[1] = (m6_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
644 | assign m6_ssel_dec[2] = (m6_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
645 | assign m6_ssel_dec[3] = (m6_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
646 | assign m6_ssel_dec[4] = (m6_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
647 | assign m6_ssel_dec[5] = (m6_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
648 | assign m6_ssel_dec[6] = (m6_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
649 | assign m6_ssel_dec[7] = (m6_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
650 | |
---|
651 | assign m7_ssel_dec[0] = (m7_adr_i[`aw -1 : `aw - s0_addr_w ] == s0_addr); |
---|
652 | assign m7_ssel_dec[1] = (m7_adr_i[`aw -1 : `aw - s1_addr_w ] == s1_addr); |
---|
653 | assign m7_ssel_dec[2] = (m7_adr_i[`aw -1 : `aw - s2_addr_w ] == s2_addr); |
---|
654 | assign m7_ssel_dec[3] = (m7_adr_i[`aw -1 : `aw - s3_addr_w ] == s3_addr); |
---|
655 | assign m7_ssel_dec[4] = (m7_adr_i[`aw -1 : `aw - s4_addr_w ] == s4_addr); |
---|
656 | assign m7_ssel_dec[5] = (m7_adr_i[`aw -1 : `aw - s5_addr_w ] == s5_addr); |
---|
657 | assign m7_ssel_dec[6] = (m7_adr_i[`aw -1 : `aw - s6_addr_w ] == s6_addr); |
---|
658 | assign m7_ssel_dec[7] = (m7_adr_i[`aw -1 : `aw - s7_addr_w ] == s7_addr); |
---|
659 | |
---|
660 | //assign i_ssel_dec[0] = (i_bus_m[`mbusw -1 : `mbusw - s0_addr_w ] == s0_addr); |
---|
661 | //assign i_ssel_dec[1] = (i_bus_m[`mbusw -1 : `mbusw - s1_addr_w ] == s1_addr); |
---|
662 | //assign i_ssel_dec[2] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s2_addr); |
---|
663 | //assign i_ssel_dec[3] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s3_addr); |
---|
664 | //assign i_ssel_dec[4] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s4_addr); |
---|
665 | //assign i_ssel_dec[5] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s5_addr); |
---|
666 | //assign i_ssel_dec[6] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s6_addr); |
---|
667 | //assign i_ssel_dec[7] = (i_bus_m[`mbusw -1 : `mbusw - s27_addr_w ] == s7_addr); |
---|
668 | |
---|
669 | |
---|
670 | endmodule |
---|
671 | |
---|