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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 412 julius
//////////////////////////////////////////////////////////////////////
2
///                                                               //// 
3
/// ORPSoC top for ML501 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 XILINX_DDR2
44
    ddr2_a, ddr2_ba, ddr2_ras_n, ddr2_cas_n, ddr2_we_n,
45
    ddr2_cs_n, ddr2_odt, ddr2_cke, ddr2_dm,
46
    ddr2_dq, ddr2_dqs, ddr2_dqs_n, ddr2_ck, ddr2_ck_n,
47
`endif
48
`ifdef XILINX_SSRAM
49
    sram_clk, sram_clk_fb, sram_flash_addr, sram_flash_data,
50
    sram_cen, sram_flash_oe_n, sram_flash_we_n, sram_bw,
51
    sram_adv_ld_n, sram_mode,
52 655 julius
`endif
53
`ifdef CFI_FLASH
54
    flash_dq_io, flash_adr_o, flash_adv_n_o, flash_ce_n_o,
55
    flash_clk_o, flash_oe_n_o, flash_rst_n_o, flash_wait_i,
56
    flash_we_n_o,
57 412 julius
`endif
58
`ifdef UART0
59
    uart0_srx_pad_i, uart0_stx_pad_o,
60
    uart0_srx_expheader_pad_i, uart0_stx_expheader_pad_o,
61
`endif
62
`ifdef SPI0
63 415 julius
    spi0_mosi_o, spi0_ss_o,/* spi0_sck_o, spi0_miso_i,via STARTUP_VIRTEX5*/
64 412 julius
`endif
65
`ifdef I2C0
66
    i2c0_sda_io, i2c0_scl_io,
67
`endif
68
`ifdef I2C1
69
    i2c1_sda_io, i2c1_scl_io,
70
`endif
71
`ifdef GPIO0
72
    gpio0_io,
73
`endif
74
 
75
`ifdef ETH0
76
    eth0_tx_clk, eth0_tx_data, eth0_tx_en, eth0_tx_er,
77
    eth0_rx_clk, eth0_rx_data, eth0_dv, eth0_rx_er,
78
    eth0_col, eth0_crs,
79
    eth0_mdc_pad_o, eth0_md_pad_io,
80
 `ifdef ETH0_PHY_RST
81
    eth0_rst_n_o,
82
 `endif
83
`endif
84
 
85
    sys_clk_in_p,sys_clk_in_n,
86
 
87
    rst_n_pad_i
88
 
89
    );
90
 
91
`include "orpsoc-params.v"
92
 
93
   input sys_clk_in_p,sys_clk_in_n;
94
 
95
   input rst_n_pad_i;
96
 
97
`ifdef JTAG_DEBUG
98
   output tdo_pad_o;
99
   input  tms_pad_i;
100
   input  tck_pad_i;
101
   input  tdi_pad_i;
102
`endif
103
`ifdef XILINX_DDR2
104
   output [12:0]               ddr2_a;
105
   output [1:0]        ddr2_ba;
106
   output                     ddr2_ras_n;
107
   output                     ddr2_cas_n;
108
   output                     ddr2_we_n;
109
   output [1:0]        ddr2_cs_n;
110
   output [1:0]        ddr2_odt;
111
   output [1:0]        ddr2_cke;
112
   output [7:0]        ddr2_dm;
113
 
114
   inout [63:0]        ddr2_dq;
115
   inout [7:0]                 ddr2_dqs;
116
   inout [7:0]                 ddr2_dqs_n;
117
   output [1:0]        ddr2_ck;
118
   output [1:0]        ddr2_ck_n;
119
`endif
120
`ifdef XILINX_SSRAM
121
   // ZBT SSRAM
122 530 julius
    output         sram_clk;
123
    input          sram_clk_fb;
124
    output [21:1]  sram_flash_addr;
125
    inout [31:0]   sram_flash_data;
126
    output         sram_cen;
127
    output         sram_flash_oe_n;
128
    output         sram_flash_we_n;
129
    output [3:0]   sram_bw;
130
    output         sram_adv_ld_n;
131
    output         sram_mode;
132 655 julius
`endif //  `ifdef XILINX_SSRAM
133
`ifdef CFI_FLASH
134
   inout [15:0]    flash_dq_io;
135
   output [23:0]    flash_adr_o;
136
   output           flash_adv_n_o;
137
   output           flash_ce_n_o;
138
   output           flash_clk_o;
139
   output           flash_oe_n_o;
140
   output           flash_rst_n_o;
141
   input            flash_wait_i;
142
   output           flash_we_n_o;
143
`endif
144 412 julius
`ifdef UART0
145
   input         uart0_srx_pad_i;
146
   output        uart0_stx_pad_o;
147
   // Duplicates of the UART signals, this time to the USB debug cable
148
   input         uart0_srx_expheader_pad_i;
149
   output        uart0_stx_expheader_pad_o;
150
`endif
151
`ifdef SPI0
152
   output        spi0_mosi_o;
153 415 julius
  output [spi0_ss_width-1:0] spi0_ss_o;
154
   /* via STARTUP_VIRTEX5
155
   output                    spi0_sck_o;
156 412 julius
   input                      spi0_miso_i;
157 415 julius
    */
158 412 julius
`endif
159
`ifdef I2C0
160
   inout                      i2c0_sda_io, i2c0_scl_io;
161
`endif
162
`ifdef I2C1
163
   inout                      i2c1_sda_io, i2c1_scl_io;
164
`endif
165
`ifdef GPIO0
166
   inout [gpio0_io_width-1:0] gpio0_io;
167
`endif
168
`ifdef ETH0
169
   input                      eth0_tx_clk;
170
   output [3:0]        eth0_tx_data;
171
   output                     eth0_tx_en;
172
   output                     eth0_tx_er;
173
   input                      eth0_rx_clk;
174
   input [3:0]                 eth0_rx_data;
175
   input                      eth0_dv;
176
   input                      eth0_rx_er;
177
   input                      eth0_col;
178
   input                      eth0_crs;
179
   output                     eth0_mdc_pad_o;
180
   inout                      eth0_md_pad_io;
181
 `ifdef ETH0_PHY_RST
182
   output                     eth0_rst_n_o;
183
 `endif
184
`endif //  `ifdef ETH0
185
 
186
   ////////////////////////////////////////////////////////////////////////
187
   //
188
   // Clock and reset generation module
189
   // 
190
   ////////////////////////////////////////////////////////////////////////
191
 
192
   //
193
   // Wires
194
   //
195
   wire                       wb_clk, wb_rst;
196
   wire                       ddr2_if_clk, ddr2_if_rst;
197
   wire                       clk200;
198
   wire                       dbg_tck;
199
 
200
 
201
   clkgen clkgen0
202
     (
203
      .sys_clk_in_p              (sys_clk_in_p),
204
      .sys_clk_in_n              (sys_clk_in_n),
205
 
206
      .wb_clk_o                  (wb_clk),
207
      .wb_rst_o                  (wb_rst),
208
 
209
`ifdef JTAG_DEBUG
210
      .tck_pad_i                 (tck_pad_i),
211
      .dbg_tck_o                 (dbg_tck),
212
`endif
213
`ifdef XILINX_DDR2
214
      .ddr2_if_clk_o             (ddr2_if_clk),
215
      .ddr2_if_rst_o             (ddr2_if_rst),
216
      .clk200_o                  (clk200),
217
`endif
218
 
219
      // Asynchronous active low reset
220
      .rst_n_pad_i               (rst_n_pad_i)
221
      );
222
 
223
 
224
   ////////////////////////////////////////////////////////////////////////
225
   //
226
   // Arbiter
227
   // 
228
   ////////////////////////////////////////////////////////////////////////
229
 
230
   // Wire naming convention:
231
   // First: wishbone master or slave (wbm/wbs)
232
   // Second: Which bus it's on instruction or data (i/d)
233
   // Third: Between which module and the arbiter the wires are
234
   // Fourth: Signal name
235
   // Fifth: Direction relative to module (not bus/arbiter!)
236
   //        ie. wbm_d_or12_adr_o is address OUT from the or1200
237
 
238
   // OR1200 instruction bus wires
239
   wire [wb_aw-1:0]            wbm_i_or12_adr_o;
240
   wire [wb_dw-1:0]            wbm_i_or12_dat_o;
241
   wire [3:0]                  wbm_i_or12_sel_o;
242
   wire                       wbm_i_or12_we_o;
243
   wire                       wbm_i_or12_cyc_o;
244
   wire                       wbm_i_or12_stb_o;
245
   wire [2:0]                  wbm_i_or12_cti_o;
246
   wire [1:0]                  wbm_i_or12_bte_o;
247
 
248
   wire [wb_dw-1:0]            wbm_i_or12_dat_i;
249
   wire                       wbm_i_or12_ack_i;
250
   wire                       wbm_i_or12_err_i;
251
   wire                       wbm_i_or12_rty_i;
252
 
253
   // OR1200 data bus wires   
254
   wire [wb_aw-1:0]            wbm_d_or12_adr_o;
255
   wire [wb_dw-1:0]            wbm_d_or12_dat_o;
256
   wire [3:0]                  wbm_d_or12_sel_o;
257
   wire                       wbm_d_or12_we_o;
258
   wire                       wbm_d_or12_cyc_o;
259
   wire                       wbm_d_or12_stb_o;
260
   wire [2:0]                  wbm_d_or12_cti_o;
261
   wire [1:0]                  wbm_d_or12_bte_o;
262
 
263
   wire [wb_dw-1:0]            wbm_d_or12_dat_i;
264
   wire                       wbm_d_or12_ack_i;
265
   wire                       wbm_d_or12_err_i;
266
   wire                       wbm_d_or12_rty_i;
267
 
268
   // Debug interface bus wires   
269
   wire [wb_aw-1:0]            wbm_d_dbg_adr_o;
270
   wire [wb_dw-1:0]            wbm_d_dbg_dat_o;
271
   wire [3:0]                  wbm_d_dbg_sel_o;
272
   wire                       wbm_d_dbg_we_o;
273
   wire                       wbm_d_dbg_cyc_o;
274
   wire                       wbm_d_dbg_stb_o;
275
   wire [2:0]                  wbm_d_dbg_cti_o;
276
   wire [1:0]                  wbm_d_dbg_bte_o;
277
 
278
   wire [wb_dw-1:0]            wbm_d_dbg_dat_i;
279
   wire                       wbm_d_dbg_ack_i;
280
   wire                       wbm_d_dbg_err_i;
281
   wire                       wbm_d_dbg_rty_i;
282
 
283
   // Byte bus bridge master signals
284
   wire [wb_aw-1:0]            wbm_b_d_adr_o;
285
   wire [wb_dw-1:0]            wbm_b_d_dat_o;
286
   wire [3:0]                  wbm_b_d_sel_o;
287
   wire                       wbm_b_d_we_o;
288
   wire                       wbm_b_d_cyc_o;
289
   wire                       wbm_b_d_stb_o;
290
   wire [2:0]                  wbm_b_d_cti_o;
291
   wire [1:0]                  wbm_b_d_bte_o;
292
 
293
   wire [wb_dw-1:0]            wbm_b_d_dat_i;
294
   wire                       wbm_b_d_ack_i;
295
   wire                       wbm_b_d_err_i;
296
   wire                       wbm_b_d_rty_i;
297
 
298
   // Instruction bus slave wires //
299
 
300
   // rom0 instruction bus wires
301
   wire [31:0]                 wbs_i_rom0_adr_i;
302
   wire [wbs_i_rom0_data_width-1:0] wbs_i_rom0_dat_i;
303
   wire [3:0]                        wbs_i_rom0_sel_i;
304
   wire                             wbs_i_rom0_we_i;
305
   wire                             wbs_i_rom0_cyc_i;
306
   wire                             wbs_i_rom0_stb_i;
307
   wire [2:0]                        wbs_i_rom0_cti_i;
308
   wire [1:0]                        wbs_i_rom0_bte_i;
309
   wire [wbs_i_rom0_data_width-1:0] wbs_i_rom0_dat_o;
310
   wire                             wbs_i_rom0_ack_o;
311
   wire                             wbs_i_rom0_err_o;
312
   wire                             wbs_i_rom0_rty_o;
313
 
314
   // mc0 instruction bus wires
315
   wire [31:0]                       wbs_i_mc0_adr_i;
316
   wire [wbs_i_mc0_data_width-1:0]  wbs_i_mc0_dat_i;
317
   wire [3:0]                        wbs_i_mc0_sel_i;
318
   wire                             wbs_i_mc0_we_i;
319
   wire                             wbs_i_mc0_cyc_i;
320
   wire                             wbs_i_mc0_stb_i;
321
   wire [2:0]                        wbs_i_mc0_cti_i;
322
   wire [1:0]                        wbs_i_mc0_bte_i;
323
   wire [wbs_i_mc0_data_width-1:0]  wbs_i_mc0_dat_o;
324
   wire                             wbs_i_mc0_ack_o;
325
   wire                             wbs_i_mc0_err_o;
326
   wire                             wbs_i_mc0_rty_o;
327 655 julius
 
328
   // flash instruction bus wires
329
   wire [31:0]                       wbs_i_flash_adr_i;
330
   wire [wbs_i_flash_data_width-1:0] wbs_i_flash_dat_i;
331
   wire [3:0]                         wbs_i_flash_sel_i;
332
   wire                              wbs_i_flash_we_i;
333
   wire                              wbs_i_flash_cyc_i;
334
   wire                              wbs_i_flash_stb_i;
335
   wire [2:0]                         wbs_i_flash_cti_i;
336
   wire [1:0]                         wbs_i_flash_bte_i;
337
   wire [wbs_i_flash_data_width-1:0] wbs_i_flash_dat_o;
338
   wire                              wbs_i_flash_ack_o;
339
   wire                              wbs_i_flash_err_o;
340
   wire                              wbs_i_flash_rty_o;
341 412 julius
 
342
   // Data bus slave wires //
343
 
344
   // mc0 data bus wires
345
   wire [31:0]                       wbs_d_mc0_adr_i;
346
   wire [wbs_d_mc0_data_width-1:0]  wbs_d_mc0_dat_i;
347
   wire [3:0]                        wbs_d_mc0_sel_i;
348
   wire                             wbs_d_mc0_we_i;
349
   wire                             wbs_d_mc0_cyc_i;
350
   wire                             wbs_d_mc0_stb_i;
351
   wire [2:0]                        wbs_d_mc0_cti_i;
352
   wire [1:0]                        wbs_d_mc0_bte_i;
353
   wire [wbs_d_mc0_data_width-1:0]  wbs_d_mc0_dat_o;
354
   wire                             wbs_d_mc0_ack_o;
355
   wire                             wbs_d_mc0_err_o;
356
   wire                             wbs_d_mc0_rty_o;
357
 
358
   // i2c0 wires
359
   wire [31:0]                       wbs_d_i2c0_adr_i;
360
   wire [wbs_d_i2c0_data_width-1:0] wbs_d_i2c0_dat_i;
361
   wire [3:0]                        wbs_d_i2c0_sel_i;
362
   wire                             wbs_d_i2c0_we_i;
363
   wire                             wbs_d_i2c0_cyc_i;
364
   wire                             wbs_d_i2c0_stb_i;
365
   wire [2:0]                        wbs_d_i2c0_cti_i;
366
   wire [1:0]                        wbs_d_i2c0_bte_i;
367
   wire [wbs_d_i2c0_data_width-1:0] wbs_d_i2c0_dat_o;
368
   wire                             wbs_d_i2c0_ack_o;
369
   wire                             wbs_d_i2c0_err_o;
370
   wire                             wbs_d_i2c0_rty_o;
371
 
372
   // i2c1 wires
373
   wire [31:0]                       wbs_d_i2c1_adr_i;
374
   wire [wbs_d_i2c1_data_width-1:0] wbs_d_i2c1_dat_i;
375
   wire [3:0]                        wbs_d_i2c1_sel_i;
376
   wire                             wbs_d_i2c1_we_i;
377
   wire                             wbs_d_i2c1_cyc_i;
378
   wire                             wbs_d_i2c1_stb_i;
379
   wire [2:0]                        wbs_d_i2c1_cti_i;
380
   wire [1:0]                        wbs_d_i2c1_bte_i;
381
   wire [wbs_d_i2c1_data_width-1:0] wbs_d_i2c1_dat_o;
382
   wire                             wbs_d_i2c1_ack_o;
383
   wire                             wbs_d_i2c1_err_o;
384
   wire                             wbs_d_i2c1_rty_o;
385
 
386
   // spi0 wires
387
   wire [31:0]                       wbs_d_spi0_adr_i;
388
   wire [wbs_d_spi0_data_width-1:0] wbs_d_spi0_dat_i;
389
   wire [3:0]                        wbs_d_spi0_sel_i;
390
   wire                             wbs_d_spi0_we_i;
391
   wire                             wbs_d_spi0_cyc_i;
392
   wire                             wbs_d_spi0_stb_i;
393
   wire [2:0]                        wbs_d_spi0_cti_i;
394
   wire [1:0]                        wbs_d_spi0_bte_i;
395
   wire [wbs_d_spi0_data_width-1:0] wbs_d_spi0_dat_o;
396
   wire                             wbs_d_spi0_ack_o;
397
   wire                             wbs_d_spi0_err_o;
398
   wire                             wbs_d_spi0_rty_o;
399
 
400
   // uart0 wires
401
   wire [31:0]                        wbs_d_uart0_adr_i;
402
   wire [wbs_d_uart0_data_width-1:0] wbs_d_uart0_dat_i;
403
   wire [3:0]                         wbs_d_uart0_sel_i;
404
   wire                              wbs_d_uart0_we_i;
405
   wire                              wbs_d_uart0_cyc_i;
406
   wire                              wbs_d_uart0_stb_i;
407
   wire [2:0]                         wbs_d_uart0_cti_i;
408
   wire [1:0]                         wbs_d_uart0_bte_i;
409
   wire [wbs_d_uart0_data_width-1:0] wbs_d_uart0_dat_o;
410
   wire                              wbs_d_uart0_ack_o;
411
   wire                              wbs_d_uart0_err_o;
412
   wire                              wbs_d_uart0_rty_o;
413
 
414
   // gpio0 wires
415
   wire [31:0]                        wbs_d_gpio0_adr_i;
416
   wire [wbs_d_gpio0_data_width-1:0] wbs_d_gpio0_dat_i;
417
   wire [3:0]                         wbs_d_gpio0_sel_i;
418
   wire                              wbs_d_gpio0_we_i;
419
   wire                              wbs_d_gpio0_cyc_i;
420
   wire                              wbs_d_gpio0_stb_i;
421
   wire [2:0]                         wbs_d_gpio0_cti_i;
422
   wire [1:0]                         wbs_d_gpio0_bte_i;
423
   wire [wbs_d_gpio0_data_width-1:0] wbs_d_gpio0_dat_o;
424
   wire                              wbs_d_gpio0_ack_o;
425
   wire                              wbs_d_gpio0_err_o;
426
   wire                              wbs_d_gpio0_rty_o;
427
 
428
   // eth0 slave wires
429
   wire [31:0]                             wbs_d_eth0_adr_i;
430
   wire [wbs_d_eth0_data_width-1:0]        wbs_d_eth0_dat_i;
431
   wire [3:0]                              wbs_d_eth0_sel_i;
432
   wire                                   wbs_d_eth0_we_i;
433
   wire                                   wbs_d_eth0_cyc_i;
434
   wire                                   wbs_d_eth0_stb_i;
435
   wire [2:0]                              wbs_d_eth0_cti_i;
436
   wire [1:0]                              wbs_d_eth0_bte_i;
437
   wire [wbs_d_eth0_data_width-1:0]        wbs_d_eth0_dat_o;
438
   wire                                   wbs_d_eth0_ack_o;
439
   wire                                   wbs_d_eth0_err_o;
440
   wire                                   wbs_d_eth0_rty_o;
441
 
442
   // eth0 master wires
443
   wire [wbm_eth0_addr_width-1:0]          wbm_eth0_adr_o;
444
   wire [wbm_eth0_data_width-1:0]          wbm_eth0_dat_o;
445
   wire [3:0]                              wbm_eth0_sel_o;
446
   wire                                   wbm_eth0_we_o;
447
   wire                                   wbm_eth0_cyc_o;
448
   wire                                   wbm_eth0_stb_o;
449
   wire [2:0]                              wbm_eth0_cti_o;
450
   wire [1:0]                              wbm_eth0_bte_o;
451
   wire [wbm_eth0_data_width-1:0]         wbm_eth0_dat_i;
452
   wire                                   wbm_eth0_ack_i;
453
   wire                                   wbm_eth0_err_i;
454
   wire                                   wbm_eth0_rty_i;
455
 
456 655 julius
   // flash slave wires
457
   wire [31:0]                             wbs_d_flash_adr_i;
458
   wire [wbs_d_flash_data_width-1:0]       wbs_d_flash_dat_i;
459
   wire [3:0]                              wbs_d_flash_sel_i;
460
   wire                                   wbs_d_flash_we_i;
461
   wire                                   wbs_d_flash_cyc_i;
462
   wire                                   wbs_d_flash_stb_i;
463
   wire [2:0]                              wbs_d_flash_cti_i;
464
   wire [1:0]                              wbs_d_flash_bte_i;
465
   wire [wbs_d_flash_data_width-1:0]       wbs_d_flash_dat_o;
466
   wire                                   wbs_d_flash_ack_o;
467
   wire                                   wbs_d_flash_err_o;
468
   wire                                   wbs_d_flash_rty_o;
469
 
470 412 julius
 
471
 
472
   //
473
   // Wishbone instruction bus arbiter
474
   //
475
 
476
   arbiter_ibus arbiter_ibus0
477
     (
478
      // Instruction Bus Master
479
      // Inputs to arbiter from master
480
      .wbm_adr_o                        (wbm_i_or12_adr_o),
481
      .wbm_dat_o                        (wbm_i_or12_dat_o),
482
      .wbm_sel_o                        (wbm_i_or12_sel_o),
483
      .wbm_we_o                         (wbm_i_or12_we_o),
484
      .wbm_cyc_o                        (wbm_i_or12_cyc_o),
485
      .wbm_stb_o                        (wbm_i_or12_stb_o),
486
      .wbm_cti_o                        (wbm_i_or12_cti_o),
487
      .wbm_bte_o                        (wbm_i_or12_bte_o),
488
      // Outputs to master from arbiter
489
      .wbm_dat_i                        (wbm_i_or12_dat_i),
490
      .wbm_ack_i                        (wbm_i_or12_ack_i),
491
      .wbm_err_i                        (wbm_i_or12_err_i),
492
      .wbm_rty_i                        (wbm_i_or12_rty_i),
493
 
494
      // Slave 0
495
      // Inputs to slave from arbiter
496
      .wbs0_adr_i                       (wbs_i_rom0_adr_i),
497
      .wbs0_dat_i                       (wbs_i_rom0_dat_i),
498
      .wbs0_sel_i                       (wbs_i_rom0_sel_i),
499
      .wbs0_we_i                        (wbs_i_rom0_we_i),
500
      .wbs0_cyc_i                       (wbs_i_rom0_cyc_i),
501
      .wbs0_stb_i                       (wbs_i_rom0_stb_i),
502
      .wbs0_cti_i                       (wbs_i_rom0_cti_i),
503
      .wbs0_bte_i                       (wbs_i_rom0_bte_i),
504
      // Outputs from slave to arbiter      
505
      .wbs0_dat_o                       (wbs_i_rom0_dat_o),
506
      .wbs0_ack_o                       (wbs_i_rom0_ack_o),
507
      .wbs0_err_o                       (wbs_i_rom0_err_o),
508
      .wbs0_rty_o                       (wbs_i_rom0_rty_o),
509
 
510
      // Slave 1
511
      // Inputs to slave from arbiter
512
      .wbs1_adr_i                       (wbs_i_mc0_adr_i),
513
      .wbs1_dat_i                       (wbs_i_mc0_dat_i),
514
      .wbs1_sel_i                       (wbs_i_mc0_sel_i),
515
      .wbs1_we_i                        (wbs_i_mc0_we_i),
516
      .wbs1_cyc_i                       (wbs_i_mc0_cyc_i),
517
      .wbs1_stb_i                       (wbs_i_mc0_stb_i),
518
      .wbs1_cti_i                       (wbs_i_mc0_cti_i),
519
      .wbs1_bte_i                       (wbs_i_mc0_bte_i),
520
      // Outputs from slave to arbiter
521
      .wbs1_dat_o                       (wbs_i_mc0_dat_o),
522
      .wbs1_ack_o                       (wbs_i_mc0_ack_o),
523
      .wbs1_err_o                       (wbs_i_mc0_err_o),
524
      .wbs1_rty_o                       (wbs_i_mc0_rty_o),
525
 
526 655 julius
      // Slave 2
527
      // Inputs to slave from arbiter
528
      .wbs2_adr_i                       (wbs_i_flash_adr_i),
529
      .wbs2_dat_i                       (wbs_i_flash_dat_i),
530
      .wbs2_sel_i                       (wbs_i_flash_sel_i),
531
      .wbs2_we_i                        (wbs_i_flash_we_i),
532
      .wbs2_cyc_i                       (wbs_i_flash_cyc_i),
533
      .wbs2_stb_i                       (wbs_i_flash_stb_i),
534
      .wbs2_cti_i                       (wbs_i_flash_cti_i),
535
      .wbs2_bte_i                       (wbs_i_flash_bte_i),
536
      // Outputs from slave to arbiter
537
      .wbs2_dat_o                       (wbs_i_flash_dat_o),
538
      .wbs2_ack_o                       (wbs_i_flash_ack_o),
539
      .wbs2_err_o                       (wbs_i_flash_err_o),
540
      .wbs2_rty_o                       (wbs_i_flash_rty_o),
541
 
542 412 julius
      // Clock, reset inputs
543
      .wb_clk                           (wb_clk),
544
      .wb_rst                           (wb_rst));
545
 
546
   defparam arbiter_ibus0.wb_addr_match_width = ibus_arb_addr_match_width;
547
 
548 655 julius
   defparam arbiter_ibus0.slave0_adr = ibus_arb_slave0_adr; // flash ROM
549
   defparam arbiter_ibus0.slave1_adr = ibus_arb_slave1_adr; // main memory
550
   defparam arbiter_ibus0.slave2_adr = ibus_arb_slave2_adr; // CFI flash
551 412 julius
 
552
   //
553
   // Wishbone data bus arbiter
554
   //
555
 
556
   arbiter_dbus arbiter_dbus0
557
     (
558
      // Master 0
559
      // Inputs to arbiter from master
560
      .wbm0_adr_o                       (wbm_d_or12_adr_o),
561
      .wbm0_dat_o                       (wbm_d_or12_dat_o),
562
      .wbm0_sel_o                       (wbm_d_or12_sel_o),
563
      .wbm0_we_o                        (wbm_d_or12_we_o),
564
      .wbm0_cyc_o                       (wbm_d_or12_cyc_o),
565
      .wbm0_stb_o                       (wbm_d_or12_stb_o),
566
      .wbm0_cti_o                       (wbm_d_or12_cti_o),
567
      .wbm0_bte_o                       (wbm_d_or12_bte_o),
568
      // Outputs to master from arbiter
569
      .wbm0_dat_i                       (wbm_d_or12_dat_i),
570
      .wbm0_ack_i                       (wbm_d_or12_ack_i),
571
      .wbm0_err_i                       (wbm_d_or12_err_i),
572
      .wbm0_rty_i                       (wbm_d_or12_rty_i),
573
 
574
      // Master 0
575
      // Inputs to arbiter from master
576
      .wbm1_adr_o                       (wbm_d_dbg_adr_o),
577
      .wbm1_dat_o                       (wbm_d_dbg_dat_o),
578
      .wbm1_we_o                        (wbm_d_dbg_we_o),
579
      .wbm1_cyc_o                       (wbm_d_dbg_cyc_o),
580
      .wbm1_sel_o                       (wbm_d_dbg_sel_o),
581
      .wbm1_stb_o                       (wbm_d_dbg_stb_o),
582
      .wbm1_cti_o                       (wbm_d_dbg_cti_o),
583
      .wbm1_bte_o                       (wbm_d_dbg_bte_o),
584
      // Outputs to master from arbiter      
585
      .wbm1_dat_i                       (wbm_d_dbg_dat_i),
586
      .wbm1_ack_i                       (wbm_d_dbg_ack_i),
587
      .wbm1_err_i                       (wbm_d_dbg_err_i),
588
      .wbm1_rty_i                       (wbm_d_dbg_rty_i),
589
 
590
      // Slaves
591
 
592
      .wbs0_adr_i                       (wbs_d_mc0_adr_i),
593
      .wbs0_dat_i                       (wbs_d_mc0_dat_i),
594
      .wbs0_sel_i                       (wbs_d_mc0_sel_i),
595
      .wbs0_we_i                        (wbs_d_mc0_we_i),
596
      .wbs0_cyc_i                       (wbs_d_mc0_cyc_i),
597
      .wbs0_stb_i                       (wbs_d_mc0_stb_i),
598
      .wbs0_cti_i                       (wbs_d_mc0_cti_i),
599
      .wbs0_bte_i                       (wbs_d_mc0_bte_i),
600
      .wbs0_dat_o                       (wbs_d_mc0_dat_o),
601
      .wbs0_ack_o                       (wbs_d_mc0_ack_o),
602
      .wbs0_err_o                       (wbs_d_mc0_err_o),
603
      .wbs0_rty_o                       (wbs_d_mc0_rty_o),
604
 
605
      .wbs1_adr_i                       (wbs_d_eth0_adr_i),
606
      .wbs1_dat_i                       (wbs_d_eth0_dat_i),
607
      .wbs1_sel_i                       (wbs_d_eth0_sel_i),
608
      .wbs1_we_i                        (wbs_d_eth0_we_i),
609
      .wbs1_cyc_i                       (wbs_d_eth0_cyc_i),
610
      .wbs1_stb_i                       (wbs_d_eth0_stb_i),
611
      .wbs1_cti_i                       (wbs_d_eth0_cti_i),
612
      .wbs1_bte_i                       (wbs_d_eth0_bte_i),
613
      .wbs1_dat_o                       (wbs_d_eth0_dat_o),
614
      .wbs1_ack_o                       (wbs_d_eth0_ack_o),
615
      .wbs1_err_o                       (wbs_d_eth0_err_o),
616
      .wbs1_rty_o                       (wbs_d_eth0_rty_o),
617 655 julius
 
618
      .wbs2_adr_i                       (wbs_d_flash_adr_i),
619
      .wbs2_dat_i                       (wbs_d_flash_dat_i),
620
      .wbs2_sel_i                       (wbs_d_flash_sel_i),
621
      .wbs2_we_i                        (wbs_d_flash_we_i),
622
      .wbs2_cyc_i                       (wbs_d_flash_cyc_i),
623
      .wbs2_stb_i                       (wbs_d_flash_stb_i),
624
      .wbs2_cti_i                       (wbs_d_flash_cti_i),
625
      .wbs2_bte_i                       (wbs_d_flash_bte_i),
626
      .wbs2_dat_o                       (wbs_d_flash_dat_o),
627
      .wbs2_ack_o                       (wbs_d_flash_ack_o),
628
      .wbs2_err_o                       (wbs_d_flash_err_o),
629
      .wbs2_rty_o                       (wbs_d_flash_rty_o),
630 412 julius
 
631 655 julius
      .wbs3_adr_i                       (wbm_b_d_adr_o),
632
      .wbs3_dat_i                       (wbm_b_d_dat_o),
633
      .wbs3_sel_i                       (wbm_b_d_sel_o),
634
      .wbs3_we_i                        (wbm_b_d_we_o),
635
      .wbs3_cyc_i                       (wbm_b_d_cyc_o),
636
      .wbs3_stb_i                       (wbm_b_d_stb_o),
637
      .wbs3_cti_i                       (wbm_b_d_cti_o),
638
      .wbs3_bte_i                       (wbm_b_d_bte_o),
639
      .wbs3_dat_o                       (wbm_b_d_dat_i),
640
      .wbs3_ack_o                       (wbm_b_d_ack_i),
641
      .wbs3_err_o                       (wbm_b_d_err_i),
642
      .wbs3_rty_o                       (wbm_b_d_rty_i),
643 412 julius
 
644
      // Clock, reset inputs
645
      .wb_clk                   (wb_clk),
646
      .wb_rst                   (wb_rst));
647
 
648
   // These settings are from top level params file
649
   defparam arbiter_dbus0.wb_addr_match_width = dbus_arb_wb_addr_match_width;
650
   defparam arbiter_dbus0.wb_num_slaves = dbus_arb_wb_num_slaves;
651
   defparam arbiter_dbus0.slave0_adr = dbus_arb_slave0_adr;
652
   defparam arbiter_dbus0.slave1_adr = dbus_arb_slave1_adr;
653 655 julius
   defparam arbiter_dbus0.slave2_adr = dbus_arb_slave2_adr;
654 412 julius
 
655
   //
656
   // Wishbone byte-wide bus arbiter
657
   //   
658
 
659
   arbiter_bytebus arbiter_bytebus0
660
     (
661
 
662
      // Master 0
663
      // Inputs to arbiter from master
664
      .wbm0_adr_o                       (wbm_b_d_adr_o),
665
      .wbm0_dat_o                       (wbm_b_d_dat_o),
666
      .wbm0_sel_o                       (wbm_b_d_sel_o),
667
      .wbm0_we_o                        (wbm_b_d_we_o),
668
      .wbm0_cyc_o                       (wbm_b_d_cyc_o),
669
      .wbm0_stb_o                       (wbm_b_d_stb_o),
670
      .wbm0_cti_o                       (wbm_b_d_cti_o),
671
      .wbm0_bte_o                       (wbm_b_d_bte_o),
672
      // Outputs to master from arbiter
673
      .wbm0_dat_i                       (wbm_b_d_dat_i),
674
      .wbm0_ack_i                       (wbm_b_d_ack_i),
675
      .wbm0_err_i                       (wbm_b_d_err_i),
676
      .wbm0_rty_i                       (wbm_b_d_rty_i),
677
 
678
      // Byte bus slaves
679
 
680
      .wbs0_adr_i                       (wbs_d_uart0_adr_i),
681
      .wbs0_dat_i                       (wbs_d_uart0_dat_i),
682
      .wbs0_we_i                        (wbs_d_uart0_we_i),
683
      .wbs0_cyc_i                       (wbs_d_uart0_cyc_i),
684
      .wbs0_stb_i                       (wbs_d_uart0_stb_i),
685
      .wbs0_cti_i                       (wbs_d_uart0_cti_i),
686
      .wbs0_bte_i                       (wbs_d_uart0_bte_i),
687
      .wbs0_dat_o                       (wbs_d_uart0_dat_o),
688
      .wbs0_ack_o                       (wbs_d_uart0_ack_o),
689
      .wbs0_err_o                       (wbs_d_uart0_err_o),
690
      .wbs0_rty_o                       (wbs_d_uart0_rty_o),
691
 
692
      .wbs1_adr_i                       (wbs_d_gpio0_adr_i),
693
      .wbs1_dat_i                       (wbs_d_gpio0_dat_i),
694
      .wbs1_we_i                        (wbs_d_gpio0_we_i),
695
      .wbs1_cyc_i                       (wbs_d_gpio0_cyc_i),
696
      .wbs1_stb_i                       (wbs_d_gpio0_stb_i),
697
      .wbs1_cti_i                       (wbs_d_gpio0_cti_i),
698
      .wbs1_bte_i                       (wbs_d_gpio0_bte_i),
699
      .wbs1_dat_o                       (wbs_d_gpio0_dat_o),
700
      .wbs1_ack_o                       (wbs_d_gpio0_ack_o),
701
      .wbs1_err_o                       (wbs_d_gpio0_err_o),
702
      .wbs1_rty_o                       (wbs_d_gpio0_rty_o),
703
 
704
      .wbs2_adr_i                       (wbs_d_i2c0_adr_i),
705
      .wbs2_dat_i                       (wbs_d_i2c0_dat_i),
706
      .wbs2_we_i                        (wbs_d_i2c0_we_i),
707
      .wbs2_cyc_i                       (wbs_d_i2c0_cyc_i),
708
      .wbs2_stb_i                       (wbs_d_i2c0_stb_i),
709
      .wbs2_cti_i                       (wbs_d_i2c0_cti_i),
710
      .wbs2_bte_i                       (wbs_d_i2c0_bte_i),
711
      .wbs2_dat_o                       (wbs_d_i2c0_dat_o),
712
      .wbs2_ack_o                       (wbs_d_i2c0_ack_o),
713
      .wbs2_err_o                       (wbs_d_i2c0_err_o),
714
      .wbs2_rty_o                       (wbs_d_i2c0_rty_o),
715
 
716
      .wbs3_adr_i                       (wbs_d_i2c1_adr_i),
717
      .wbs3_dat_i                       (wbs_d_i2c1_dat_i),
718
      .wbs3_we_i                        (wbs_d_i2c1_we_i),
719
      .wbs3_cyc_i                       (wbs_d_i2c1_cyc_i),
720
      .wbs3_stb_i                       (wbs_d_i2c1_stb_i),
721
      .wbs3_cti_i                       (wbs_d_i2c1_cti_i),
722
      .wbs3_bte_i                       (wbs_d_i2c1_bte_i),
723
      .wbs3_dat_o                       (wbs_d_i2c1_dat_o),
724
      .wbs3_ack_o                       (wbs_d_i2c1_ack_o),
725
      .wbs3_err_o                       (wbs_d_i2c1_err_o),
726
      .wbs3_rty_o                       (wbs_d_i2c1_rty_o),
727
 
728
      .wbs4_adr_i                       (wbs_d_spi0_adr_i),
729
      .wbs4_dat_i                       (wbs_d_spi0_dat_i),
730
      .wbs4_we_i                        (wbs_d_spi0_we_i),
731
      .wbs4_cyc_i                       (wbs_d_spi0_cyc_i),
732
      .wbs4_stb_i                       (wbs_d_spi0_stb_i),
733
      .wbs4_cti_i                       (wbs_d_spi0_cti_i),
734
      .wbs4_bte_i                       (wbs_d_spi0_bte_i),
735
      .wbs4_dat_o                       (wbs_d_spi0_dat_o),
736
      .wbs4_ack_o                       (wbs_d_spi0_ack_o),
737
      .wbs4_err_o                       (wbs_d_spi0_err_o),
738
      .wbs4_rty_o                       (wbs_d_spi0_rty_o),
739
 
740
      // Clock, reset inputs
741
      .wb_clk                   (wb_clk),
742
      .wb_rst                   (wb_rst));
743
 
744
   defparam arbiter_bytebus0.wb_addr_match_width = bbus_arb_wb_addr_match_width;
745
   defparam arbiter_bytebus0.wb_num_slaves = bbus_arb_wb_num_slaves;
746
 
747
   defparam arbiter_bytebus0.slave0_adr = bbus_arb_slave0_adr;
748
   defparam arbiter_bytebus0.slave1_adr = bbus_arb_slave1_adr;
749
   defparam arbiter_bytebus0.slave2_adr = bbus_arb_slave2_adr;
750
   defparam arbiter_bytebus0.slave3_adr = bbus_arb_slave3_adr;
751
   defparam arbiter_bytebus0.slave4_adr = bbus_arb_slave4_adr;
752
 
753
 
754
`ifdef JTAG_DEBUG
755
   ////////////////////////////////////////////////////////////////////////
756
   //
757
   // JTAG TAP
758
   // 
759
   ////////////////////////////////////////////////////////////////////////
760
 
761
   //
762
   // Wires
763
   //
764
   wire                                   dbg_if_select;
765
   wire                                   dbg_if_tdo;
766
   wire                                   jtag_tap_tdo;
767
   wire                                   jtag_tap_shift_dr, jtag_tap_pause_dr,
768
                                          jtag_tap_upate_dr, jtag_tap_capture_dr;
769
   //
770
   // Instantiation
771
   //
772
 
773
   jtag_tap jtag_tap0
774
     (
775
      // Ports to pads
776
      .tdo_pad_o                        (tdo_pad_o),
777
      .tms_pad_i                        (tms_pad_i),
778
      .tck_pad_i                        (dbg_tck),
779
      .trst_pad_i                       (async_rst),
780
      .tdi_pad_i                        (tdi_pad_i),
781
 
782
      .tdo_padoe_o                      (tdo_padoe_o),
783
 
784
      .tdo_o                            (jtag_tap_tdo),
785
 
786
      .shift_dr_o                       (jtag_tap_shift_dr),
787
      .pause_dr_o                       (jtag_tap_pause_dr),
788
      .update_dr_o                      (jtag_tap_update_dr),
789
      .capture_dr_o                     (jtag_tap_capture_dr),
790
 
791
      .extest_select_o                  (),
792
      .sample_preload_select_o          (),
793
      .mbist_select_o                   (),
794
      .debug_select_o                   (dbg_if_select),
795
 
796
 
797
      .bs_chain_tdi_i                   (1'b0),
798
      .mbist_tdi_i                      (1'b0),
799
      .debug_tdi_i                      (dbg_if_tdo)
800
 
801
      );
802
 
803
   ////////////////////////////////////////////////////////////////////////
804
`endif //  `ifdef JTAG_DEBUG
805
 
806
   ////////////////////////////////////////////////////////////////////////
807
   //
808
   // OpenRISC processor
809
   // 
810
   ////////////////////////////////////////////////////////////////////////
811
 
812
   // 
813
   // Wires
814
   // 
815
 
816
   wire [30:0]                             or1200_pic_ints;
817
 
818
   wire [31:0]                             or1200_dbg_dat_i;
819
   wire [31:0]                             or1200_dbg_adr_i;
820
   wire                                   or1200_dbg_we_i;
821
   wire                                   or1200_dbg_stb_i;
822
   wire                                   or1200_dbg_ack_o;
823
   wire [31:0]                             or1200_dbg_dat_o;
824
 
825
   wire                                   or1200_dbg_stall_i;
826
   wire                                   or1200_dbg_ewt_i;
827
   wire [3:0]                              or1200_dbg_lss_o;
828
   wire [1:0]                              or1200_dbg_is_o;
829
   wire [10:0]                             or1200_dbg_wp_o;
830
   wire                                   or1200_dbg_bp_o;
831
   wire                                   or1200_dbg_rst;
832
 
833
   wire                                   or1200_clk, or1200_rst;
834
   wire                                   sig_tick;
835
 
836
   //
837
   // Assigns
838
   //
839
   assign or1200_clk = wb_clk;
840
   assign or1200_rst = wb_rst | or1200_dbg_rst;
841
 
842
   // 
843
   // Instantiation
844
   //    
845
   or1200_top or1200_top0
846
       (
847
        // Instruction bus, clocks, reset
848
        .iwb_clk_i                      (wb_clk),
849
        .iwb_rst_i                      (wb_rst),
850
        .iwb_ack_i                      (wbm_i_or12_ack_i),
851
        .iwb_err_i                      (wbm_i_or12_err_i),
852
        .iwb_rty_i                      (wbm_i_or12_rty_i),
853
        .iwb_dat_i                      (wbm_i_or12_dat_i),
854
 
855
        .iwb_cyc_o                      (wbm_i_or12_cyc_o),
856
        .iwb_adr_o                      (wbm_i_or12_adr_o),
857
        .iwb_stb_o                      (wbm_i_or12_stb_o),
858
        .iwb_we_o                               (wbm_i_or12_we_o),
859
        .iwb_sel_o                      (wbm_i_or12_sel_o),
860
        .iwb_dat_o                      (wbm_i_or12_dat_o),
861
        .iwb_cti_o                      (wbm_i_or12_cti_o),
862
        .iwb_bte_o                      (wbm_i_or12_bte_o),
863
 
864
        // Data bus, clocks, reset            
865
        .dwb_clk_i                      (wb_clk),
866
        .dwb_rst_i                      (wb_rst),
867
        .dwb_ack_i                      (wbm_d_or12_ack_i),
868
        .dwb_err_i                      (wbm_d_or12_err_i),
869
        .dwb_rty_i                      (wbm_d_or12_rty_i),
870
        .dwb_dat_i                      (wbm_d_or12_dat_i),
871
 
872
        .dwb_cyc_o                      (wbm_d_or12_cyc_o),
873
        .dwb_adr_o                      (wbm_d_or12_adr_o),
874
        .dwb_stb_o                      (wbm_d_or12_stb_o),
875
        .dwb_we_o                               (wbm_d_or12_we_o),
876
        .dwb_sel_o                      (wbm_d_or12_sel_o),
877
        .dwb_dat_o                      (wbm_d_or12_dat_o),
878
        .dwb_cti_o                      (wbm_d_or12_cti_o),
879
        .dwb_bte_o                      (wbm_d_or12_bte_o),
880
 
881
        // Debug interface ports
882
        .dbg_stall_i                    (or1200_dbg_stall_i),
883
        //.dbg_ewt_i                    (or1200_dbg_ewt_i),
884
        .dbg_ewt_i                      (1'b0),
885
        .dbg_lss_o                      (or1200_dbg_lss_o),
886
        .dbg_is_o                               (or1200_dbg_is_o),
887
        .dbg_wp_o                               (or1200_dbg_wp_o),
888
        .dbg_bp_o                               (or1200_dbg_bp_o),
889
 
890
        .dbg_adr_i                      (or1200_dbg_adr_i),
891
        .dbg_we_i                               (or1200_dbg_we_i ),
892
        .dbg_stb_i                      (or1200_dbg_stb_i),
893
        .dbg_dat_i                      (or1200_dbg_dat_i),
894
        .dbg_dat_o                      (or1200_dbg_dat_o),
895
        .dbg_ack_o                      (or1200_dbg_ack_o),
896
 
897
        .pm_clksd_o                     (),
898
        .pm_dc_gate_o                   (),
899
        .pm_ic_gate_o                   (),
900
        .pm_dmmu_gate_o                 (),
901
        .pm_immu_gate_o                 (),
902
        .pm_tt_gate_o                   (),
903
        .pm_cpu_gate_o                  (),
904
        .pm_wakeup_o                    (),
905
        .pm_lvolt_o                     (),
906
 
907
        // Core clocks, resets
908
        .clk_i                          (or1200_clk),
909
        .rst_i                          (or1200_rst),
910
 
911
        .clmode_i                               (2'b00),
912
        // Interrupts      
913
        .pic_ints_i                     (or1200_pic_ints),
914
        .sig_tick(sig_tick),
915
        /*
916
         .mbist_so_o                    (),
917
         .mbist_si_i                    (0),
918
         .mbist_ctrl_i                  (0),
919
         */
920
 
921
        .pm_cpustall_i                  (1'b0)
922
 
923
        );
924
 
925
   ////////////////////////////////////////////////////////////////////////
926
 
927
 
928
`ifdef JTAG_DEBUG
929
   ////////////////////////////////////////////////////////////////////////
930
         //
931
   // OR1200 Debug Interface
932
   // 
933
   ////////////////////////////////////////////////////////////////////////
934
 
935
   dbg_if dbg_if0
936
     (
937
      // OR1200 interface
938
      .cpu0_clk_i                       (or1200_clk),
939
      .cpu0_rst_o                       (or1200_dbg_rst),
940
      .cpu0_addr_o                      (or1200_dbg_adr_i),
941
      .cpu0_data_o                      (or1200_dbg_dat_i),
942
      .cpu0_stb_o                       (or1200_dbg_stb_i),
943
      .cpu0_we_o                        (or1200_dbg_we_i),
944
      .cpu0_data_i                      (or1200_dbg_dat_o),
945
      .cpu0_ack_i                       (or1200_dbg_ack_o),
946
 
947
 
948
      .cpu0_stall_o                     (or1200_dbg_stall_i),
949
      .cpu0_bp_i                        (or1200_dbg_bp_o),
950
 
951
      // TAP interface
952
      .tck_i                            (dbg_tck),
953
      .tdi_i                            (jtag_tap_tdo),
954
      .tdo_o                            (dbg_if_tdo),
955
      .rst_i                            (wb_rst),
956
      .shift_dr_i                       (jtag_tap_shift_dr),
957
      .pause_dr_i                       (jtag_tap_pause_dr),
958
      .update_dr_i                      (jtag_tap_update_dr),
959
      .debug_select_i                   (dbg_if_select),
960
 
961
      // Wishbone debug master
962
      .wb_clk_i                         (wb_clk),
963
      .wb_dat_i                         (wbm_d_dbg_dat_i),
964
      .wb_ack_i                         (wbm_d_dbg_ack_i),
965
      .wb_err_i                         (wbm_d_dbg_err_i),
966
      .wb_adr_o                         (wbm_d_dbg_adr_o),
967
      .wb_dat_o                         (wbm_d_dbg_dat_o),
968
      .wb_cyc_o                         (wbm_d_dbg_cyc_o),
969
      .wb_stb_o                         (wbm_d_dbg_stb_o),
970
      .wb_sel_o                         (wbm_d_dbg_sel_o),
971
      .wb_we_o                          (wbm_d_dbg_we_o ),
972
      .wb_cti_o                         (wbm_d_dbg_cti_o),
973
      .wb_cab_o                         (/*   UNUSED  */),
974
      .wb_bte_o                         (wbm_d_dbg_bte_o)
975
      );
976
 
977
   ////////////////////////////////////////////////////////////////////////   
978
`else // !`ifdef JTAG_DEBUG
979
 
980
   assign wbm_d_dbg_adr_o = 0;
981
   assign wbm_d_dbg_dat_o = 0;
982
   assign wbm_d_dbg_cyc_o = 0;
983
   assign wbm_d_dbg_stb_o = 0;
984
   assign wbm_d_dbg_sel_o = 0;
985
   assign wbm_d_dbg_we_o  = 0;
986
   assign wbm_d_dbg_cti_o = 0;
987
   assign wbm_d_dbg_bte_o = 0;
988
 
989
   assign or1200_dbg_adr_i = 0;
990
   assign or1200_dbg_dat_i = 0;
991
   assign or1200_dbg_stb_i = 0;
992
   assign or1200_dbg_we_i = 0;
993
   assign or1200_dbg_stall_i = 0;
994
 
995
   ////////////////////////////////////////////////////////////////////////   
996
`endif // !`ifdef JTAG_DEBUG
997
 
998
`ifdef XILINX_DDR2
999
   ////////////////////////////////////////////////////////////////////////
1000
   //
1001
   // Xilinx MIG DDR2 controller, Wishbone interface
1002
   // 
1003
   ////////////////////////////////////////////////////////////////////////
1004
   xilinx_ddr2 xilinx_ddr2_0
1005
     (
1006
      .wbm0_adr_i                       (wbm_eth0_adr_o),
1007
      .wbm0_bte_i                       (wbm_eth0_bte_o),
1008
      .wbm0_cti_i                       (wbm_eth0_cti_o),
1009
      .wbm0_cyc_i                       (wbm_eth0_cyc_o),
1010
      .wbm0_dat_i                       (wbm_eth0_dat_o),
1011
      .wbm0_sel_i                       (wbm_eth0_sel_o),
1012
      .wbm0_stb_i                       (wbm_eth0_stb_o),
1013
      .wbm0_we_i                        (wbm_eth0_we_o),
1014
      .wbm0_ack_o                       (wbm_eth0_ack_i),
1015
      .wbm0_err_o                       (wbm_eth0_err_i),
1016
      .wbm0_rty_o                       (wbm_eth0_rty_i),
1017
      .wbm0_dat_o                       (wbm_eth0_dat_i),
1018
 
1019
      .wbm1_adr_i                       (wbs_d_mc0_adr_i),
1020
      .wbm1_bte_i                       (wbs_d_mc0_bte_i),
1021
      .wbm1_cti_i                       (wbs_d_mc0_cti_i),
1022
      .wbm1_cyc_i                       (wbs_d_mc0_cyc_i),
1023
      .wbm1_dat_i                       (wbs_d_mc0_dat_i),
1024
      .wbm1_sel_i                       (wbs_d_mc0_sel_i),
1025
      .wbm1_stb_i                       (wbs_d_mc0_stb_i),
1026
      .wbm1_we_i                        (wbs_d_mc0_we_i),
1027
      .wbm1_ack_o                       (wbs_d_mc0_ack_o),
1028
      .wbm1_err_o                       (wbs_d_mc0_err_o),
1029
      .wbm1_rty_o                       (wbs_d_mc0_rty_o),
1030
      .wbm1_dat_o                       (wbs_d_mc0_dat_o),
1031
 
1032
      .wbm2_adr_i                       (wbs_i_mc0_adr_i),
1033
      .wbm2_bte_i                       (wbs_i_mc0_bte_i),
1034
      .wbm2_cti_i                       (wbs_i_mc0_cti_i),
1035
      .wbm2_cyc_i                       (wbs_i_mc0_cyc_i),
1036
      .wbm2_dat_i                       (wbs_i_mc0_dat_i),
1037
      .wbm2_sel_i                       (wbs_i_mc0_sel_i),
1038
      .wbm2_stb_i                       (wbs_i_mc0_stb_i),
1039
      .wbm2_we_i                        (wbs_i_mc0_we_i),
1040
      .wbm2_ack_o                       (wbs_i_mc0_ack_o),
1041
      .wbm2_err_o                       (wbs_i_mc0_err_o),
1042
      .wbm2_rty_o                       (wbs_i_mc0_rty_o),
1043
      .wbm2_dat_o                       (wbs_i_mc0_dat_o),
1044
 
1045
      .wb_clk                           (wb_clk),
1046
      .wb_rst                           (wb_rst),
1047
 
1048
      .ddr2_a                           (ddr2_a[12:0]),
1049
      .ddr2_ba                          (ddr2_ba[1:0]),
1050
      .ddr2_ras_n                       (ddr2_ras_n),
1051
      .ddr2_cas_n                       (ddr2_cas_n),
1052
      .ddr2_we_n                        (ddr2_we_n),
1053
      .ddr2_cs_n                        (ddr2_cs_n),
1054
      .ddr2_odt                         (ddr2_odt),
1055
      .ddr2_cke                         (ddr2_cke),
1056
      .ddr2_dm                          (ddr2_dm[7:0]),
1057
      .ddr2_ck                          (ddr2_ck[1:0]),
1058
      .ddr2_ck_n                        (ddr2_ck_n[1:0]),
1059
      .ddr2_dq                          (ddr2_dq[63:0]),
1060
      .ddr2_dqs                         (ddr2_dqs[7:0]),
1061
      .ddr2_dqs_n                       (ddr2_dqs_n[7:0]),
1062
      .ddr2_if_clk                      (ddr2_if_clk),
1063
      .clk200                           (clk200),
1064
      .ddr2_if_rst                      (ddr2_if_rst)
1065
      );
1066
 
1067
`endif
1068
 
1069
 
1070
   ////////////////////////////////////////////////////////////////////////
1071
   //
1072
   // ROM
1073
   // 
1074
   ////////////////////////////////////////////////////////////////////////
1075
 
1076
   rom rom0
1077
     (
1078
      .wb_dat_o                         (wbs_i_rom0_dat_o),
1079
      .wb_ack_o                         (wbs_i_rom0_ack_o),
1080
      .wb_adr_i                         (wbs_i_rom0_adr_i[(wbs_i_rom0_addr_width+2)-1:2]),
1081
      .wb_stb_i                         (wbs_i_rom0_stb_i),
1082
      .wb_cyc_i                         (wbs_i_rom0_cyc_i),
1083
      .wb_cti_i                         (wbs_i_rom0_cti_i),
1084
      .wb_bte_i                         (wbs_i_rom0_bte_i),
1085
      .wb_clk                           (wb_clk),
1086
      .wb_rst                           (wb_rst));
1087
 
1088
   defparam rom0.addr_width = wbs_i_rom0_addr_width;
1089
 
1090
   assign wbs_i_rom0_err_o = 0;
1091
   assign wbs_i_rom0_rty_o = 0;
1092
 
1093
   ////////////////////////////////////////////////////////////////////////
1094
 
1095
`ifdef RAM_WB
1096
   ////////////////////////////////////////////////////////////////////////
1097
   //
1098
   // Generic RAM
1099
   // 
1100
   ////////////////////////////////////////////////////////////////////////
1101
 
1102
   ram_wb ram_wb0
1103
     (
1104
      // Wishbone slave interface 0
1105
      .wbm0_dat_i                       (wbs_i_mc0_dat_i),
1106
      .wbm0_adr_i                       (wbs_i_mc0_adr_i),
1107
      .wbm0_sel_i                       (wbs_i_mc0_sel_i),
1108
      .wbm0_cti_i                       (wbs_i_mc0_cti_i),
1109
      .wbm0_bte_i                       (wbs_i_mc0_bte_i),
1110
      .wbm0_we_i                        (wbs_i_mc0_we_i ),
1111
      .wbm0_cyc_i                       (wbs_i_mc0_cyc_i),
1112
      .wbm0_stb_i                       (wbs_i_mc0_stb_i),
1113
      .wbm0_dat_o                       (wbs_i_mc0_dat_o),
1114
      .wbm0_ack_o                       (wbs_i_mc0_ack_o),
1115 439 julius
      .wbm0_err_o                       (wbs_i_mc0_err_o),
1116
      .wbm0_rty_o                       (wbs_i_mc0_rty_o),
1117 412 julius
      // Wishbone slave interface 1
1118
      .wbm1_dat_i                       (wbs_d_mc0_dat_i),
1119
      .wbm1_adr_i                       (wbs_d_mc0_adr_i),
1120
      .wbm1_sel_i                       (wbs_d_mc0_sel_i),
1121
      .wbm1_cti_i                       (wbs_d_mc0_cti_i),
1122
      .wbm1_bte_i                       (wbs_d_mc0_bte_i),
1123
      .wbm1_we_i                        (wbs_d_mc0_we_i ),
1124
      .wbm1_cyc_i                       (wbs_d_mc0_cyc_i),
1125
      .wbm1_stb_i                       (wbs_d_mc0_stb_i),
1126
      .wbm1_dat_o                       (wbs_d_mc0_dat_o),
1127
      .wbm1_ack_o                       (wbs_d_mc0_ack_o),
1128 439 julius
      .wbm1_err_o                       (wbs_d_mc0_err_o),
1129
      .wbm1_rty_o                       (wbs_d_mc0_rty_o),
1130
      // Wishbone slave interface 2
1131
      .wbm2_dat_i                       (wbm_eth0_dat_o),
1132
      .wbm2_adr_i                       (wbm_eth0_adr_o),
1133
      .wbm2_sel_i                       (wbm_eth0_sel_o),
1134
      .wbm2_cti_i                       (wbm_eth0_cti_o),
1135
      .wbm2_bte_i                       (wbm_eth0_bte_o),
1136
      .wbm2_we_i                        (wbm_eth0_we_o ),
1137
      .wbm2_cyc_i                       (wbm_eth0_cyc_o),
1138
      .wbm2_stb_i                       (wbm_eth0_stb_o),
1139
      .wbm2_dat_o                       (wbm_eth0_dat_i),
1140
      .wbm2_ack_o                       (wbm_eth0_ack_i),
1141
      .wbm2_err_o                       (wbm_eth0_err_i),
1142
      .wbm2_rty_o                       (wbm_eth0_rty_i),
1143 412 julius
      // Clock, reset
1144
      .wb_clk_i                         (wb_clk),
1145
      .wb_rst_i                         (wb_rst));
1146
 
1147
   defparam ram_wb0.aw = wb_aw;
1148
   defparam ram_wb0.dw = wb_dw;
1149 439 julius
 
1150 655 julius
   defparam ram_wb0.mem_size_bytes = internal_sram_mem_span;
1151
   defparam ram_wb0.mem_adr_width = internal_sram_adr_width_for_span;
1152 412 julius
   ////////////////////////////////////////////////////////////////////////
1153
`endif //  `ifdef RAM_WB
1154
 
1155 655 julius
`ifdef CFI_FLASH
1156 412 julius
 
1157 655 julius
   /* Lighweight arbiter between instruction and data busses going
1158
    into the CFI controller */
1159
 
1160
   wire [31:0]                             flash_wb_adr_i;
1161
   wire [31:0]                             flash_wb_dat_i;
1162
   wire [31:0]                             flash_wb_dat_o;
1163
   wire [3:0]                              flash_wb_sel_i;
1164
   wire                                   flash_wb_cyc_i;
1165
   wire                                   flash_wb_stb_i;
1166
   wire                                   flash_wb_we_i;
1167
   wire                                   flash_wb_ack_o;
1168
 
1169
   reg [1:0]                               flash_mst_sel;
1170
 
1171
reg [9:0]                                  flash_arb_timeout;
1172
   wire                                   flash_arb_reset;
1173
 
1174
   always @(posedge wb_clk)
1175
     if (wb_rst)
1176
       flash_mst_sel <= 0;
1177
     else begin
1178
        if (flash_mst_sel==2'b00) begin
1179
           /* wait for new access from masters. data takes priority */
1180
           if (wbs_d_flash_cyc_i & wbs_d_flash_stb_i)
1181
             flash_mst_sel[1] <= 1;
1182
           else if (wbs_i_flash_cyc_i & wbs_i_flash_stb_i)
1183
             flash_mst_sel[0] <= 1;
1184
        end
1185
        else begin
1186
           if (flash_wb_ack_o | flash_arb_reset)
1187
             flash_mst_sel <= 0;
1188
        end // else: !if(flash_mst_sel==2'b00)
1189
     end // else: !if(wb_rst)
1190
 
1191
   assign flash_wb_adr_i = flash_mst_sel[0] ? wbs_i_flash_adr_i :
1192
                           wbs_d_flash_adr_i;
1193
   assign flash_wb_dat_i = flash_mst_sel[0] ? wbs_i_flash_dat_i :
1194
                           wbs_d_flash_dat_i;
1195
   assign flash_wb_stb_i = flash_mst_sel[0] ?  wbs_i_flash_stb_i :
1196
                           flash_mst_sel[1]  ? wbs_d_flash_stb_i : 0;
1197
   assign flash_wb_cyc_i = flash_mst_sel[0] ?  wbs_i_flash_cyc_i :
1198
                           flash_mst_sel[1] ?  wbs_d_flash_cyc_i : 0;
1199
   assign flash_wb_we_i = flash_mst_sel[0] ? wbs_i_flash_we_i :
1200
                          wbs_d_flash_we_i;
1201
   assign flash_wb_sel_i = flash_mst_sel[0] ? wbs_i_flash_sel_i :
1202
                          wbs_d_flash_sel_i;
1203
 
1204
   assign wbs_i_flash_dat_o = flash_wb_dat_o;
1205
   assign wbs_d_flash_dat_o = flash_wb_dat_o;
1206
   assign wbs_i_flash_ack_o = flash_wb_ack_o & flash_mst_sel[0];
1207
   assign wbs_d_flash_ack_o = flash_wb_ack_o & flash_mst_sel[1];
1208
   assign wbs_i_flash_err_o = flash_arb_reset & flash_mst_sel[0];
1209
   assign wbs_i_flash_rty_o = 0;
1210
   assign wbs_d_flash_err_o = flash_arb_reset & flash_mst_sel[1];
1211
   assign wbs_d_flash_rty_o = 0;
1212
 
1213
 
1214
 
1215
   always @(posedge wb_clk)
1216
     if (wb_rst)
1217
       flash_arb_timeout <= 0;
1218
     else if (flash_wb_ack_o)
1219
       flash_arb_timeout <= 0;
1220
     else if (flash_wb_stb_i & flash_wb_cyc_i)
1221
       flash_arb_timeout <= flash_arb_timeout + 1;
1222
 
1223
   assign flash_arb_reset = (&flash_arb_timeout);
1224
 
1225
   cfi_ctrl
1226
     /* Use the simple flash interface */
1227
     #(.cfi_engine("DISABLED"))
1228
     cfi_ctrl0
1229
     (
1230
      .wb_clk_i(wb_clk),
1231
      .wb_rst_i(wb_rst | flash_arb_reset),
1232
 
1233
      .wb_adr_i(flash_wb_adr_i),
1234
      .wb_dat_i(flash_wb_dat_i),
1235
      .wb_stb_i(flash_wb_stb_i),
1236
      .wb_cyc_i(flash_wb_cyc_i),
1237
      .wb_we_i (flash_wb_we_i ),
1238
      .wb_sel_i(flash_wb_sel_i),
1239
      .wb_dat_o(flash_wb_dat_o),
1240
      .wb_ack_o(flash_wb_ack_o),
1241
      .wb_err_o(),
1242
      .wb_rty_o(),
1243
 
1244
      .flash_dq_io(flash_dq_io),
1245
      .flash_adr_o(flash_adr_o),
1246
      .flash_adv_n_o(flash_adv_n_o),
1247
      .flash_ce_n_o(flash_ce_n_o),
1248
      .flash_clk_o(flash_clk_o),
1249
      .flash_oe_n_o(flash_oe_n_o),
1250
      .flash_rst_n_o(flash_rst_n_o),
1251
      .flash_wait_i(flash_wait_i),
1252
      .flash_we_n_o(flash_we_n_o),
1253
      .flash_wp_n_o()
1254
      );
1255
 
1256
`else
1257
 
1258
   assign wbs_i_flash_dat_o = 0;
1259
   assign wbs_i_flash_ack_o = 0;
1260
   assign wbs_i_flash_err_o = 0;
1261
   assign wbs_i_flash_rty_o = 0;
1262
 
1263
   assign wbs_d_flash_dat_o = 0;
1264
   assign wbs_d_flash_ack_o = 0;
1265
   assign wbs_d_flash_err_o = 0;
1266
   assign wbs_d_flash_rty_o = 0;
1267
 
1268
 
1269
 
1270
`endif //  `ifdef CFI_FLASH
1271
 
1272 412 julius
`ifdef ETH0
1273
 
1274
   //
1275
   // Wires
1276
   //
1277
   wire        eth0_irq;
1278
   wire [3:0]  eth0_mtxd;
1279
   wire        eth0_mtxen;
1280
   wire        eth0_mtxerr;
1281
   wire        eth0_mtx_clk;
1282
   wire        eth0_mrx_clk;
1283
   wire [3:0]  eth0_mrxd;
1284
   wire        eth0_mrxdv;
1285
   wire        eth0_mrxerr;
1286
   wire        eth0_mcoll;
1287
   wire        eth0_mcrs;
1288
   wire        eth0_speed;
1289
   wire        eth0_duplex;
1290
   wire        eth0_link;
1291
   // Management interface wires
1292
   wire        eth0_md_i;
1293
   wire        eth0_md_o;
1294
   wire        eth0_md_oe;
1295
 
1296
 
1297
   //
1298
   // assigns
1299
 
1300
   // Hook up MII wires
1301
   assign eth0_mtx_clk   = eth0_tx_clk;
1302
   assign eth0_tx_data   = eth0_mtxd[3:0];
1303
   assign eth0_tx_en     = eth0_mtxen;
1304
   assign eth0_tx_er     = eth0_mtxerr;
1305
   assign eth0_mrxd[3:0] = eth0_rx_data;
1306
   assign eth0_mrxdv     = eth0_dv;
1307
   assign eth0_mrxerr    = eth0_rx_er;
1308
   assign eth0_mrx_clk   = eth0_rx_clk;
1309
   assign eth0_mcoll     = eth0_col;
1310
   assign eth0_mcrs      = eth0_crs;
1311
 
1312
`ifdef XILINX
1313
   // Xilinx primitive for MDIO tristate
1314
   IOBUF iobuf_phy_smi_data
1315
     (
1316
      // Outputs
1317
      .O                                 (eth0_md_i),
1318
      // Inouts
1319
      .IO                                (eth0_md_pad_io),
1320
      // Inputs
1321
      .I                                 (eth0_md_o),
1322
      .T                                 (!eth0_md_oe));
1323
`else // !`ifdef XILINX
1324
 
1325
   // Generic technology tristate control for management interface
1326
   assign eth0_md_pad_io = eth0_md_oe ? eth0_md_o : 1'bz;
1327
   assign eth0_md_i = eth0_md_pad_io;
1328
 
1329
`endif // !`ifdef XILINX
1330
 
1331
`ifdef ETH0_PHY_RST
1332
   assign eth0_rst_n_o = !wb_rst;
1333
`endif
1334
 
1335
   ethmac ethmac0
1336
     (
1337
      // Wishbone Slave interface
1338
      .wb_clk_i         (wb_clk),
1339
      .wb_rst_i         (wb_rst),
1340
      .wb_dat_i         (wbs_d_eth0_dat_i[31:0]),
1341
      .wb_adr_i         (wbs_d_eth0_adr_i[wbs_d_eth0_addr_width-1:2]),
1342
      .wb_sel_i         (wbs_d_eth0_sel_i[3:0]),
1343
      .wb_we_i          (wbs_d_eth0_we_i),
1344
      .wb_cyc_i         (wbs_d_eth0_cyc_i),
1345
      .wb_stb_i         (wbs_d_eth0_stb_i),
1346
      .wb_dat_o         (wbs_d_eth0_dat_o[31:0]),
1347
      .wb_err_o         (wbs_d_eth0_err_o),
1348
      .wb_ack_o         (wbs_d_eth0_ack_o),
1349
      // Wishbone Master Interface
1350
      .m_wb_adr_o       (wbm_eth0_adr_o[31:0]),
1351
      .m_wb_sel_o       (wbm_eth0_sel_o[3:0]),
1352
      .m_wb_we_o        (wbm_eth0_we_o),
1353
      .m_wb_dat_o       (wbm_eth0_dat_o[31:0]),
1354
      .m_wb_cyc_o       (wbm_eth0_cyc_o),
1355
      .m_wb_stb_o       (wbm_eth0_stb_o),
1356
      .m_wb_cti_o       (wbm_eth0_cti_o[2:0]),
1357
      .m_wb_bte_o       (wbm_eth0_bte_o[1:0]),
1358
      .m_wb_dat_i       (wbm_eth0_dat_i[31:0]),
1359
      .m_wb_ack_i       (wbm_eth0_ack_i),
1360
      .m_wb_err_i       (wbm_eth0_err_i),
1361
 
1362
      // Ethernet MII interface
1363
      // Transmit
1364
      .mtxd_pad_o       (eth0_mtxd[3:0]),
1365
      .mtxen_pad_o      (eth0_mtxen),
1366
      .mtxerr_pad_o     (eth0_mtxerr),
1367
      .mtx_clk_pad_i    (eth0_mtx_clk),
1368
      // Receive
1369
      .mrx_clk_pad_i    (eth0_mrx_clk),
1370
      .mrxd_pad_i       (eth0_mrxd[3:0]),
1371
      .mrxdv_pad_i      (eth0_mrxdv),
1372
      .mrxerr_pad_i     (eth0_mrxerr),
1373
      .mcoll_pad_i      (eth0_mcoll),
1374
      .mcrs_pad_i       (eth0_mcrs),
1375
      // Management interface
1376
      .md_pad_i         (eth0_md_i),
1377
      .mdc_pad_o        (eth0_mdc_pad_o),
1378
      .md_pad_o         (eth0_md_o),
1379
      .md_padoe_o       (eth0_md_oe),
1380
 
1381
      // Processor interrupt
1382
      .int_o            (eth0_irq)
1383
 
1384
      /*
1385
       .mbist_so_o                      (),
1386
       .mbist_si_i                      (),
1387
       .mbist_ctrl_i                    ()
1388
       */
1389
 
1390
      );
1391
 
1392
   assign wbs_d_eth0_rty_o = 0;
1393
 
1394
`else
1395
   assign wbs_d_eth0_dat_o = 0;
1396
   assign wbs_d_eth0_err_o = 0;
1397
   assign wbs_d_eth0_ack_o = 0;
1398
   assign wbs_d_eth0_rty_o = 0;
1399
   assign wbm_eth0_adr_o = 0;
1400
   assign wbm_eth0_sel_o = 0;
1401
   assign wbm_eth0_we_o = 0;
1402
   assign wbm_eth0_dat_o = 0;
1403
   assign wbm_eth0_cyc_o = 0;
1404
   assign wbm_eth0_stb_o = 0;
1405
   assign wbm_eth0_cti_o = 0;
1406
   assign wbm_eth0_bte_o = 0;
1407
`endif
1408
 
1409
`ifdef UART0
1410
   ////////////////////////////////////////////////////////////////////////
1411
   //
1412
   // UART0
1413
   // 
1414
   ////////////////////////////////////////////////////////////////////////
1415
 
1416
   //
1417
   // Wires
1418
   //
1419
   wire        uart0_srx;
1420
   wire        uart0_stx;
1421
 
1422
   wire        uart0_irq;
1423
 
1424
   //
1425
   // Assigns
1426
   //
1427
   assign wbs_d_uart0_err_o = 0;
1428
   assign wbs_d_uart0_rty_o = 0;
1429
 
1430
   // Two UART lines coming to single one (ensure they go high when unconnected)
1431 415 julius
   assign uart0_srx = uart0_srx_pad_i & uart0_srx_expheader_pad_i;
1432 412 julius
   assign uart0_stx_pad_o = uart0_stx;
1433
   assign uart0_stx_expheader_pad_o = uart0_stx;
1434
 
1435
 
1436
   uart16550 uart16550_0
1437
     (
1438
      // Wishbone slave interface
1439
      .wb_clk_i                         (wb_clk),
1440
      .wb_rst_i                         (wb_rst),
1441
      .wb_adr_i                         (wbs_d_uart0_adr_i[uart0_addr_width-1:0]),
1442
      .wb_dat_i                         (wbs_d_uart0_dat_i),
1443
      .wb_we_i                          (wbs_d_uart0_we_i),
1444
      .wb_stb_i                         (wbs_d_uart0_stb_i),
1445
      .wb_cyc_i                         (wbs_d_uart0_cyc_i),
1446
      //.wb_sel_i                               (),
1447
      .wb_dat_o                         (wbs_d_uart0_dat_o),
1448
      .wb_ack_o                         (wbs_d_uart0_ack_o),
1449
 
1450
      .int_o                            (uart0_irq),
1451
      .stx_pad_o                        (uart0_stx),
1452
      .rts_pad_o                        (),
1453
      .dtr_pad_o                        (),
1454
      //      .baud_o                           (),
1455
      // Inputs
1456
      .srx_pad_i                        (uart0_srx),
1457
      .cts_pad_i                        (1'b0),
1458
      .dsr_pad_i                        (1'b0),
1459
      .ri_pad_i                         (1'b0),
1460
      .dcd_pad_i                        (1'b0));
1461
 
1462
   ////////////////////////////////////////////////////////////////////////          
1463
`else // !`ifdef UART0
1464
 
1465
   //
1466
   // Assigns
1467
   //
1468
   assign wbs_d_uart0_err_o = 0;
1469
   assign wbs_d_uart0_rty_o = 0;
1470
   assign wbs_d_uart0_ack_o = 0;
1471
   assign wbs_d_uart0_dat_o = 0;
1472
 
1473
   ////////////////////////////////////////////////////////////////////////       
1474
`endif // !`ifdef UART0
1475
 
1476
`ifdef SPI0
1477
   ////////////////////////////////////////////////////////////////////////
1478
   //
1479
   // SPI0 controller
1480
   // 
1481
   ////////////////////////////////////////////////////////////////////////
1482
 
1483
   //
1484
   // Wires
1485
   //
1486
   wire                              spi0_irq;
1487
 
1488
   //
1489
   // Assigns
1490
   //
1491
   assign wbs_d_spi0_err_o = 0;
1492
   assign wbs_d_spi0_rty_o = 0;
1493
   //assign spi0_hold_n_o = 1;
1494
   //assign spi0_w_n_o = 1;
1495
 
1496
 
1497
   simple_spi spi0
1498
     (
1499
      // Wishbone slave interface
1500
      .clk_i                            (wb_clk),
1501
      .rst_i                            (wb_rst),
1502
      .cyc_i                            (wbs_d_spi0_cyc_i),
1503
      .stb_i                            (wbs_d_spi0_stb_i),
1504
      .adr_i                            (wbs_d_spi0_adr_i[spi0_wb_adr_width-1:0]),
1505
      .we_i                             (wbs_d_spi0_we_i),
1506
      .dat_i                            (wbs_d_spi0_dat_i),
1507
      .dat_o                            (wbs_d_spi0_dat_o),
1508
      .ack_o                            (wbs_d_spi0_ack_o),
1509
      // SPI IRQ
1510
      .inta_o                           (spi0_irq),
1511
      // External SPI interface
1512
      .sck_o                            (spi0_sck_o),
1513
      .ss_o                             (spi0_ss_o),
1514
      .mosi_o                           (spi0_mosi_o),
1515
      .miso_i                           (spi0_miso_i)
1516
      );
1517
 
1518
   defparam spi0.slave_select_width = spi0_ss_width;
1519 415 julius
 
1520
   // SPI clock and MISO lines must go through STARTUP_VIRTEX5 block.
1521
   STARTUP_VIRTEX5 startup_virtex5
1522
     (
1523
      .CFGCLK(),
1524
      .CFGMCLK(),
1525
      .DINSPI(spi0_miso_i),
1526
      .EOS(),
1527
      .TCKSPI(),
1528
      .CLK(),
1529
      .GSR(1'b0),
1530
      .GTS(1'b0),
1531
      .USRCCLKO(spi0_sck_o),
1532
      .USRCCLKTS(1'b0),
1533
      .USRDONEO(),
1534
      .USRDONETS()
1535
      );
1536 412 julius
 
1537
   ////////////////////////////////////////////////////////////////////////   
1538
`else // !`ifdef SPI0
1539
 
1540
   //
1541
   // Assigns
1542
   //
1543
   assign wbs_d_spi0_dat_o = 0;
1544
   assign wbs_d_spi0_ack_o = 0;
1545
   assign wbs_d_spi0_err_o = 0;
1546
   assign wbs_d_spi0_rty_o = 0;
1547
 
1548
   ////////////////////////////////////////////////////////////////////////
1549
`endif // !`ifdef SPI0   
1550
 
1551
 
1552
`ifdef I2C0
1553
   ////////////////////////////////////////////////////////////////////////
1554
   //
1555
   // i2c controller 0
1556
   // 
1557
   ////////////////////////////////////////////////////////////////////////
1558
 
1559
   //
1560
   // Wires
1561
   //
1562
   wire                              i2c0_irq;
1563
   wire                              scl0_pad_o;
1564
   wire                              scl0_padoen_o;
1565
   wire                              sda0_pad_o;
1566
   wire                              sda0_padoen_o;
1567
 
1568
  i2c_master_slave
1569
    #
1570
    (
1571
     .DEFAULT_SLAVE_ADDR(HV0_SADR)
1572
    )
1573
  i2c_master_slave0
1574
    (
1575
     .wb_clk_i                       (wb_clk),
1576
     .wb_rst_i                       (wb_rst),
1577
     .arst_i                         (wb_rst),
1578
     .wb_adr_i                       (wbs_d_i2c0_adr_i[i2c_0_wb_adr_width-1:0]),
1579
     .wb_dat_i                       (wbs_d_i2c0_dat_i),
1580
     .wb_we_i                        (wbs_d_i2c0_we_i ),
1581
     .wb_cyc_i                       (wbs_d_i2c0_cyc_i),
1582
     .wb_stb_i                       (wbs_d_i2c0_stb_i),
1583
     .wb_dat_o                       (wbs_d_i2c0_dat_o),
1584
     .wb_ack_o                       (wbs_d_i2c0_ack_o),
1585
     .scl_pad_i                      (i2c0_scl_io     ),
1586
     .scl_pad_o                      (scl0_pad_o         ),
1587
     .scl_padoen_o                   (scl0_padoen_o      ),
1588
     .sda_pad_i                      (i2c0_sda_io        ),
1589
     .sda_pad_o                      (sda0_pad_o         ),
1590
     .sda_padoen_o                   (sda0_padoen_o      ),
1591
 
1592
      // Interrupt
1593
     .wb_inta_o                      (i2c0_irq)
1594
 
1595
      );
1596
 
1597
   assign wbs_d_i2c0_err_o = 0;
1598
   assign wbs_d_i2c0_rty_o = 0;
1599
 
1600
   // i2c phy lines
1601
   assign i2c0_scl_io = scl0_padoen_o ? 1'bz : scl0_pad_o;
1602
   assign i2c0_sda_io = sda0_padoen_o ? 1'bz : sda0_pad_o;
1603
 
1604
 
1605
   ////////////////////////////////////////////////////////////////////////
1606
`else // !`ifdef I2C0
1607
 
1608
   assign wbs_d_i2c0_dat_o = 0;
1609
   assign wbs_d_i2c0_ack_o = 0;
1610
   assign wbs_d_i2c0_err_o = 0;
1611
   assign wbs_d_i2c0_rty_o = 0;
1612
 
1613
   ////////////////////////////////////////////////////////////////////////
1614
`endif // !`ifdef I2C0   
1615
 
1616
`ifdef I2C1
1617
   ////////////////////////////////////////////////////////////////////////
1618
   //
1619
   // i2c controller 1
1620
   // 
1621
   ////////////////////////////////////////////////////////////////////////
1622
 
1623
   //
1624
   // Wires
1625
   //
1626
   wire                              i2c1_irq;
1627
   wire                              scl1_pad_o;
1628
   wire                              scl1_padoen_o;
1629
   wire                              sda1_pad_o;
1630
   wire                              sda1_padoen_o;
1631
 
1632
   i2c_master_slave
1633
    #
1634
    (
1635
     .DEFAULT_SLAVE_ADDR(HV1_SADR)
1636
    )
1637
   i2c_master_slave1
1638
     (
1639
      .wb_clk_i                      (wb_clk),
1640
      .wb_rst_i                      (wb_rst),
1641
      .arst_i                        (wb_rst),
1642
      .wb_adr_i                      (wbs_d_i2c1_adr_i[i2c_1_wb_adr_width-1:0]),
1643
      .wb_dat_i                      (wbs_d_i2c1_dat_i),
1644
      .wb_we_i                       (wbs_d_i2c1_we_i ),
1645
      .wb_cyc_i                      (wbs_d_i2c1_cyc_i),
1646
      .wb_stb_i                      (wbs_d_i2c1_stb_i),
1647
      .wb_dat_o                      (wbs_d_i2c1_dat_o),
1648
      .wb_ack_o                      (wbs_d_i2c1_ack_o),
1649
      .scl_pad_i                     (i2c1_scl_io     ),
1650
      .scl_pad_o                     (scl1_pad_o         ),
1651
      .scl_padoen_o                  (scl1_padoen_o      ),
1652
      .sda_pad_i                     (i2c1_sda_io        ),
1653
      .sda_pad_o                     (sda1_pad_o         ),
1654
      .sda_padoen_o                  (sda1_padoen_o      ),
1655
 
1656
      // Interrupt
1657
      .wb_inta_o                     (i2c1_irq)
1658
 
1659
      );
1660
 
1661
   assign wbs_d_i2c1_err_o = 0;
1662
   assign wbs_d_i2c1_rty_o = 0;
1663
 
1664
   // i2c phy lines
1665
   assign i2c1_scl_io = scl1_padoen_o ? 1'bz : scl1_pad_o;
1666
   assign i2c1_sda_io = sda1_padoen_o ? 1'bz : sda1_pad_o;
1667
 
1668
   ////////////////////////////////////////////////////////////////////////
1669
`else // !`ifdef I2C1   
1670
 
1671
   assign wbs_d_i2c1_dat_o = 0;
1672
   assign wbs_d_i2c1_ack_o = 0;
1673
   assign wbs_d_i2c1_err_o = 0;
1674
   assign wbs_d_i2c1_rty_o = 0;
1675
 
1676
   ////////////////////////////////////////////////////////////////////////
1677
`endif // !`ifdef I2C1   
1678
 
1679
`ifdef GPIO0
1680
   ////////////////////////////////////////////////////////////////////////
1681
   //
1682
   // GPIO 0
1683
   // 
1684
   ////////////////////////////////////////////////////////////////////////
1685
 
1686
   gpio gpio0
1687
     (
1688
      // GPIO bus
1689
      .gpio_io                          (gpio0_io[gpio0_io_width-1:0]),
1690
      // Wishbone slave interface
1691
      .wb_adr_i                         (wbs_d_gpio0_adr_i[gpio0_wb_adr_width-1:0]),
1692
      .wb_dat_i                         (wbs_d_gpio0_dat_i),
1693
      .wb_we_i                          (wbs_d_gpio0_we_i),
1694
      .wb_cyc_i                         (wbs_d_gpio0_cyc_i),
1695
      .wb_stb_i                         (wbs_d_gpio0_stb_i),
1696
      .wb_cti_i                         (wbs_d_gpio0_cti_i),
1697
      .wb_bte_i                         (wbs_d_gpio0_bte_i),
1698
      .wb_dat_o                         (wbs_d_gpio0_dat_o),
1699
      .wb_ack_o                         (wbs_d_gpio0_ack_o),
1700
      .wb_err_o                         (wbs_d_gpio0_err_o),
1701
      .wb_rty_o                         (wbs_d_gpio0_rty_o),
1702
 
1703
      .wb_clk                           (wb_clk),
1704
      .wb_rst                           (wb_rst)
1705
      );
1706
 
1707
   defparam gpio0.gpio_io_width = gpio0_io_width;
1708
   defparam gpio0.gpio_dir_reset_val = gpio0_dir_reset_val;
1709
   defparam gpio0.gpio_o_reset_val = gpio0_o_reset_val;
1710
 
1711
   ////////////////////////////////////////////////////////////////////////
1712
`else // !`ifdef GPIO0
1713
   assign wbs_d_gpio0_dat_o = 0;
1714
   assign wbs_d_gpio0_ack_o = 0;
1715
   assign wbs_d_gpio0_err_o = 0;
1716
   assign wbs_d_gpio0_rty_o = 0;
1717
   ////////////////////////////////////////////////////////////////////////
1718
`endif // !`ifdef GPIO0
1719
 
1720
   ////////////////////////////////////////////////////////////////////////
1721
   //
1722
   // OR1200 Interrupt assignment
1723
   // 
1724
   ////////////////////////////////////////////////////////////////////////
1725
 
1726
   assign or1200_pic_ints[0] = 0; // Non-maskable inside OR1200
1727
   assign or1200_pic_ints[1] = 0; // Non-maskable inside OR1200
1728
`ifdef UART0
1729
   assign or1200_pic_ints[2] = uart0_irq;
1730
`else
1731
   assign or1200_pic_ints[2] = 0;
1732
`endif
1733
   assign or1200_pic_ints[3] = 0;
1734
`ifdef ETH0
1735
   assign or1200_pic_ints[4] = eth0_irq;
1736
`else
1737
   assign or1200_pic_ints[4] = 0;
1738
`endif
1739
   assign or1200_pic_ints[5] = 0;
1740
`ifdef SPI0
1741
   assign or1200_pic_ints[6] = spi0_irq;
1742
`else
1743
   assign or1200_pic_ints[6] = 0;
1744
`endif
1745
   assign or1200_pic_ints[7] = 0;
1746
   assign or1200_pic_ints[8] = 0;
1747
   assign or1200_pic_ints[9] = 0;
1748
`ifdef I2C0
1749
   assign or1200_pic_ints[10] = i2c0_irq;
1750
`else
1751
   assign or1200_pic_ints[10] = 0;
1752
`endif
1753
`ifdef I2C1
1754
   assign or1200_pic_ints[11] = i2c1_irq;
1755
`else
1756
   assign or1200_pic_ints[11] = 0;
1757
`endif
1758
   assign or1200_pic_ints[12] = 0;
1759
   assign or1200_pic_ints[13] = 0;
1760
   assign or1200_pic_ints[14] = 0;
1761
   assign or1200_pic_ints[15] = 0;
1762
   assign or1200_pic_ints[16] = 0;
1763
   assign or1200_pic_ints[17] = 0;
1764
   assign or1200_pic_ints[18] = 0;
1765
   assign or1200_pic_ints[19] = 0;
1766
   assign or1200_pic_ints[20] = 0;
1767
   assign or1200_pic_ints[21] = 0;
1768
   assign or1200_pic_ints[22] = 0;
1769
   assign or1200_pic_ints[23] = 0;
1770
   assign or1200_pic_ints[24] = 0;
1771
   assign or1200_pic_ints[25] = 0;
1772
   assign or1200_pic_ints[26] = 0;
1773
   assign or1200_pic_ints[27] = 0;
1774
   assign or1200_pic_ints[28] = 0;
1775
   assign or1200_pic_ints[29] = 0;
1776
   assign or1200_pic_ints[30] = 0;
1777
 
1778
endmodule // orpsoc_top
1779
 
1780
 

powered by: WebSVN 2.1.0

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