OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [boards/] [xilinx/] [ml501/] [rtl/] [verilog/] [arbiter/] [arbiter_ibus.v] - Blame information for rev 655

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 412 julius
//////////////////////////////////////////////////////////////////////
2
///                                                               //// 
3
/// Wishbone arbiter, burst-compatible                            ////
4
///                                                               ////
5
/// Simple arbiter, single master, dual slave, primarily for      ////
6
/// processor instruction bus, providing access to one main       ////
7
/// memory server and one ROM                                     ////
8
///                                                               ////
9
/// Julius Baxter, julius@opencores.org                           ////
10
///                                                               ////
11
//////////////////////////////////////////////////////////////////////
12
////                                                              ////
13 655 julius
//// Copyright (C) 2009, 2010, 2011 Authors and OPENCORES.ORG     ////
14 412 julius
////                                                              ////
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
`include "orpsoc-defines.v"
38
// One master, 2 slaves.
39
module arbiter_ibus
40
  (
41
   // instruction bus in
42
   // Wishbone Master interface
43
   wbm_adr_o,
44
   wbm_dat_o,
45
   wbm_sel_o,
46
   wbm_we_o,
47
   wbm_cyc_o,
48
   wbm_stb_o,
49
   wbm_cti_o,
50
   wbm_bte_o,
51
 
52
   wbm_dat_i,
53
   wbm_ack_i,
54
   wbm_err_i,
55
   wbm_rty_i,
56
 
57
 
58
   // Slave one
59
   // Wishbone Slave interface
60
   wbs0_adr_i,
61
   wbs0_dat_i,
62
   wbs0_sel_i,
63
   wbs0_we_i,
64
   wbs0_cyc_i,
65
   wbs0_stb_i,
66
   wbs0_cti_i,
67
   wbs0_bte_i,
68
 
69
   wbs0_dat_o,
70
   wbs0_ack_o,
71
   wbs0_err_o,
72
   wbs0_rty_o,
73
 
74
   // Slave two
75
   // Wishbone Slave interface
76
   wbs1_adr_i,
77
   wbs1_dat_i,
78
   wbs1_sel_i,
79
   wbs1_we_i,
80
   wbs1_cyc_i,
81
   wbs1_stb_i,
82
   wbs1_cti_i,
83
   wbs1_bte_i,
84
 
85
   wbs1_dat_o,
86
   wbs1_ack_o,
87
   wbs1_err_o,
88
   wbs1_rty_o,
89
 
90 655 julius
 
91
   // Slave three
92
   // Wishbone Slave interface
93
   wbs2_adr_i,
94
   wbs2_dat_i,
95
   wbs2_sel_i,
96
   wbs2_we_i,
97
   wbs2_cyc_i,
98
   wbs2_stb_i,
99
   wbs2_cti_i,
100
   wbs2_bte_i,
101
 
102
   wbs2_dat_o,
103
   wbs2_ack_o,
104
   wbs2_err_o,
105
   wbs2_rty_o,
106
 
107
 
108 412 julius
   wb_clk,
109
   wb_rst
110
   );
111
 
112
 
113
   parameter wb_dat_width = 32;
114
   parameter wb_adr_width = 32;
115
 
116
   parameter wb_addr_match_width = 8;
117
 
118 655 julius
   parameter slave0_adr = 8'he0; // FLASH ROM
119 412 julius
   parameter slave1_adr = 8'h00; // Main memory (SDRAM/FPGA SRAM)
120 655 julius
   parameter slave2_adr = 8'hf0; // External flash
121 412 julius
 
122
`define WB_ARB_ADDR_MATCH_SEL wb_adr_width-1:wb_adr_width-wb_addr_match_width
123
 
124
   input wb_clk;
125
   input wb_rst;
126
 
127
 
128
   // WB Master
129
   input [wb_adr_width-1:0] wbm_adr_o;
130
   input [wb_dat_width-1:0] wbm_dat_o;
131
   input [3:0]               wbm_sel_o;
132
   input                    wbm_we_o;
133
   input                    wbm_cyc_o;
134
   input                    wbm_stb_o;
135
   input [2:0]               wbm_cti_o;
136
   input [1:0]               wbm_bte_o;
137
   output [wb_dat_width-1:0] wbm_dat_i;
138
   output                    wbm_ack_i;
139
   output                    wbm_err_i;
140
   output                    wbm_rty_i;
141
 
142
   // WB Slave 0
143
   output [wb_adr_width-1:0] wbs0_adr_i;
144
   output [wb_dat_width-1:0] wbs0_dat_i;
145
   output [3:0]       wbs0_sel_i;
146
   output                    wbs0_we_i;
147
   output                    wbs0_cyc_i;
148
   output                    wbs0_stb_i;
149
   output [2:0]       wbs0_cti_i;
150
   output [1:0]       wbs0_bte_i;
151
   input [wb_dat_width-1:0]  wbs0_dat_o;
152
   input                     wbs0_ack_o;
153
   input                     wbs0_err_o;
154
   input                     wbs0_rty_o;
155
 
156
   // WB Slave 1
157
   output [wb_adr_width-1:0] wbs1_adr_i;
158
   output [wb_dat_width-1:0] wbs1_dat_i;
159
   output [3:0]       wbs1_sel_i;
160
   output                    wbs1_we_i;
161
   output                    wbs1_cyc_i;
162
   output                    wbs1_stb_i;
163
   output [2:0]       wbs1_cti_i;
164
   output [1:0]       wbs1_bte_i;
165
   input [wb_dat_width-1:0]  wbs1_dat_o;
166
   input                     wbs1_ack_o;
167
   input                     wbs1_err_o;
168
   input                     wbs1_rty_o;
169
 
170
 
171 655 julius
   // WB Slave 2
172
   output [wb_adr_width-1:0] wbs2_adr_i;
173
   output [wb_dat_width-1:0] wbs2_dat_i;
174
   output [3:0]       wbs2_sel_i;
175
   output                    wbs2_we_i;
176
   output                    wbs2_cyc_i;
177
   output                    wbs2_stb_i;
178
   output [2:0]       wbs2_cti_i;
179
   output [1:0]       wbs2_bte_i;
180
   input [wb_dat_width-1:0]  wbs2_dat_o;
181
   input                     wbs2_ack_o;
182
   input                     wbs2_err_o;
183
   input                     wbs2_rty_o;
184
 
185
 
186
   wire [2:0]                 slave_sel; // One bit per slave
187
 
188 412 julius
   reg                       watchdog_err;
189
 
190
`ifdef ARBITER_IBUS_WATCHDOG
191
   reg [`ARBITER_IBUS_WATCHDOG_TIMER_WIDTH:0]  watchdog_timer;
192
   reg                       wbm_stb_r; // Register strobe
193
   wire                      wbm_stb_edge; // Detect its edge
194
   reg                       wbm_stb_edge_r, wbm_ack_i_r; // Reg these, better timing
195
 
196
   always @(posedge wb_clk)
197
     wbm_stb_r <= wbm_stb_o;
198
 
199
   assign wbm_stb_edge = (wbm_stb_o & !wbm_stb_r);
200
 
201
   always @(posedge wb_clk)
202
     wbm_stb_edge_r <= wbm_stb_edge;
203
 
204
   always @(posedge wb_clk)
205
     wbm_ack_i_r <= wbm_ack_i;
206
 
207
 
208
   // Counter logic
209
   always @(posedge wb_clk)
210
     if (wb_rst) watchdog_timer <= 0;
211
     else if (wbm_ack_i_r) // When we see an ack, turn off timer
212
       watchdog_timer <= 0;
213
     else if (wbm_stb_edge_r) // New access means start timer again
214
       watchdog_timer <= 1;
215
     else if (|watchdog_timer) // Continue counting if counter > 0
216
       watchdog_timer <= watchdog_timer + 1;
217
 
218
   always @(posedge wb_clk)
219
     watchdog_err <= (&watchdog_timer);
220
 
221
`else // !`ifdef ARBITER_IBUS_WATCHDOG
222
 
223
   always @(posedge wb_clk)
224
     watchdog_err <= 0;
225
 
226
`endif // !`ifdef ARBITER_IBUS_WATCHDOG
227
 
228
 
229
 
230
`ifdef ARBITER_IBUS_REGISTERING
231
 
232
   // Master input registers
233
   reg [wb_adr_width-1:0]    wbm_adr_o_r;
234
   reg [wb_dat_width-1:0]    wbm_dat_o_r;
235
   reg [3:0]                  wbm_sel_o_r;
236
   reg                       wbm_we_o_r;
237
   reg                       wbm_cyc_o_r;
238
   reg                       wbm_stb_o_r;
239
   reg [2:0]                  wbm_cti_o_r;
240
   reg [1:0]                  wbm_bte_o_r;
241
   // Slave output registers
242
   reg [wb_dat_width-1:0]    wbs0_dat_o_r;
243
   reg                       wbs0_ack_o_r;
244
   reg                       wbs0_err_o_r;
245
   reg                       wbs0_rty_o_r;
246
   reg [wb_dat_width-1:0]    wbs1_dat_o_r;
247
   reg                       wbs1_ack_o_r;
248
   reg                       wbs1_err_o_r;
249
   reg                       wbs1_rty_o_r;
250 655 julius
   reg [wb_dat_width-1:0]    wbs2_dat_o_r;
251
   reg                       wbs2_ack_o_r;
252
   reg                       wbs2_err_o_r;
253
   reg                       wbs2_rty_o_r;
254 412 julius
 
255
   wire                      wbm_ack_i_pre_reg;
256
 
257
 
258
 
259
   // Register master input signals
260
   always @(posedge wb_clk)
261
     begin
262
        wbm_adr_o_r <= wbm_adr_o;
263
        wbm_dat_o_r <= wbm_dat_o;
264
        wbm_sel_o_r <= wbm_sel_o;
265
        wbm_we_o_r <= wbm_we_o;
266
        wbm_cyc_o_r <= wbm_cyc_o;
267
        wbm_stb_o_r <= wbm_stb_o & !wbm_ack_i_pre_reg & !wbm_ack_i;//classic
268
        wbm_cti_o_r <= wbm_cti_o;
269
        wbm_bte_o_r <= wbm_bte_o;
270
 
271
        // Slave signals
272
        wbs0_dat_o_r <= wbs0_dat_o;
273
        wbs0_ack_o_r <= wbs0_ack_o;
274
        wbs0_err_o_r <= wbs0_err_o;
275
        wbs0_rty_o_r <= wbs0_rty_o;
276
        wbs1_dat_o_r <= wbs1_dat_o;
277
        wbs1_ack_o_r <= wbs1_ack_o;
278
        wbs1_err_o_r <= wbs1_err_o;
279
        wbs1_rty_o_r <= wbs1_rty_o;
280 655 julius
        wbs2_dat_o_r <= wbs2_dat_o;
281
        wbs2_ack_o_r <= wbs2_ack_o;
282
        wbs2_err_o_r <= wbs2_err_o;
283
        wbs2_rty_o_r <= wbs2_rty_o;
284 412 julius
 
285
     end // always @ (posedge wb_clk)
286
 
287
   // Slave select
288
   assign slave_sel[0] = wbm_adr_o_r[`WB_ARB_ADDR_MATCH_SEL] ==
289
                         slave0_adr;
290
 
291
   assign slave_sel[1] = wbm_adr_o_r[`WB_ARB_ADDR_MATCH_SEL] ==
292
                         slave1_adr;
293
 
294 655 julius
   assign slave_sel[2] = wbm_adr_o_r[`WB_ARB_ADDR_MATCH_SEL] ==
295
                         slave2_adr;
296
 
297 412 julius
   // Slave out assigns
298
   assign wbs0_adr_i = wbm_adr_o_r;
299
   assign wbs0_dat_i = wbm_dat_o_r;
300
   assign wbs0_we_i = wbm_dat_o_r;
301
   assign wbs0_sel_i = wbm_sel_o_r;
302
   assign wbs0_cti_i = wbm_cti_o_r;
303
   assign wbs0_bte_i = wbm_bte_o_r;
304
   assign wbs0_cyc_i = wbm_cyc_o_r & slave_sel[0];
305
   assign wbs0_stb_i = wbm_stb_o_r & slave_sel[0];
306
 
307
   assign wbs1_adr_i = wbm_adr_o_r;
308
   assign wbs1_dat_i = wbm_dat_o_r;
309
   assign wbs1_we_i = wbm_dat_o_r;
310
   assign wbs1_sel_i = wbm_sel_o_r;
311
   assign wbs1_cti_i = wbm_cti_o_r;
312
   assign wbs1_bte_i = wbm_bte_o_r;
313
   assign wbs1_cyc_i = wbm_cyc_o_r & slave_sel[1];
314
   assign wbs1_stb_i = wbm_stb_o_r & slave_sel[1];
315
 
316 655 julius
   assign wbs2_adr_i = wbm_adr_o_r;
317
   assign wbs2_dat_i = wbm_dat_o_r;
318
   assign wbs2_we_i = wbm_dat_o_r;
319
   assign wbs2_sel_i = wbm_sel_o_r;
320
   assign wbs2_cti_i = wbm_cti_o_r;
321
   assign wbs2_bte_i = wbm_bte_o_r;
322
   assign wbs2_cyc_i = wbm_cyc_o_r & slave_sel[1];
323
   assign wbs2_stb_i = wbm_stb_o_r & slave_sel[1];
324
 
325
 
326 412 julius
   // Master out assigns
327
   // Don't care about none selected...
328 655 julius
   assign wbm_dat_i = slave_sel[2] ? wbs2_dat_o_r :
329
                      slave_sel[1] ? wbs1_dat_o_r :
330 412 julius
                      wbs0_dat_o_r ;
331
 
332
   assign wbm_ack_i = (slave_sel[0] & wbs0_ack_o_r) |
333 655 julius
                      (slave_sel[1] & wbs1_ack_o_r) |
334
                      (slave_sel[2] & wbs2_ack_o_r);
335 412 julius
 
336
   assign wbm_err_i = (slave_sel[0] & wbs0_err_o_r) |
337
                      (slave_sel[1] & wbs1_err_o_r) |
338 655 julius
                      (slave_sel[2] & wbs2_err_o_r) |
339 412 julius
                      watchdog_err;
340
 
341
   assign wbm_rty_i = (slave_sel[0] & wbs0_rty_o_r) |
342 655 julius
                      (slave_sel[1] & wbs1_rty_o_r) |
343
                      (slave_sel[2] & wbs2_rty_o_r);
344 412 julius
 
345
   // Non-registered ack
346
   assign wbm_ack_i_pre_reg = (slave_sel[0] & wbs0_ack_o) |
347 655 julius
                              (slave_sel[1] & wbs1_ack_o) |
348
                              (slave_sel[2] & wbs2_ack_o);
349 412 julius
 
350
`else // !`ifdef ARBITER_IBUS_REGISTERING
351
 
352
   // Slave select
353
   assign slave_sel[0] = wbm_adr_o[`WB_ARB_ADDR_MATCH_SEL] ==
354
                         slave0_adr;
355
 
356
   assign slave_sel[1] = wbm_adr_o[`WB_ARB_ADDR_MATCH_SEL] ==
357
                         slave1_adr;
358
 
359 655 julius
   assign slave_sel[2] = wbm_adr_o[`WB_ARB_ADDR_MATCH_SEL] ==
360
                         slave2_adr;
361
 
362
 
363 412 julius
   // Slave out assigns
364
   assign wbs0_adr_i = wbm_adr_o;
365
   assign wbs0_dat_i = wbm_dat_o;
366
   assign wbs0_we_i  = wbm_we_o;
367
   assign wbs0_sel_i = wbm_sel_o;
368
   assign wbs0_cti_i = wbm_cti_o;
369
   assign wbs0_bte_i = wbm_bte_o;
370
   assign wbs0_cyc_i = wbm_cyc_o & slave_sel[0];
371
   assign wbs0_stb_i = wbm_stb_o & slave_sel[0];
372
 
373
   assign wbs1_adr_i = wbm_adr_o;
374
   assign wbs1_dat_i = wbm_dat_o;
375
   assign wbs1_we_i  = wbm_we_o;
376
   assign wbs1_sel_i = wbm_sel_o;
377
   assign wbs1_cti_i = wbm_cti_o;
378
   assign wbs1_bte_i = wbm_bte_o;
379
   assign wbs1_cyc_i = wbm_cyc_o & slave_sel[1];
380
   assign wbs1_stb_i = wbm_stb_o & slave_sel[1];
381
 
382 655 julius
   assign wbs2_adr_i = wbm_adr_o;
383
   assign wbs2_dat_i = wbm_dat_o;
384
   assign wbs2_we_i  = wbm_we_o;
385
   assign wbs2_sel_i = wbm_sel_o;
386
   assign wbs2_cti_i = wbm_cti_o;
387
   assign wbs2_bte_i = wbm_bte_o;
388
   assign wbs2_cyc_i = wbm_cyc_o & slave_sel[2];
389
   assign wbs2_stb_i = wbm_stb_o & slave_sel[2];
390
 
391 412 julius
   // Master out assigns
392
   // Don't care about none selected...
393 655 julius
   assign wbm_dat_i = slave_sel[2] ? wbs2_dat_o :
394
                      slave_sel[1] ? wbs1_dat_o :
395 412 julius
                      wbs0_dat_o ;
396
 
397
   assign wbm_ack_i = (slave_sel[0] & wbs0_ack_o) |
398 655 julius
                      (slave_sel[1] & wbs1_ack_o) |
399
                      (slave_sel[2] & wbs2_ack_o);
400 412 julius
 
401
 
402
   assign wbm_err_i = (slave_sel[0] & wbs0_err_o) |
403
                      (slave_sel[1] & wbs1_err_o) |
404 655 julius
                      (slave_sel[2] & wbs2_err_o) |
405 412 julius
                      watchdog_err;
406
 
407
   assign wbm_rty_i = (slave_sel[0] & wbs0_rty_o) |
408 655 julius
                      (slave_sel[1] & wbs1_rty_o) |
409
                      (slave_sel[2] & wbs2_rty_o);
410 412 julius
 
411
 
412
`endif
413
endmodule // arbiter_ibus
414
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.