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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [vlog/] [system/] [system.v] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 csantifort
//////////////////////////////////////////////////////////////////
2
//                                                              //
3
//  Top-level module instantiating the entire Amber 2 system.   //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  This is the highest level synthesizable module in the       //
10
//  project. The ports in this module represent pins on the     //
11
//  FPGA.                                                       //
12
//                                                              //
13
//  Author(s):                                                  //
14
//      - Conor Santifort, csantifort.amber@gmail.com           //
15
//                                                              //
16
//////////////////////////////////////////////////////////////////
17
//                                                              //
18
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
19
//                                                              //
20
// This source file may be used and distributed without         //
21
// restriction provided that this copyright statement is not    //
22
// removed from the file and that any derivative work contains  //
23
// the original copyright notice and the associated disclaimer. //
24
//                                                              //
25
// This source file is free software; you can redistribute it   //
26
// and/or modify it under the terms of the GNU Lesser General   //
27
// Public License as published by the Free Software Foundation; //
28
// either version 2.1 of the License, or (at your option) any   //
29
// later version.                                               //
30
//                                                              //
31
// This source is distributed in the hope that it will be       //
32
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
33
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
34
// PURPOSE.  See the GNU Lesser General Public License for more //
35
// details.                                                     //
36
//                                                              //
37
// You should have received a copy of the GNU Lesser General    //
38
// Public License along with this source; if not, download it   //
39
// from http://www.opencores.org/lgpl.shtml                     //
40
//                                                              //
41
//////////////////////////////////////////////////////////////////
42
 
43
 
44
module system
45
(
46
input                       brd_rst,
47
input                       brd_clk_n,
48
input                       brd_clk_p,
49
 
50
`ifdef XILINX_VIRTEX6_FPGA
51
input                       sys_clk_p,
52
input                       sys_clk_n,
53
`endif
54
 
55
// UART 0 Interface
56
input                       i_uart0_rts,
57
output                      o_uart0_rx,
58
output                      o_uart0_cts,
59
input                       i_uart0_tx,
60
 
61
// Xilinx Spartan 6 MCB DDR3 Interface
62
inout  [15:0]               ddr3_dq,
63
output [12:0]               ddr3_addr,
64
output [2:0]                ddr3_ba,
65
output                      ddr3_ras_n,
66
output                      ddr3_cas_n,
67
output                      ddr3_we_n,
68
output                      ddr3_odt,
69
output                      ddr3_reset_n,
70
output                      ddr3_cke,
71
output [1:0]                ddr3_dm,
72
inout  [1:0]                ddr3_dqs_p,
73
inout  [1:0]                ddr3_dqs_n,
74
output                      ddr3_ck_p,
75
output                      ddr3_ck_n,
76
`ifdef XILINX_VIRTEX6_FPGA
77
output                      ddr3_cs_n,
78
`endif
79
`ifdef XILINX_SPARTAN6_FPGA
80
inout                       mcb3_rzq,
81
inout                       mcb3_zio,
82
`endif
83
 
84
 
85
// Ethmac B100 MAC to PHY Interface
86
input                       mtx_clk_pad_i,
87
output  [3:0]               mtxd_pad_o,
88
output                      mtxen_pad_o,
89
output                      mtxerr_pad_o,
90
input                       mrx_clk_pad_i,
91
input   [3:0]               mrxd_pad_i,
92
input                       mrxdv_pad_i,
93
input                       mrxerr_pad_i,
94
input                       mcoll_pad_i,
95
input                       mcrs_pad_i,
96
inout                       md_pad_io,
97
output                      mdc_pad_o,
98
output                      phy_reset_n
99
);
100
 
101
 
102
wire            sys_clk;    // System clock
103
wire            sys_rst;    // Active low reset, synchronous to sys_clk
104
wire            clk_200;    // 200MHz from board
105
 
106
 
107
// ======================================
108
// Xilinx MCB DDR3 Controller connections
109
// ======================================
110
`ifdef XILINX_SPARTAN6_FPGA
111
wire            c3_p0_cmd_en;
112
wire  [2:0]     c3_p0_cmd_instr;
113
wire  [29:0]    c3_p0_cmd_byte_addr;
114
wire            c3_p0_wr_en;
115
wire  [15:0]    c3_p0_wr_mask;
116
wire  [127:0]   c3_p0_wr_data;
117
wire  [127:0]   c3_p0_rd_data;
118
wire            c3_p0_rd_empty;
119
wire            c3_p0_cmd_full;
120
wire            c3_p0_wr_full;
121
`endif
122
 
123
wire            phy_init_done;
124
 
125
// ======================================
126
// Xilinx Virtex-6 DDR3 Controller connections
127
// ======================================
128
`ifdef XILINX_VIRTEX6_FPGA
129
wire            phy_init_done1;
130
wire            xv6_cmd_en;
131
wire  [2:0]     xv6_cmd_instr;
132
wire  [26:0]    xv6_cmd_byte_addr;
133
wire            xv6_cmd_full;
134
wire            xv6_wr_full;
135
wire            xv6_wr_en;
136
wire            xv6_wr_end;
137
wire  [7:0]     xv6_wr_mask;
138
wire  [63:0]    xv6_wr_data;
139
wire  [63:0]    xv6_rd_data;
140
wire            xv6_rd_data_valid;
141
wire            xv6_ddr3_clk;
142
`endif
143
 
144
// ======================================
145
// Ethmac MII
146
// ======================================
147
wire            md_pad_i;
148
wire            md_pad_o;
149
wire            md_padoe_o;
150
 
151
// ======================================
152
// Wishbone Buses
153
// ======================================
154
 
155
localparam WB_MASTERS = 2;
156
localparam WB_SLAVES  = 9;
157
 
158
 
159
// Wishbone Master Buses
160
wire      [31:0]            m_wb_adr      [WB_MASTERS-1:0];
161
wire      [3:0]             m_wb_sel      [WB_MASTERS-1:0];
162
wire      [WB_MASTERS-1:0]  m_wb_we                       ;
163
wire      [31:0]            m_wb_dat_w    [WB_MASTERS-1:0];
164
wire      [31:0]            m_wb_dat_r    [WB_MASTERS-1:0];
165
wire      [WB_MASTERS-1:0]  m_wb_cyc                      ;
166
wire      [WB_MASTERS-1:0]  m_wb_stb                      ;
167
wire      [WB_MASTERS-1:0]  m_wb_ack                      ;
168
wire      [WB_MASTERS-1:0]  m_wb_err                      ;
169
 
170
 
171
// Wishbone Slave Buses
172
wire      [31:0]            s_wb_adr      [WB_SLAVES-1:0];
173
wire      [3:0]             s_wb_sel      [WB_SLAVES-1:0];
174
wire      [WB_SLAVES-1:0]   s_wb_we                      ;
175
wire      [31:0]            s_wb_dat_w    [WB_SLAVES-1:0];
176
wire      [31:0]            s_wb_dat_r    [WB_SLAVES-1:0];
177
wire      [WB_SLAVES-1:0]   s_wb_cyc                     ;
178
wire      [WB_SLAVES-1:0]   s_wb_stb                     ;
179
wire      [WB_SLAVES-1:0]   s_wb_ack                     ;
180
wire      [WB_SLAVES-1:0]   s_wb_err                     ;
181
 
182
 
183
// ======================================
184
// Interrupts
185
// ======================================
186
wire                        amber_irq;
187
wire                        amber_firq;
188
wire                        ethmac_int;
189
wire                        test_reg_irq;
190
wire                        test_reg_firq;
191
wire                        uart0_int;
192
wire                        uart1_int;
193
wire      [2:0]             timer_int;
194
 
195
 
196
// ======================================
197
// Clocks and Resets Module
198
// ======================================
199
clocks_resets u_clocks_resets (
200
    .i_brd_rst          ( brd_rst           ),
201
    .i_brd_clk_n        ( brd_clk_n         ),
202
    .i_brd_clk_p        ( brd_clk_p         ),
203
    .i_ddr_calib_done   ( phy_init_done     ),
204
    .o_sys_rst          ( sys_rst           ),
205
    .o_sys_clk          ( sys_clk           ),
206
    .o_clk_200          ( clk_200           )
207
);
208
 
209
 
210
// -------------------------------------------------------------
211
// Instantiate Amber Processor Core
212
// -------------------------------------------------------------
213
 
214
amber u_amber (
215
    .i_clk          ( sys_clk         ),
216
 
217
    .i_irq          ( amber_irq       ),
218
    .i_firq         ( amber_firq      ),
219
 
220
    .i_system_rdy   ( phy_init_done   ),
221
 
222
    .o_wb_adr       ( m_wb_adr  [1]   ),
223
    .o_wb_sel       ( m_wb_sel  [1]   ),
224
    .o_wb_we        ( m_wb_we   [1]   ),
225
    .i_wb_dat       ( m_wb_dat_r[1]   ),
226
    .o_wb_dat       ( m_wb_dat_w[1]   ),
227
    .o_wb_cyc       ( m_wb_cyc  [1]   ),
228
    .o_wb_stb       ( m_wb_stb  [1]   ),
229
    .i_wb_ack       ( m_wb_ack  [1]   ),
230
    .i_wb_err       ( m_wb_err  [1]   )
231
);
232
 
233
 
234
// -------------------------------------------------------------
235
// Instantiate B100 Ethernet MAC
236
// -------------------------------------------------------------
237
 
238
eth_top u_eth_top (
239
    .wb_clk_i                   ( sys_clk                ),
240
    .wb_rst_i                   ( sys_rst                ),
241
 
242
    // WISHBONE slave
243
    .wb_adr_i                   ( s_wb_adr   [0][11:2]   ),
244
    .wb_sel_i                   ( s_wb_sel   [0]         ),
245
    .wb_we_i                    ( s_wb_we    [0]         ),
246
    .wb_cyc_i                   ( s_wb_cyc   [0]         ),
247
    .wb_stb_i                   ( s_wb_stb   [0]         ),
248
    .wb_ack_o                   ( s_wb_ack   [0]         ),
249
    .wb_dat_i                   ( s_wb_dat_w [0]         ),
250
    .wb_dat_o                   ( s_wb_dat_r [0]         ),
251
    .wb_err_o                   ( s_wb_err   [0]         ),
252
 
253
    // WISHBONE master
254
    .m_wb_adr_o                 ( m_wb_adr   [0]         ),
255
    .m_wb_sel_o                 ( m_wb_sel   [0]         ),
256
    .m_wb_we_o                  ( m_wb_we    [0]         ),
257
    .m_wb_dat_i                 ( m_wb_dat_r [0]         ),
258
    .m_wb_dat_o                 ( m_wb_dat_w [0]         ),
259
    .m_wb_cyc_o                 ( m_wb_cyc   [0]         ),
260
    .m_wb_stb_o                 ( m_wb_stb   [0]         ),
261
    .m_wb_ack_i                 ( m_wb_ack   [0]         ),
262
    .m_wb_err_i                 ( m_wb_err   [0]         ),
263
 
264
    // MAC to PHY I/F
265
    .mtx_clk_pad_i              ( mtx_clk_pad_i          ),
266
    .mtxd_pad_o                 ( mtxd_pad_o             ),
267
    .mtxen_pad_o                ( mtxen_pad_o            ),
268
    .mtxerr_pad_o               ( mtxerr_pad_o           ),
269
    .mrx_clk_pad_i              ( mrx_clk_pad_i          ),
270
    .mrxd_pad_i                 ( mrxd_pad_i             ),
271
    .mrxdv_pad_i                ( mrxdv_pad_i            ),
272
    .mrxerr_pad_i               ( mrxerr_pad_i           ),
273
    .mcoll_pad_i                ( mcoll_pad_i            ),
274
    .mcrs_pad_i                 ( mcrs_pad_i             ),
275
    .md_pad_i                   ( md_pad_i               ),
276
    .mdc_pad_o                  ( mdc_pad_o              ),
277
    .md_pad_o                   ( md_pad_o               ),
278
    .md_padoe_o                 ( md_padoe_o             ),
279
 
280
    // Interrupt
281
    .int_o                      ( ethmac_int             )
282
);
283
 
284
 
285
 
286
// -------------------------------------------------------------
287
// Instantiate Ethernet Control Interface tri-state buffer
288
// -------------------------------------------------------------
289
`ifdef XILINX_FPGA
290
IOBUF u_iobuf (
291
`else
292
generic_iobuf u_iobuf (
293
`endif
294
    .O                          ( md_pad_i              ),
295
    .IO                         ( md_pad_io             ),
296
    .I                          ( md_pad_o              ),
297
    // T is high for tri-state output
298
    .T                          ( ~md_padoe_o           )
299
);
300
 
301
// Ethernet MII PHY reset
302
assign phy_reset_n = !sys_rst;
303
 
304
 
305
// -------------------------------------------------------------
306
// Instantiate Boot Memory - 8KBytes of Embedded SRAM
307
// -------------------------------------------------------------
308
boot_mem u_boot_mem (
309
    .i_wb_clk               ( sys_clk         ),
310
 
311
    .i_wb_adr               ( s_wb_adr  [1]   ),
312
    .i_wb_sel               ( s_wb_sel  [1]   ),
313
    .i_wb_we                ( s_wb_we   [1]   ),
314
    .o_wb_dat               ( s_wb_dat_r[1]   ),
315
    .i_wb_dat               ( s_wb_dat_w[1]   ),
316
    .i_wb_cyc               ( s_wb_cyc  [1]   ),
317
    .i_wb_stb               ( s_wb_stb  [1]   ),
318
    .o_wb_ack               ( s_wb_ack  [1]   ),
319
    .o_wb_err               ( s_wb_err  [1]   )
320
);
321
 
322
 
323
 
324
// -------------------------------------------------------------
325
// Instantiate UART0
326
// -------------------------------------------------------------
327
uart u_uart0 (
328
    .i_clk                  ( sys_clk        ),
329
 
330
    .o_uart_int             ( uart0_int      ),
331
 
332
    .i_uart_cts_n           ( i_uart0_rts    ),
333
    .o_uart_txd             ( o_uart0_rx     ),
334
    .o_uart_rts_n           ( o_uart0_cts    ),
335
    .i_uart_rxd             ( i_uart0_tx     ),
336
 
337
    .i_wb_adr               ( s_wb_adr  [3]  ),
338
    .i_wb_sel               ( s_wb_sel  [3]  ),
339
    .i_wb_we                ( s_wb_we   [3]  ),
340
    .o_wb_dat               ( s_wb_dat_r[3]  ),
341
    .i_wb_dat               ( s_wb_dat_w[3]  ),
342
    .i_wb_cyc               ( s_wb_cyc  [3]  ),
343
    .i_wb_stb               ( s_wb_stb  [3]  ),
344
    .o_wb_ack               ( s_wb_ack  [3]  ),
345
    .o_wb_err               ( s_wb_err  [3]  )
346
);
347
 
348
 
349
// -------------------------------------------------------------
350
// Instantiate UART1
351
// -------------------------------------------------------------
352
uart u_uart1 (
353
    .i_clk                  ( sys_clk        ),
354
 
355
    .o_uart_int             ( uart1_int      ),
356
 
357
    // These are not connected. ONly pins for 1 UART
358
    // on my development board
359
    .i_uart_cts_n           ( 1'd1           ),
360
    .o_uart_txd             (                ),
361
    .o_uart_rts_n           (                ),
362
    .i_uart_rxd             ( 1'd1           ),
363
 
364
    .i_wb_adr               ( s_wb_adr  [4]  ),
365
    .i_wb_sel               ( s_wb_sel  [4]  ),
366
    .i_wb_we                ( s_wb_we   [4]  ),
367
    .o_wb_dat               ( s_wb_dat_r[4]  ),
368
    .i_wb_dat               ( s_wb_dat_w[4]  ),
369
    .i_wb_cyc               ( s_wb_cyc  [4]  ),
370
    .i_wb_stb               ( s_wb_stb  [4]  ),
371
    .o_wb_ack               ( s_wb_ack  [4]  ),
372
    .o_wb_err               ( s_wb_err  [4]  )
373
);
374
 
375
 
376
// -------------------------------------------------------------
377
// Instantiate Test Module
378
//   - includes register used to terminate tests
379
// -------------------------------------------------------------
380
test_module u_test_module (
381
    .i_clk                  ( sys_clk        ),
382
 
383
    .o_irq                  ( test_reg_irq   ),
384
    .o_firq                 ( test_reg_firq  ),
385
    .i_wb_adr               ( s_wb_adr  [5]  ),
386
    .i_wb_sel               ( s_wb_sel  [5]  ),
387
    .i_wb_we                ( s_wb_we   [5]  ),
388
    .o_wb_dat               ( s_wb_dat_r[5]  ),
389
    .i_wb_dat               ( s_wb_dat_w[5]  ),
390
    .i_wb_cyc               ( s_wb_cyc  [5]  ),
391
    .i_wb_stb               ( s_wb_stb  [5]  ),
392
    .o_wb_ack               ( s_wb_ack  [5]  ),
393
    .o_wb_err               ( s_wb_err  [5]  )
394
);
395
 
396
 
397
// -------------------------------------------------------------
398
// Instantiate Timer Module
399
// -------------------------------------------------------------
400
timer_module u_timer_module (
401
    .i_clk                  ( sys_clk        ),
402
 
403
    // Interrupt outputs
404
    .o_timer_int            ( timer_int      ),
405
 
406
    // Wishbone interface
407
    .i_wb_adr               ( s_wb_adr  [6]  ),
408
    .i_wb_sel               ( s_wb_sel  [6]  ),
409
    .i_wb_we                ( s_wb_we   [6]  ),
410
    .o_wb_dat               ( s_wb_dat_r[6]  ),
411
    .i_wb_dat               ( s_wb_dat_w[6]  ),
412
    .i_wb_cyc               ( s_wb_cyc  [6]  ),
413
    .i_wb_stb               ( s_wb_stb  [6]  ),
414
    .o_wb_ack               ( s_wb_ack  [6]  ),
415
    .o_wb_err               ( s_wb_err  [6]  )
416
);
417
 
418
 
419
// -------------------------------------------------------------
420
// Instantiate Interrupt Controller Module
421
// -------------------------------------------------------------
422
interrupt_controller u_interrupt_controller (
423
    .i_clk                  ( sys_clk        ),
424
 
425
    // Interrupt outputs
426
    .o_irq                  ( amber_irq      ),
427
    .o_firq                 ( amber_firq     ),
428
 
429
    // Interrupt inputs
430
    .i_uart0_int            ( uart0_int      ),
431
    .i_uart1_int            ( uart1_int      ),
432
    .i_ethmac_int           ( ethmac_int     ),
433
    .i_test_reg_irq         ( test_reg_irq   ),
434
    .i_test_reg_firq        ( test_reg_firq  ),
435
    .i_tm_timer_int         ( timer_int      ),
436
 
437
    // Wishbone interface
438
    .i_wb_adr               ( s_wb_adr  [7]  ),
439
    .i_wb_sel               ( s_wb_sel  [7]  ),
440
    .i_wb_we                ( s_wb_we   [7]  ),
441
    .o_wb_dat               ( s_wb_dat_r[7]  ),
442
    .i_wb_dat               ( s_wb_dat_w[7]  ),
443
    .i_wb_cyc               ( s_wb_cyc  [7]  ),
444
    .i_wb_stb               ( s_wb_stb  [7]  ),
445
    .o_wb_ack               ( s_wb_ack  [7]  ),
446
    .o_wb_err               ( s_wb_err  [7]  )
447
);
448
 
449
 
450
 
451
 
452
`ifndef XILINX_FPGA
453
    // ======================================
454
    // Instantiate non-synthesizable main memory model
455
    // ======================================
456
 
457
    assign phy_init_done = 1'd1;
458
 
459
    main_mem u_main_mem (
460
               .i_clk                  ( sys_clk               ),
461
               .i_wb_adr               ( s_wb_adr  [2]         ),
462
               .i_wb_sel               ( s_wb_sel  [2]         ),
463
               .i_wb_we                ( s_wb_we   [2]         ),
464
               .o_wb_dat               ( s_wb_dat_r[2]         ),
465
               .i_wb_dat               ( s_wb_dat_w[2]         ),
466
               .i_wb_cyc               ( s_wb_cyc  [2]         ),
467
               .i_wb_stb               ( s_wb_stb  [2]         ),
468
               .o_wb_ack               ( s_wb_ack  [2]         ),
469
               .o_wb_err               ( s_wb_err  [2]         )
470
            );
471
 
472
`endif
473
 
474
 
475
`ifdef XILINX_SPARTAN6_FPGA
476
    // -------------------------------------------------------------
477
    // Instantiate Wishbone to Xilinx Spartan-6 DDR3 Bridge
478
    // -------------------------------------------------------------
479
    // The clock crossing fifo for spartan-6 is build into the mcb
480
    wb_xs6_ddr3_bridge u_wb_xs6_ddr3_bridge (
481
        .i_clk                  ( sys_clk               ),
482
 
483
        .o_cmd_en               ( c3_p0_cmd_en          ),
484
        .o_cmd_instr            ( c3_p0_cmd_instr       ),
485
        .o_cmd_byte_addr        ( c3_p0_cmd_byte_addr   ),
486
        .i_cmd_full             ( c3_p0_cmd_full        ),
487
        .i_wr_full              ( c3_p0_wr_full         ),
488
        .o_wr_en                ( c3_p0_wr_en           ),
489
        .o_wr_mask              ( c3_p0_wr_mask         ),
490
        .o_wr_data              ( c3_p0_wr_data         ),
491
        .i_rd_data              ( c3_p0_rd_data         ),
492
        .i_rd_empty             ( c3_p0_rd_empty        ),
493
 
494
        .i_wb_adr               ( s_wb_adr  [2]         ),
495
        .i_wb_sel               ( s_wb_sel  [2]         ),
496
        .i_wb_we                ( s_wb_we   [2]         ),
497
        .o_wb_dat               ( s_wb_dat_r[2]         ),
498
        .i_wb_dat               ( s_wb_dat_w[2]         ),
499
        .i_wb_cyc               ( s_wb_cyc  [2]         ),
500
        .i_wb_stb               ( s_wb_stb  [2]         ),
501
        .o_wb_ack               ( s_wb_ack  [2]         ),
502
        .o_wb_err               ( s_wb_err  [2]         )
503
    );
504
 
505
 
506
    // -------------------------------------------------------------
507
    // Instantiate Xilinx Spartan-6 FPGA MCB-DDR3 Controller
508
    // -------------------------------------------------------------
509
    mcb_ddr3 u_mcb_ddr3  (
510
 
511
                // DDR3 signals
512
               .mcb3_dram_dq            ( ddr3_dq               ),
513
               .mcb3_dram_a             ( ddr3_addr             ),
514
               .mcb3_dram_ba            ( ddr3_ba               ),
515
               .mcb3_dram_ras_n         ( ddr3_ras_n            ),
516
               .mcb3_dram_cas_n         ( ddr3_cas_n            ),
517
               .mcb3_dram_we_n          ( ddr3_we_n             ),
518
               .mcb3_dram_odt           ( ddr3_odt              ),
519
               .mcb3_dram_reset_n       ( ddr3_reset_n          ),
520
               .mcb3_dram_cke           ( ddr3_cke              ),
521
               .mcb3_dram_udm           ( ddr3_dm[1]            ),
522
               .mcb3_dram_dm            ( ddr3_dm[0]            ),
523
               .mcb3_rzq                ( mcb3_rzq              ),
524
               .mcb3_zio                ( mcb3_zio              ),
525
               .mcb3_dram_udqs          ( ddr3_dqs_p[1]         ),
526
               .mcb3_dram_dqs           ( ddr3_dqs_p[0]         ),
527
               .mcb3_dram_udqs_n        ( ddr3_dqs_n[1]         ),
528
               .mcb3_dram_dqs_n         ( ddr3_dqs_n[0]         ),
529
               .mcb3_dram_ck            ( ddr3_ck_p             ),
530
               .mcb3_dram_ck_n          ( ddr3_ck_n             ),
531
 
532
               .sys_clk_ibufg           ( clk_200               ),
533
               .c3_sys_rst_n            ( brd_rst               ),
534
 
535
               .c3_calib_done           ( phy_init_done         ),
536
 
537
               .c3_p0_cmd_clk           ( sys_clk               ),
538
 
539
               .c3_p0_cmd_en            ( c3_p0_cmd_en          ),
540
               .c3_p0_cmd_instr         ( c3_p0_cmd_instr       ),
541
               .c3_p0_cmd_bl            ( 6'd0                  ),
542
               .c3_p0_cmd_byte_addr     ( c3_p0_cmd_byte_addr   ),
543
               .c3_p0_cmd_empty         (                       ),
544
               .c3_p0_cmd_full          ( c3_p0_cmd_full        ),
545
 
546
               .c3_p0_wr_clk            ( sys_clk               ),
547
 
548
               .c3_p0_wr_en             ( c3_p0_wr_en           ),
549
               .c3_p0_wr_mask           ( c3_p0_wr_mask         ),
550
               .c3_p0_wr_data           ( c3_p0_wr_data         ),
551
               .c3_p0_wr_full           ( c3_p0_wr_full         ),
552
               .c3_p0_wr_empty          (                       ),
553
               .c3_p0_wr_count          (                       ),
554
               .c3_p0_wr_underrun       (                       ),
555
               .c3_p0_wr_error          (                       ),
556
 
557
               .c3_p0_rd_clk            ( sys_clk               ),
558
 
559
               .c3_p0_rd_en             ( 1'd1                  ),
560
               .c3_p0_rd_data           ( c3_p0_rd_data         ),
561
               .c3_p0_rd_full           (                       ),
562
               .c3_p0_rd_empty          ( c3_p0_rd_empty        ),
563
               .c3_p0_rd_count          (                       ),
564
               .c3_p0_rd_overflow       (                       ),
565
               .c3_p0_rd_error          (                       )
566
       );
567
`endif
568
 
569
 
570
`ifdef XILINX_VIRTEX6_FPGA
571
    // -------------------------------------------------------------
572
    // Instantiate Wishbone to Xilinx Spartan-6 DDR3 Bridge
573
    // -------------------------------------------------------------
574
    // The clock crossing fifo for virtex-6 is insode the bridge
575
    // module
576
    wb_xv6_ddr3_bridge u_wb_xv6_ddr3_bridge (
577
        .i_sys_clk              ( sys_clk               ),
578
        .i_ddr_clk              ( xv6_ddr3_clk          ),
579
 
580
        .o_ddr_cmd_en           ( xv6_cmd_en            ),
581
        .o_ddr_cmd_instr        ( xv6_cmd_instr         ),
582
        .o_ddr_cmd_byte_addr    ( xv6_cmd_byte_addr     ),
583
        .i_ddr_cmd_full         ( xv6_cmd_full          ),
584
 
585
        .i_ddr_wr_full          ( xv6_wr_full           ),
586
        .o_ddr_wr_en            ( xv6_wr_en             ),
587
        .o_ddr_wr_end           ( xv6_wr_end            ),
588
        .o_ddr_wr_mask          ( xv6_wr_mask           ),
589
        .o_ddr_wr_data          ( xv6_wr_data           ),
590
 
591
        .i_ddr_rd_data          ( xv6_rd_data           ),
592
        .i_ddr_rd_valid         ( xv6_rd_data_valid     ),
593
 
594
        .i_phy_init_done        ( phy_init_done1        ),
595
        .o_phy_init_done        ( phy_init_done         ),  // delayed version
596
 
597
        .i_wb_adr               ( s_wb_adr  [2]         ),
598
        .i_wb_sel               ( s_wb_sel  [2]         ),
599
        .i_wb_we                ( s_wb_we   [2]         ),
600
        .o_wb_dat               ( s_wb_dat_r[2]         ),
601
        .i_wb_dat               ( s_wb_dat_w[2]         ),
602
        .i_wb_cyc               ( s_wb_cyc  [2]         ),
603
        .i_wb_stb               ( s_wb_stb  [2]         ),
604
        .o_wb_ack               ( s_wb_ack  [2]         ),
605
        .o_wb_err               ( s_wb_err  [2]         )
606
    );
607
 
608
 
609
    // -------------------------------------------------------------
610
    // Instantiate Xilinx Virtex-6 FPGA DDR3 Controller
611
    // -------------------------------------------------------------
612
    xv6_ddr3
613
    #(          // - Skip the memory initilization sequence,
614
                .SIM_INIT_OPTION        ("SKIP_PU_DLY"              ),
615
                // - Skip the delay Calibration process
616
                .SIM_CAL_OPTION         ("FAST_CAL"                 ),
617
                .RST_ACT_LOW            ( 0                         )
618
                )
619
    u_xv6_ddr3  (
620
                // DDR3 signals
621
                .ddr3_dq                ( ddr3_dq                   ),
622
                .ddr3_addr              ( ddr3_addr                 ),
623
                .ddr3_ba                ( ddr3_ba                   ),
624
                .ddr3_ras_n             ( ddr3_ras_n                ),
625
                .ddr3_cas_n             ( ddr3_cas_n                ),
626
                .ddr3_we_n              ( ddr3_we_n                 ),
627
                .ddr3_odt               ( ddr3_odt                  ),
628
                .ddr3_reset_n           ( ddr3_reset_n              ),
629
                .ddr3_cke               ( ddr3_cke                  ),
630
                .ddr3_dm                ( ddr3_dm                   ),
631
                .ddr3_dqs_p             ( ddr3_dqs_p                ),
632
                .ddr3_dqs_n             ( ddr3_dqs_n                ),
633
                .ddr3_ck_p              ( ddr3_ck_p                 ),
634
                .ddr3_ck_n              ( ddr3_ck_n                 ),
635
                .ddr3_cs_n              ( ddr3_cs_n                 ),
636
 
637
                // DDR clock
638
                .sys_clk_p              ( sys_clk_p                 ),
639
                .sys_clk_n              ( sys_clk_n                 ),
640
                .clk_ref                ( clk_200                   ),
641
                .sys_rst                ( brd_rst                   ),
642
                .tb_rst                 (                           ),
643
                .tb_clk                 ( xv6_ddr3_clk              ),
644
                .phy_init_done          ( phy_init_done1             ),
645
 
646
                .app_en                 ( xv6_cmd_en                ),
647
                .app_cmd                ( xv6_cmd_instr             ),
648
                .tg_addr                ( xv6_cmd_byte_addr         ),
649
                .app_full               ( xv6_cmd_full              ),
650
 
651
                .app_wdf_wren           ( xv6_wr_en                 ),
652
                .app_wdf_mask           ( xv6_wr_mask               ),
653
                .app_wdf_data           ( xv6_wr_data               ),
654
                .app_wdf_end            ( xv6_wr_end                ),
655
                .app_wdf_full           ( xv6_wr_full               ),
656
 
657
                .app_rd_data            ( xv6_rd_data               ),
658
                .app_rd_data_valid      ( xv6_rd_data_valid         )
659
                );
660
 
661
`endif
662
 
663
 
664
 
665
// -------------------------------------------------------------
666
// Instantiate Wishbone Arbiter
667
// -------------------------------------------------------------
668
wishbone_arbiter u_wishbone_arbiter (
669
    .i_wb_clk               ( sys_clk           ),
670
 
671
    // WISHBONE master 0 - Ethmac
672
    .i_m0_wb_adr            ( m_wb_adr   [0]    ),
673
    .i_m0_wb_sel            ( m_wb_sel   [0]    ),
674
    .i_m0_wb_we             ( m_wb_we    [0]    ),
675
    .o_m0_wb_dat            ( m_wb_dat_r [0]    ),
676
    .i_m0_wb_dat            ( m_wb_dat_w [0]    ),
677
    .i_m0_wb_cyc            ( m_wb_cyc   [0]    ),
678
    .i_m0_wb_stb            ( m_wb_stb   [0]    ),
679
    .o_m0_wb_ack            ( m_wb_ack   [0]    ),
680
    .o_m0_wb_err            ( m_wb_err   [0]    ),
681
 
682
 
683
    // WISHBONE master 1 - Amber Process or
684
    .i_m1_wb_adr            ( m_wb_adr   [1]    ),
685
    .i_m1_wb_sel            ( m_wb_sel   [1]    ),
686
    .i_m1_wb_we             ( m_wb_we    [1]    ),
687
    .o_m1_wb_dat            ( m_wb_dat_r [1]    ),
688
    .i_m1_wb_dat            ( m_wb_dat_w [1]    ),
689
    .i_m1_wb_cyc            ( m_wb_cyc   [1]    ),
690
    .i_m1_wb_stb            ( m_wb_stb   [1]    ),
691
    .o_m1_wb_ack            ( m_wb_ack   [1]    ),
692
    .o_m1_wb_err            ( m_wb_err   [1]    ),
693
 
694
 
695
    // WISHBONE slave 0 - Ethmac
696
    .o_s0_wb_adr            ( s_wb_adr   [0]    ),
697
    .o_s0_wb_sel            ( s_wb_sel   [0]    ),
698
    .o_s0_wb_we             ( s_wb_we    [0]    ),
699
    .i_s0_wb_dat            ( s_wb_dat_r [0]    ),
700
    .o_s0_wb_dat            ( s_wb_dat_w [0]    ),
701
    .o_s0_wb_cyc            ( s_wb_cyc   [0]    ),
702
    .o_s0_wb_stb            ( s_wb_stb   [0]    ),
703
    .i_s0_wb_ack            ( s_wb_ack   [0]    ),
704
    .i_s0_wb_err            ( s_wb_err   [0]    ),
705
 
706
 
707
    // WISHBONE slave 1 - Boot Memory
708
    .o_s1_wb_adr            ( s_wb_adr   [1]    ),
709
    .o_s1_wb_sel            ( s_wb_sel   [1]    ),
710
    .o_s1_wb_we             ( s_wb_we    [1]    ),
711
    .i_s1_wb_dat            ( s_wb_dat_r [1]    ),
712
    .o_s1_wb_dat            ( s_wb_dat_w [1]    ),
713
    .o_s1_wb_cyc            ( s_wb_cyc   [1]    ),
714
    .o_s1_wb_stb            ( s_wb_stb   [1]    ),
715
    .i_s1_wb_ack            ( s_wb_ack   [1]    ),
716
    .i_s1_wb_err            ( s_wb_err   [1]    ),
717
 
718
 
719
    // WISHBONE slave 2 - Main Memory
720
    .o_s2_wb_adr            ( s_wb_adr   [2]    ),
721
    .o_s2_wb_sel            ( s_wb_sel   [2]    ),
722
    .o_s2_wb_we             ( s_wb_we    [2]    ),
723
    .i_s2_wb_dat            ( s_wb_dat_r [2]    ),
724
    .o_s2_wb_dat            ( s_wb_dat_w [2]    ),
725
    .o_s2_wb_cyc            ( s_wb_cyc   [2]    ),
726
    .o_s2_wb_stb            ( s_wb_stb   [2]    ),
727
    .i_s2_wb_ack            ( s_wb_ack   [2]    ),
728
    .i_s2_wb_err            ( s_wb_err   [2]    ),
729
 
730
 
731
    // WISHBONE slave 3 - UART 0
732
    .o_s3_wb_adr            ( s_wb_adr   [3]    ),
733
    .o_s3_wb_sel            ( s_wb_sel   [3]    ),
734
    .o_s3_wb_we             ( s_wb_we    [3]    ),
735
    .i_s3_wb_dat            ( s_wb_dat_r [3]    ),
736
    .o_s3_wb_dat            ( s_wb_dat_w [3]    ),
737
    .o_s3_wb_cyc            ( s_wb_cyc   [3]    ),
738
    .o_s3_wb_stb            ( s_wb_stb   [3]    ),
739
    .i_s3_wb_ack            ( s_wb_ack   [3]    ),
740
    .i_s3_wb_err            ( s_wb_err   [3]    ),
741
 
742
 
743
    // WISHBONE slave 4 - UART 1
744
    .o_s4_wb_adr            ( s_wb_adr   [4]    ),
745
    .o_s4_wb_sel            ( s_wb_sel   [4]    ),
746
    .o_s4_wb_we             ( s_wb_we    [4]    ),
747
    .i_s4_wb_dat            ( s_wb_dat_r [4]    ),
748
    .o_s4_wb_dat            ( s_wb_dat_w [4]    ),
749
    .o_s4_wb_cyc            ( s_wb_cyc   [4]    ),
750
    .o_s4_wb_stb            ( s_wb_stb   [4]    ),
751
    .i_s4_wb_ack            ( s_wb_ack   [4]    ),
752
    .i_s4_wb_err            ( s_wb_err   [4]    ),
753
 
754
 
755
    // WISHBONE slave 5 - Test Module
756
    .o_s5_wb_adr            ( s_wb_adr   [5]    ),
757
    .o_s5_wb_sel            ( s_wb_sel   [5]    ),
758
    .o_s5_wb_we             ( s_wb_we    [5]    ),
759
    .i_s5_wb_dat            ( s_wb_dat_r [5]    ),
760
    .o_s5_wb_dat            ( s_wb_dat_w [5]    ),
761
    .o_s5_wb_cyc            ( s_wb_cyc   [5]    ),
762
    .o_s5_wb_stb            ( s_wb_stb   [5]    ),
763
    .i_s5_wb_ack            ( s_wb_ack   [5]    ),
764
    .i_s5_wb_err            ( s_wb_err   [5]    ),
765
 
766
 
767
    // WISHBONE slave 6 - Timer Module
768
    .o_s6_wb_adr            ( s_wb_adr   [6]    ),
769
    .o_s6_wb_sel            ( s_wb_sel   [6]    ),
770
    .o_s6_wb_we             ( s_wb_we    [6]    ),
771
    .i_s6_wb_dat            ( s_wb_dat_r [6]    ),
772
    .o_s6_wb_dat            ( s_wb_dat_w [6]    ),
773
    .o_s6_wb_cyc            ( s_wb_cyc   [6]    ),
774
    .o_s6_wb_stb            ( s_wb_stb   [6]    ),
775
    .i_s6_wb_ack            ( s_wb_ack   [6]    ),
776
    .i_s6_wb_err            ( s_wb_err   [6]    ),
777
 
778
 
779
    // WISHBONE slave 7 - Interrupt Controller
780
    .o_s7_wb_adr            ( s_wb_adr   [7]    ),
781
    .o_s7_wb_sel            ( s_wb_sel   [7]    ),
782
    .o_s7_wb_we             ( s_wb_we    [7]    ),
783
    .i_s7_wb_dat            ( s_wb_dat_r [7]    ),
784
    .o_s7_wb_dat            ( s_wb_dat_w [7]    ),
785
    .o_s7_wb_cyc            ( s_wb_cyc   [7]    ),
786
    .o_s7_wb_stb            ( s_wb_stb   [7]    ),
787
    .i_s7_wb_ack            ( s_wb_ack   [7]    ),
788
    .i_s7_wb_err            ( s_wb_err   [7]    )
789
    );
790
 
791
 
792
 
793
endmodule
794
 

powered by: WebSVN 2.1.0

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