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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [boards/] [actel/] [ordb1a3pe1500/] [rtl/] [verilog/] [orpsoc_top/] [orpsoc_top.v] - Blame information for rev 544

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 408 julius
//////////////////////////////////////////////////////////////////////
2
///                                                               //// 
3
/// ORPSoC top for ordb1 board                                    ////
4
///                                                               ////
5
/// Instantiates modules, depending on ORPSoC defines file        ////
6
///                                                               ////
7
/// Julius Baxter, julius@opencores.org                           ////
8
///                                                               ////
9
//////////////////////////////////////////////////////////////////////
10
////                                                              ////
11
//// Copyright (C) 2009, 2010 Authors and OPENCORES.ORG           ////
12
////                                                              ////
13
//// This source file may be used and distributed without         ////
14
//// restriction provided that this copyright statement is not    ////
15
//// removed from the file and that any derivative work contains  ////
16
//// the original copyright notice and the associated disclaimer. ////
17
////                                                              ////
18
//// This source file is free software; you can redistribute it   ////
19
//// and/or modify it under the terms of the GNU Lesser General   ////
20
//// Public License as published by the Free Software Foundation; ////
21
//// either version 2.1 of the License, or (at your option) any   ////
22
//// later version.                                               ////
23
////                                                              ////
24
//// This source is distributed in the hope that it will be       ////
25
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
26
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
27
//// PURPOSE.  See the GNU Lesser General Public License for more ////
28
//// details.                                                     ////
29
////                                                              ////
30
//// You should have received a copy of the GNU Lesser General    ////
31
//// Public License along with this source; if not, download it   ////
32
//// from http://www.opencores.org/lgpl.shtml                     ////
33
////                                                              ////
34
//////////////////////////////////////////////////////////////////////
35
 
36
`include "orpsoc-defines.v"
37
`include "synthesis-defines.v"
38
module orpsoc_top
39
  (
40
`ifdef JTAG_DEBUG
41
    tdo_pad_o, tms_pad_i, tck_pad_i, tdi_pad_i,
42
`endif
43
`ifdef VERSATILE_SDRAM
44
    sdram_ba_pad_o,sdram_a_pad_o,sdram_cs_n_pad_o, sdram_ras_pad_o,
45
    sdram_cas_pad_o, sdram_we_pad_o, sdram_dq_pad_io, sdram_dqm_pad_o,
46
    sdram_cke_pad_o,
47
`endif
48
`ifdef UART0
49
    uart0_srx_pad_i, uart0_stx_pad_o,
50
`endif
51
`ifdef SPI0
52
    spi0_sck_o, spi0_mosi_o, spi0_miso_i, spi0_hold_n_o, spi0_w_n_o,
53
 `ifdef SPI0_SLAVE_SELECTS
54
    spi0_ss_o,
55
 `endif
56
`endif
57
`ifdef SPI1
58
    spi1_sck_o, spi1_mosi_o, spi1_miso_i,
59
    `ifdef SPI1_SLAVE_SELECTS
60
    spi1_ss_o,
61
    `endif
62
`endif
63
`ifdef SPI2
64
    spi2_sck_o, spi2_mosi_o, spi2_miso_i,
65
    `ifdef SPI2_SLAVE_SELECTS
66
    spi2_ss_o,
67
    `endif
68
`endif
69
`ifdef I2C0
70
    i2c0_sda_io, i2c0_scl_io,
71
`endif
72
`ifdef I2C1
73
    i2c1_sda_io, i2c1_scl_io,
74
`endif
75
`ifdef I2C2
76
    i2c2_sda_io, i2c2_scl_io,
77
`endif
78
`ifdef I2C3
79
    i2c3_sda_io, i2c3_scl_io,
80
`endif
81
`ifdef USB0
82
    usb0dat_pad_i, usb0dat_pad_o, usb0ctrl_pad_o, usb0fullspeed_pad_o,
83
`endif
84
`ifdef USB1
85
    usb1dat_pad_i, usb1dat_pad_o, usb1ctrl_pad_o, usb1fullspeed_pad_o,
86
`endif
87
`ifdef GPIO0
88
    gpio0_io,
89
`endif
90
 
91
`ifdef ETH0
92
 `ifdef SMII0
93
    eth0_smii_sync_pad_o, eth0_smii_tx_pad_o, eth0_smii_rx_pad_i,
94
 `else
95
    eth0_tx_clk, eth0_tx_data, eth0_tx_en, eth0_tx_er,
96
    eth0_rx_clk, eth0_rx_data, eth0_dv, eth0_rx_er,
97
    eth0_col, eth0_crs,
98
 `endif
99
    eth0_mdc_pad_o, eth0_md_pad_io,
100
`endif //  `ifdef ETH0
101
`ifdef ETH0_PHY_RST
102
    eth0_rst_n_o,
103
`endif
104
`ifdef ETH_CLK
105
    eth_clk_pad_i,
106
`endif
107 544 julius
`ifdef SDC_CONTROLLER
108
    sdc_cmd_pad_io , sdc_dat_pad_io ,  sdc_clk_pad_o,
109
    sdc_card_detect_pad_i,
110
`endif
111 408 julius
    sys_clk_pad_i,
112
 
113
    rst_n_pad_i
114
 
115 544 julius
    )/* synthesis syn_global_buffers = 18; */;
116 408 julius
 
117
`include "orpsoc-params.v"
118
 
119
   input sys_clk_pad_i;
120
 
121
   input rst_n_pad_i;
122
 
123
`ifdef JTAG_DEBUG
124
   output tdo_pad_o;
125
   input  tms_pad_i;
126
   input  tck_pad_i;
127
   input  tdi_pad_i;
128
`endif
129
`ifdef VERSATILE_SDRAM
130
   output [1:0] sdram_ba_pad_o;
131
   output [12:0] sdram_a_pad_o;
132
   output        sdram_cs_n_pad_o;
133
   output        sdram_ras_pad_o;
134
   output        sdram_cas_pad_o;
135
   output        sdram_we_pad_o;
136
   inout [15:0]  sdram_dq_pad_io;
137
   output [1:0]  sdram_dqm_pad_o;
138
   output        sdram_cke_pad_o;
139
`endif
140
`ifdef UART0
141
   input         uart0_srx_pad_i;
142
   output        uart0_stx_pad_o;
143
`endif
144
`ifdef SPI0
145
   output        spi0_sck_o;
146
   output        spi0_mosi_o;
147
 `ifdef SPI0_SLAVE_SELECTS
148
   output [spi0_ss_width-1:0] spi0_ss_o;
149
 `endif
150
   output                     spi0_hold_n_o;
151
   output                     spi0_w_n_o;
152
   input                      spi0_miso_i;
153
`endif
154
`ifdef SPI1
155
   output                     spi1_sck_o;
156
   output                     spi1_mosi_o;
157
 `ifdef SPI1_SLAVE_SELECTS
158
   output [spi1_ss_width-1:0] spi1_ss_o;
159
 `endif
160
   input                      spi1_miso_i;
161
`endif
162
`ifdef SPI2
163
   output                     spi2_sck_o;
164
   output                     spi2_mosi_o;
165
 `ifdef SPI2_SLAVE_SELECTS
166
   output [spi2_ss_width-1:0] spi2_ss_o;
167
 `endif
168
   input                      spi2_miso_i;
169
`endif
170
`ifdef I2C0
171
   inout                      i2c0_sda_io, i2c0_scl_io;
172
`endif
173
`ifdef I2C1
174
   inout                      i2c1_sda_io, i2c1_scl_io;
175
`endif
176
`ifdef I2C2
177
   inout                      i2c2_sda_io, i2c2_scl_io;
178
`endif
179
`ifdef I2C3
180
   inout                      i2c3_sda_io, i2c3_scl_io;
181
`endif
182
`ifdef USB0
183
   input [1:0]                 usb0dat_pad_i;
184
   //   input                 usb0vbusdetect;
185
   output [1:0]        usb0dat_pad_o;
186
   output                     usb0ctrl_pad_o;
187
   output                     usb0fullspeed_pad_o;
188
`endif
189
`ifdef USB1
190
   input [1:0]                 usb1dat_pad_i;
191
   //   input                 usb1vbusdetect;
192
   output [1:0]        usb1dat_pad_o;
193
   output                     usb1ctrl_pad_o;
194
   output                     usb1fullspeed_pad_o;
195
`endif
196
`ifdef GPIO0
197
   inout [gpio0_io_width-1:0] gpio0_io;
198
`endif
199
`ifdef ETH0
200
 `ifdef SMII0
201
   output                     eth0_smii_sync_pad_o, eth0_smii_tx_pad_o;
202
   input                      eth0_smii_rx_pad_i;
203
 `else
204
   input                      eth0_tx_clk;
205
   output [3:0]        eth0_tx_data;
206
   output                     eth0_tx_en;
207
   output                     eth0_tx_er;
208
   input                      eth0_rx_clk;
209
   input [3:0]                 eth0_rx_data;
210
   input                      eth0_dv;
211
   input                      eth0_rx_er;
212
   input                      eth0_col;
213
   input                      eth0_crs;
214
 `endif // !`ifdef SMII0
215
   output                     eth0_mdc_pad_o;
216
   inout                      eth0_md_pad_io;
217
`endif //  `ifdef ETH0
218
`ifdef ETH_CLK
219
   input                      eth_clk_pad_i;
220
`endif
221 544 julius
`ifdef SDC_CONTROLLER
222
   inout                      sdc_cmd_pad_io;
223
   input                      sdc_card_detect_pad_i;
224
   inout [3:0]                 sdc_dat_pad_io ;
225
   output                     sdc_clk_pad_o ;
226
`endif
227 408 julius
   ////////////////////////////////////////////////////////////////////////
228
   //
229
   // Clock and reset generation module
230
   // 
231
   ////////////////////////////////////////////////////////////////////////
232
 
233
   //
234
   // Wires
235
   //
236
   wire                       wb_clk, wb_rst;
237
   wire                       sdram_clk, sdram_rst;
238
   wire                       ddr2_if_clk, ddr2_if_rst;
239
   wire                       clk200;
240
   wire                       usb_clk;
241
   wire                       spw_clk;
242
   wire                       eth_smii_clk, eth_smii_rst;
243
   wire                       dbg_tck;
244
 
245
 
246
   clkgen clkgen0
247
     (
248
      .sys_clk_pad_i             (sys_clk_pad_i),
249
 
250
      .wb_clk_o                  (wb_clk),
251
      .wb_rst_o                  (wb_rst),
252
 
253
`ifdef JTAG_DEBUG
254
      .tck_pad_i                 (tck_pad_i),
255
      .dbg_tck_o                 (dbg_tck),
256
`endif
257
`ifdef VERSATILE_SDRAM
258
      .sdram_clk_o               (sdram_clk),
259
      .sdram_rst_o               (sdram_rst),
260
`endif
261
`ifdef ETH_CLK
262
      .eth_clk_pad_i             (eth_clk_pad_i),
263
      .eth_clk_o                 (eth_smii_clk),
264
      .eth_rst_o                 (eth_smii_rst),
265
`endif
266
`ifdef USB_CLK
267
      .usb_clk_o                 (usb_clk),
268
`endif
269
 
270
      // Asynchronous active low reset
271
      .rst_n_pad_i               (rst_n_pad_i)
272
      );
273
 
274
 
275
   ////////////////////////////////////////////////////////////////////////
276
   //
277
   // Arbiter
278
   // 
279
   ////////////////////////////////////////////////////////////////////////
280
 
281
   // Wire naming convention:
282
   // First: wishbone master or slave (wbm/wbs)
283
   // Second: Which bus it's on instruction or data (i/d)
284
   // Third: Between which module and the arbiter the wires are
285
   // Fourth: Signal name
286
   // Fifth: Direction relative to module (not bus/arbiter!)
287
   //        ie. wbm_d_or12_adr_o is address OUT from the or1200
288
 
289
   // OR1200 instruction bus wires
290
   wire [wb_aw-1:0]            wbm_i_or12_adr_o;
291
   wire [wb_dw-1:0]            wbm_i_or12_dat_o;
292
   wire [3:0]                  wbm_i_or12_sel_o;
293
   wire                       wbm_i_or12_we_o;
294
   wire                       wbm_i_or12_cyc_o;
295
   wire                       wbm_i_or12_stb_o;
296
   wire [2:0]                  wbm_i_or12_cti_o;
297
   wire [1:0]                  wbm_i_or12_bte_o;
298
 
299
   wire [wb_dw-1:0]            wbm_i_or12_dat_i;
300
   wire                       wbm_i_or12_ack_i;
301
   wire                       wbm_i_or12_err_i;
302
   wire                       wbm_i_or12_rty_i;
303
 
304
   // OR1200 data bus wires   
305
   wire [wb_aw-1:0]            wbm_d_or12_adr_o;
306
   wire [wb_dw-1:0]            wbm_d_or12_dat_o;
307
   wire [3:0]                  wbm_d_or12_sel_o;
308
   wire                       wbm_d_or12_we_o;
309
   wire                       wbm_d_or12_cyc_o;
310
   wire                       wbm_d_or12_stb_o;
311
   wire [2:0]                  wbm_d_or12_cti_o;
312
   wire [1:0]                  wbm_d_or12_bte_o;
313
 
314
   wire [wb_dw-1:0]            wbm_d_or12_dat_i;
315
   wire                       wbm_d_or12_ack_i;
316
   wire                       wbm_d_or12_err_i;
317
   wire                       wbm_d_or12_rty_i;
318
 
319
   // Debug interface bus wires   
320
   wire [wb_aw-1:0]            wbm_d_dbg_adr_o;
321
   wire [wb_dw-1:0]            wbm_d_dbg_dat_o;
322
   wire [3:0]                  wbm_d_dbg_sel_o;
323
   wire                       wbm_d_dbg_we_o;
324
   wire                       wbm_d_dbg_cyc_o;
325
   wire                       wbm_d_dbg_stb_o;
326
   wire [2:0]                  wbm_d_dbg_cti_o;
327
   wire [1:0]                  wbm_d_dbg_bte_o;
328
 
329
   wire [wb_dw-1:0]            wbm_d_dbg_dat_i;
330
   wire                       wbm_d_dbg_ack_i;
331
   wire                       wbm_d_dbg_err_i;
332
   wire                       wbm_d_dbg_rty_i;
333
 
334
   // Byte bus bridge master signals
335
   wire [wb_aw-1:0]            wbm_b_d_adr_o;
336
   wire [wb_dw-1:0]            wbm_b_d_dat_o;
337
   wire [3:0]                  wbm_b_d_sel_o;
338
   wire                       wbm_b_d_we_o;
339
   wire                       wbm_b_d_cyc_o;
340
   wire                       wbm_b_d_stb_o;
341
   wire [2:0]                  wbm_b_d_cti_o;
342
   wire [1:0]                  wbm_b_d_bte_o;
343
 
344
   wire [wb_dw-1:0]            wbm_b_d_dat_i;
345
   wire                       wbm_b_d_ack_i;
346
   wire                       wbm_b_d_err_i;
347
   wire                       wbm_b_d_rty_i;
348
 
349
   // Instruction bus slave wires //
350
 
351
   // rom0 instruction bus wires
352
   wire [31:0]                 wbs_i_rom0_adr_i;
353
   wire [wbs_i_rom0_data_width-1:0] wbs_i_rom0_dat_i;
354
   wire [3:0]                        wbs_i_rom0_sel_i;
355
   wire                             wbs_i_rom0_we_i;
356
   wire                             wbs_i_rom0_cyc_i;
357
   wire                             wbs_i_rom0_stb_i;
358
   wire [2:0]                        wbs_i_rom0_cti_i;
359
   wire [1:0]                        wbs_i_rom0_bte_i;
360
   wire [wbs_i_rom0_data_width-1:0] wbs_i_rom0_dat_o;
361
   wire                             wbs_i_rom0_ack_o;
362
   wire                             wbs_i_rom0_err_o;
363
   wire                             wbs_i_rom0_rty_o;
364
 
365
   // mc0 instruction bus wires
366
   wire [31:0]                       wbs_i_mc0_adr_i;
367
   wire [wbs_i_mc0_data_width-1:0]  wbs_i_mc0_dat_i;
368
   wire [3:0]                        wbs_i_mc0_sel_i;
369
   wire                             wbs_i_mc0_we_i;
370
   wire                             wbs_i_mc0_cyc_i;
371
   wire                             wbs_i_mc0_stb_i;
372
   wire [2:0]                        wbs_i_mc0_cti_i;
373
   wire [1:0]                        wbs_i_mc0_bte_i;
374
   wire [wbs_i_mc0_data_width-1:0]  wbs_i_mc0_dat_o;
375
   wire                             wbs_i_mc0_ack_o;
376
   wire                             wbs_i_mc0_err_o;
377
   wire                             wbs_i_mc0_rty_o;
378
 
379
   // Data bus slave wires //
380
 
381
   // mc0 data bus wires
382
   wire [31:0]                       wbs_d_mc0_adr_i;
383
   wire [wbs_d_mc0_data_width-1:0]  wbs_d_mc0_dat_i;
384
   wire [3:0]                        wbs_d_mc0_sel_i;
385
   wire                             wbs_d_mc0_we_i;
386
   wire                             wbs_d_mc0_cyc_i;
387
   wire                             wbs_d_mc0_stb_i;
388
   wire [2:0]                        wbs_d_mc0_cti_i;
389
   wire [1:0]                        wbs_d_mc0_bte_i;
390
   wire [wbs_d_mc0_data_width-1:0]  wbs_d_mc0_dat_o;
391
   wire                             wbs_d_mc0_ack_o;
392
   wire                             wbs_d_mc0_err_o;
393
   wire                             wbs_d_mc0_rty_o;
394
 
395
   // i2c0 wires
396
   wire [31:0]                       wbs_d_i2c0_adr_i;
397
   wire [wbs_d_i2c0_data_width-1:0] wbs_d_i2c0_dat_i;
398
   wire [3:0]                        wbs_d_i2c0_sel_i;
399
   wire                             wbs_d_i2c0_we_i;
400
   wire                             wbs_d_i2c0_cyc_i;
401
   wire                             wbs_d_i2c0_stb_i;
402
   wire [2:0]                        wbs_d_i2c0_cti_i;
403
   wire [1:0]                        wbs_d_i2c0_bte_i;
404
   wire [wbs_d_i2c0_data_width-1:0] wbs_d_i2c0_dat_o;
405
   wire                             wbs_d_i2c0_ack_o;
406
   wire                             wbs_d_i2c0_err_o;
407
   wire                             wbs_d_i2c0_rty_o;
408
 
409
   // i2c1 wires
410
   wire [31:0]                       wbs_d_i2c1_adr_i;
411
   wire [wbs_d_i2c1_data_width-1:0] wbs_d_i2c1_dat_i;
412
   wire [3:0]                        wbs_d_i2c1_sel_i;
413
   wire                             wbs_d_i2c1_we_i;
414
   wire                             wbs_d_i2c1_cyc_i;
415
   wire                             wbs_d_i2c1_stb_i;
416
   wire [2:0]                        wbs_d_i2c1_cti_i;
417
   wire [1:0]                        wbs_d_i2c1_bte_i;
418
   wire [wbs_d_i2c1_data_width-1:0] wbs_d_i2c1_dat_o;
419
   wire                             wbs_d_i2c1_ack_o;
420
   wire                             wbs_d_i2c1_err_o;
421
   wire                             wbs_d_i2c1_rty_o;
422
 
423
   // i2c2 wires
424
   wire [31:0]                       wbs_d_i2c2_adr_i;
425
   wire [wbs_d_i2c2_data_width-1:0] wbs_d_i2c2_dat_i;
426
   wire [3:0]                        wbs_d_i2c2_sel_i;
427
   wire                             wbs_d_i2c2_we_i;
428
   wire                             wbs_d_i2c2_cyc_i;
429
   wire                             wbs_d_i2c2_stb_i;
430
   wire [2:0]                        wbs_d_i2c2_cti_i;
431
   wire [1:0]                        wbs_d_i2c2_bte_i;
432
   wire [wbs_d_i2c2_data_width-1:0] wbs_d_i2c2_dat_o;
433
   wire                             wbs_d_i2c2_ack_o;
434
   wire                             wbs_d_i2c2_err_o;
435
   wire                             wbs_d_i2c2_rty_o;
436
 
437
   // i2c3 wires
438
   wire [31:0]                       wbs_d_i2c3_adr_i;
439
   wire [wbs_d_i2c3_data_width-1:0] wbs_d_i2c3_dat_i;
440
   wire [3:0]                        wbs_d_i2c3_sel_i;
441
   wire                             wbs_d_i2c3_we_i;
442
   wire                             wbs_d_i2c3_cyc_i;
443
   wire                             wbs_d_i2c3_stb_i;
444
   wire [2:0]                        wbs_d_i2c3_cti_i;
445
   wire [1:0]                        wbs_d_i2c3_bte_i;
446
   wire [wbs_d_i2c3_data_width-1:0] wbs_d_i2c3_dat_o;
447
   wire                             wbs_d_i2c3_ack_o;
448
   wire                             wbs_d_i2c3_err_o;
449
   wire                             wbs_d_i2c3_rty_o;
450
 
451
   // spi0 wires
452
   wire [31:0]                       wbs_d_spi0_adr_i;
453
   wire [wbs_d_spi0_data_width-1:0] wbs_d_spi0_dat_i;
454
   wire [3:0]                        wbs_d_spi0_sel_i;
455
   wire                             wbs_d_spi0_we_i;
456
   wire                             wbs_d_spi0_cyc_i;
457
   wire                             wbs_d_spi0_stb_i;
458
   wire [2:0]                        wbs_d_spi0_cti_i;
459
   wire [1:0]                        wbs_d_spi0_bte_i;
460
   wire [wbs_d_spi0_data_width-1:0] wbs_d_spi0_dat_o;
461
   wire                             wbs_d_spi0_ack_o;
462
   wire                             wbs_d_spi0_err_o;
463
   wire                             wbs_d_spi0_rty_o;
464
 
465
   // spi1 wires
466
   wire [31:0]                       wbs_d_spi1_adr_i;
467
   wire [wbs_d_spi1_data_width-1:0] wbs_d_spi1_dat_i;
468
   wire [3:0]                        wbs_d_spi1_sel_i;
469
   wire                             wbs_d_spi1_we_i;
470
   wire                             wbs_d_spi1_cyc_i;
471
   wire                             wbs_d_spi1_stb_i;
472
   wire [2:0]                        wbs_d_spi1_cti_i;
473
   wire [1:0]                        wbs_d_spi1_bte_i;
474
   wire [wbs_d_spi1_data_width-1:0] wbs_d_spi1_dat_o;
475
   wire                             wbs_d_spi1_ack_o;
476
   wire                             wbs_d_spi1_err_o;
477
   wire                             wbs_d_spi1_rty_o;
478
 
479
   // spi2 wires
480
   wire [31:0]                       wbs_d_spi2_adr_i;
481
   wire [wbs_d_spi2_data_width-1:0] wbs_d_spi2_dat_i;
482
   wire [3:0]                        wbs_d_spi2_sel_i;
483
   wire                             wbs_d_spi2_we_i;
484
   wire                             wbs_d_spi2_cyc_i;
485
   wire                             wbs_d_spi2_stb_i;
486
   wire [2:0]                        wbs_d_spi2_cti_i;
487
   wire [1:0]                        wbs_d_spi2_bte_i;
488
   wire [wbs_d_spi2_data_width-1:0] wbs_d_spi2_dat_o;
489
   wire                             wbs_d_spi2_ack_o;
490
   wire                             wbs_d_spi2_err_o;
491
   wire                             wbs_d_spi2_rty_o;
492
 
493
   // uart0 wires
494
   wire [31:0]                        wbs_d_uart0_adr_i;
495
   wire [wbs_d_uart0_data_width-1:0] wbs_d_uart0_dat_i;
496
   wire [3:0]                         wbs_d_uart0_sel_i;
497
   wire                              wbs_d_uart0_we_i;
498
   wire                              wbs_d_uart0_cyc_i;
499
   wire                              wbs_d_uart0_stb_i;
500
   wire [2:0]                         wbs_d_uart0_cti_i;
501
   wire [1:0]                         wbs_d_uart0_bte_i;
502
   wire [wbs_d_uart0_data_width-1:0] wbs_d_uart0_dat_o;
503
   wire                              wbs_d_uart0_ack_o;
504
   wire                              wbs_d_uart0_err_o;
505
   wire                              wbs_d_uart0_rty_o;
506
 
507
   // usb0 wires
508
   wire [31:0]                        wbs_d_usb0_adr_i;
509
   wire [wbs_d_usb0_data_width-1:0]  wbs_d_usb0_dat_i;
510
   wire [3:0]                         wbs_d_usb0_sel_i;
511
   wire                              wbs_d_usb0_we_i;
512
   wire                              wbs_d_usb0_cyc_i;
513
   wire                              wbs_d_usb0_stb_i;
514
   wire [2:0]                         wbs_d_usb0_cti_i;
515
   wire [1:0]                         wbs_d_usb0_bte_i;
516
   wire [wbs_d_usb0_data_width-1:0]  wbs_d_usb0_dat_o;
517
   wire                              wbs_d_usb0_ack_o;
518
   wire                              wbs_d_usb0_err_o;
519
   wire                              wbs_d_usb0_rty_o;
520
 
521
   // usb1 wires
522
   wire [31:0]                        wbs_d_usb1_adr_i;
523
   wire [wbs_d_usb1_data_width-1:0]  wbs_d_usb1_dat_i;
524
   wire [3:0]                         wbs_d_usb1_sel_i;
525
   wire                              wbs_d_usb1_we_i;
526
   wire                              wbs_d_usb1_cyc_i;
527
   wire                              wbs_d_usb1_stb_i;
528
   wire [2:0]                         wbs_d_usb1_cti_i;
529
   wire [1:0]                         wbs_d_usb1_bte_i;
530
   wire [wbs_d_usb1_data_width-1:0]  wbs_d_usb1_dat_o;
531
   wire                              wbs_d_usb1_ack_o;
532
   wire                              wbs_d_usb1_err_o;
533
   wire                              wbs_d_usb1_rty_o;
534 544 julius
 
535
   // sdcard slave wires
536
   wire [31:0]                        wbs_d_sdc_adr_i;
537
   wire [wbs_d_sdc_data_width-1:0]   wbs_d_sdc_dat_i;
538
   wire [3:0]                         wbs_d_sdc_sel_i;
539
   wire                              wbs_d_sdc_we_i;
540
   wire                              wbs_d_sdc_cyc_i;
541
   wire                              wbs_d_sdc_stb_i;
542
   wire [2:0]                         wbs_d_sdc_cti_i;
543
   wire [1:0]                         wbs_d_sdc_bte_i;
544
   wire [wbs_d_sdc_data_width-1:0]   wbs_d_sdc_dat_o;
545
   wire                              wbs_d_sdc_ack_o;
546
   wire                              wbs_d_sdc_err_o;
547
   wire                              wbs_d_sdc_rty_o;
548
 
549
   // sdcard master wires
550
   wire [wbm_sdc_addr_width-1:0]     wbm_sdc_adr_o;
551
   wire [wbm_sdc_data_width-1:0]     wbm_sdc_dat_o;
552
   wire [3:0]                         wbm_sdc_sel_o;
553
   wire                              wbm_sdc_we_o;
554
   wire                              wbm_sdc_cyc_o;
555
   wire                              wbm_sdc_stb_o;
556
   wire [2:0]                         wbm_sdc_cti_o;
557
   wire [1:0]                         wbm_sdc_bte_o;
558
   wire [wbm_sdc_data_width-1:0]     wbm_sdc_dat_i;
559
   wire                              wbm_sdc_ack_i;
560
   wire                              wbm_sdc_err_i;
561
   wire                              wbm_sdc_rty_i;
562
 
563 408 julius
 
564
   // gpio0 wires
565
   wire [31:0]                        wbs_d_gpio0_adr_i;
566
   wire [wbs_d_gpio0_data_width-1:0] wbs_d_gpio0_dat_i;
567
   wire [3:0]                         wbs_d_gpio0_sel_i;
568
   wire                              wbs_d_gpio0_we_i;
569
   wire                              wbs_d_gpio0_cyc_i;
570
   wire                              wbs_d_gpio0_stb_i;
571
   wire [2:0]                         wbs_d_gpio0_cti_i;
572
   wire [1:0]                         wbs_d_gpio0_bte_i;
573
   wire [wbs_d_gpio0_data_width-1:0] wbs_d_gpio0_dat_o;
574
   wire                              wbs_d_gpio0_ack_o;
575
   wire                              wbs_d_gpio0_err_o;
576
   wire                              wbs_d_gpio0_rty_o;
577
 
578
   // flashROM wires
579
   wire [31:0]                             wbs_d_flashrom_adr_i;
580
   wire [flashrom_wb_data_width-1:0]       wbs_d_flashrom_dat_i;
581
   wire [3:0]                              wbs_d_flashrom_sel_i;
582
   wire                                   wbs_d_flashrom_we_i;
583
   wire                                   wbs_d_flashrom_cyc_i;
584
   wire                                   wbs_d_flashrom_stb_i;
585
   wire [2:0]                              wbs_d_flashrom_cti_i;
586
   wire [1:0]                              wbs_d_flashrom_bte_i;
587
   wire [flashrom_wb_data_width-1:0]       wbs_d_flashrom_dat_o;
588
   wire                                   wbs_d_flashrom_ack_o;
589
   wire                                   wbs_d_flashrom_err_o;
590
   wire                                   wbs_d_flashrom_rty_o;
591
 
592
   // eth0 slave wires
593
   wire [31:0]                             wbs_d_eth0_adr_i;
594
   wire [wbs_d_eth0_data_width-1:0]        wbs_d_eth0_dat_i;
595
   wire [3:0]                              wbs_d_eth0_sel_i;
596
   wire                                   wbs_d_eth0_we_i;
597
   wire                                   wbs_d_eth0_cyc_i;
598
   wire                                   wbs_d_eth0_stb_i;
599
   wire [2:0]                              wbs_d_eth0_cti_i;
600
   wire [1:0]                              wbs_d_eth0_bte_i;
601
   wire [wbs_d_eth0_data_width-1:0]        wbs_d_eth0_dat_o;
602
   wire                                   wbs_d_eth0_ack_o;
603
   wire                                   wbs_d_eth0_err_o;
604
   wire                                   wbs_d_eth0_rty_o;
605
   // eth0 master wires
606
   wire [wbm_eth0_addr_width-1:0]          wbm_eth0_adr_o;
607
   wire [wbm_eth0_data_width-1:0]          wbm_eth0_dat_o;
608
   wire [3:0]                              wbm_eth0_sel_o;
609
   wire                                   wbm_eth0_we_o;
610
   wire                                   wbm_eth0_cyc_o;
611
   wire                                   wbm_eth0_stb_o;
612
   wire [2:0]                              wbm_eth0_cti_o;
613
   wire [1:0]                              wbm_eth0_bte_o;
614
   wire [wbm_eth0_data_width-1:0]         wbm_eth0_dat_i;
615
   wire                                   wbm_eth0_ack_i;
616
   wire                                   wbm_eth0_err_i;
617
   wire                                   wbm_eth0_rty_i;
618
 
619 544 julius
 
620 408 julius
 
621
 
622
   //
623
   // Wishbone instruction bus arbiter
624
   //
625
 
626
   arbiter_ibus arbiter_ibus0
627
     (
628
      // Instruction Bus Master
629
      // Inputs to arbiter from master
630
      .wbm_adr_o                        (wbm_i_or12_adr_o),
631
      .wbm_dat_o                        (wbm_i_or12_dat_o),
632
      .wbm_sel_o                        (wbm_i_or12_sel_o),
633
      .wbm_we_o                         (wbm_i_or12_we_o),
634
      .wbm_cyc_o                        (wbm_i_or12_cyc_o),
635
      .wbm_stb_o                        (wbm_i_or12_stb_o),
636
      .wbm_cti_o                        (wbm_i_or12_cti_o),
637
      .wbm_bte_o                        (wbm_i_or12_bte_o),
638
      // Outputs to master from arbiter
639
      .wbm_dat_i                        (wbm_i_or12_dat_i),
640
      .wbm_ack_i                        (wbm_i_or12_ack_i),
641
      .wbm_err_i                        (wbm_i_or12_err_i),
642
      .wbm_rty_i                        (wbm_i_or12_rty_i),
643
 
644
      // Slave 0
645
      // Inputs to slave from arbiter
646
      .wbs0_adr_i                       (wbs_i_rom0_adr_i),
647
      .wbs0_dat_i                       (wbs_i_rom0_dat_i),
648
      .wbs0_sel_i                       (wbs_i_rom0_sel_i),
649
      .wbs0_we_i                        (wbs_i_rom0_we_i),
650
      .wbs0_cyc_i                       (wbs_i_rom0_cyc_i),
651
      .wbs0_stb_i                       (wbs_i_rom0_stb_i),
652
      .wbs0_cti_i                       (wbs_i_rom0_cti_i),
653
      .wbs0_bte_i                       (wbs_i_rom0_bte_i),
654
      // Outputs from slave to arbiter      
655
      .wbs0_dat_o                       (wbs_i_rom0_dat_o),
656
      .wbs0_ack_o                       (wbs_i_rom0_ack_o),
657
      .wbs0_err_o                       (wbs_i_rom0_err_o),
658
      .wbs0_rty_o                       (wbs_i_rom0_rty_o),
659
 
660
      // Slave 1
661
      // Inputs to slave from arbiter
662
      .wbs1_adr_i                       (wbs_i_mc0_adr_i),
663
      .wbs1_dat_i                       (wbs_i_mc0_dat_i),
664
      .wbs1_sel_i                       (wbs_i_mc0_sel_i),
665
      .wbs1_we_i                        (wbs_i_mc0_we_i),
666
      .wbs1_cyc_i                       (wbs_i_mc0_cyc_i),
667
      .wbs1_stb_i                       (wbs_i_mc0_stb_i),
668
      .wbs1_cti_i                       (wbs_i_mc0_cti_i),
669
      .wbs1_bte_i                       (wbs_i_mc0_bte_i),
670
      // Outputs from slave to arbiter
671
      .wbs1_dat_o                       (wbs_i_mc0_dat_o),
672
      .wbs1_ack_o                       (wbs_i_mc0_ack_o),
673
      .wbs1_err_o                       (wbs_i_mc0_err_o),
674
      .wbs1_rty_o                       (wbs_i_mc0_rty_o),
675
 
676
      // Clock, reset inputs
677
      .wb_clk                           (wb_clk),
678
      .wb_rst                           (wb_rst));
679
 
680
   defparam arbiter_ibus0.wb_addr_match_width = ibus_arb_addr_match_width;
681
 
682
   defparam arbiter_ibus0.slave0_adr = ibus_arb_slave0_adr; // FLASH ROM
683
   defparam arbiter_ibus0.slave1_adr = ibus_arb_slave1_adr; // Main memory
684
 
685
   //
686
   // Wishbone data bus arbiter
687
   //
688
 
689
   arbiter_dbus arbiter_dbus0
690
     (
691
      // Master 0
692
      // Inputs to arbiter from master
693
      .wbm0_adr_o                       (wbm_d_or12_adr_o),
694
      .wbm0_dat_o                       (wbm_d_or12_dat_o),
695
      .wbm0_sel_o                       (wbm_d_or12_sel_o),
696
      .wbm0_we_o                        (wbm_d_or12_we_o),
697
      .wbm0_cyc_o                       (wbm_d_or12_cyc_o),
698
      .wbm0_stb_o                       (wbm_d_or12_stb_o),
699
      .wbm0_cti_o                       (wbm_d_or12_cti_o),
700
      .wbm0_bte_o                       (wbm_d_or12_bte_o),
701
      // Outputs to master from arbiter
702
      .wbm0_dat_i                       (wbm_d_or12_dat_i),
703
      .wbm0_ack_i                       (wbm_d_or12_ack_i),
704
      .wbm0_err_i                       (wbm_d_or12_err_i),
705
      .wbm0_rty_i                       (wbm_d_or12_rty_i),
706
 
707
      // Master 0
708
      // Inputs to arbiter from master
709
      .wbm1_adr_o                       (wbm_d_dbg_adr_o),
710
      .wbm1_dat_o                       (wbm_d_dbg_dat_o),
711
      .wbm1_we_o                        (wbm_d_dbg_we_o),
712
      .wbm1_cyc_o                       (wbm_d_dbg_cyc_o),
713
      .wbm1_sel_o                       (wbm_d_dbg_sel_o),
714
      .wbm1_stb_o                       (wbm_d_dbg_stb_o),
715
      .wbm1_cti_o                       (wbm_d_dbg_cti_o),
716
      .wbm1_bte_o                       (wbm_d_dbg_bte_o),
717
      // Outputs to master from arbiter      
718
      .wbm1_dat_i                       (wbm_d_dbg_dat_i),
719
      .wbm1_ack_i                       (wbm_d_dbg_ack_i),
720
      .wbm1_err_i                       (wbm_d_dbg_err_i),
721
      .wbm1_rty_i                       (wbm_d_dbg_rty_i),
722
 
723
      // Slaves
724
 
725
      .wbs0_adr_i                       (wbs_d_mc0_adr_i),
726
      .wbs0_dat_i                       (wbs_d_mc0_dat_i),
727
      .wbs0_sel_i                       (wbs_d_mc0_sel_i),
728
      .wbs0_we_i                        (wbs_d_mc0_we_i),
729
      .wbs0_cyc_i                       (wbs_d_mc0_cyc_i),
730
      .wbs0_stb_i                       (wbs_d_mc0_stb_i),
731
      .wbs0_cti_i                       (wbs_d_mc0_cti_i),
732
      .wbs0_bte_i                       (wbs_d_mc0_bte_i),
733
      .wbs0_dat_o                       (wbs_d_mc0_dat_o),
734
      .wbs0_ack_o                       (wbs_d_mc0_ack_o),
735
      .wbs0_err_o                       (wbs_d_mc0_err_o),
736
      .wbs0_rty_o                       (wbs_d_mc0_rty_o),
737
 
738
      .wbs1_adr_i                       (wbs_d_eth0_adr_i),
739
      .wbs1_dat_i                       (wbs_d_eth0_dat_i),
740
      .wbs1_sel_i                       (wbs_d_eth0_sel_i),
741
      .wbs1_we_i                        (wbs_d_eth0_we_i),
742
      .wbs1_cyc_i                       (wbs_d_eth0_cyc_i),
743
      .wbs1_stb_i                       (wbs_d_eth0_stb_i),
744
      .wbs1_cti_i                       (wbs_d_eth0_cti_i),
745
      .wbs1_bte_i                       (wbs_d_eth0_bte_i),
746
      .wbs1_dat_o                       (wbs_d_eth0_dat_o),
747
      .wbs1_ack_o                       (wbs_d_eth0_ack_o),
748
      .wbs1_err_o                       (wbs_d_eth0_err_o),
749
      .wbs1_rty_o                       (wbs_d_eth0_rty_o),
750 544 julius
 
751
      .wbs2_adr_i                       (wbs_d_sdc_adr_i),
752
      .wbs2_dat_i                       (wbs_d_sdc_dat_i),
753
      .wbs2_sel_i                       (wbs_d_sdc_sel_i),
754
      .wbs2_we_i                        (wbs_d_sdc_we_i),
755
      .wbs2_cyc_i                       (wbs_d_sdc_cyc_i),
756
      .wbs2_stb_i                       (wbs_d_sdc_stb_i),
757
      .wbs2_cti_i                       (wbs_d_sdc_cti_i),
758
      .wbs2_bte_i                       (wbs_d_sdc_bte_i),
759
      .wbs2_dat_o                       (wbs_d_sdc_dat_o),
760
      .wbs2_ack_o                       (wbs_d_sdc_ack_o),
761
      .wbs2_err_o                       (wbs_d_sdc_err_o),
762
      .wbs2_rty_o                       (wbs_d_sdc_rty_o),
763 408 julius
 
764 544 julius
      .wbs3_adr_i                       (wbm_b_d_adr_o),
765
      .wbs3_dat_i                       (wbm_b_d_dat_o),
766
      .wbs3_sel_i                       (wbm_b_d_sel_o),
767
      .wbs3_we_i                        (wbm_b_d_we_o),
768
      .wbs3_cyc_i                       (wbm_b_d_cyc_o),
769
      .wbs3_stb_i                       (wbm_b_d_stb_o),
770
      .wbs3_cti_i                       (wbm_b_d_cti_o),
771
      .wbs3_bte_i                       (wbm_b_d_bte_o),
772
      .wbs3_dat_o                       (wbm_b_d_dat_i),
773
      .wbs3_ack_o                       (wbm_b_d_ack_i),
774
      .wbs3_err_o                       (wbm_b_d_err_i),
775
      .wbs3_rty_o                       (wbm_b_d_rty_i),
776 408 julius
 
777
      // Clock, reset inputs
778
      .wb_clk                   (wb_clk),
779
      .wb_rst                   (wb_rst));
780
 
781
   // These settings are from top level params file
782
   defparam arbiter_dbus0.wb_addr_match_width = dbus_arb_wb_addr_match_width;
783
   defparam arbiter_dbus0.wb_num_slaves = dbus_arb_wb_num_slaves;
784
   defparam arbiter_dbus0.slave0_adr = dbus_arb_slave0_adr;
785
   defparam arbiter_dbus0.slave1_adr = dbus_arb_slave1_adr;
786 544 julius
   defparam arbiter_dbus0.slave2_adr = dbus_arb_slave2_adr;
787 408 julius
 
788
   //
789
   // Wishbone byte-wide bus arbiter
790
   //   
791
 
792
   arbiter_bytebus arbiter_bytebus0
793
     (
794
 
795
      // Master 0
796
      // Inputs to arbiter from master
797
      .wbm0_adr_o                       (wbm_b_d_adr_o),
798
      .wbm0_dat_o                       (wbm_b_d_dat_o),
799
      .wbm0_sel_o                       (wbm_b_d_sel_o),
800
      .wbm0_we_o                        (wbm_b_d_we_o),
801
      .wbm0_cyc_o                       (wbm_b_d_cyc_o),
802
      .wbm0_stb_o                       (wbm_b_d_stb_o),
803
      .wbm0_cti_o                       (wbm_b_d_cti_o),
804
      .wbm0_bte_o                       (wbm_b_d_bte_o),
805
      // Outputs to master from arbiter
806
      .wbm0_dat_i                       (wbm_b_d_dat_i),
807
      .wbm0_ack_i                       (wbm_b_d_ack_i),
808
      .wbm0_err_i                       (wbm_b_d_err_i),
809
      .wbm0_rty_i                       (wbm_b_d_rty_i),
810
 
811
      // Byte bus slaves
812
 
813
      .wbs0_adr_i                       (wbs_d_uart0_adr_i),
814
      .wbs0_dat_i                       (wbs_d_uart0_dat_i),
815
      .wbs0_we_i                        (wbs_d_uart0_we_i),
816
      .wbs0_cyc_i                       (wbs_d_uart0_cyc_i),
817
      .wbs0_stb_i                       (wbs_d_uart0_stb_i),
818
      .wbs0_cti_i                       (wbs_d_uart0_cti_i),
819
      .wbs0_bte_i                       (wbs_d_uart0_bte_i),
820
      .wbs0_dat_o                       (wbs_d_uart0_dat_o),
821
      .wbs0_ack_o                       (wbs_d_uart0_ack_o),
822
      .wbs0_err_o                       (wbs_d_uart0_err_o),
823
      .wbs0_rty_o                       (wbs_d_uart0_rty_o),
824
 
825
      .wbs1_adr_i                       (wbs_d_gpio0_adr_i),
826
      .wbs1_dat_i                       (wbs_d_gpio0_dat_i),
827
      .wbs1_we_i                        (wbs_d_gpio0_we_i),
828
      .wbs1_cyc_i                       (wbs_d_gpio0_cyc_i),
829
      .wbs1_stb_i                       (wbs_d_gpio0_stb_i),
830
      .wbs1_cti_i                       (wbs_d_gpio0_cti_i),
831
      .wbs1_bte_i                       (wbs_d_gpio0_bte_i),
832
      .wbs1_dat_o                       (wbs_d_gpio0_dat_o),
833
      .wbs1_ack_o                       (wbs_d_gpio0_ack_o),
834
      .wbs1_err_o                       (wbs_d_gpio0_err_o),
835
      .wbs1_rty_o                       (wbs_d_gpio0_rty_o),
836
 
837
      .wbs2_adr_i                       (wbs_d_usb0_adr_i),
838
      .wbs2_dat_i                       (wbs_d_usb0_dat_i),
839
      .wbs2_we_i                        (wbs_d_usb0_we_i),
840
      .wbs2_cyc_i                       (wbs_d_usb0_cyc_i),
841
      .wbs2_stb_i                       (wbs_d_usb0_stb_i),
842
      .wbs2_cti_i                       (wbs_d_usb0_cti_i),
843
      .wbs2_bte_i                       (wbs_d_usb0_bte_i),
844
      .wbs2_dat_o                       (wbs_d_usb0_dat_o),
845
      .wbs2_ack_o                       (wbs_d_usb0_ack_o),
846
      .wbs2_err_o                       (wbs_d_usb0_err_o),
847
      .wbs2_rty_o                       (wbs_d_usb0_rty_o),
848
 
849
      .wbs3_adr_i                       (wbs_d_i2c0_adr_i),
850
      .wbs3_dat_i                       (wbs_d_i2c0_dat_i),
851
      .wbs3_we_i                        (wbs_d_i2c0_we_i),
852
      .wbs3_cyc_i                       (wbs_d_i2c0_cyc_i),
853
      .wbs3_stb_i                       (wbs_d_i2c0_stb_i),
854
      .wbs3_cti_i                       (wbs_d_i2c0_cti_i),
855
      .wbs3_bte_i                       (wbs_d_i2c0_bte_i),
856
      .wbs3_dat_o                       (wbs_d_i2c0_dat_o),
857
      .wbs3_ack_o                       (wbs_d_i2c0_ack_o),
858
      .wbs3_err_o                       (wbs_d_i2c0_err_o),
859
      .wbs3_rty_o                       (wbs_d_i2c0_rty_o),
860
 
861
      .wbs4_adr_i                       (wbs_d_i2c1_adr_i),
862
      .wbs4_dat_i                       (wbs_d_i2c1_dat_i),
863
      .wbs4_we_i                        (wbs_d_i2c1_we_i),
864
      .wbs4_cyc_i                       (wbs_d_i2c1_cyc_i),
865
      .wbs4_stb_i                       (wbs_d_i2c1_stb_i),
866
      .wbs4_cti_i                       (wbs_d_i2c1_cti_i),
867
      .wbs4_bte_i                       (wbs_d_i2c1_bte_i),
868
      .wbs4_dat_o                       (wbs_d_i2c1_dat_o),
869
      .wbs4_ack_o                       (wbs_d_i2c1_ack_o),
870
      .wbs4_err_o                       (wbs_d_i2c1_err_o),
871
      .wbs4_rty_o                       (wbs_d_i2c1_rty_o),
872
 
873
      .wbs5_adr_i                       (wbs_d_i2c2_adr_i),
874
      .wbs5_dat_i                       (wbs_d_i2c2_dat_i),
875
      .wbs5_we_i                        (wbs_d_i2c2_we_i),
876
      .wbs5_cyc_i                       (wbs_d_i2c2_cyc_i),
877
      .wbs5_stb_i                       (wbs_d_i2c2_stb_i),
878
      .wbs5_cti_i                       (wbs_d_i2c2_cti_i),
879
      .wbs5_bte_i                       (wbs_d_i2c2_bte_i),
880
      .wbs5_dat_o                       (wbs_d_i2c2_dat_o),
881
      .wbs5_ack_o                       (wbs_d_i2c2_ack_o),
882
      .wbs5_err_o                       (wbs_d_i2c2_err_o),
883
      .wbs5_rty_o                       (wbs_d_i2c2_rty_o),
884
 
885
      .wbs6_adr_i                       (wbs_d_i2c3_adr_i),
886
      .wbs6_dat_i                       (wbs_d_i2c3_dat_i),
887
      .wbs6_we_i                        (wbs_d_i2c3_we_i),
888
      .wbs6_cyc_i                       (wbs_d_i2c3_cyc_i),
889
      .wbs6_stb_i                       (wbs_d_i2c3_stb_i),
890
      .wbs6_cti_i                       (wbs_d_i2c3_cti_i),
891
      .wbs6_bte_i                       (wbs_d_i2c3_bte_i),
892
      .wbs6_dat_o                       (wbs_d_i2c3_dat_o),
893
      .wbs6_ack_o                       (wbs_d_i2c3_ack_o),
894
      .wbs6_err_o                       (wbs_d_i2c3_err_o),
895
      .wbs6_rty_o                       (wbs_d_i2c3_rty_o),
896
 
897
      .wbs7_adr_i                       (wbs_d_spi0_adr_i),
898
      .wbs7_dat_i                       (wbs_d_spi0_dat_i),
899
      .wbs7_we_i                        (wbs_d_spi0_we_i),
900
      .wbs7_cyc_i                       (wbs_d_spi0_cyc_i),
901
      .wbs7_stb_i                       (wbs_d_spi0_stb_i),
902
      .wbs7_cti_i                       (wbs_d_spi0_cti_i),
903
      .wbs7_bte_i                       (wbs_d_spi0_bte_i),
904
      .wbs7_dat_o                       (wbs_d_spi0_dat_o),
905
      .wbs7_ack_o                       (wbs_d_spi0_ack_o),
906
      .wbs7_err_o                       (wbs_d_spi0_err_o),
907
      .wbs7_rty_o                       (wbs_d_spi0_rty_o),
908
 
909
      .wbs8_adr_i                       (wbs_d_spi1_adr_i),
910
      .wbs8_dat_i                       (wbs_d_spi1_dat_i),
911
      .wbs8_we_i                        (wbs_d_spi1_we_i),
912
      .wbs8_cyc_i                       (wbs_d_spi1_cyc_i),
913
      .wbs8_stb_i                       (wbs_d_spi1_stb_i),
914
      .wbs8_cti_i                       (wbs_d_spi1_cti_i),
915
      .wbs8_bte_i                       (wbs_d_spi1_bte_i),
916
      .wbs8_dat_o                       (wbs_d_spi1_dat_o),
917
      .wbs8_ack_o                       (wbs_d_spi1_ack_o),
918
      .wbs8_err_o                       (wbs_d_spi1_err_o),
919
      .wbs8_rty_o                       (wbs_d_spi1_rty_o),
920
 
921
      .wbs9_adr_i                       (wbs_d_spi2_adr_i),
922
      .wbs9_dat_i                       (wbs_d_spi2_dat_i),
923
      .wbs9_we_i                        (wbs_d_spi2_we_i),
924
      .wbs9_cyc_i                       (wbs_d_spi2_cyc_i),
925
      .wbs9_stb_i                       (wbs_d_spi2_stb_i),
926
      .wbs9_cti_i                       (wbs_d_spi2_cti_i),
927
      .wbs9_bte_i                       (wbs_d_spi2_bte_i),
928
      .wbs9_dat_o                       (wbs_d_spi2_dat_o),
929
      .wbs9_ack_o                       (wbs_d_spi2_ack_o),
930
      .wbs9_err_o                       (wbs_d_spi2_err_o),
931
      .wbs9_rty_o                       (wbs_d_spi2_rty_o),
932
 
933
      .wbs10_adr_i                      (wbs_d_flashrom_adr_i),
934
      .wbs10_dat_i                      (wbs_d_flashrom_dat_i),
935
      .wbs10_we_i                       (wbs_d_flashrom_we_i),
936
      .wbs10_cyc_i                      (wbs_d_flashrom_cyc_i),
937
      .wbs10_stb_i                      (wbs_d_flashrom_stb_i),
938
      .wbs10_cti_i                      (wbs_d_flashrom_cti_i),
939
      .wbs10_bte_i                      (wbs_d_flashrom_bte_i),
940
      .wbs10_dat_o                      (wbs_d_flashrom_dat_o),
941
      .wbs10_ack_o                      (wbs_d_flashrom_ack_o),
942
      .wbs10_err_o                      (wbs_d_flashrom_err_o),
943
      .wbs10_rty_o                      (wbs_d_flashrom_rty_o),
944
 
945
      .wbs11_adr_i                      (wbs_d_usb1_adr_i),
946
      .wbs11_dat_i                      (wbs_d_usb1_dat_i),
947
      .wbs11_we_i                       (wbs_d_usb1_we_i),
948
      .wbs11_cyc_i                      (wbs_d_usb1_cyc_i),
949
      .wbs11_stb_i                      (wbs_d_usb1_stb_i),
950
      .wbs11_cti_i                      (wbs_d_usb1_cti_i),
951
      .wbs11_bte_i                      (wbs_d_usb1_bte_i),
952
      .wbs11_dat_o                      (wbs_d_usb1_dat_o),
953
      .wbs11_ack_o                      (wbs_d_usb1_ack_o),
954
      .wbs11_err_o                      (wbs_d_usb1_err_o),
955
      .wbs11_rty_o                      (wbs_d_usb1_rty_o),
956
 
957
      // Clock, reset inputs
958
      .wb_clk                   (wb_clk),
959
      .wb_rst                   (wb_rst));
960
 
961
   defparam arbiter_bytebus0.wb_addr_match_width = bbus_arb_wb_addr_match_width;
962
   defparam arbiter_bytebus0.wb_num_slaves = bbus_arb_wb_num_slaves;
963
 
964
   defparam arbiter_bytebus0.slave0_adr = bbus_arb_slave0_adr;
965
   defparam arbiter_bytebus0.slave1_adr = bbus_arb_slave1_adr;
966
   defparam arbiter_bytebus0.slave2_adr = bbus_arb_slave2_adr;
967
   defparam arbiter_bytebus0.slave3_adr = bbus_arb_slave3_adr;
968
   defparam arbiter_bytebus0.slave4_adr = bbus_arb_slave4_adr;
969
   defparam arbiter_bytebus0.slave5_adr = bbus_arb_slave5_adr;
970
   defparam arbiter_bytebus0.slave6_adr = bbus_arb_slave6_adr;
971
   defparam arbiter_bytebus0.slave7_adr = bbus_arb_slave7_adr;
972
   defparam arbiter_bytebus0.slave8_adr = bbus_arb_slave8_adr;
973
   defparam arbiter_bytebus0.slave9_adr = bbus_arb_slave9_adr;
974
   defparam arbiter_bytebus0.slave10_adr = bbus_arb_slave10_adr;
975
   defparam arbiter_bytebus0.slave11_adr = bbus_arb_slave11_adr;
976
 
977
 
978
`ifdef JTAG_DEBUG
979
   ////////////////////////////////////////////////////////////////////////
980
   //
981
   // JTAG TAP
982
   // 
983
   ////////////////////////////////////////////////////////////////////////
984
 
985
   //
986
   // Wires
987
   //
988
   wire                                   dbg_if_select;
989
   wire                                   dbg_if_tdo;
990
   wire                                   jtag_tap_tdo;
991
   wire                                   jtag_tap_shift_dr, jtag_tap_pause_dr,
992
                                          jtag_tap_upate_dr, jtag_tap_capture_dr;
993
   //
994
   // Instantiation
995
   //
996
 
997
   jtag_tap jtag_tap0
998
     (
999
      // Ports to pads
1000
      .tdo_pad_o                        (tdo_pad_o),
1001
      .tms_pad_i                        (tms_pad_i),
1002
      .tck_pad_i                        (dbg_tck),
1003
      .trst_pad_i                       (async_rst),
1004
      .tdi_pad_i                        (tdi_pad_i),
1005
 
1006
      .tdo_padoe_o                      (tdo_padoe_o),
1007
 
1008
      .tdo_o                            (jtag_tap_tdo),
1009
 
1010
      .shift_dr_o                       (jtag_tap_shift_dr),
1011
      .pause_dr_o                       (jtag_tap_pause_dr),
1012
      .update_dr_o                      (jtag_tap_update_dr),
1013
      .capture_dr_o                     (jtag_tap_capture_dr),
1014
 
1015
      .extest_select_o                  (),
1016
      .sample_preload_select_o          (),
1017
      .mbist_select_o                   (),
1018
      .debug_select_o                   (dbg_if_select),
1019
 
1020
 
1021
      .bs_chain_tdi_i                   (1'b0),
1022
      .mbist_tdi_i                      (1'b0),
1023
      .debug_tdi_i                      (dbg_if_tdo)
1024
 
1025
      );
1026
 
1027
   ////////////////////////////////////////////////////////////////////////
1028
`endif //  `ifdef JTAG_DEBUG
1029
 
1030
   ////////////////////////////////////////////////////////////////////////
1031
   //
1032
   // OpenRISC processor
1033
   // 
1034
   ////////////////////////////////////////////////////////////////////////
1035
 
1036
   // 
1037
   // Wires
1038
   // 
1039
 
1040
   wire [30:0]                             or1200_pic_ints;
1041
 
1042
   wire [31:0]                             or1200_dbg_dat_i;
1043
   wire [31:0]                             or1200_dbg_adr_i;
1044
   wire                                   or1200_dbg_we_i;
1045
   wire                                   or1200_dbg_stb_i;
1046
   wire                                   or1200_dbg_ack_o;
1047
   wire [31:0]                             or1200_dbg_dat_o;
1048
 
1049
   wire                                   or1200_dbg_stall_i;
1050
   wire                                   or1200_dbg_ewt_i;
1051
   wire [3:0]                              or1200_dbg_lss_o;
1052
   wire [1:0]                              or1200_dbg_is_o;
1053
   wire [10:0]                             or1200_dbg_wp_o;
1054
   wire                                   or1200_dbg_bp_o;
1055
   wire                                   or1200_dbg_rst;
1056 485 julius
 
1057 408 julius
   wire                                   or1200_clk, or1200_rst;
1058
   wire                                   sig_tick;
1059
 
1060
   //
1061
   // Assigns
1062
   //
1063
   assign or1200_clk = wb_clk;
1064 544 julius
   assign or1200_rst = wb_rst /* | or1200_dbg_rst*/;
1065 408 julius
 
1066
   // 
1067
   // Instantiation
1068
   //    
1069
   or1200_top or1200_top0
1070
       (
1071
        // Instruction bus, clocks, reset
1072
        .iwb_clk_i                      (wb_clk),
1073
        .iwb_rst_i                      (wb_rst),
1074
        .iwb_ack_i                      (wbm_i_or12_ack_i),
1075
        .iwb_err_i                      (wbm_i_or12_err_i),
1076
        .iwb_rty_i                      (wbm_i_or12_rty_i),
1077
        .iwb_dat_i                      (wbm_i_or12_dat_i),
1078
 
1079
        .iwb_cyc_o                      (wbm_i_or12_cyc_o),
1080
        .iwb_adr_o                      (wbm_i_or12_adr_o),
1081
        .iwb_stb_o                      (wbm_i_or12_stb_o),
1082
        .iwb_we_o                               (wbm_i_or12_we_o),
1083
        .iwb_sel_o                      (wbm_i_or12_sel_o),
1084
        .iwb_dat_o                      (wbm_i_or12_dat_o),
1085
        .iwb_cti_o                      (wbm_i_or12_cti_o),
1086
        .iwb_bte_o                      (wbm_i_or12_bte_o),
1087
 
1088
        // Data bus, clocks, reset            
1089
        .dwb_clk_i                      (wb_clk),
1090
        .dwb_rst_i                      (wb_rst),
1091
        .dwb_ack_i                      (wbm_d_or12_ack_i),
1092
        .dwb_err_i                      (wbm_d_or12_err_i),
1093
        .dwb_rty_i                      (wbm_d_or12_rty_i),
1094
        .dwb_dat_i                      (wbm_d_or12_dat_i),
1095
 
1096
        .dwb_cyc_o                      (wbm_d_or12_cyc_o),
1097
        .dwb_adr_o                      (wbm_d_or12_adr_o),
1098
        .dwb_stb_o                      (wbm_d_or12_stb_o),
1099
        .dwb_we_o                               (wbm_d_or12_we_o),
1100
        .dwb_sel_o                      (wbm_d_or12_sel_o),
1101
        .dwb_dat_o                      (wbm_d_or12_dat_o),
1102
        .dwb_cti_o                      (wbm_d_or12_cti_o),
1103
        .dwb_bte_o                      (wbm_d_or12_bte_o),
1104
 
1105
        // Debug interface ports
1106
        .dbg_stall_i                    (or1200_dbg_stall_i),
1107
        //.dbg_ewt_i                    (or1200_dbg_ewt_i),
1108
        .dbg_ewt_i                      (1'b0),
1109
        .dbg_lss_o                      (or1200_dbg_lss_o),
1110
        .dbg_is_o                               (or1200_dbg_is_o),
1111
        .dbg_wp_o                               (or1200_dbg_wp_o),
1112
        .dbg_bp_o                               (or1200_dbg_bp_o),
1113
 
1114
        .dbg_adr_i                      (or1200_dbg_adr_i),
1115
        .dbg_we_i                               (or1200_dbg_we_i ),
1116
        .dbg_stb_i                      (or1200_dbg_stb_i),
1117
        .dbg_dat_i                      (or1200_dbg_dat_i),
1118
        .dbg_dat_o                      (or1200_dbg_dat_o),
1119
        .dbg_ack_o                      (or1200_dbg_ack_o),
1120
 
1121
        .pm_clksd_o                     (),
1122
        .pm_dc_gate_o                   (),
1123
        .pm_ic_gate_o                   (),
1124
        .pm_dmmu_gate_o                 (),
1125
        .pm_immu_gate_o                 (),
1126
        .pm_tt_gate_o                   (),
1127
        .pm_cpu_gate_o                  (),
1128
        .pm_wakeup_o                    (),
1129
        .pm_lvolt_o                     (),
1130
 
1131
        // Core clocks, resets
1132
        .clk_i                          (or1200_clk),
1133
        .rst_i                          (or1200_rst),
1134
 
1135
        .clmode_i                               (2'b00),
1136
        // Interrupts      
1137
        .pic_ints_i                     (or1200_pic_ints),
1138
        .sig_tick(sig_tick),
1139
        /*
1140
         .mbist_so_o                    (),
1141
         .mbist_si_i                    (0),
1142
         .mbist_ctrl_i                  (0),
1143
         */
1144
 
1145
        .pm_cpustall_i                  (1'b0)
1146
 
1147
        );
1148
 
1149
   ////////////////////////////////////////////////////////////////////////
1150
 
1151
 
1152
`ifdef JTAG_DEBUG
1153
   ////////////////////////////////////////////////////////////////////////
1154
         //
1155
   // OR1200 Debug Interface
1156
   // 
1157
   ////////////////////////////////////////////////////////////////////////
1158
 
1159
   dbg_if dbg_if0
1160
     (
1161
      // OR1200 interface
1162
      .cpu0_clk_i                       (or1200_clk),
1163
      .cpu0_rst_o                       (or1200_dbg_rst),
1164
      .cpu0_addr_o                      (or1200_dbg_adr_i),
1165
      .cpu0_data_o                      (or1200_dbg_dat_i),
1166
      .cpu0_stb_o                       (or1200_dbg_stb_i),
1167
      .cpu0_we_o                        (or1200_dbg_we_i),
1168
      .cpu0_data_i                      (or1200_dbg_dat_o),
1169
      .cpu0_ack_i                       (or1200_dbg_ack_o),
1170
 
1171
 
1172
      .cpu0_stall_o                     (or1200_dbg_stall_i),
1173
      .cpu0_bp_i                        (or1200_dbg_bp_o),
1174
 
1175
      // TAP interface
1176
      .tck_i                            (dbg_tck),
1177
      .tdi_i                            (jtag_tap_tdo),
1178
      .tdo_o                            (dbg_if_tdo),
1179
      .rst_i                            (wb_rst),
1180
      .shift_dr_i                       (jtag_tap_shift_dr),
1181
      .pause_dr_i                       (jtag_tap_pause_dr),
1182
      .update_dr_i                      (jtag_tap_update_dr),
1183
      .debug_select_i                   (dbg_if_select),
1184
 
1185
      // Wishbone debug master
1186
      .wb_clk_i                         (wb_clk),
1187
      .wb_dat_i                         (wbm_d_dbg_dat_i),
1188
      .wb_ack_i                         (wbm_d_dbg_ack_i),
1189
      .wb_err_i                         (wbm_d_dbg_err_i),
1190
      .wb_adr_o                         (wbm_d_dbg_adr_o),
1191
      .wb_dat_o                         (wbm_d_dbg_dat_o),
1192
      .wb_cyc_o                         (wbm_d_dbg_cyc_o),
1193
      .wb_stb_o                         (wbm_d_dbg_stb_o),
1194
      .wb_sel_o                         (wbm_d_dbg_sel_o),
1195
      .wb_we_o                          (wbm_d_dbg_we_o ),
1196
      .wb_cti_o                         (wbm_d_dbg_cti_o),
1197
      .wb_cab_o                         (/*   UNUSED  */),
1198
      .wb_bte_o                         (wbm_d_dbg_bte_o)
1199
      );
1200
 
1201
   ////////////////////////////////////////////////////////////////////////   
1202
`else // !`ifdef JTAG_DEBUG
1203
 
1204
   assign wbm_d_dbg_adr_o = 0;
1205
   assign wbm_d_dbg_dat_o = 0;
1206
   assign wbm_d_dbg_cyc_o = 0;
1207
   assign wbm_d_dbg_stb_o = 0;
1208
   assign wbm_d_dbg_sel_o = 0;
1209
   assign wbm_d_dbg_we_o  = 0;
1210
   assign wbm_d_dbg_cti_o = 0;
1211
   assign wbm_d_dbg_bte_o = 0;
1212
 
1213
   assign or1200_dbg_adr_i = 0;
1214
   assign or1200_dbg_dat_i = 0;
1215
   assign or1200_dbg_stb_i = 0;
1216
   assign or1200_dbg_we_i = 0;
1217
   assign or1200_dbg_stall_i = 0;
1218
 
1219
   ////////////////////////////////////////////////////////////////////////   
1220
`endif // !`ifdef JTAG_DEBUG
1221
 
1222
`ifdef VERSATILE_SDRAM
1223
   ////////////////////////////////////////////////////////////////////////
1224
   //
1225
   // Versatile Memory Controller (SDRAM configured)
1226
   // 
1227
   ////////////////////////////////////////////////////////////////////////
1228
 
1229
   //
1230
   // Wires
1231
   //
1232
 
1233
   wire [15:0]                             sdram_dq_i;
1234
   wire [15:0]                             sdram_dq_o;
1235
   wire                                   sdram_dq_oe;
1236
 
1237
   //
1238
   // Assigns
1239
   //
1240
 
1241
   assign sdram_dq_i = sdram_dq_pad_io;
1242
   assign sdram_dq_pad_io = sdram_dq_oe ? sdram_dq_o : 16'bz;
1243
 
1244
   versatile_mem_ctrl versatile_mem_ctrl0
1245
     (
1246
      // External SDRAM interface
1247
      .ba_pad_o                         (sdram_ba_pad_o[1:0]),
1248
      .a_pad_o                          (sdram_a_pad_o[12:0]),
1249
      .cs_n_pad_o                       (sdram_cs_n_pad_o),
1250
      .ras_pad_o                        (sdram_ras_pad_o),
1251
      .cas_pad_o                        (sdram_cas_pad_o),
1252
      .we_pad_o                         (sdram_we_pad_o),
1253
      .dq_i                             (sdram_dq_i[15:0]),
1254
      .dq_o                             (sdram_dq_o[15:0]),
1255
      .dqm_pad_o                        (sdram_dqm_pad_o[1:0]),
1256
      .dq_oe                            (sdram_dq_oe),
1257
      .cke_pad_o                        (sdram_cke_pad_o),
1258
      .sdram_clk                        (sdram_clk),
1259
      .sdram_rst                        (sdram_rst),
1260
 `ifdef ETH0
1261 544 julius
  `ifdef SDC_CONTROLLER
1262 408 julius
      // Wishbone slave interface 0
1263 544 julius
      .wb_dat_i_0                       ({{wbm_eth0_dat_o, wbm_eth0_sel_o},{wbm_sdc_dat_o, wbm_sdc_sel_o},
1264
                                          {wbs_d_mc0_dat_i, wbs_d_mc0_sel_i},{wbs_i_mc0_dat_i,wbs_i_mc0_sel_i}}),
1265 408 julius
      .wb_adr_i_0                       ({{wbm_eth0_adr_o[31:2], wbm_eth0_we_o, wbm_eth0_bte_o, wbm_eth0_cti_o},
1266 544 julius
                                          {wbm_sdc_adr_o[31:2], wbm_sdc_we_o,   wbm_sdc_bte_o,   wbm_sdc_cti_o},
1267 408 julius
                                          {wbs_d_mc0_adr_i[31:2], wbs_d_mc0_we_i, wbs_d_mc0_bte_i, wbs_d_mc0_cti_i},
1268
                                          {wbs_i_mc0_adr_i[31:2], wbs_i_mc0_we_i, wbs_i_mc0_bte_i, wbs_i_mc0_cti_i}}),
1269 544 julius
      .wb_cyc_i_0                       ({wbm_eth0_cyc_o,wbm_sdc_cyc_o,wbs_d_mc0_cyc_i,wbs_i_mc0_cyc_i}),
1270
      .wb_stb_i_0                       ({wbm_eth0_stb_o,wbm_sdc_stb_o,wbs_d_mc0_stb_i,wbs_i_mc0_stb_i}),
1271
      .wb_dat_o_0                       ({wbm_eth0_dat_i,wbm_sdc_dat_i,wbs_d_mc0_dat_o,wbs_i_mc0_dat_o}),
1272
      .wb_ack_o_0                       ({wbm_eth0_ack_i,wbm_sdc_ack_i,wbs_d_mc0_ack_o,wbs_i_mc0_ack_o}),
1273
  `else
1274
      // Wishbone slave interface 0
1275
      .wb_dat_i_0                       ({{wbm_eth0_dat_o, wbm_eth0_sel_o},{wbs_d_mc0_dat_i, wbs_d_mc0_sel_i},
1276
                                          {wbs_i_mc0_dat_i,wbs_i_mc0_sel_i}}),
1277
      .wb_adr_i_0                       ({{wbm_eth0_adr_o[31:2], wbm_eth0_we_o, wbm_eth0_bte_o, wbm_eth0_cti_o},
1278
                                          {wbs_d_mc0_adr_i[31:2], wbs_d_mc0_we_i, wbs_d_mc0_bte_i, wbs_d_mc0_cti_i},
1279
                                          {wbs_i_mc0_adr_i[31:2], wbs_i_mc0_we_i, wbs_i_mc0_bte_i, wbs_i_mc0_cti_i}}),
1280 408 julius
      .wb_cyc_i_0                       ({wbm_eth0_cyc_o,wbs_d_mc0_cyc_i,wbs_i_mc0_cyc_i}),
1281
      .wb_stb_i_0                       ({wbm_eth0_stb_o,wbs_d_mc0_stb_i,wbs_i_mc0_stb_i}),
1282
      .wb_dat_o_0                       ({wbm_eth0_dat_i,wbs_d_mc0_dat_o,wbs_i_mc0_dat_o}),
1283
      .wb_ack_o_0                       ({wbm_eth0_ack_i,wbs_d_mc0_ack_o,wbs_i_mc0_ack_o}),
1284 544 julius
  `endif
1285 408 julius
 `else // !`ifdef ETH0
1286 544 julius
  `ifdef SDC_CONTROLLER
1287 408 julius
      // Wishbone slave interface 0
1288 544 julius
      .wb_dat_i_0                       ({{wbm_sdc_dat_o, wbm_sdc_sel_o},{wbs_d_mc0_dat_i, wbs_d_mc0_sel_i},
1289
                                          {wbs_i_mc0_dat_i,wbs_i_mc0_sel_i}}),
1290
      .wb_adr_i_0                       ({{wbm_sdc_adr_o[31:2]  , wbm_sdc_we_o  ,   wbm_sdc_bte_o,   wbm_sdc_cti_o},
1291
                                          {wbs_d_mc0_adr_i[31:2], wbs_d_mc0_we_i, wbs_d_mc0_bte_i, wbs_d_mc0_cti_i},
1292
                                          {wbs_i_mc0_adr_i[31:2], wbs_i_mc0_we_i, wbs_i_mc0_bte_i, wbs_i_mc0_cti_i}}),
1293
      .wb_cyc_i_0                       ({wbm_sdc_cyc_o,wbs_d_mc0_cyc_i,wbs_i_mc0_cyc_i}),
1294
      .wb_stb_i_0                       ({wbm_sdc_stb_o,wbs_d_mc0_stb_i,wbs_i_mc0_stb_i}),
1295
      .wb_dat_o_0                       ({wbm_sdc_dat_i,wbs_d_mc0_dat_o,wbs_i_mc0_dat_o}),
1296
      .wb_ack_o_0                       ({wbm_sdc_ack_i,wbs_d_mc0_ack_o,wbs_i_mc0_ack_o}),
1297
  `else
1298
      // Wishbone slave interface 0
1299 408 julius
      .wb_dat_i_0                       ({{wbs_d_mc0_dat_i, wbs_d_mc0_sel_i},{wbs_i_mc0_dat_i,wbs_i_mc0_sel_i}}),
1300
      .wb_adr_i_0                       ({{wbs_d_mc0_adr_i[31:2], wbs_d_mc0_we_i, wbs_d_mc0_bte_i, wbs_d_mc0_cti_i},
1301
                                          {wbs_i_mc0_adr_i[31:2], wbs_i_mc0_we_i, wbs_i_mc0_bte_i, wbs_i_mc0_cti_i}}),
1302
      .wb_cyc_i_0                       ({wbs_d_mc0_cyc_i,wbs_i_mc0_cyc_i}),
1303
      .wb_stb_i_0                       ({wbs_d_mc0_stb_i,wbs_i_mc0_stb_i}),
1304
      .wb_dat_o_0                       ({wbs_d_mc0_dat_o,wbs_i_mc0_dat_o}),
1305
      .wb_ack_o_0                       ({wbs_d_mc0_ack_o,wbs_i_mc0_ack_o}),
1306 544 julius
  `endif
1307 408 julius
 `endif // !`ifdef ETH0
1308
 
1309
      // Wishbone slave interface 1
1310
      .wb_dat_i_1                       (2'd0),
1311
      .wb_adr_i_1                       (2'd0),
1312
      .wb_cyc_i_1                       (2'd0),
1313
      .wb_stb_i_1                       (2'd0),
1314
      .wb_dat_o_1                       (),
1315
      .wb_ack_o_1                       (),
1316
 
1317
      // Wishbone slave interface 2
1318
      .wb_dat_i_2                       (2'd0),
1319
      .wb_adr_i_2                       (2'd0),
1320
      .wb_cyc_i_2                       (2'd0),
1321
      .wb_stb_i_2                       (2'd0),
1322
      .wb_dat_o_2                       (),
1323
      .wb_ack_o_2                       (),
1324
 
1325
      // Wishbone slave interface 3
1326
      .wb_dat_i_3                       (2'd0),
1327
      .wb_adr_i_3                       (2'd0),
1328
      .wb_cyc_i_3                       (2'd0),
1329
      .wb_stb_i_3                       (2'd0),
1330
      .wb_dat_o_3                       (),
1331
      .wb_ack_o_3                       (),
1332
 
1333
      .wb_clk                           (wb_clk),
1334
      .wb_rst                           (wb_rst)
1335
      );
1336
 
1337
   // If not using gatelevel, define parameters
1338
   // Hard-set here to just 2 ports from the same domain
1339
 
1340
   defparam versatile_mem_ctrl0.nr_of_wb_clk_domains = 1;
1341 544 julius
 `ifdef ETH0
1342
  `ifdef SDC_CONTROLLER
1343
   defparam versatile_mem_ctrl0.nr_of_wb_ports_clk0  = 4;
1344
  `else
1345 408 julius
   defparam versatile_mem_ctrl0.nr_of_wb_ports_clk0  = 3;
1346 544 julius
  `endif
1347 408 julius
 `else
1348 544 julius
  `ifdef SDC_CONTROLLER
1349
   defparam versatile_mem_ctrl0.nr_of_wb_ports_clk0  = 3;
1350
  `else
1351 408 julius
   defparam versatile_mem_ctrl0.nr_of_wb_ports_clk0  = 2;
1352 544 julius
  `endif
1353 408 julius
 `endif
1354
   defparam versatile_mem_ctrl0.nr_of_wb_ports_clk1  = 0;
1355
   defparam versatile_mem_ctrl0.nr_of_wb_ports_clk2  = 0;
1356
   defparam versatile_mem_ctrl0.nr_of_wb_ports_clk3  = 0;
1357
 
1358
   assign wbs_i_mc0_err_o = 0;
1359
   assign wbs_i_mc0_rty_o = 0;
1360
 
1361
   assign wbs_d_mc0_err_o = 0;
1362
   assign wbs_d_mc0_rty_o = 0;
1363
 
1364
   assign wbm_eth0_err_i = 0;
1365
   assign wbm_eth0_rty_i = 0;
1366
 
1367
 
1368
   ////////////////////////////////////////////////////////////////////////
1369
`endif //  `ifdef VERSATILE_SDRAM
1370
 
1371
   ////////////////////////////////////////////////////////////////////////
1372
   //
1373
   // ROM
1374
   // 
1375
   ////////////////////////////////////////////////////////////////////////
1376
 
1377
   rom rom0
1378
     (
1379
      .wb_dat_o                         (wbs_i_rom0_dat_o),
1380
      .wb_ack_o                         (wbs_i_rom0_ack_o),
1381
      .wb_adr_i                         (wbs_i_rom0_adr_i[(wbs_i_rom0_addr_width+2)-1:2]),
1382
      .wb_stb_i                         (wbs_i_rom0_stb_i),
1383
      .wb_cyc_i                         (wbs_i_rom0_cyc_i),
1384
      .wb_cti_i                         (wbs_i_rom0_cti_i),
1385
      .wb_bte_i                         (wbs_i_rom0_bte_i),
1386
      .wb_clk                           (wb_clk),
1387
      .wb_rst                           (wb_rst));
1388
 
1389
   defparam rom0.addr_width = wbs_i_rom0_addr_width;
1390
 
1391
   assign wbs_i_rom0_err_o = 0;
1392
   assign wbs_i_rom0_rty_o = 0;
1393
 
1394
   ////////////////////////////////////////////////////////////////////////
1395
 
1396
 
1397
`ifdef ACTEL_UFR
1398
   ////////////////////////////////////////////////////////////////////////
1399
   //
1400
   // Flash ROM
1401
   // 
1402
   ////////////////////////////////////////////////////////////////////////
1403
   flashrom flashrom0
1404
     (
1405
      .wb_dat_o                         (wbs_d_flashrom_dat_o),
1406
      .wb_ack_o                         (wbs_d_flashrom_ack_o),
1407
      .wb_err_o                         (wbs_d_flashrom_err_o),
1408
      .wb_rty_o                         (wbs_d_flashrom_rty_o),
1409
      .wb_adr_i                         (wbs_d_flashrom_adr_i[flashrom_wb_adr_width-1:0]),
1410
      .wb_stb_i                         (wbs_d_flashrom_stb_i),
1411
      .wb_cyc_i                         (wbs_d_flashrom_cyc_i),
1412
      .wb_clk                           (wb_clk),
1413
      .wb_rst                           (wb_rst));
1414
`else // !`ifdef ACTEL_UFR0
1415
   assign wbs_d_flashrom_dat_o = 0;
1416
   assign wbs_d_flashrom_ack_o = wbs_d_flashrom_stb_i;
1417
`endif // !`ifdef ACTEL_UFR0
1418
 
1419
   assign wbs_i_rom0_err_o = 0;
1420
   assign wbs_i_rom0_rty_o = 0;
1421
 
1422
`ifdef RAM_WB
1423
   ////////////////////////////////////////////////////////////////////////
1424
   //
1425
   // Generic RAM
1426
   // 
1427
   ////////////////////////////////////////////////////////////////////////
1428
 
1429
   ram_wb ram_wb0
1430
     (
1431
      // Wishbone slave interface 0
1432
      .wbm0_dat_i                       (wbs_i_mc0_dat_i),
1433
      .wbm0_adr_i                       (wbs_i_mc0_adr_i),
1434
      .wbm0_sel_i                       (wbs_i_mc0_sel_i),
1435
      .wbm0_cti_i                       (wbs_i_mc0_cti_i),
1436
      .wbm0_bte_i                       (wbs_i_mc0_bte_i),
1437
      .wbm0_we_i                        (wbs_i_mc0_we_i ),
1438
      .wbm0_cyc_i                       (wbs_i_mc0_cyc_i),
1439
      .wbm0_stb_i                       (wbs_i_mc0_stb_i),
1440
      .wbm0_dat_o                       (wbs_i_mc0_dat_o),
1441
      .wbm0_ack_o                       (wbs_i_mc0_ack_o),
1442 439 julius
      .wbm0_err_o                       (wbs_i_mc0_err_o),
1443
      .wbm0_rty_o                       (wbs_i_mc0_rty_o),
1444 408 julius
      // Wishbone slave interface 1
1445
      .wbm1_dat_i                       (wbs_d_mc0_dat_i),
1446
      .wbm1_adr_i                       (wbs_d_mc0_adr_i),
1447
      .wbm1_sel_i                       (wbs_d_mc0_sel_i),
1448
      .wbm1_cti_i                       (wbs_d_mc0_cti_i),
1449
      .wbm1_bte_i                       (wbs_d_mc0_bte_i),
1450
      .wbm1_we_i                        (wbs_d_mc0_we_i ),
1451
      .wbm1_cyc_i                       (wbs_d_mc0_cyc_i),
1452
      .wbm1_stb_i                       (wbs_d_mc0_stb_i),
1453
      .wbm1_dat_o                       (wbs_d_mc0_dat_o),
1454
      .wbm1_ack_o                       (wbs_d_mc0_ack_o),
1455 439 julius
      .wbm1_err_o                       (wbs_d_mc0_err_o),
1456
      .wbm1_rty_o                       (wbs_d_mc0_rty_o),
1457
      // Wishbone slave interface 2
1458
      .wbm2_dat_i                       (wbm_eth0_dat_o),
1459
      .wbm2_adr_i                       (wbm_eth0_adr_o),
1460
      .wbm2_sel_i                       (wbm_eth0_sel_o),
1461
      .wbm2_cti_i                       (wbm_eth0_cti_o),
1462
      .wbm2_bte_i                       (wbm_eth0_bte_o),
1463
      .wbm2_we_i                        (wbm_eth0_we_o ),
1464
      .wbm2_cyc_i                       (wbm_eth0_cyc_o),
1465
      .wbm2_stb_i                       (wbm_eth0_stb_o),
1466
      .wbm2_dat_o                       (wbm_eth0_dat_i),
1467
      .wbm2_ack_o                       (wbm_eth0_ack_i),
1468
      .wbm2_err_o                       (wbm_eth0_err_i),
1469
      .wbm2_rty_o                       (wbm_eth0_rty_i),
1470 408 julius
      // Clock, reset
1471
      .wb_clk_i                         (wb_clk),
1472
      .wb_rst_i                         (wb_rst));
1473
 
1474
   defparam ram_wb0.aw = wb_aw;
1475
   defparam ram_wb0.dw = wb_dw;
1476 439 julius
   defparam ram_wb0.mem_size_bytes = internal_sram_mem_span;
1477
   defparam ram_wb0.mem_adr_width = internal_sram_adr_width_for_span;
1478 408 julius
   ////////////////////////////////////////////////////////////////////////
1479
`endif //  `ifdef RAM_WB
1480
 
1481
 
1482
`ifdef ETH0
1483
 
1484
   //
1485
   // Wires
1486
   //
1487
   wire        eth0_irq;
1488
   wire [3:0]  eth0_mtxd;
1489
   wire        eth0_mtxen;
1490
   wire        eth0_mtxerr;
1491
   wire        eth0_mtx_clk;
1492
   wire        eth0_mrx_clk;
1493
   wire [3:0]  eth0_mrxd;
1494
   wire        eth0_mrxdv;
1495
   wire        eth0_mrxerr;
1496
   wire        eth0_mcoll;
1497
   wire        eth0_mcrs;
1498
   wire        eth0_speed;
1499
   wire        eth0_duplex;
1500
   wire        eth0_link;
1501
   // Management interface wires
1502
   wire        eth0_md_i;
1503
   wire        eth0_md_o;
1504
   wire        eth0_md_oe;
1505
 
1506
 
1507
   //
1508
   // assigns
1509
 `ifdef SMII0
1510
   smii smii0
1511
     (
1512
      // SMII pads
1513
      .eth_sync_pad_o                   (eth0_smii_sync_pad_o),
1514
      .eth_tx_pad_o                     (eth0_smii_tx_pad_o),
1515
      .eth_rx_pad_i                     (eth0_smii_rx_pad_i),
1516
 
1517
      // MII interface to MAC
1518
      // Transmit
1519
      .mtx_clk                          (eth0_mtx_clk),
1520
      .mtxd                             (eth0_mtxd[3:0]),
1521
      .mtxen                            (eth0_mtxen),
1522
      .mtxerr                           (eth0_mtxerr),
1523
      .mrxd                             (eth0_mrxd[3:0]),
1524
      // Receive
1525
      .mrxdv                            (eth0_mrxdv),
1526
      .mrxerr                           (eth0_mrxerr),
1527
      .mrx_clk                          (eth0_mrx_clk),
1528
      // Status signals
1529
      .mcoll                            (eth0_mcoll),
1530
      .mcrs                             (eth0_mcrs),
1531
      .speed                            (eth0_speed),
1532
      .duplex                           (eth0_duplex),
1533
      .link                             (eth0_link),
1534
 
1535
      // Inputs
1536
      .eth_clk                          (eth_smii_clk),
1537
      .eth_rst                          (eth_smii_rst)
1538
      );
1539
 
1540
`else // !`ifdef SMII0
1541
 
1542
   // Hook up MII wires
1543
   assign eth0_mtx_clk   = eth0_tx_clk;
1544
   assign eth0_tx_data   = eth0_mtxd[3:0];
1545
   assign eth0_tx_en     = eth0_mtxen;
1546
   assign eth0_tx_er     = eth0_mtxerr;
1547
   assign eth0_mrxd[3:0] = eth0_rx_data;
1548
   assign eth0_mrxdv     = eth0_dv;
1549
   assign eth0_mrxerr    = eth0_rx_er;
1550
   assign eth0_mrx_clk   = eth0_rx_clk;
1551
   assign eth0_mcoll     = eth0_col;
1552
   assign eth0_mcrs      = eth0_crs;
1553
 
1554
`endif // !`ifdef SMII0
1555
 
1556
`ifdef XILINX
1557
   // Xilinx primitive for MDIO tristate
1558
   IOBUF iobuf_phy_smi_data
1559
     (
1560
      // Outputs
1561
      .O                                 (eth0_md_i),
1562
      // Inouts
1563
      .IO                                (eth0_md_pad_io),
1564
      // Inputs
1565
      .I                                 (eth0_md_o),
1566
      .T                                 (!eth0_md_oe));
1567
`else // !`ifdef XILINX
1568
 
1569
   // Generic technology tristate control for management interface
1570
   assign eth0_md_pad_io = eth0_md_oe ? eth0_md_o : 1'bz;
1571
   assign eth0_md_i = eth0_md_pad_io;
1572
 
1573
`endif // !`ifdef XILINX
1574
 
1575
`ifdef ETH0_PHY_RST
1576
   assign eth0_rst_n_o = !wb_rst;
1577
`endif
1578
 
1579 409 julius
   ethmac ethmac0
1580 408 julius
     (
1581
      // Wishbone Slave interface
1582
      .wb_clk_i         (wb_clk),
1583
      .wb_rst_i         (wb_rst),
1584
      .wb_dat_i         (wbs_d_eth0_dat_i[31:0]),
1585
      .wb_adr_i         (wbs_d_eth0_adr_i[wbs_d_eth0_addr_width-1:2]),
1586
      .wb_sel_i         (wbs_d_eth0_sel_i[3:0]),
1587
      .wb_we_i          (wbs_d_eth0_we_i),
1588
      .wb_cyc_i         (wbs_d_eth0_cyc_i),
1589
      .wb_stb_i         (wbs_d_eth0_stb_i),
1590
      .wb_dat_o         (wbs_d_eth0_dat_o[31:0]),
1591
      .wb_err_o         (wbs_d_eth0_err_o),
1592
      .wb_ack_o         (wbs_d_eth0_ack_o),
1593
      // Wishbone Master Interface
1594
      .m_wb_adr_o       (wbm_eth0_adr_o[31:0]),
1595
      .m_wb_sel_o       (wbm_eth0_sel_o[3:0]),
1596
      .m_wb_we_o        (wbm_eth0_we_o),
1597
      .m_wb_dat_o       (wbm_eth0_dat_o[31:0]),
1598
      .m_wb_cyc_o       (wbm_eth0_cyc_o),
1599
      .m_wb_stb_o       (wbm_eth0_stb_o),
1600
      .m_wb_cti_o       (wbm_eth0_cti_o[2:0]),
1601
      .m_wb_bte_o       (wbm_eth0_bte_o[1:0]),
1602
      .m_wb_dat_i       (wbm_eth0_dat_i[31:0]),
1603
      .m_wb_ack_i       (wbm_eth0_ack_i),
1604
      .m_wb_err_i       (wbm_eth0_err_i),
1605
 
1606
      // Ethernet MII interface
1607
      // Transmit
1608
      .mtxd_pad_o       (eth0_mtxd[3:0]),
1609
      .mtxen_pad_o      (eth0_mtxen),
1610
      .mtxerr_pad_o     (eth0_mtxerr),
1611
      .mtx_clk_pad_i    (eth0_mtx_clk),
1612
      // Receive
1613
      .mrx_clk_pad_i    (eth0_mrx_clk),
1614
      .mrxd_pad_i       (eth0_mrxd[3:0]),
1615
      .mrxdv_pad_i      (eth0_mrxdv),
1616
      .mrxerr_pad_i     (eth0_mrxerr),
1617
      .mcoll_pad_i      (eth0_mcoll),
1618
      .mcrs_pad_i       (eth0_mcrs),
1619
      // Management interface
1620
      .md_pad_i         (eth0_md_i),
1621
      .mdc_pad_o        (eth0_mdc_pad_o),
1622
      .md_pad_o         (eth0_md_o),
1623
      .md_padoe_o       (eth0_md_oe),
1624
 
1625
      // Processor interrupt
1626
      .int_o            (eth0_irq)
1627
 
1628
      /*
1629
       .mbist_so_o                      (),
1630
       .mbist_si_i                      (),
1631
       .mbist_ctrl_i                    ()
1632
       */
1633
 
1634
      );
1635
 
1636
   assign wbs_d_eth0_rty_o = 0;
1637
 
1638
`else
1639
   assign wbs_d_eth0_dat_o = 0;
1640
   assign wbs_d_eth0_err_o = 0;
1641
   assign wbs_d_eth0_ack_o = 0;
1642
   assign wbs_d_eth0_rty_o = 0;
1643
   assign wbm_eth0_adr_o = 0;
1644
   assign wbm_eth0_sel_o = 0;
1645
   assign wbm_eth0_we_o = 0;
1646
   assign wbm_eth0_dat_o = 0;
1647
   assign wbm_eth0_cyc_o = 0;
1648
   assign wbm_eth0_stb_o = 0;
1649
   assign wbm_eth0_cti_o = 0;
1650
   assign wbm_eth0_bte_o = 0;
1651
`endif
1652
 
1653
`ifdef UART0
1654
   ////////////////////////////////////////////////////////////////////////
1655
   //
1656
   // UART0
1657
   // 
1658
   ////////////////////////////////////////////////////////////////////////
1659
 
1660
   //
1661
   // Wires
1662
   //
1663
   wire        uart0_irq;
1664
 
1665
   //
1666
   // Assigns
1667
   //
1668
   assign wbs_d_uart0_err_o = 0;
1669
   assign wbs_d_uart0_rty_o = 0;
1670
 
1671
   uart16550 uart16550_0
1672
     (
1673
      // Wishbone slave interface
1674
      .wb_clk_i                         (wb_clk),
1675
      .wb_rst_i                         (wb_rst),
1676
      .wb_adr_i                         (wbs_d_uart0_adr_i[uart0_addr_width-1:0]),
1677
      .wb_dat_i                         (wbs_d_uart0_dat_i),
1678
      .wb_we_i                          (wbs_d_uart0_we_i),
1679
      .wb_stb_i                         (wbs_d_uart0_stb_i),
1680
      .wb_cyc_i                         (wbs_d_uart0_cyc_i),
1681
      //.wb_sel_i                               (),
1682
      .wb_dat_o                         (wbs_d_uart0_dat_o),
1683
      .wb_ack_o                         (wbs_d_uart0_ack_o),
1684
 
1685
      .int_o                            (uart0_irq),
1686
      .stx_pad_o                        (uart0_stx_pad_o),
1687
      .rts_pad_o                        (),
1688
      .dtr_pad_o                        (),
1689
      //      .baud_o                           (),
1690
      // Inputs
1691
      .srx_pad_i                        (uart0_srx_pad_i),
1692
      .cts_pad_i                        (1'b0),
1693
      .dsr_pad_i                        (1'b0),
1694
      .ri_pad_i                         (1'b0),
1695
      .dcd_pad_i                        (1'b0));
1696
 
1697
   ////////////////////////////////////////////////////////////////////////          
1698
`else // !`ifdef UART0
1699
 
1700
   //
1701
   // Assigns
1702
   //
1703
   assign wbs_d_uart0_err_o = 0;
1704
   assign wbs_d_uart0_rty_o = 0;
1705
   assign wbs_d_uart0_ack_o = 0;
1706
   assign wbs_d_uart0_dat_o = 0;
1707
 
1708
   ////////////////////////////////////////////////////////////////////////       
1709
`endif // !`ifdef UART0
1710
 
1711
`ifdef SPI0
1712
   ////////////////////////////////////////////////////////////////////////
1713
   //
1714
   // SPI0 controller
1715
   // 
1716
   ////////////////////////////////////////////////////////////////////////
1717
 
1718
   //
1719
   // Wires
1720
   //
1721
   wire                              spi0_irq;
1722
 
1723
   //
1724
   // Assigns
1725
   //
1726
   assign wbs_d_spi0_err_o = 0;
1727
   assign wbs_d_spi0_rty_o = 0;
1728
   assign spi0_hold_n_o = 1;
1729
   assign spi0_w_n_o = 1;
1730
 
1731
 
1732
   simple_spi spi0
1733
     (
1734
      // Wishbone slave interface
1735
      .clk_i                            (wb_clk),
1736
      .rst_i                            (wb_rst),
1737
      .cyc_i                            (wbs_d_spi0_cyc_i),
1738
      .stb_i                            (wbs_d_spi0_stb_i),
1739
      .adr_i                            (wbs_d_spi0_adr_i[spi0_wb_adr_width-1:0]),
1740
      .we_i                             (wbs_d_spi0_we_i),
1741
      .dat_i                            (wbs_d_spi0_dat_i),
1742
      .dat_o                            (wbs_d_spi0_dat_o),
1743
      .ack_o                            (wbs_d_spi0_ack_o),
1744
      // SPI IRQ
1745
      .inta_o                           (spi0_irq),
1746
      // External SPI interface
1747
      .sck_o                            (spi0_sck_o),
1748
 `ifdef SPI0_SLAVE_SELECTS
1749
      .ss_o                             (spi0_ss_o),
1750
 `else
1751
      .ss_o                             (),
1752
 `endif
1753
      .mosi_o                           (spi0_mosi_o),
1754
      .miso_i                           (spi0_miso_i)
1755
      );
1756
 
1757
   defparam spi0.slave_select_width = spi0_ss_width;
1758
 
1759
   ////////////////////////////////////////////////////////////////////////   
1760
`else // !`ifdef SPI0
1761
 
1762
   //
1763
   // Assigns
1764
   //
1765
   assign wbs_d_spi0_dat_o = 0;
1766
   assign wbs_d_spi0_ack_o = 0;
1767
   assign wbs_d_spi0_err_o = 0;
1768
   assign wbs_d_spi0_rty_o = 0;
1769
 
1770
   ////////////////////////////////////////////////////////////////////////
1771
`endif // !`ifdef SPI0   
1772
 
1773
 
1774
`ifdef SPI1
1775
   ////////////////////////////////////////////////////////////////////////
1776
   //
1777
   // SPI1 controller
1778
   // 
1779
   ////////////////////////////////////////////////////////////////////////
1780
 
1781
   //
1782
   // Wires
1783
   //
1784
   wire                              spi1_irq;
1785
 
1786
   //
1787
   // Assigns
1788
   //
1789
   assign wbs_d_spi1_err_o = 0;
1790
   assign wbs_d_spi1_rty_o = 0;
1791
 
1792
   simple_spi spi1
1793
     (
1794
      // Wishbone slave interface
1795
      .clk_i                            (wb_clk),
1796
      .rst_i                            (wb_rst),
1797
      .cyc_i                            (wbs_d_spi1_cyc_i),
1798
      .stb_i                            (wbs_d_spi1_stb_i),
1799
      .adr_i                            (wbs_d_spi1_adr_i[spi1_wb_adr_width-1:0]),
1800
      .we_i                             (wbs_d_spi1_we_i),
1801
      .dat_i                            (wbs_d_spi1_dat_i),
1802
      .dat_o                            (wbs_d_spi1_dat_o),
1803
      .ack_o                            (wbs_d_spi1_ack_o),
1804
      // SPI IRQ
1805
      .inta_o                           (spi1_irq),
1806
      // External SPI interface
1807
      .sck_o                            (spi1_sck_o),
1808
`ifdef SPI1_SLAVE_SELECTS
1809
      .ss_o                             (spi1_ss_o),
1810
`else
1811
      .ss_o                             (),
1812
`endif
1813
      .mosi_o                           (spi1_mosi_o),
1814
      .miso_i                           (spi1_miso_i)
1815
      );
1816
 
1817
   defparam spi1.slave_select_width = spi1_ss_width;
1818
 
1819
   ////////////////////////////////////////////////////////////////////////   
1820
`else // !`ifdef SPI1
1821
 
1822
   //
1823
   // Assigns
1824
   //
1825
   assign wbs_d_spi1_dat_o = 0;
1826
   assign wbs_d_spi1_ack_o = 0;
1827
   assign wbs_d_spi1_err_o = 0;
1828
   assign wbs_d_spi1_rty_o = 0;
1829
 
1830
   ////////////////////////////////////////////////////////////////////////
1831
`endif // !`ifdef SPI1
1832
 
1833
 
1834
`ifdef SPI2
1835
   ////////////////////////////////////////////////////////////////////////
1836
   //
1837
   // SPI2 controller
1838
   // 
1839
   ////////////////////////////////////////////////////////////////////////
1840
 
1841
   //
1842
   // Wires
1843
   //
1844
   wire                              spi2_irq;
1845
 
1846
   //
1847
   // Assigns
1848
   //
1849
   assign wbs_d_spi2_err_o = 0;
1850
   assign wbs_d_spi2_rty_o = 0;
1851
 
1852
   simple_spi spi2
1853
     (
1854
      // Wishbone slave interface
1855
      .clk_i                            (wb_clk),
1856
      .rst_i                            (wb_rst),
1857
      .cyc_i                            (wbs_d_spi2_cyc_i),
1858
      .stb_i                            (wbs_d_spi2_stb_i),
1859
      .adr_i                            (wbs_d_spi2_adr_i[spi2_wb_adr_width-1:0]),
1860
      .we_i                             (wbs_d_spi2_we_i),
1861
      .dat_i                            (wbs_d_spi2_dat_i),
1862
      .dat_o                            (wbs_d_spi2_dat_o),
1863
      .ack_o                            (wbs_d_spi2_ack_o),
1864
      // SPI IRQ
1865
      .inta_o                           (spi2_irq),
1866
      // External SPI interface
1867
      .sck_o                            (spi2_sck_o),
1868
`ifdef SPI2_SLAVE_SELECTS
1869
      .ss_o                             (spi2_ss_o),
1870
`else
1871
      .ss_o                             (),
1872
`endif
1873
      .mosi_o                           (spi2_mosi_o),
1874
      .miso_i                           (spi2_miso_i)
1875
      );
1876
 
1877
   defparam spi2.slave_select_width = spi2_ss_width;
1878
 
1879
   ////////////////////////////////////////////////////////////////////////   
1880
`else // !`ifdef SPI2
1881
 
1882
   //
1883
   // Assigns
1884
   //
1885
   assign wbs_d_spi2_dat_o = 0;
1886
   assign wbs_d_spi2_ack_o = 0;
1887
   assign wbs_d_spi2_err_o = 0;
1888
   assign wbs_d_spi2_rty_o = 0;
1889
 
1890
   ////////////////////////////////////////////////////////////////////////
1891
`endif // !`ifdef SPI2   
1892
 
1893
 
1894
`ifdef I2C0
1895
   ////////////////////////////////////////////////////////////////////////
1896
   //
1897
   // i2c controller 0
1898
   // 
1899
   ////////////////////////////////////////////////////////////////////////
1900
 
1901
   //
1902
   // Wires
1903
   //
1904
   wire                              i2c0_irq;
1905
   wire                              scl0_pad_o;
1906
   wire                              scl0_padoen_o;
1907
   wire                              sda0_pad_o;
1908
   wire                              sda0_padoen_o;
1909
 
1910
  i2c_master_slave
1911
    #
1912
    (
1913
     .DEFAULT_SLAVE_ADDR(HV0_SADR)
1914
    )
1915
  i2c_master_slave0
1916
    (
1917
     .wb_clk_i                       (wb_clk),
1918
     .wb_rst_i                       (wb_rst),
1919
     .arst_i                         (wb_rst),
1920
     .wb_adr_i                       (wbs_d_i2c0_adr_i[i2c_0_wb_adr_width-1:0]),
1921
     .wb_dat_i                       (wbs_d_i2c0_dat_i),
1922
     .wb_we_i                        (wbs_d_i2c0_we_i ),
1923
     .wb_cyc_i                       (wbs_d_i2c0_cyc_i),
1924
     .wb_stb_i                       (wbs_d_i2c0_stb_i),
1925
     .wb_dat_o                       (wbs_d_i2c0_dat_o),
1926
     .wb_ack_o                       (wbs_d_i2c0_ack_o),
1927
     .scl_pad_i                      (i2c0_scl_io     ),
1928
     .scl_pad_o                      (scl0_pad_o         ),
1929
     .scl_padoen_o                   (scl0_padoen_o      ),
1930
     .sda_pad_i                      (i2c0_sda_io        ),
1931
     .sda_pad_o                      (sda0_pad_o         ),
1932
     .sda_padoen_o                   (sda0_padoen_o      ),
1933
 
1934
      // Interrupt
1935
     .wb_inta_o                      (i2c0_irq)
1936
 
1937
      );
1938
 
1939
   assign wbs_d_i2c0_err_o = 0;
1940
   assign wbs_d_i2c0_rty_o = 0;
1941
 
1942
   // i2c phy lines
1943
   assign i2c0_scl_io = scl0_padoen_o ? 1'bz : scl0_pad_o;
1944
   assign i2c0_sda_io = sda0_padoen_o ? 1'bz : sda0_pad_o;
1945
 
1946
 
1947
   ////////////////////////////////////////////////////////////////////////
1948
`else // !`ifdef I2C0
1949
 
1950
   assign wbs_d_i2c0_dat_o = 0;
1951
   assign wbs_d_i2c0_ack_o = 0;
1952
   assign wbs_d_i2c0_err_o = 0;
1953
   assign wbs_d_i2c0_rty_o = 0;
1954
 
1955
   ////////////////////////////////////////////////////////////////////////
1956
`endif // !`ifdef I2C0   
1957
 
1958
`ifdef I2C1
1959
   ////////////////////////////////////////////////////////////////////////
1960
   //
1961
   // i2c controller 1
1962
   // 
1963
   ////////////////////////////////////////////////////////////////////////
1964
 
1965
   //
1966
   // Wires
1967
   //
1968
   wire                              i2c1_irq;
1969
   wire                              scl1_pad_o;
1970
   wire                              scl1_padoen_o;
1971
   wire                              sda1_pad_o;
1972
   wire                              sda1_padoen_o;
1973
 
1974
   i2c_master_slave
1975
    #
1976
    (
1977
     .DEFAULT_SLAVE_ADDR(HV1_SADR)
1978
    )
1979
   i2c_master_slave1
1980
     (
1981
      .wb_clk_i                      (wb_clk),
1982
      .wb_rst_i                      (wb_rst),
1983
      .arst_i                        (wb_rst),
1984
      .wb_adr_i                      (wbs_d_i2c1_adr_i[i2c_1_wb_adr_width-1:0]),
1985
      .wb_dat_i                      (wbs_d_i2c1_dat_i),
1986
      .wb_we_i                       (wbs_d_i2c1_we_i ),
1987
      .wb_cyc_i                      (wbs_d_i2c1_cyc_i),
1988
      .wb_stb_i                      (wbs_d_i2c1_stb_i),
1989
      .wb_dat_o                      (wbs_d_i2c1_dat_o),
1990
      .wb_ack_o                      (wbs_d_i2c1_ack_o),
1991
      .scl_pad_i                     (i2c1_scl_io     ),
1992
      .scl_pad_o                     (scl1_pad_o         ),
1993
      .scl_padoen_o                  (scl1_padoen_o      ),
1994
      .sda_pad_i                     (i2c1_sda_io        ),
1995
      .sda_pad_o                     (sda1_pad_o         ),
1996
      .sda_padoen_o                  (sda1_padoen_o      ),
1997
 
1998
      // Interrupt
1999
      .wb_inta_o                     (i2c1_irq)
2000
 
2001
      );
2002
 
2003
   assign wbs_d_i2c1_err_o = 0;
2004
   assign wbs_d_i2c1_rty_o = 0;
2005
 
2006
   // i2c phy lines
2007
   assign i2c1_scl_io = scl1_padoen_o ? 1'bz : scl1_pad_o;
2008
   assign i2c1_sda_io = sda1_padoen_o ? 1'bz : sda1_pad_o;
2009
 
2010
   ////////////////////////////////////////////////////////////////////////
2011
`else // !`ifdef I2C1   
2012
 
2013
   assign wbs_d_i2c1_dat_o = 0;
2014
   assign wbs_d_i2c1_ack_o = 0;
2015
   assign wbs_d_i2c1_err_o = 0;
2016
   assign wbs_d_i2c1_rty_o = 0;
2017
 
2018
   ////////////////////////////////////////////////////////////////////////
2019
`endif // !`ifdef I2C1   
2020
 
2021
`ifdef I2C2
2022
   ////////////////////////////////////////////////////////////////////////
2023
   //
2024
   // i2c controller 2
2025
   // 
2026
   ////////////////////////////////////////////////////////////////////////
2027
 
2028
   //
2029
   // Wires
2030
   //
2031
   wire                              i2c2_irq;
2032
   wire                              scl2_pad_o;
2033
   wire                              scl2_padoen_o;
2034
   wire                              sda2_pad_o;
2035
   wire                              sda2_padoen_o;
2036
 
2037
   i2c_master_slave
2038
    #
2039
     (
2040
     .DEFAULT_SLAVE_ADDR(HV2_SADR)
2041
      )
2042
   hv_i2c_master_slave2
2043
     (
2044
      .wb_clk_i                         (wb_clk),
2045
      .wb_rst_i                         (wb_rst),
2046
      .arst_i                           (wb_rst),
2047
      .wb_adr_i                         (wbs_d_i2c2_adr_i[i2c_2_wb_adr_width-1:0]),
2048
      .wb_dat_i                         (wbs_d_i2c2_dat_i),
2049
      .wb_we_i                          (wbs_d_i2c2_we_i ),
2050
      .wb_cyc_i                         (wbs_d_i2c2_cyc_i),
2051
      .wb_stb_i                         (wbs_d_i2c2_stb_i),
2052
      .wb_dat_o                         (wbs_d_i2c2_dat_o),
2053
      .wb_ack_o                         (wbs_d_i2c2_ack_o),
2054
      .scl_pad_i                        (i2c2_scl_io     ),
2055
      .scl_pad_o                        (scl2_pad_o      ),
2056
      .scl_padoen_o                     (scl2_padoen_o   ),
2057
      .sda_pad_i                        (i2c2_sda_io     ),
2058
      .sda_pad_o                        (sda2_pad_o      ),
2059
      .sda_padoen_o                     (sda2_padoen_o   ),
2060
 
2061
      // Interrupt
2062
      .wb_inta_o                        (i2c2_irq)
2063
 
2064
      );
2065
 
2066
   assign wbs_d_i2c2_err_o = 0;
2067
   assign wbs_d_i2c2_rty_o = 0;
2068
 
2069
   // i2c phy lines
2070
   assign i2c2_sda_io = scl2_padoen_o ? 1'bz : scl2_pad_o;
2071
   assign i2c2_scl_io = sda2_padoen_o ? 1'bz : sda2_pad_o;
2072
 
2073
   ////////////////////////////////////////////////////////////////////////   
2074
 
2075
`else // !`ifdef I2C2   
2076
 
2077
   assign wbs_d_i2c2_dat_o = 0;
2078
   assign wbs_d_i2c2_ack_o = 0;
2079
   assign wbs_d_i2c2_err_o = 0;
2080
   assign wbs_d_i2c2_rty_o = 0;
2081
 
2082
   ////////////////////////////////////////////////////////////////////////
2083
 
2084
`endif // !`ifdef I2C2   
2085
 
2086
`ifdef I2C3
2087
   ////////////////////////////////////////////////////////////////////////
2088
   //
2089
   // i2c controller 3
2090
   // 
2091
   ////////////////////////////////////////////////////////////////////////
2092
 
2093
   //
2094
   // Wires
2095
   //
2096
   wire                              i2c3_irq;
2097
   wire                              scl3_pad_o;
2098
   wire                              scl3_padoen_o;
2099
   wire                              sda3_pad_o;
2100
   wire                              sda3_padoen_o;
2101
 
2102
   hv_i2c_master_slave
2103
         #
2104
     (
2105
     .DEFAULT_SLAVE_ADDR(HV3_SADR)
2106
      )
2107
     hv_i2c_master_slave3
2108
     (
2109
      .wb_clk_i                         (wb_clk),
2110
      .wb_rst_i                         (wb_rst),
2111
      .arst_i                           (wb_rst),
2112
      .wb_adr_i                         (wbs_d_i2c3_adr_i[i2c_3_wb_adr_width-1:0]),
2113
      .wb_dat_i                         (wbs_d_i2c3_dat_i),
2114
      .wb_we_i                          (wbs_d_i2c3_we_i ),
2115
      .wb_cyc_i                         (wbs_d_i2c3_cyc_i),
2116
      .wb_stb_i                         (wbs_d_i2c3_stb_i),
2117
      .wb_dat_o                         (wbs_d_i2c3_dat_o),
2118
      .wb_ack_o                         (wbs_d_i2c3_ack_o),
2119
      .scl_pad_i                        (i2c3_scl_io     ),
2120
      .scl_pad_o                        (scl3_pad_o      ),
2121
      .scl_padoen_o                     (scl3_padoen_o   ),
2122
      .sda_pad_i                        (i2c3_sda_io     ),
2123
      .sda_pad_o                        (sda3_pad_o      ),
2124
      .sda_padoen_o                     (sda3_padoen_o   ),
2125
 
2126
      // Interrupt
2127
      .wb_inta_o                        (i2c3_irq)
2128
 
2129
      );
2130
 
2131
   assign wbs_d_i2c3_err_o = 0;
2132
   assign wbs_d_i2c3_rty_o = 0;
2133
 
2134
   // i2c phy lines  
2135
   assign i2c3_sda_io = scl3_padoen_o ? 1'bz : scl3_pad_o;
2136
   assign i2c3_scl_io = sda3_padoen_o ? 1'bz : sda3_pad_o;
2137
 
2138
   ////////////////////////////////////////////////////////////////////////
2139
`else // !`ifdef I2C3
2140
 
2141
   assign wbs_d_i2c3_dat_o = 0;
2142
   assign wbs_d_i2c3_ack_o = 0;
2143
   assign wbs_d_i2c3_err_o = 0;
2144
   assign wbs_d_i2c3_rty_o = 0;
2145
 
2146
   ////////////////////////////////////////////////////////////////////////
2147
`endif // !`ifdef I2C3
2148
 
2149
`ifdef USB0
2150
   ////////////////////////////////////////////////////////////////////////
2151
   //
2152
   // USB Host/Slave controller 0
2153
   // 
2154
   ////////////////////////////////////////////////////////////////////////
2155
 
2156
   //
2157
   // Wires
2158
   //
2159
   wire                              usb0_slavesofrxed_irq;
2160
   wire                              usb0_slaveresetevent_irq;
2161
   wire                              usb0_slaveresume_irq;
2162
   wire                              usb0_slavetransdone_irq;
2163
   wire                              usb0_slavenaksent_irq;
2164
   wire                              usb0_slavevbusdet_irq;
2165
   wire                              usb0_hostSOFSentIntOut;
2166
   wire                              usb0_hostConnEventIntOut;
2167
   wire                              usb0_hostResumeIntOut;
2168
   wire                              usb0_hostTransDoneIntOut;
2169
   wire                              usb0_host_irq, usb0_slave_irq;
2170
   wire                              usb0_oe;
2171
   wire [1:0]                         usb0dat_o_int;
2172
 
2173
 
2174
   //
2175
   // Registers
2176
   //
2177
   reg [1:0]                          usb0_rx_data  /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
2178
   reg [1:0]                          usb0_tx_data /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
2179
   reg                               usb0_oe_n  /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
2180
 
2181
   always @(posedge usb_clk) usb0_rx_data <= usb0dat_pad_i;
2182
   always @(posedge usb_clk) usb0_tx_data <= usb0dat_o_int;
2183
   always @(posedge usb_clk) usb0_oe_n <= ~usb0_oe;
2184
 
2185
 
2186
   //
2187
   // Assigns
2188
   //
2189
   assign usb0dat_pad_o = usb0_tx_data;
2190
   assign usb0ctrl_pad_o = usb0_oe_n; // Actual oe to transciever
2191
   assign usb0_host_irq = usb0_hostSOFSentIntOut | usb0_hostConnEventIntOut |
2192
                         usb0_hostResumeIntOut | usb0_hostTransDoneIntOut;
2193
   assign usb0_slave_irq = usb0_slavesofrxed_irq | usb0_slaveresetevent_irq |
2194
                          usb0_slaveresume_irq | usb0_slavetransdone_irq |
2195
                          usb0_slavenaksent_irq/* | usb0_slavevbusdet_irq */;
2196
 
2197
`ifdef USB0_ONLY_HOST
2198
   usbhost usbhost0
2199
`else
2200
     usbhostslave usbhostslave0
2201
`endif
2202
 
2203
     (
2204
      // USB PHY lines
2205
      // In
2206
      .usbClk                           (usb_clk), // logic clock,48MHz +/-0.25%
2207
      .USBWireDataIn                    (usb0_rx_data), // Diff. data in
2208
      // Out
2209
      .USBWireDataOut                   (usb0dat_o_int), // Diff. dat out
2210
      .USBWireCtrlOut                   (usb0_oe),     // OE
2211
      .USBFullSpeed                     (usb0fullspeed_pad_o),// Full speed en.
2212
      //Debug   
2213
      .USBWireDataOutTick               (), // Debug output
2214
      .USBWireDataInTick                (),  // Debug ouptut
2215
 
2216
      // Interrupt lines
2217
      // Slave
2218
`ifndef USB0_ONLY_HOST
2219
      .slaveSOFRxedIntOut               (usb0_slavesofrxed_irq),
2220
      .slaveResetEventIntOut            (usb0_slaveresetevent_irq),
2221
      .slaveResumeIntOut                (usb0_slaveresume_irq),
2222
      .slaveTransDoneIntOut             (usb0_slavetransdone_irq),
2223
      .slaveNAKSentIntOut               (usb0_slavenaksent_irq),
2224
      .USBDPlusPullup                   (),
2225
      .USBDMinusPullup                  (),
2226
      .vBusDetect                       (1'b1), // bus detect from phy
2227
`endif
2228
 
2229
      // Host
2230
      .hostSOFSentIntOut                (usb0_hostSOFSentIntOut),
2231
      .hostConnEventIntOut              (usb0_hostConnEventIntOut),
2232
      .hostResumeIntOut                 (usb0_hostResumeIntOut),
2233
      .hostTransDoneIntOut              (usb0_hostTransDoneIntOut),
2234
      // Wishbone slave interface
2235
      .address_i                        (wbs_d_usb0_adr_i[wbs_d_usb0_adr_width-1:0]),
2236
      .data_i                           (wbs_d_usb0_dat_i),
2237
      .we_i                             (wbs_d_usb0_we_i),
2238
      .strobe_i                         (wbs_d_usb0_stb_i),
2239
      .data_o                           (wbs_d_usb0_dat_o),
2240
      .ack_o                            (wbs_d_usb0_ack_o),
2241
      .clk_i                            (wb_clk),
2242
      .rst_i                            (wb_rst)
2243
 
2244
      );
2245
 
2246
   assign wbs_d_usb0_err_o = 0;
2247
   assign wbs_d_usb0_rty_o = 0;
2248
 
2249
`ifdef USB0_ONLY_HOST
2250
   // Tie off unused IRQs if we're only a host
2251
   assign usb0_slavesofrxed_irq = 0;
2252
   assign usb0_slaveresetevent_irq = 0;
2253
   assign usb0_slaveresume_irq = 0;
2254
   assign usb0_slavetransdone_irq = 0;
2255
   assign usb0_slavenaksent_irq = 0;
2256
   assign usb0_slavevbusdet_irq = 0;
2257
`endif
2258
 
2259
`else
2260
 
2261
   assign wbs_d_usb0_dat_o = 0;
2262
   assign wbs_d_usb0_ack_o = 0;
2263
   assign wbs_d_usb0_err_o = 0;
2264
   assign wbs_d_usb0_rty_o = 0;
2265
 
2266
`endif // !`ifdef USB0
2267
 
2268
`ifdef USB1
2269
   ////////////////////////////////////////////////////////////////////////
2270
   //
2271
   // USB Host/Slave controller 1
2272
   // 
2273
   ////////////////////////////////////////////////////////////////////////
2274
 
2275
   //
2276
   // Wires
2277
   //
2278
   wire                              usb1_slavesofrxed_irq;
2279
   wire                              usb1_slaveresetevent_irq;
2280
   wire                              usb1_slaveresume_irq;
2281
   wire                              usb1_slavetransdone_irq;
2282
   wire                              usb1_slavenaksent_irq;
2283
   wire                              usb1_slavevbusdet_irq;
2284
   wire                              usb1_hostSOFSentIntOut;
2285
   wire                              usb1_hostConnEventIntOut;
2286
   wire                              usb1_hostResumeIntOut;
2287
   wire                              usb1_hostTransDoneIntOut;
2288
   wire                              usb1_host_irq, usb1_slave_irq;
2289
   wire                              usb1_oe;
2290
   wire [1:0]                         usb1dat_o_int;
2291
 
2292
 
2293
   //
2294
   // Registers
2295
   //
2296
   reg [1:0]                          usb1_rx_data  /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
2297
   reg [1:0]                          usb1_tx_data /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
2298
   reg                               usb1_oe_n  /*synthesis syn_useioff=1 syn_allow_retiming=0 */;
2299
 
2300
   always @(posedge usb_clk) usb1_rx_data <= usb1dat_pad_i;
2301
   always @(posedge usb_clk) usb1_tx_data <= usb1dat_o_int;
2302
   always @(posedge usb_clk) usb1_oe_n <= ~usb1_oe;
2303
 
2304
 
2305
   //
2306
   // Assigns
2307
   //
2308
   assign usb1dat_pad_o = usb1_tx_data;
2309
   assign usb1ctrl_pad_o = usb1_oe_n; // Actual oe to transciever
2310
   assign usb1_host_irq = usb1_hostSOFSentIntOut | usb1_hostConnEventIntOut |
2311
                         usb1_hostResumeIntOut | usb1_hostTransDoneIntOut;
2312
   assign usb1_slave_irq = usb1_slavesofrxed_irq | usb1_slaveresetevent_irq |
2313
                          usb1_slaveresume_irq | usb1_slavetransdone_irq |
2314
                          usb1_slavenaksent_irq /*| usb1_slavevbusdet_irq*/ ;
2315
 
2316
`ifdef USB1_ONLY_HOST
2317
   usbhost usbhost1
2318
`else
2319
 `ifdef USB1_ONLY_SLAVE
2320
   usbslave usbslave1
2321
 `else
2322
   usbhostslave usbhostslave1
2323
 `endif
2324
`endif
2325
     (
2326
      // USB PHY lines
2327
      // In
2328
      .usbClk                           (usb_clk), // logic clock,48MHz +/-0.25%
2329
      .USBWireDataIn                    (usb1_rx_data), // Diff. data in
2330
      // Out
2331
      .USBWireDataOut                   (usb1dat_o_int), // Diff. dat out
2332
      .USBWireCtrlOut                   (usb1_oe),     // OE
2333
      .USBFullSpeed                     (usb1fullspeed_pad_o),// Full speed en.
2334
      //Debug   
2335
      .USBWireDataOutTick               (), // Debug output
2336
      .USBWireDataInTick                (),  // Debug ouptut    
2337
 
2338
      // Interrupt lines
2339
      // Slave
2340
`ifndef USB1_ONLY_HOST
2341
      .slaveSOFRxedIntOut               (usb1_slavesofrxed_irq),
2342
      .slaveResetEventIntOut            (usb1_slaveresetevent_irq),
2343
      .slaveResumeIntOut                (usb1_slaveresume_irq),
2344
      .slaveTransDoneIntOut             (usb1_slavetransdone_irq),
2345
      .slaveNAKSentIntOut               (usb1_slavenaksent_irq),
2346
      .slaveVBusDetIntOut               (usb1_slavevbusdet_irq),
2347
      .USBDPlusPullup                   (),
2348
      .USBDMinusPullup                  (),
2349
      .vBusDetect                       (1'b1), // bus detect from phy
2350
`endif
2351
`ifndef USB1_ONLY_SLAVE
2352
      // Host
2353
      .hostSOFSentIntOut                (usb1_hostSOFSentIntOut),
2354
      .hostConnEventIntOut              (usb1_hostConnEventIntOut),
2355
      .hostResumeIntOut                 (usb1_hostResumeIntOut),
2356
      .hostTransDoneIntOut              (usb1_hostTransDoneIntOut),
2357
`endif
2358
      // Wishbone slave interface
2359
      .address_i                        (wbs_d_usb1_adr_i[wbs_d_usb1_adr_width-1:0]),
2360
      .data_i                           (wbs_d_usb1_dat_i),
2361
      .we_i                             (wbs_d_usb1_we_i),
2362
      .strobe_i                         (wbs_d_usb1_stb_i),
2363
      .data_o                           (wbs_d_usb1_dat_o),
2364
      .ack_o                            (wbs_d_usb1_ack_o),
2365
      .clk_i                            (wb_clk),
2366
      .rst_i                            (wb_rst)
2367
 
2368
      );
2369
 
2370
   assign wbs_d_usb1_err_o = 0;
2371
   assign wbs_d_usb1_rty_o = 0;
2372
 
2373
`ifdef USB1_ONLY_HOST
2374
   // Tie off unused IRQs if we're only a host
2375
   assign usb1_slavesofrxed_irq = 0;
2376
   assign usb1_slaveresetevent_irq = 0;
2377
   assign usb1_slaveresume_irq = 0;
2378
   assign usb1_slavetransdone_irq = 0;
2379
   assign usb1_slavenaksent_irq = 0;
2380
   assign usb1_slavevbusdet_irq = 0;
2381
`endif
2382
`ifdef USB1_ONLY_SLAVE
2383
   assign usb1_hostSOFSentIntOut  = 0;
2384
   assign usb1_hostConnEventIntOut = 0;
2385
   assign usb1_hostResumeIntOut = 0;
2386
   assign usb1_hostTransDoneIntOut = 0;
2387
`endif
2388
 
2389
`else
2390
 
2391
   assign wbs_d_usb1_dat_o = 0;
2392
   assign wbs_d_usb1_ack_o = 0;
2393
   assign wbs_d_usb1_err_o = 0;
2394
   assign wbs_d_usb1_rty_o = 0;
2395
 
2396
`endif // !`ifdef USB1
2397
 
2398 544 julius
`ifdef SDC_CONTROLLER
2399
   wire                              sdc_cmd_oe;
2400
   wire                              sdc_dat_oe;
2401
   wire                              sdc_cmdIn;
2402
   wire [3:0]                         sdc_datIn ;
2403
   wire                              sdc_irq_a;
2404
   wire                              sdc_irq_b;
2405
   wire                              sdc_irq_c;
2406
 
2407
   assign sdc_cmd_pad_io = sdc_cmd_oe ? sdc_cmdIn : 1'bz;
2408
   assign sdc_dat_pad_io = sdc_dat_oe  ? sdc_datIn : 4'bz;
2409
 
2410
   assign wbs_d_sdc_err_o = 0;
2411
   assign wbs_d_sdc_rty_o= 0;
2412
 
2413
   assign wbm_sdc_err_i = 0;
2414
   assign wbm_sdc_rty_i = 0;
2415
 
2416
   sdc_controller sdc_controller_0
2417
        (
2418
         .wb_clk_i (wb_clk),
2419
         .wb_rst_i (wb_rst),
2420
         .wb_dat_i (wbs_d_sdc_dat_i),
2421
         .wb_dat_o (wbs_d_sdc_dat_o),
2422
         .wb_adr_i (wbs_d_sdc_adr_i[7:0]),
2423
         .wb_sel_i (4'hf),
2424
         .wb_we_i  (wbs_d_sdc_we_i),
2425
         .wb_stb_i (wbs_d_sdc_stb_i),
2426
         .wb_cyc_i (wbs_d_sdc_cyc_i),
2427
         .wb_ack_o (wbs_d_sdc_ack_o),
2428
 
2429
         .m_wb_adr_o (wbm_sdc_adr_o),
2430
         .m_wb_sel_o (wbm_sdc_sel_o),
2431
         .m_wb_we_o  (wbm_sdc_we_o),
2432
         .m_wb_dat_o (wbm_sdc_dat_o),
2433
         .m_wb_dat_i (wbm_sdc_dat_i),
2434
         .m_wb_cyc_o (wbm_sdc_cyc_o),
2435
         .m_wb_stb_o (wbm_sdc_stb_o),
2436
         .m_wb_ack_i (wbm_sdc_ack_i),
2437
         .m_wb_cti_o (wbm_sdc_cti_o),
2438
         .m_wb_bte_o (wbm_sdc_bte_o),
2439
 
2440
         .sd_cmd_dat_i (sdc_cmd_pad_io),
2441
         .sd_cmd_out_o (sdc_cmdIn ),
2442
         .sd_cmd_oe_o  (sdc_cmd_oe),
2443
         .sd_dat_dat_i (sdc_dat_pad_io  ),
2444
         .sd_dat_out_o (sdc_datIn  ) ,
2445
         .sd_dat_oe_o  (sdc_dat_oe  ),
2446
         .sd_clk_o_pad (sdc_clk_pad_o),
2447
         .card_detect  (sdc_card_detect_pad_i),
2448
 
2449
         .sd_clk_i_pad (wb_clk),
2450
 
2451
         .int_a (sdc_irq_a),
2452
         .int_b (sdc_irq_b),
2453
         .int_c (sdc_irq_c)
2454
         );
2455
 
2456
`else
2457
 
2458
   assign wbs_sdc_err_o = 0;
2459
   assign wbs_sdc_rty_o= 0;
2460
   assign wbs_sdc_ack_o = 0;
2461
   assign wbs_sdc_dat_o = 0;
2462
 
2463
`endif
2464
 
2465 408 julius
`ifdef GPIO0
2466
   ////////////////////////////////////////////////////////////////////////
2467
   //
2468
   // GPIO 0
2469
   // 
2470
   ////////////////////////////////////////////////////////////////////////
2471
 
2472
   gpio gpio0
2473
     (
2474
      // GPIO bus
2475
      .gpio_io                          (gpio0_io[gpio0_io_width-1:0]),
2476
      // Wishbone slave interface
2477
      .wb_adr_i                         (wbs_d_gpio0_adr_i[gpio0_wb_adr_width-1:0]),
2478
      .wb_dat_i                         (wbs_d_gpio0_dat_i),
2479
      .wb_we_i                          (wbs_d_gpio0_we_i),
2480
      .wb_cyc_i                         (wbs_d_gpio0_cyc_i),
2481
      .wb_stb_i                         (wbs_d_gpio0_stb_i),
2482
      .wb_cti_i                         (wbs_d_gpio0_cti_i),
2483
      .wb_bte_i                         (wbs_d_gpio0_bte_i),
2484
      .wb_dat_o                         (wbs_d_gpio0_dat_o),
2485
      .wb_ack_o                         (wbs_d_gpio0_ack_o),
2486
      .wb_err_o                         (wbs_d_gpio0_err_o),
2487
      .wb_rty_o                         (wbs_d_gpio0_rty_o),
2488
 
2489
      .wb_clk                           (wb_clk),
2490
      .wb_rst                           (wb_rst)
2491
      );
2492
 
2493
   defparam gpio0.gpio_io_width = gpio0_io_width;
2494
   defparam gpio0.gpio_dir_reset_val = gpio0_dir_reset_val;
2495
   defparam gpio0.gpio_o_reset_val = gpio0_o_reset_val;
2496
 
2497
   ////////////////////////////////////////////////////////////////////////
2498
`else // !`ifdef GPIO0
2499
   assign wbs_d_gpio0_dat_o = 0;
2500
   assign wbs_d_gpio0_ack_o = 0;
2501
   assign wbs_d_gpio0_err_o = 0;
2502
   assign wbs_d_gpio0_rty_o = 0;
2503
   ////////////////////////////////////////////////////////////////////////
2504
`endif // !`ifdef GPIO0
2505
 
2506
   ////////////////////////////////////////////////////////////////////////
2507
   //
2508
   // OR1200 Interrupt assignment
2509
   // 
2510
   ////////////////////////////////////////////////////////////////////////
2511
 
2512
   assign or1200_pic_ints[0] = 0; // Non-maskable inside OR1200
2513
   assign or1200_pic_ints[1] = 0; // Non-maskable inside OR1200
2514
`ifdef UART0
2515
   assign or1200_pic_ints[2] = uart0_irq;
2516
`else
2517
   assign or1200_pic_ints[2] = 0;
2518
`endif
2519
`ifdef UART1
2520
   assign or1200_pic_ints[3] = uart1_irq;
2521
`else
2522
   assign or1200_pic_ints[3] = 0;
2523
`endif
2524
`ifdef ETH0
2525
   assign or1200_pic_ints[4] = eth0_irq;
2526
`else
2527
   assign or1200_pic_ints[4] = 0;
2528
`endif
2529
`ifdef UART2
2530
   assign or1200_pic_ints[5] = uart2_irq;
2531
`else
2532
   assign or1200_pic_ints[5] = 0;
2533
`endif
2534
`ifdef SPI0
2535
   assign or1200_pic_ints[6] = spi0_irq;
2536
`else
2537
   assign or1200_pic_ints[6] = 0;
2538
`endif
2539
`ifdef SPI1
2540
   assign or1200_pic_ints[7] = spi1_irq;
2541
`else
2542
   assign or1200_pic_ints[7] = 0;
2543
`endif
2544
`ifdef SPI2
2545
   assign or1200_pic_ints[8] = spi2_irq;
2546
`else
2547
   assign or1200_pic_ints[8] = 0;
2548
`endif
2549
   assign or1200_pic_ints[9] = 0;
2550
`ifdef I2C0
2551
   assign or1200_pic_ints[10] = i2c0_irq;
2552
`else
2553
   assign or1200_pic_ints[10] = 0;
2554
`endif
2555
`ifdef I2C1
2556
   assign or1200_pic_ints[11] = i2c1_irq;
2557
`else
2558
   assign or1200_pic_ints[11] = 0;
2559
`endif
2560
`ifdef I2C2
2561
   assign or1200_pic_ints[12] = i2c2_irq;
2562
`else
2563
   assign or1200_pic_ints[12] = 0;
2564
`endif
2565
`ifdef I2C3
2566
   assign or1200_pic_ints[13] = i2c3_irq;
2567
`else
2568
   assign or1200_pic_ints[13] = 0;
2569 544 julius
`endif
2570
`ifdef SDC_CONTROLLER
2571
   assign or1200_pic_ints[14] = sdc_irq_a;
2572
   assign or1200_pic_ints[15] = sdc_irq_b;
2573
   assign or1200_pic_ints[16] = sdc_irq_c;
2574
`else
2575 408 julius
   assign or1200_pic_ints[14] = 0;
2576
   assign or1200_pic_ints[15] = 0;
2577
   assign or1200_pic_ints[16] = 0;
2578 544 julius
`endif
2579 408 julius
   assign or1200_pic_ints[17] = 0;
2580
   assign or1200_pic_ints[18] = 0;
2581
   assign or1200_pic_ints[19] = 0;
2582
`ifdef USB0
2583
   assign or1200_pic_ints[20] = usb0_host_irq;
2584
   assign or1200_pic_ints[21] = usb0_slave_irq;
2585
`else
2586
   assign or1200_pic_ints[20] = 0;
2587
   assign or1200_pic_ints[21] = 0;
2588
`endif
2589
`ifdef USB1
2590
   assign or1200_pic_ints[22] = usb1_host_irq;
2591
   assign or1200_pic_ints[23] = usb1_slave_irq;
2592
`else
2593
   assign or1200_pic_ints[22] = 0;
2594
   assign or1200_pic_ints[23] = 0;
2595
`endif
2596
   assign or1200_pic_ints[24] = 0;
2597
   assign or1200_pic_ints[25] = 0;
2598
   assign or1200_pic_ints[26] = 0;
2599
   assign or1200_pic_ints[27] = 0;
2600
   assign or1200_pic_ints[28] = 0;
2601
   assign or1200_pic_ints[29] = 0;
2602
   assign or1200_pic_ints[30] = 0;
2603
 
2604
endmodule // orpsoc_top
2605
 
2606
 

powered by: WebSVN 2.1.0

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