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

Subversion Repositories amber

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

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 11 csantifort
wire            test_mem_ctrl;
125 15 csantifort
wire            system_rdy;
126 2 csantifort
 
127
// ======================================
128
// Xilinx Virtex-6 DDR3 Controller connections
129
// ======================================
130
`ifdef XILINX_VIRTEX6_FPGA
131
wire            phy_init_done1;
132
wire            xv6_cmd_en;
133
wire  [2:0]     xv6_cmd_instr;
134
wire  [26:0]    xv6_cmd_byte_addr;
135
wire            xv6_cmd_full;
136
wire            xv6_wr_full;
137
wire            xv6_wr_en;
138
wire            xv6_wr_end;
139
wire  [7:0]     xv6_wr_mask;
140
wire  [63:0]    xv6_wr_data;
141
wire  [63:0]    xv6_rd_data;
142
wire            xv6_rd_data_valid;
143
wire            xv6_ddr3_clk;
144
`endif
145
 
146
// ======================================
147
// Ethmac MII
148
// ======================================
149
wire            md_pad_i;
150
wire            md_pad_o;
151
wire            md_padoe_o;
152
 
153
// ======================================
154
// Wishbone Buses
155
// ======================================
156
 
157
localparam WB_MASTERS = 2;
158
localparam WB_SLAVES  = 9;
159
 
160 35 csantifort
`ifdef AMBER_A25_CORE
161
localparam WB_DWIDTH  = 128;
162
localparam WB_SWIDTH  = 16;
163
`else
164
localparam WB_DWIDTH  = 32;
165
localparam WB_SWIDTH  = 4;
166
`endif
167 2 csantifort
 
168 35 csantifort
 
169 2 csantifort
// Wishbone Master Buses
170
wire      [31:0]            m_wb_adr      [WB_MASTERS-1:0];
171 35 csantifort
wire      [WB_SWIDTH-1:0]   m_wb_sel      [WB_MASTERS-1:0];
172 2 csantifort
wire      [WB_MASTERS-1:0]  m_wb_we                       ;
173 35 csantifort
wire      [WB_DWIDTH-1:0]   m_wb_dat_w    [WB_MASTERS-1:0];
174
wire      [WB_DWIDTH-1:0]   m_wb_dat_r    [WB_MASTERS-1:0];
175 2 csantifort
wire      [WB_MASTERS-1:0]  m_wb_cyc                      ;
176
wire      [WB_MASTERS-1:0]  m_wb_stb                      ;
177
wire      [WB_MASTERS-1:0]  m_wb_ack                      ;
178
wire      [WB_MASTERS-1:0]  m_wb_err                      ;
179
 
180
 
181
// Wishbone Slave Buses
182
wire      [31:0]            s_wb_adr      [WB_SLAVES-1:0];
183 35 csantifort
wire      [WB_SWIDTH-1:0]   s_wb_sel      [WB_SLAVES-1:0];
184 2 csantifort
wire      [WB_SLAVES-1:0]   s_wb_we                      ;
185 35 csantifort
wire      [WB_DWIDTH-1:0]   s_wb_dat_w    [WB_SLAVES-1:0];
186
wire      [WB_DWIDTH-1:0]   s_wb_dat_r    [WB_SLAVES-1:0];
187 2 csantifort
wire      [WB_SLAVES-1:0]   s_wb_cyc                     ;
188
wire      [WB_SLAVES-1:0]   s_wb_stb                     ;
189
wire      [WB_SLAVES-1:0]   s_wb_ack                     ;
190
wire      [WB_SLAVES-1:0]   s_wb_err                     ;
191
 
192 35 csantifort
wire      [31:0]            emm_wb_adr;
193
wire      [3:0]             emm_wb_sel;
194
wire                        emm_wb_we;
195
wire      [31:0]            emm_wb_rdat;
196
wire      [31:0]            emm_wb_wdat;
197
wire                        emm_wb_cyc;
198
wire                        emm_wb_stb;
199
wire                        emm_wb_ack;
200
wire                        emm_wb_err;
201 2 csantifort
 
202 35 csantifort
wire      [31:0]            ems_wb_adr;
203
wire      [3:0]             ems_wb_sel;
204
wire                        ems_wb_we;
205
wire      [31:0]            ems_wb_rdat;
206
wire      [31:0]            ems_wb_wdat;
207
wire                        ems_wb_cyc;
208
wire                        ems_wb_stb;
209
wire                        ems_wb_ack;
210
wire                        ems_wb_err;
211
 
212
 
213 2 csantifort
// ======================================
214
// Interrupts
215
// ======================================
216
wire                        amber_irq;
217
wire                        amber_firq;
218
wire                        ethmac_int;
219
wire                        test_reg_irq;
220
wire                        test_reg_firq;
221
wire                        uart0_int;
222
wire                        uart1_int;
223
wire      [2:0]             timer_int;
224
 
225
 
226
// ======================================
227
// Clocks and Resets Module
228
// ======================================
229
clocks_resets u_clocks_resets (
230
    .i_brd_rst          ( brd_rst           ),
231
    .i_brd_clk_n        ( brd_clk_n         ),
232
    .i_brd_clk_p        ( brd_clk_p         ),
233
    .i_ddr_calib_done   ( phy_init_done     ),
234
    .o_sys_rst          ( sys_rst           ),
235
    .o_sys_clk          ( sys_clk           ),
236
    .o_clk_200          ( clk_200           )
237
);
238
 
239
 
240
// -------------------------------------------------------------
241
// Instantiate Amber Processor Core
242
// -------------------------------------------------------------
243 15 csantifort
`ifdef AMBER_A25_CORE
244
a25_core u_amber (
245
`else
246
a23_core u_amber (
247
`endif
248 2 csantifort
    .i_clk          ( sys_clk         ),
249
 
250
    .i_irq          ( amber_irq       ),
251
    .i_firq         ( amber_firq      ),
252
 
253 15 csantifort
    .i_system_rdy   ( system_rdy      ),
254 2 csantifort
 
255
    .o_wb_adr       ( m_wb_adr  [1]   ),
256
    .o_wb_sel       ( m_wb_sel  [1]   ),
257
    .o_wb_we        ( m_wb_we   [1]   ),
258
    .i_wb_dat       ( m_wb_dat_r[1]   ),
259
    .o_wb_dat       ( m_wb_dat_w[1]   ),
260
    .o_wb_cyc       ( m_wb_cyc  [1]   ),
261
    .o_wb_stb       ( m_wb_stb  [1]   ),
262
    .i_wb_ack       ( m_wb_ack  [1]   ),
263
    .i_wb_err       ( m_wb_err  [1]   )
264
);
265
 
266
 
267
// -------------------------------------------------------------
268
// Instantiate B100 Ethernet MAC
269
// -------------------------------------------------------------
270 35 csantifort
 
271 2 csantifort
eth_top u_eth_top (
272
    .wb_clk_i                   ( sys_clk                ),
273
    .wb_rst_i                   ( sys_rst                ),
274
 
275
    // WISHBONE slave
276 35 csantifort
    .wb_adr_i                   ( ems_wb_adr [11:2]      ),
277
    .wb_sel_i                   ( ems_wb_sel             ),
278
    .wb_we_i                    ( ems_wb_we              ),
279
    .wb_cyc_i                   ( ems_wb_cyc             ),
280
    .wb_stb_i                   ( ems_wb_stb             ),
281
    .wb_ack_o                   ( ems_wb_ack             ),
282
    .wb_dat_i                   ( ems_wb_wdat            ),
283
    .wb_dat_o                   ( ems_wb_rdat            ),
284
    .wb_err_o                   ( ems_wb_err             ),
285 2 csantifort
 
286
    // WISHBONE master
287 35 csantifort
    .m_wb_adr_o                 ( emm_wb_adr             ),
288
    .m_wb_sel_o                 ( emm_wb_sel             ),
289
    .m_wb_we_o                  ( emm_wb_we              ),
290
    .m_wb_dat_i                 ( emm_wb_rdat            ),
291
    .m_wb_dat_o                 ( emm_wb_wdat            ),
292
    .m_wb_cyc_o                 ( emm_wb_cyc             ),
293
    .m_wb_stb_o                 ( emm_wb_stb             ),
294
    .m_wb_ack_i                 ( emm_wb_ack             ),
295
    .m_wb_err_i                 ( emm_wb_err             ),
296 2 csantifort
 
297
    // MAC to PHY I/F
298
    .mtx_clk_pad_i              ( mtx_clk_pad_i          ),
299
    .mtxd_pad_o                 ( mtxd_pad_o             ),
300
    .mtxen_pad_o                ( mtxen_pad_o            ),
301
    .mtxerr_pad_o               ( mtxerr_pad_o           ),
302
    .mrx_clk_pad_i              ( mrx_clk_pad_i          ),
303
    .mrxd_pad_i                 ( mrxd_pad_i             ),
304
    .mrxdv_pad_i                ( mrxdv_pad_i            ),
305
    .mrxerr_pad_i               ( mrxerr_pad_i           ),
306
    .mcoll_pad_i                ( mcoll_pad_i            ),
307
    .mcrs_pad_i                 ( mcrs_pad_i             ),
308
    .md_pad_i                   ( md_pad_i               ),
309
    .mdc_pad_o                  ( mdc_pad_o              ),
310
    .md_pad_o                   ( md_pad_o               ),
311
    .md_padoe_o                 ( md_padoe_o             ),
312
 
313
    // Interrupt
314
    .int_o                      ( ethmac_int             )
315
);
316
 
317
 
318
// -------------------------------------------------------------
319
// Instantiate Ethernet Control Interface tri-state buffer
320
// -------------------------------------------------------------
321
`ifdef XILINX_FPGA
322
IOBUF u_iobuf (
323
`else
324
generic_iobuf u_iobuf (
325
`endif
326
    .O                          ( md_pad_i              ),
327
    .IO                         ( md_pad_io             ),
328
    .I                          ( md_pad_o              ),
329
    // T is high for tri-state output
330
    .T                          ( ~md_padoe_o           )
331
);
332
 
333
// Ethernet MII PHY reset
334
assign phy_reset_n = !sys_rst;
335
 
336 15 csantifort
// Halt core until system is ready
337
assign system_rdy = phy_init_done && !sys_rst;
338 2 csantifort
 
339
// -------------------------------------------------------------
340
// Instantiate Boot Memory - 8KBytes of Embedded SRAM
341
// -------------------------------------------------------------
342 35 csantifort
boot_mem #(
343
    .WB_DWIDTH              ( WB_DWIDTH       ),
344
    .WB_SWIDTH              ( WB_SWIDTH       )
345
    )
346
u_boot_mem (
347 2 csantifort
    .i_wb_clk               ( sys_clk         ),
348
 
349
    .i_wb_adr               ( s_wb_adr  [1]   ),
350
    .i_wb_sel               ( s_wb_sel  [1]   ),
351
    .i_wb_we                ( s_wb_we   [1]   ),
352
    .o_wb_dat               ( s_wb_dat_r[1]   ),
353
    .i_wb_dat               ( s_wb_dat_w[1]   ),
354
    .i_wb_cyc               ( s_wb_cyc  [1]   ),
355
    .i_wb_stb               ( s_wb_stb  [1]   ),
356
    .o_wb_ack               ( s_wb_ack  [1]   ),
357
    .o_wb_err               ( s_wb_err  [1]   )
358
);
359
 
360
 
361
// -------------------------------------------------------------
362
// Instantiate UART0
363
// -------------------------------------------------------------
364 35 csantifort
uart  #(
365
    .WB_DWIDTH              ( WB_DWIDTH       ),
366
    .WB_SWIDTH              ( WB_SWIDTH       )
367
    )
368
u_uart0 (
369 2 csantifort
    .i_clk                  ( sys_clk        ),
370
 
371
    .o_uart_int             ( uart0_int      ),
372
 
373
    .i_uart_cts_n           ( i_uart0_rts    ),
374
    .o_uart_txd             ( o_uart0_rx     ),
375
    .o_uart_rts_n           ( o_uart0_cts    ),
376
    .i_uart_rxd             ( i_uart0_tx     ),
377
 
378
    .i_wb_adr               ( s_wb_adr  [3]  ),
379
    .i_wb_sel               ( s_wb_sel  [3]  ),
380
    .i_wb_we                ( s_wb_we   [3]  ),
381
    .o_wb_dat               ( s_wb_dat_r[3]  ),
382
    .i_wb_dat               ( s_wb_dat_w[3]  ),
383
    .i_wb_cyc               ( s_wb_cyc  [3]  ),
384
    .i_wb_stb               ( s_wb_stb  [3]  ),
385
    .o_wb_ack               ( s_wb_ack  [3]  ),
386
    .o_wb_err               ( s_wb_err  [3]  )
387
);
388
 
389
 
390
// -------------------------------------------------------------
391
// Instantiate UART1
392
// -------------------------------------------------------------
393 35 csantifort
uart  #(
394
    .WB_DWIDTH              ( WB_DWIDTH       ),
395
    .WB_SWIDTH              ( WB_SWIDTH       )
396
    )
397
u_uart1 (
398 2 csantifort
    .i_clk                  ( sys_clk        ),
399
 
400
    .o_uart_int             ( uart1_int      ),
401
 
402
    // These are not connected. ONly pins for 1 UART
403
    // on my development board
404
    .i_uart_cts_n           ( 1'd1           ),
405
    .o_uart_txd             (                ),
406
    .o_uart_rts_n           (                ),
407
    .i_uart_rxd             ( 1'd1           ),
408
 
409
    .i_wb_adr               ( s_wb_adr  [4]  ),
410
    .i_wb_sel               ( s_wb_sel  [4]  ),
411
    .i_wb_we                ( s_wb_we   [4]  ),
412
    .o_wb_dat               ( s_wb_dat_r[4]  ),
413
    .i_wb_dat               ( s_wb_dat_w[4]  ),
414
    .i_wb_cyc               ( s_wb_cyc  [4]  ),
415
    .i_wb_stb               ( s_wb_stb  [4]  ),
416
    .o_wb_ack               ( s_wb_ack  [4]  ),
417
    .o_wb_err               ( s_wb_err  [4]  )
418
);
419
 
420
 
421
// -------------------------------------------------------------
422
// Instantiate Test Module
423
//   - includes register used to terminate tests
424
// -------------------------------------------------------------
425 35 csantifort
test_module #(
426
    .WB_DWIDTH              ( WB_DWIDTH      ),
427
    .WB_SWIDTH              ( WB_SWIDTH      )
428
    )
429
u_test_module (
430 2 csantifort
    .i_clk                  ( sys_clk        ),
431
 
432
    .o_irq                  ( test_reg_irq   ),
433
    .o_firq                 ( test_reg_firq  ),
434 11 csantifort
    .o_mem_ctrl             ( test_mem_ctrl  ),
435 2 csantifort
    .i_wb_adr               ( s_wb_adr  [5]  ),
436
    .i_wb_sel               ( s_wb_sel  [5]  ),
437
    .i_wb_we                ( s_wb_we   [5]  ),
438
    .o_wb_dat               ( s_wb_dat_r[5]  ),
439
    .i_wb_dat               ( s_wb_dat_w[5]  ),
440
    .i_wb_cyc               ( s_wb_cyc  [5]  ),
441
    .i_wb_stb               ( s_wb_stb  [5]  ),
442
    .o_wb_ack               ( s_wb_ack  [5]  ),
443
    .o_wb_err               ( s_wb_err  [5]  )
444
);
445
 
446
 
447
// -------------------------------------------------------------
448
// Instantiate Timer Module
449
// -------------------------------------------------------------
450 35 csantifort
timer_module  #(
451
    .WB_DWIDTH              ( WB_DWIDTH      ),
452
    .WB_SWIDTH              ( WB_SWIDTH      )
453
    )
454
u_timer_module (
455 2 csantifort
    .i_clk                  ( sys_clk        ),
456
 
457
    // Interrupt outputs
458
    .o_timer_int            ( timer_int      ),
459
 
460
    // Wishbone interface
461
    .i_wb_adr               ( s_wb_adr  [6]  ),
462
    .i_wb_sel               ( s_wb_sel  [6]  ),
463
    .i_wb_we                ( s_wb_we   [6]  ),
464
    .o_wb_dat               ( s_wb_dat_r[6]  ),
465
    .i_wb_dat               ( s_wb_dat_w[6]  ),
466
    .i_wb_cyc               ( s_wb_cyc  [6]  ),
467
    .i_wb_stb               ( s_wb_stb  [6]  ),
468
    .o_wb_ack               ( s_wb_ack  [6]  ),
469
    .o_wb_err               ( s_wb_err  [6]  )
470
);
471
 
472
 
473
// -------------------------------------------------------------
474
// Instantiate Interrupt Controller Module
475
// -------------------------------------------------------------
476 35 csantifort
interrupt_controller  #(
477
    .WB_DWIDTH              ( WB_DWIDTH      ),
478
    .WB_SWIDTH              ( WB_SWIDTH      )
479
    )
480
u_interrupt_controller (
481 2 csantifort
    .i_clk                  ( sys_clk        ),
482
 
483
    // Interrupt outputs
484
    .o_irq                  ( amber_irq      ),
485
    .o_firq                 ( amber_firq     ),
486
 
487
    // Interrupt inputs
488
    .i_uart0_int            ( uart0_int      ),
489
    .i_uart1_int            ( uart1_int      ),
490
    .i_ethmac_int           ( ethmac_int     ),
491
    .i_test_reg_irq         ( test_reg_irq   ),
492
    .i_test_reg_firq        ( test_reg_firq  ),
493
    .i_tm_timer_int         ( timer_int      ),
494
 
495
    // Wishbone interface
496
    .i_wb_adr               ( s_wb_adr  [7]  ),
497
    .i_wb_sel               ( s_wb_sel  [7]  ),
498
    .i_wb_we                ( s_wb_we   [7]  ),
499
    .o_wb_dat               ( s_wb_dat_r[7]  ),
500
    .i_wb_dat               ( s_wb_dat_w[7]  ),
501
    .i_wb_cyc               ( s_wb_cyc  [7]  ),
502
    .i_wb_stb               ( s_wb_stb  [7]  ),
503
    .o_wb_ack               ( s_wb_ack  [7]  ),
504
    .o_wb_err               ( s_wb_err  [7]  )
505
);
506
 
507
 
508
 
509
 
510
`ifndef XILINX_FPGA
511
    // ======================================
512
    // Instantiate non-synthesizable main memory model
513
    // ======================================
514
 
515
    assign phy_init_done = 1'd1;
516
 
517 35 csantifort
    main_mem #(
518
                .WB_DWIDTH             ( WB_DWIDTH             ),
519
                .WB_SWIDTH             ( WB_SWIDTH             )
520
                )
521
    u_main_mem (
522 2 csantifort
               .i_clk                  ( sys_clk               ),
523 11 csantifort
               .i_mem_ctrl             ( test_mem_ctrl         ),
524 2 csantifort
               .i_wb_adr               ( s_wb_adr  [2]         ),
525
               .i_wb_sel               ( s_wb_sel  [2]         ),
526
               .i_wb_we                ( s_wb_we   [2]         ),
527
               .o_wb_dat               ( s_wb_dat_r[2]         ),
528
               .i_wb_dat               ( s_wb_dat_w[2]         ),
529
               .i_wb_cyc               ( s_wb_cyc  [2]         ),
530
               .i_wb_stb               ( s_wb_stb  [2]         ),
531
               .o_wb_ack               ( s_wb_ack  [2]         ),
532
               .o_wb_err               ( s_wb_err  [2]         )
533
            );
534
 
535
`endif
536
 
537
 
538
`ifdef XILINX_SPARTAN6_FPGA
539
    // -------------------------------------------------------------
540
    // Instantiate Wishbone to Xilinx Spartan-6 DDR3 Bridge
541
    // -------------------------------------------------------------
542
    // The clock crossing fifo for spartan-6 is build into the mcb
543
    wb_xs6_ddr3_bridge u_wb_xs6_ddr3_bridge (
544
        .i_clk                  ( sys_clk               ),
545
 
546
        .o_cmd_en               ( c3_p0_cmd_en          ),
547
        .o_cmd_instr            ( c3_p0_cmd_instr       ),
548
        .o_cmd_byte_addr        ( c3_p0_cmd_byte_addr   ),
549
        .i_cmd_full             ( c3_p0_cmd_full        ),
550
        .i_wr_full              ( c3_p0_wr_full         ),
551
        .o_wr_en                ( c3_p0_wr_en           ),
552
        .o_wr_mask              ( c3_p0_wr_mask         ),
553
        .o_wr_data              ( c3_p0_wr_data         ),
554
        .i_rd_data              ( c3_p0_rd_data         ),
555
        .i_rd_empty             ( c3_p0_rd_empty        ),
556
 
557 11 csantifort
        .i_mem_ctrl             ( test_mem_ctrl         ),
558 2 csantifort
        .i_wb_adr               ( s_wb_adr  [2]         ),
559
        .i_wb_sel               ( s_wb_sel  [2]         ),
560
        .i_wb_we                ( s_wb_we   [2]         ),
561
        .o_wb_dat               ( s_wb_dat_r[2]         ),
562
        .i_wb_dat               ( s_wb_dat_w[2]         ),
563
        .i_wb_cyc               ( s_wb_cyc  [2]         ),
564
        .i_wb_stb               ( s_wb_stb  [2]         ),
565
        .o_wb_ack               ( s_wb_ack  [2]         ),
566
        .o_wb_err               ( s_wb_err  [2]         )
567
    );
568
 
569
 
570
    // -------------------------------------------------------------
571
    // Instantiate Xilinx Spartan-6 FPGA MCB-DDR3 Controller
572
    // -------------------------------------------------------------
573
    mcb_ddr3 u_mcb_ddr3  (
574
 
575
                // DDR3 signals
576
               .mcb3_dram_dq            ( ddr3_dq               ),
577
               .mcb3_dram_a             ( ddr3_addr             ),
578
               .mcb3_dram_ba            ( ddr3_ba               ),
579
               .mcb3_dram_ras_n         ( ddr3_ras_n            ),
580
               .mcb3_dram_cas_n         ( ddr3_cas_n            ),
581
               .mcb3_dram_we_n          ( ddr3_we_n             ),
582
               .mcb3_dram_odt           ( ddr3_odt              ),
583
               .mcb3_dram_reset_n       ( ddr3_reset_n          ),
584
               .mcb3_dram_cke           ( ddr3_cke              ),
585
               .mcb3_dram_udm           ( ddr3_dm[1]            ),
586
               .mcb3_dram_dm            ( ddr3_dm[0]            ),
587
               .mcb3_rzq                ( mcb3_rzq              ),
588
               .mcb3_zio                ( mcb3_zio              ),
589
               .mcb3_dram_udqs          ( ddr3_dqs_p[1]         ),
590
               .mcb3_dram_dqs           ( ddr3_dqs_p[0]         ),
591
               .mcb3_dram_udqs_n        ( ddr3_dqs_n[1]         ),
592
               .mcb3_dram_dqs_n         ( ddr3_dqs_n[0]         ),
593
               .mcb3_dram_ck            ( ddr3_ck_p             ),
594
               .mcb3_dram_ck_n          ( ddr3_ck_n             ),
595
 
596
               .sys_clk_ibufg           ( clk_200               ),
597
               .c3_sys_rst_n            ( brd_rst               ),
598
 
599
               .c3_calib_done           ( phy_init_done         ),
600
 
601
               .c3_p0_cmd_clk           ( sys_clk               ),
602
 
603
               .c3_p0_cmd_en            ( c3_p0_cmd_en          ),
604
               .c3_p0_cmd_instr         ( c3_p0_cmd_instr       ),
605
               .c3_p0_cmd_bl            ( 6'd0                  ),
606
               .c3_p0_cmd_byte_addr     ( c3_p0_cmd_byte_addr   ),
607
               .c3_p0_cmd_empty         (                       ),
608
               .c3_p0_cmd_full          ( c3_p0_cmd_full        ),
609
 
610
               .c3_p0_wr_clk            ( sys_clk               ),
611
 
612
               .c3_p0_wr_en             ( c3_p0_wr_en           ),
613
               .c3_p0_wr_mask           ( c3_p0_wr_mask         ),
614
               .c3_p0_wr_data           ( c3_p0_wr_data         ),
615
               .c3_p0_wr_full           ( c3_p0_wr_full         ),
616
               .c3_p0_wr_empty          (                       ),
617
               .c3_p0_wr_count          (                       ),
618
               .c3_p0_wr_underrun       (                       ),
619
               .c3_p0_wr_error          (                       ),
620
 
621
               .c3_p0_rd_clk            ( sys_clk               ),
622
 
623
               .c3_p0_rd_en             ( 1'd1                  ),
624
               .c3_p0_rd_data           ( c3_p0_rd_data         ),
625
               .c3_p0_rd_full           (                       ),
626
               .c3_p0_rd_empty          ( c3_p0_rd_empty        ),
627
               .c3_p0_rd_count          (                       ),
628
               .c3_p0_rd_overflow       (                       ),
629
               .c3_p0_rd_error          (                       )
630
       );
631
`endif
632
 
633
 
634
`ifdef XILINX_VIRTEX6_FPGA
635
    // -------------------------------------------------------------
636
    // Instantiate Wishbone to Xilinx Spartan-6 DDR3 Bridge
637
    // -------------------------------------------------------------
638
    // The clock crossing fifo for virtex-6 is insode the bridge
639
    // module
640
    wb_xv6_ddr3_bridge u_wb_xv6_ddr3_bridge (
641
        .i_sys_clk              ( sys_clk               ),
642
        .i_ddr_clk              ( xv6_ddr3_clk          ),
643
 
644
        .o_ddr_cmd_en           ( xv6_cmd_en            ),
645
        .o_ddr_cmd_instr        ( xv6_cmd_instr         ),
646
        .o_ddr_cmd_byte_addr    ( xv6_cmd_byte_addr     ),
647
        .i_ddr_cmd_full         ( xv6_cmd_full          ),
648
 
649
        .i_ddr_wr_full          ( xv6_wr_full           ),
650
        .o_ddr_wr_en            ( xv6_wr_en             ),
651
        .o_ddr_wr_end           ( xv6_wr_end            ),
652
        .o_ddr_wr_mask          ( xv6_wr_mask           ),
653
        .o_ddr_wr_data          ( xv6_wr_data           ),
654
 
655
        .i_ddr_rd_data          ( xv6_rd_data           ),
656
        .i_ddr_rd_valid         ( xv6_rd_data_valid     ),
657
 
658
        .i_phy_init_done        ( phy_init_done1        ),
659
        .o_phy_init_done        ( phy_init_done         ),  // delayed version
660
 
661 11 csantifort
        .i_mem_ctrl             ( test_mem_ctrl         ),
662 2 csantifort
        .i_wb_adr               ( s_wb_adr  [2]         ),
663
        .i_wb_sel               ( s_wb_sel  [2]         ),
664
        .i_wb_we                ( s_wb_we   [2]         ),
665
        .o_wb_dat               ( s_wb_dat_r[2]         ),
666
        .i_wb_dat               ( s_wb_dat_w[2]         ),
667
        .i_wb_cyc               ( s_wb_cyc  [2]         ),
668
        .i_wb_stb               ( s_wb_stb  [2]         ),
669
        .o_wb_ack               ( s_wb_ack  [2]         ),
670
        .o_wb_err               ( s_wb_err  [2]         )
671
    );
672
 
673
 
674
    // -------------------------------------------------------------
675
    // Instantiate Xilinx Virtex-6 FPGA DDR3 Controller
676
    // -------------------------------------------------------------
677
    xv6_ddr3
678
    #(          // - Skip the memory initilization sequence,
679
                .SIM_INIT_OPTION        ("SKIP_PU_DLY"              ),
680
                // - Skip the delay Calibration process
681
                .SIM_CAL_OPTION         ("FAST_CAL"                 ),
682
                .RST_ACT_LOW            ( 0                         )
683
                )
684
    u_xv6_ddr3  (
685
                // DDR3 signals
686
                .ddr3_dq                ( ddr3_dq                   ),
687
                .ddr3_addr              ( ddr3_addr                 ),
688
                .ddr3_ba                ( ddr3_ba                   ),
689
                .ddr3_ras_n             ( ddr3_ras_n                ),
690
                .ddr3_cas_n             ( ddr3_cas_n                ),
691
                .ddr3_we_n              ( ddr3_we_n                 ),
692
                .ddr3_odt               ( ddr3_odt                  ),
693
                .ddr3_reset_n           ( ddr3_reset_n              ),
694
                .ddr3_cke               ( ddr3_cke                  ),
695
                .ddr3_dm                ( ddr3_dm                   ),
696
                .ddr3_dqs_p             ( ddr3_dqs_p                ),
697
                .ddr3_dqs_n             ( ddr3_dqs_n                ),
698
                .ddr3_ck_p              ( ddr3_ck_p                 ),
699
                .ddr3_ck_n              ( ddr3_ck_n                 ),
700
                .ddr3_cs_n              ( ddr3_cs_n                 ),
701
 
702
                // DDR clock
703
                .sys_clk_p              ( sys_clk_p                 ),
704
                .sys_clk_n              ( sys_clk_n                 ),
705
                .clk_ref                ( clk_200                   ),
706
                .sys_rst                ( brd_rst                   ),
707
                .tb_rst                 (                           ),
708
                .tb_clk                 ( xv6_ddr3_clk              ),
709
                .phy_init_done          ( phy_init_done1             ),
710
 
711
                .app_en                 ( xv6_cmd_en                ),
712
                .app_cmd                ( xv6_cmd_instr             ),
713
                .tg_addr                ( xv6_cmd_byte_addr         ),
714
                .app_full               ( xv6_cmd_full              ),
715
 
716
                .app_wdf_wren           ( xv6_wr_en                 ),
717
                .app_wdf_mask           ( xv6_wr_mask               ),
718
                .app_wdf_data           ( xv6_wr_data               ),
719
                .app_wdf_end            ( xv6_wr_end                ),
720
                .app_wdf_full           ( xv6_wr_full               ),
721
 
722
                .app_rd_data            ( xv6_rd_data               ),
723
                .app_rd_data_valid      ( xv6_rd_data_valid         )
724
                );
725
 
726
`endif
727
 
728
 
729
 
730
// -------------------------------------------------------------
731
// Instantiate Wishbone Arbiter
732
// -------------------------------------------------------------
733 35 csantifort
wishbone_arbiter #(
734
    .WB_DWIDTH              ( WB_DWIDTH         ),
735
    .WB_SWIDTH              ( WB_SWIDTH         )
736
    )
737
u_wishbone_arbiter (
738 2 csantifort
    .i_wb_clk               ( sys_clk           ),
739
 
740
    // WISHBONE master 0 - Ethmac
741
    .i_m0_wb_adr            ( m_wb_adr   [0]    ),
742
    .i_m0_wb_sel            ( m_wb_sel   [0]    ),
743
    .i_m0_wb_we             ( m_wb_we    [0]    ),
744
    .o_m0_wb_dat            ( m_wb_dat_r [0]    ),
745
    .i_m0_wb_dat            ( m_wb_dat_w [0]    ),
746
    .i_m0_wb_cyc            ( m_wb_cyc   [0]    ),
747
    .i_m0_wb_stb            ( m_wb_stb   [0]    ),
748
    .o_m0_wb_ack            ( m_wb_ack   [0]    ),
749
    .o_m0_wb_err            ( m_wb_err   [0]    ),
750
 
751
 
752
    // WISHBONE master 1 - Amber Process or
753
    .i_m1_wb_adr            ( m_wb_adr   [1]    ),
754
    .i_m1_wb_sel            ( m_wb_sel   [1]    ),
755
    .i_m1_wb_we             ( m_wb_we    [1]    ),
756
    .o_m1_wb_dat            ( m_wb_dat_r [1]    ),
757
    .i_m1_wb_dat            ( m_wb_dat_w [1]    ),
758
    .i_m1_wb_cyc            ( m_wb_cyc   [1]    ),
759
    .i_m1_wb_stb            ( m_wb_stb   [1]    ),
760
    .o_m1_wb_ack            ( m_wb_ack   [1]    ),
761
    .o_m1_wb_err            ( m_wb_err   [1]    ),
762
 
763
 
764
    // WISHBONE slave 0 - Ethmac
765
    .o_s0_wb_adr            ( s_wb_adr   [0]    ),
766
    .o_s0_wb_sel            ( s_wb_sel   [0]    ),
767
    .o_s0_wb_we             ( s_wb_we    [0]    ),
768
    .i_s0_wb_dat            ( s_wb_dat_r [0]    ),
769
    .o_s0_wb_dat            ( s_wb_dat_w [0]    ),
770
    .o_s0_wb_cyc            ( s_wb_cyc   [0]    ),
771
    .o_s0_wb_stb            ( s_wb_stb   [0]    ),
772
    .i_s0_wb_ack            ( s_wb_ack   [0]    ),
773
    .i_s0_wb_err            ( s_wb_err   [0]    ),
774
 
775
 
776
    // WISHBONE slave 1 - Boot Memory
777
    .o_s1_wb_adr            ( s_wb_adr   [1]    ),
778
    .o_s1_wb_sel            ( s_wb_sel   [1]    ),
779
    .o_s1_wb_we             ( s_wb_we    [1]    ),
780
    .i_s1_wb_dat            ( s_wb_dat_r [1]    ),
781
    .o_s1_wb_dat            ( s_wb_dat_w [1]    ),
782
    .o_s1_wb_cyc            ( s_wb_cyc   [1]    ),
783
    .o_s1_wb_stb            ( s_wb_stb   [1]    ),
784
    .i_s1_wb_ack            ( s_wb_ack   [1]    ),
785
    .i_s1_wb_err            ( s_wb_err   [1]    ),
786
 
787
 
788
    // WISHBONE slave 2 - Main Memory
789
    .o_s2_wb_adr            ( s_wb_adr   [2]    ),
790
    .o_s2_wb_sel            ( s_wb_sel   [2]    ),
791
    .o_s2_wb_we             ( s_wb_we    [2]    ),
792
    .i_s2_wb_dat            ( s_wb_dat_r [2]    ),
793
    .o_s2_wb_dat            ( s_wb_dat_w [2]    ),
794
    .o_s2_wb_cyc            ( s_wb_cyc   [2]    ),
795
    .o_s2_wb_stb            ( s_wb_stb   [2]    ),
796
    .i_s2_wb_ack            ( s_wb_ack   [2]    ),
797
    .i_s2_wb_err            ( s_wb_err   [2]    ),
798
 
799
 
800
    // WISHBONE slave 3 - UART 0
801
    .o_s3_wb_adr            ( s_wb_adr   [3]    ),
802
    .o_s3_wb_sel            ( s_wb_sel   [3]    ),
803
    .o_s3_wb_we             ( s_wb_we    [3]    ),
804
    .i_s3_wb_dat            ( s_wb_dat_r [3]    ),
805
    .o_s3_wb_dat            ( s_wb_dat_w [3]    ),
806
    .o_s3_wb_cyc            ( s_wb_cyc   [3]    ),
807
    .o_s3_wb_stb            ( s_wb_stb   [3]    ),
808
    .i_s3_wb_ack            ( s_wb_ack   [3]    ),
809
    .i_s3_wb_err            ( s_wb_err   [3]    ),
810
 
811
 
812
    // WISHBONE slave 4 - UART 1
813
    .o_s4_wb_adr            ( s_wb_adr   [4]    ),
814
    .o_s4_wb_sel            ( s_wb_sel   [4]    ),
815
    .o_s4_wb_we             ( s_wb_we    [4]    ),
816
    .i_s4_wb_dat            ( s_wb_dat_r [4]    ),
817
    .o_s4_wb_dat            ( s_wb_dat_w [4]    ),
818
    .o_s4_wb_cyc            ( s_wb_cyc   [4]    ),
819
    .o_s4_wb_stb            ( s_wb_stb   [4]    ),
820
    .i_s4_wb_ack            ( s_wb_ack   [4]    ),
821
    .i_s4_wb_err            ( s_wb_err   [4]    ),
822
 
823
 
824
    // WISHBONE slave 5 - Test Module
825
    .o_s5_wb_adr            ( s_wb_adr   [5]    ),
826
    .o_s5_wb_sel            ( s_wb_sel   [5]    ),
827
    .o_s5_wb_we             ( s_wb_we    [5]    ),
828
    .i_s5_wb_dat            ( s_wb_dat_r [5]    ),
829
    .o_s5_wb_dat            ( s_wb_dat_w [5]    ),
830
    .o_s5_wb_cyc            ( s_wb_cyc   [5]    ),
831
    .o_s5_wb_stb            ( s_wb_stb   [5]    ),
832
    .i_s5_wb_ack            ( s_wb_ack   [5]    ),
833
    .i_s5_wb_err            ( s_wb_err   [5]    ),
834
 
835
 
836
    // WISHBONE slave 6 - Timer Module
837
    .o_s6_wb_adr            ( s_wb_adr   [6]    ),
838
    .o_s6_wb_sel            ( s_wb_sel   [6]    ),
839
    .o_s6_wb_we             ( s_wb_we    [6]    ),
840
    .i_s6_wb_dat            ( s_wb_dat_r [6]    ),
841
    .o_s6_wb_dat            ( s_wb_dat_w [6]    ),
842
    .o_s6_wb_cyc            ( s_wb_cyc   [6]    ),
843
    .o_s6_wb_stb            ( s_wb_stb   [6]    ),
844
    .i_s6_wb_ack            ( s_wb_ack   [6]    ),
845
    .i_s6_wb_err            ( s_wb_err   [6]    ),
846
 
847
 
848
    // WISHBONE slave 7 - Interrupt Controller
849
    .o_s7_wb_adr            ( s_wb_adr   [7]    ),
850
    .o_s7_wb_sel            ( s_wb_sel   [7]    ),
851
    .o_s7_wb_we             ( s_wb_we    [7]    ),
852
    .i_s7_wb_dat            ( s_wb_dat_r [7]    ),
853
    .o_s7_wb_dat            ( s_wb_dat_w [7]    ),
854
    .o_s7_wb_cyc            ( s_wb_cyc   [7]    ),
855
    .o_s7_wb_stb            ( s_wb_stb   [7]    ),
856
    .i_s7_wb_ack            ( s_wb_ack   [7]    ),
857
    .i_s7_wb_err            ( s_wb_err   [7]    )
858
    );
859
 
860
 
861 35 csantifort
ethmac_wb #(
862
    .WB_DWIDTH              ( WB_DWIDTH         ),
863
    .WB_SWIDTH              ( WB_SWIDTH         )
864
    )
865
u_ethmac_wb (
866
    // Wishbone arbiter side
867
    .o_m_wb_adr             ( m_wb_adr   [0]    ),
868
    .o_m_wb_sel             ( m_wb_sel   [0]    ),
869
    .o_m_wb_we              ( m_wb_we    [0]    ),
870
    .i_m_wb_rdat            ( m_wb_dat_r [0]    ),
871
    .o_m_wb_wdat            ( m_wb_dat_w [0]    ),
872
    .o_m_wb_cyc             ( m_wb_cyc   [0]    ),
873
    .o_m_wb_stb             ( m_wb_stb   [0]    ),
874
    .i_m_wb_ack             ( m_wb_ack   [0]    ),
875
    .i_m_wb_err             ( m_wb_err   [0]    ),
876 2 csantifort
 
877 35 csantifort
    // Wishbone arbiter side
878
    .i_s_wb_adr             ( s_wb_adr   [0]    ),
879
    .i_s_wb_sel             ( s_wb_sel   [0]    ),
880
    .i_s_wb_we              ( s_wb_we    [0]    ),
881
    .i_s_wb_cyc             ( s_wb_cyc   [0]    ),
882
    .i_s_wb_stb             ( s_wb_stb   [0]    ),
883
    .o_s_wb_ack             ( s_wb_ack   [0]    ),
884
    .i_s_wb_wdat            ( s_wb_dat_w [0]    ),
885
    .o_s_wb_rdat            ( s_wb_dat_r [0]    ),
886
    .o_s_wb_err             ( s_wb_err   [0]    ),
887
 
888
    // Ethmac side
889
    .i_m_wb_adr             ( emm_wb_adr        ),
890
    .i_m_wb_sel             ( emm_wb_sel        ),
891
    .i_m_wb_we              ( emm_wb_we         ),
892
    .o_m_wb_rdat            ( emm_wb_rdat       ),
893
    .i_m_wb_wdat            ( emm_wb_wdat       ),
894
    .i_m_wb_cyc             ( emm_wb_cyc        ),
895
    .i_m_wb_stb             ( emm_wb_stb        ),
896
    .o_m_wb_ack             ( emm_wb_ack        ),
897
    .o_m_wb_err             ( emm_wb_err        ),
898
 
899
    // Ethmac side
900
    .o_s_wb_adr             ( ems_wb_adr        ),
901
    .o_s_wb_sel             ( ems_wb_sel        ),
902
    .o_s_wb_we              ( ems_wb_we         ),
903
    .i_s_wb_rdat            ( ems_wb_rdat       ),
904
    .o_s_wb_wdat            ( ems_wb_wdat       ),
905
    .o_s_wb_cyc             ( ems_wb_cyc        ),
906
    .o_s_wb_stb             ( ems_wb_stb        ),
907
    .i_s_wb_ack             ( ems_wb_ack        ),
908
    .i_s_wb_err             ( ems_wb_err        )
909
);
910
 
911
 
912
 
913
 
914 2 csantifort
endmodule
915
 
916 35 csantifort
 

powered by: WebSVN 2.1.0

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