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

Subversion Repositories amber

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

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
 
343 36 csantifort
generate
344
if (WB_DWIDTH == 32) begin : boot_mem32
345
    boot_mem32 u_boot_mem (
346
        .i_wb_clk               ( sys_clk         ),
347
        .i_wb_adr               ( s_wb_adr  [1]   ),
348
        .i_wb_sel               ( s_wb_sel  [1]   ),
349
        .i_wb_we                ( s_wb_we   [1]   ),
350
        .o_wb_dat               ( s_wb_dat_r[1]   ),
351
        .i_wb_dat               ( s_wb_dat_w[1]   ),
352
        .i_wb_cyc               ( s_wb_cyc  [1]   ),
353
        .i_wb_stb               ( s_wb_stb  [1]   ),
354
        .o_wb_ack               ( s_wb_ack  [1]   ),
355
        .o_wb_err               ( s_wb_err  [1]   )
356
    );
357
end
358
else begin : boot_mem128
359
    boot_mem128 u_boot_mem (
360
        .i_wb_clk               ( sys_clk         ),
361
        .i_wb_adr               ( s_wb_adr  [1]   ),
362
        .i_wb_sel               ( s_wb_sel  [1]   ),
363
        .i_wb_we                ( s_wb_we   [1]   ),
364
        .o_wb_dat               ( s_wb_dat_r[1]   ),
365
        .i_wb_dat               ( s_wb_dat_w[1]   ),
366
        .i_wb_cyc               ( s_wb_cyc  [1]   ),
367
        .i_wb_stb               ( s_wb_stb  [1]   ),
368
        .o_wb_ack               ( s_wb_ack  [1]   ),
369
        .o_wb_err               ( s_wb_err  [1]   )
370
    );
371
end
372
endgenerate
373 2 csantifort
 
374
 
375
// -------------------------------------------------------------
376
// Instantiate UART0
377
// -------------------------------------------------------------
378 35 csantifort
uart  #(
379
    .WB_DWIDTH              ( WB_DWIDTH       ),
380
    .WB_SWIDTH              ( WB_SWIDTH       )
381
    )
382
u_uart0 (
383 2 csantifort
    .i_clk                  ( sys_clk        ),
384
 
385
    .o_uart_int             ( uart0_int      ),
386
 
387
    .i_uart_cts_n           ( i_uart0_rts    ),
388
    .o_uart_txd             ( o_uart0_rx     ),
389
    .o_uart_rts_n           ( o_uart0_cts    ),
390
    .i_uart_rxd             ( i_uart0_tx     ),
391
 
392
    .i_wb_adr               ( s_wb_adr  [3]  ),
393
    .i_wb_sel               ( s_wb_sel  [3]  ),
394
    .i_wb_we                ( s_wb_we   [3]  ),
395
    .o_wb_dat               ( s_wb_dat_r[3]  ),
396
    .i_wb_dat               ( s_wb_dat_w[3]  ),
397
    .i_wb_cyc               ( s_wb_cyc  [3]  ),
398
    .i_wb_stb               ( s_wb_stb  [3]  ),
399
    .o_wb_ack               ( s_wb_ack  [3]  ),
400
    .o_wb_err               ( s_wb_err  [3]  )
401
);
402
 
403
 
404
// -------------------------------------------------------------
405
// Instantiate UART1
406
// -------------------------------------------------------------
407 35 csantifort
uart  #(
408
    .WB_DWIDTH              ( WB_DWIDTH       ),
409
    .WB_SWIDTH              ( WB_SWIDTH       )
410
    )
411
u_uart1 (
412 2 csantifort
    .i_clk                  ( sys_clk        ),
413
 
414
    .o_uart_int             ( uart1_int      ),
415
 
416
    // These are not connected. ONly pins for 1 UART
417
    // on my development board
418
    .i_uart_cts_n           ( 1'd1           ),
419
    .o_uart_txd             (                ),
420
    .o_uart_rts_n           (                ),
421
    .i_uart_rxd             ( 1'd1           ),
422
 
423
    .i_wb_adr               ( s_wb_adr  [4]  ),
424
    .i_wb_sel               ( s_wb_sel  [4]  ),
425
    .i_wb_we                ( s_wb_we   [4]  ),
426
    .o_wb_dat               ( s_wb_dat_r[4]  ),
427
    .i_wb_dat               ( s_wb_dat_w[4]  ),
428
    .i_wb_cyc               ( s_wb_cyc  [4]  ),
429
    .i_wb_stb               ( s_wb_stb  [4]  ),
430
    .o_wb_ack               ( s_wb_ack  [4]  ),
431
    .o_wb_err               ( s_wb_err  [4]  )
432
);
433
 
434
 
435
// -------------------------------------------------------------
436
// Instantiate Test Module
437
//   - includes register used to terminate tests
438
// -------------------------------------------------------------
439 35 csantifort
test_module #(
440
    .WB_DWIDTH              ( WB_DWIDTH      ),
441
    .WB_SWIDTH              ( WB_SWIDTH      )
442
    )
443
u_test_module (
444 2 csantifort
    .i_clk                  ( sys_clk        ),
445
 
446
    .o_irq                  ( test_reg_irq   ),
447
    .o_firq                 ( test_reg_firq  ),
448 11 csantifort
    .o_mem_ctrl             ( test_mem_ctrl  ),
449 2 csantifort
    .i_wb_adr               ( s_wb_adr  [5]  ),
450
    .i_wb_sel               ( s_wb_sel  [5]  ),
451
    .i_wb_we                ( s_wb_we   [5]  ),
452
    .o_wb_dat               ( s_wb_dat_r[5]  ),
453
    .i_wb_dat               ( s_wb_dat_w[5]  ),
454
    .i_wb_cyc               ( s_wb_cyc  [5]  ),
455
    .i_wb_stb               ( s_wb_stb  [5]  ),
456
    .o_wb_ack               ( s_wb_ack  [5]  ),
457
    .o_wb_err               ( s_wb_err  [5]  )
458
);
459
 
460
 
461
// -------------------------------------------------------------
462
// Instantiate Timer Module
463
// -------------------------------------------------------------
464 35 csantifort
timer_module  #(
465
    .WB_DWIDTH              ( WB_DWIDTH      ),
466
    .WB_SWIDTH              ( WB_SWIDTH      )
467
    )
468
u_timer_module (
469 2 csantifort
    .i_clk                  ( sys_clk        ),
470
 
471
    // Interrupt outputs
472
    .o_timer_int            ( timer_int      ),
473
 
474
    // Wishbone interface
475
    .i_wb_adr               ( s_wb_adr  [6]  ),
476
    .i_wb_sel               ( s_wb_sel  [6]  ),
477
    .i_wb_we                ( s_wb_we   [6]  ),
478
    .o_wb_dat               ( s_wb_dat_r[6]  ),
479
    .i_wb_dat               ( s_wb_dat_w[6]  ),
480
    .i_wb_cyc               ( s_wb_cyc  [6]  ),
481
    .i_wb_stb               ( s_wb_stb  [6]  ),
482
    .o_wb_ack               ( s_wb_ack  [6]  ),
483
    .o_wb_err               ( s_wb_err  [6]  )
484
);
485
 
486
 
487
// -------------------------------------------------------------
488
// Instantiate Interrupt Controller Module
489
// -------------------------------------------------------------
490 35 csantifort
interrupt_controller  #(
491
    .WB_DWIDTH              ( WB_DWIDTH      ),
492
    .WB_SWIDTH              ( WB_SWIDTH      )
493
    )
494
u_interrupt_controller (
495 2 csantifort
    .i_clk                  ( sys_clk        ),
496
 
497
    // Interrupt outputs
498
    .o_irq                  ( amber_irq      ),
499
    .o_firq                 ( amber_firq     ),
500
 
501
    // Interrupt inputs
502
    .i_uart0_int            ( uart0_int      ),
503
    .i_uart1_int            ( uart1_int      ),
504
    .i_ethmac_int           ( ethmac_int     ),
505
    .i_test_reg_irq         ( test_reg_irq   ),
506
    .i_test_reg_firq        ( test_reg_firq  ),
507
    .i_tm_timer_int         ( timer_int      ),
508
 
509
    // Wishbone interface
510
    .i_wb_adr               ( s_wb_adr  [7]  ),
511
    .i_wb_sel               ( s_wb_sel  [7]  ),
512
    .i_wb_we                ( s_wb_we   [7]  ),
513
    .o_wb_dat               ( s_wb_dat_r[7]  ),
514
    .i_wb_dat               ( s_wb_dat_w[7]  ),
515
    .i_wb_cyc               ( s_wb_cyc  [7]  ),
516
    .i_wb_stb               ( s_wb_stb  [7]  ),
517
    .o_wb_ack               ( s_wb_ack  [7]  ),
518
    .o_wb_err               ( s_wb_err  [7]  )
519
);
520
 
521
 
522
 
523
 
524
`ifndef XILINX_FPGA
525
    // ======================================
526
    // Instantiate non-synthesizable main memory model
527
    // ======================================
528
 
529
    assign phy_init_done = 1'd1;
530
 
531 35 csantifort
    main_mem #(
532
                .WB_DWIDTH             ( WB_DWIDTH             ),
533
                .WB_SWIDTH             ( WB_SWIDTH             )
534
                )
535
    u_main_mem (
536 2 csantifort
               .i_clk                  ( sys_clk               ),
537 11 csantifort
               .i_mem_ctrl             ( test_mem_ctrl         ),
538 2 csantifort
               .i_wb_adr               ( s_wb_adr  [2]         ),
539
               .i_wb_sel               ( s_wb_sel  [2]         ),
540
               .i_wb_we                ( s_wb_we   [2]         ),
541
               .o_wb_dat               ( s_wb_dat_r[2]         ),
542
               .i_wb_dat               ( s_wb_dat_w[2]         ),
543
               .i_wb_cyc               ( s_wb_cyc  [2]         ),
544
               .i_wb_stb               ( s_wb_stb  [2]         ),
545
               .o_wb_ack               ( s_wb_ack  [2]         ),
546
               .o_wb_err               ( s_wb_err  [2]         )
547
            );
548
 
549
`endif
550
 
551
 
552
`ifdef XILINX_SPARTAN6_FPGA
553
    // -------------------------------------------------------------
554
    // Instantiate Wishbone to Xilinx Spartan-6 DDR3 Bridge
555
    // -------------------------------------------------------------
556
    // The clock crossing fifo for spartan-6 is build into the mcb
557 36 csantifort
    wb_xs6_ddr3_bridge   #(
558
        .WB_DWIDTH              ( WB_DWIDTH             ),
559
        .WB_SWIDTH              ( WB_SWIDTH             )
560
        )
561
    u_wb_xs6_ddr3_bridge(
562 2 csantifort
        .i_clk                  ( sys_clk               ),
563
 
564
        .o_cmd_en               ( c3_p0_cmd_en          ),
565
        .o_cmd_instr            ( c3_p0_cmd_instr       ),
566
        .o_cmd_byte_addr        ( c3_p0_cmd_byte_addr   ),
567
        .i_cmd_full             ( c3_p0_cmd_full        ),
568
        .i_wr_full              ( c3_p0_wr_full         ),
569
        .o_wr_en                ( c3_p0_wr_en           ),
570
        .o_wr_mask              ( c3_p0_wr_mask         ),
571
        .o_wr_data              ( c3_p0_wr_data         ),
572
        .i_rd_data              ( c3_p0_rd_data         ),
573
        .i_rd_empty             ( c3_p0_rd_empty        ),
574
 
575 11 csantifort
        .i_mem_ctrl             ( test_mem_ctrl         ),
576 2 csantifort
        .i_wb_adr               ( s_wb_adr  [2]         ),
577
        .i_wb_sel               ( s_wb_sel  [2]         ),
578
        .i_wb_we                ( s_wb_we   [2]         ),
579
        .o_wb_dat               ( s_wb_dat_r[2]         ),
580
        .i_wb_dat               ( s_wb_dat_w[2]         ),
581
        .i_wb_cyc               ( s_wb_cyc  [2]         ),
582
        .i_wb_stb               ( s_wb_stb  [2]         ),
583
        .o_wb_ack               ( s_wb_ack  [2]         ),
584
        .o_wb_err               ( s_wb_err  [2]         )
585
    );
586
 
587
 
588
    // -------------------------------------------------------------
589
    // Instantiate Xilinx Spartan-6 FPGA MCB-DDR3 Controller
590
    // -------------------------------------------------------------
591
    mcb_ddr3 u_mcb_ddr3  (
592
 
593
                // DDR3 signals
594
               .mcb3_dram_dq            ( ddr3_dq               ),
595
               .mcb3_dram_a             ( ddr3_addr             ),
596
               .mcb3_dram_ba            ( ddr3_ba               ),
597
               .mcb3_dram_ras_n         ( ddr3_ras_n            ),
598
               .mcb3_dram_cas_n         ( ddr3_cas_n            ),
599
               .mcb3_dram_we_n          ( ddr3_we_n             ),
600
               .mcb3_dram_odt           ( ddr3_odt              ),
601
               .mcb3_dram_reset_n       ( ddr3_reset_n          ),
602
               .mcb3_dram_cke           ( ddr3_cke              ),
603
               .mcb3_dram_udm           ( ddr3_dm[1]            ),
604
               .mcb3_dram_dm            ( ddr3_dm[0]            ),
605
               .mcb3_rzq                ( mcb3_rzq              ),
606
               .mcb3_zio                ( mcb3_zio              ),
607
               .mcb3_dram_udqs          ( ddr3_dqs_p[1]         ),
608
               .mcb3_dram_dqs           ( ddr3_dqs_p[0]         ),
609
               .mcb3_dram_udqs_n        ( ddr3_dqs_n[1]         ),
610
               .mcb3_dram_dqs_n         ( ddr3_dqs_n[0]         ),
611
               .mcb3_dram_ck            ( ddr3_ck_p             ),
612
               .mcb3_dram_ck_n          ( ddr3_ck_n             ),
613
 
614
               .sys_clk_ibufg           ( clk_200               ),
615
               .c3_sys_rst_n            ( brd_rst               ),
616
 
617
               .c3_calib_done           ( phy_init_done         ),
618
 
619
               .c3_p0_cmd_clk           ( sys_clk               ),
620
 
621
               .c3_p0_cmd_en            ( c3_p0_cmd_en          ),
622
               .c3_p0_cmd_instr         ( c3_p0_cmd_instr       ),
623
               .c3_p0_cmd_bl            ( 6'd0                  ),
624
               .c3_p0_cmd_byte_addr     ( c3_p0_cmd_byte_addr   ),
625
               .c3_p0_cmd_empty         (                       ),
626
               .c3_p0_cmd_full          ( c3_p0_cmd_full        ),
627
 
628
               .c3_p0_wr_clk            ( sys_clk               ),
629
 
630
               .c3_p0_wr_en             ( c3_p0_wr_en           ),
631
               .c3_p0_wr_mask           ( c3_p0_wr_mask         ),
632
               .c3_p0_wr_data           ( c3_p0_wr_data         ),
633
               .c3_p0_wr_full           ( c3_p0_wr_full         ),
634
               .c3_p0_wr_empty          (                       ),
635
               .c3_p0_wr_count          (                       ),
636
               .c3_p0_wr_underrun       (                       ),
637
               .c3_p0_wr_error          (                       ),
638
 
639
               .c3_p0_rd_clk            ( sys_clk               ),
640
 
641
               .c3_p0_rd_en             ( 1'd1                  ),
642
               .c3_p0_rd_data           ( c3_p0_rd_data         ),
643
               .c3_p0_rd_full           (                       ),
644
               .c3_p0_rd_empty          ( c3_p0_rd_empty        ),
645
               .c3_p0_rd_count          (                       ),
646
               .c3_p0_rd_overflow       (                       ),
647
               .c3_p0_rd_error          (                       )
648
       );
649
`endif
650
 
651
 
652
`ifdef XILINX_VIRTEX6_FPGA
653
    // -------------------------------------------------------------
654
    // Instantiate Wishbone to Xilinx Spartan-6 DDR3 Bridge
655
    // -------------------------------------------------------------
656
    // The clock crossing fifo for virtex-6 is insode the bridge
657
    // module
658 38 csantifort
    wb_xv6_ddr3_bridge    #(
659
        .WB_DWIDTH              ( WB_DWIDTH             ),
660
        .WB_SWIDTH              ( WB_SWIDTH             )
661
        )
662
    u_wb_xv6_ddr3_bridge (
663 2 csantifort
        .i_sys_clk              ( sys_clk               ),
664
        .i_ddr_clk              ( xv6_ddr3_clk          ),
665
 
666
        .o_ddr_cmd_en           ( xv6_cmd_en            ),
667
        .o_ddr_cmd_instr        ( xv6_cmd_instr         ),
668
        .o_ddr_cmd_byte_addr    ( xv6_cmd_byte_addr     ),
669
        .i_ddr_cmd_full         ( xv6_cmd_full          ),
670
 
671
        .i_ddr_wr_full          ( xv6_wr_full           ),
672
        .o_ddr_wr_en            ( xv6_wr_en             ),
673
        .o_ddr_wr_end           ( xv6_wr_end            ),
674
        .o_ddr_wr_mask          ( xv6_wr_mask           ),
675
        .o_ddr_wr_data          ( xv6_wr_data           ),
676
 
677
        .i_ddr_rd_data          ( xv6_rd_data           ),
678
        .i_ddr_rd_valid         ( xv6_rd_data_valid     ),
679
 
680
        .i_phy_init_done        ( phy_init_done1        ),
681
        .o_phy_init_done        ( phy_init_done         ),  // delayed version
682
 
683 11 csantifort
        .i_mem_ctrl             ( test_mem_ctrl         ),
684 2 csantifort
        .i_wb_adr               ( s_wb_adr  [2]         ),
685
        .i_wb_sel               ( s_wb_sel  [2]         ),
686
        .i_wb_we                ( s_wb_we   [2]         ),
687
        .o_wb_dat               ( s_wb_dat_r[2]         ),
688
        .i_wb_dat               ( s_wb_dat_w[2]         ),
689
        .i_wb_cyc               ( s_wb_cyc  [2]         ),
690
        .i_wb_stb               ( s_wb_stb  [2]         ),
691
        .o_wb_ack               ( s_wb_ack  [2]         ),
692
        .o_wb_err               ( s_wb_err  [2]         )
693
    );
694
 
695
 
696
    // -------------------------------------------------------------
697
    // Instantiate Xilinx Virtex-6 FPGA DDR3 Controller
698
    // -------------------------------------------------------------
699
    xv6_ddr3
700
    #(          // - Skip the memory initilization sequence,
701
                .SIM_INIT_OPTION        ("SKIP_PU_DLY"              ),
702
                // - Skip the delay Calibration process
703
                .SIM_CAL_OPTION         ("FAST_CAL"                 ),
704
                .RST_ACT_LOW            ( 0                         )
705
                )
706
    u_xv6_ddr3  (
707
                // DDR3 signals
708
                .ddr3_dq                ( ddr3_dq                   ),
709
                .ddr3_addr              ( ddr3_addr                 ),
710
                .ddr3_ba                ( ddr3_ba                   ),
711
                .ddr3_ras_n             ( ddr3_ras_n                ),
712
                .ddr3_cas_n             ( ddr3_cas_n                ),
713
                .ddr3_we_n              ( ddr3_we_n                 ),
714
                .ddr3_odt               ( ddr3_odt                  ),
715
                .ddr3_reset_n           ( ddr3_reset_n              ),
716
                .ddr3_cke               ( ddr3_cke                  ),
717
                .ddr3_dm                ( ddr3_dm                   ),
718
                .ddr3_dqs_p             ( ddr3_dqs_p                ),
719
                .ddr3_dqs_n             ( ddr3_dqs_n                ),
720
                .ddr3_ck_p              ( ddr3_ck_p                 ),
721
                .ddr3_ck_n              ( ddr3_ck_n                 ),
722
                .ddr3_cs_n              ( ddr3_cs_n                 ),
723
 
724
                // DDR clock
725
                .sys_clk_p              ( sys_clk_p                 ),
726
                .sys_clk_n              ( sys_clk_n                 ),
727
                .clk_ref                ( clk_200                   ),
728
                .sys_rst                ( brd_rst                   ),
729
                .tb_rst                 (                           ),
730
                .tb_clk                 ( xv6_ddr3_clk              ),
731
                .phy_init_done          ( phy_init_done1             ),
732
 
733
                .app_en                 ( xv6_cmd_en                ),
734
                .app_cmd                ( xv6_cmd_instr             ),
735
                .tg_addr                ( xv6_cmd_byte_addr         ),
736
                .app_full               ( xv6_cmd_full              ),
737
 
738
                .app_wdf_wren           ( xv6_wr_en                 ),
739
                .app_wdf_mask           ( xv6_wr_mask               ),
740
                .app_wdf_data           ( xv6_wr_data               ),
741
                .app_wdf_end            ( xv6_wr_end                ),
742
                .app_wdf_full           ( xv6_wr_full               ),
743
 
744
                .app_rd_data            ( xv6_rd_data               ),
745
                .app_rd_data_valid      ( xv6_rd_data_valid         )
746
                );
747
 
748
`endif
749
 
750
 
751
 
752
// -------------------------------------------------------------
753
// Instantiate Wishbone Arbiter
754
// -------------------------------------------------------------
755 35 csantifort
wishbone_arbiter #(
756
    .WB_DWIDTH              ( WB_DWIDTH         ),
757
    .WB_SWIDTH              ( WB_SWIDTH         )
758
    )
759
u_wishbone_arbiter (
760 2 csantifort
    .i_wb_clk               ( sys_clk           ),
761
 
762
    // WISHBONE master 0 - Ethmac
763
    .i_m0_wb_adr            ( m_wb_adr   [0]    ),
764
    .i_m0_wb_sel            ( m_wb_sel   [0]    ),
765
    .i_m0_wb_we             ( m_wb_we    [0]    ),
766
    .o_m0_wb_dat            ( m_wb_dat_r [0]    ),
767
    .i_m0_wb_dat            ( m_wb_dat_w [0]    ),
768
    .i_m0_wb_cyc            ( m_wb_cyc   [0]    ),
769
    .i_m0_wb_stb            ( m_wb_stb   [0]    ),
770
    .o_m0_wb_ack            ( m_wb_ack   [0]    ),
771
    .o_m0_wb_err            ( m_wb_err   [0]    ),
772
 
773
 
774
    // WISHBONE master 1 - Amber Process or
775
    .i_m1_wb_adr            ( m_wb_adr   [1]    ),
776
    .i_m1_wb_sel            ( m_wb_sel   [1]    ),
777
    .i_m1_wb_we             ( m_wb_we    [1]    ),
778
    .o_m1_wb_dat            ( m_wb_dat_r [1]    ),
779
    .i_m1_wb_dat            ( m_wb_dat_w [1]    ),
780
    .i_m1_wb_cyc            ( m_wb_cyc   [1]    ),
781
    .i_m1_wb_stb            ( m_wb_stb   [1]    ),
782
    .o_m1_wb_ack            ( m_wb_ack   [1]    ),
783
    .o_m1_wb_err            ( m_wb_err   [1]    ),
784
 
785
 
786
    // WISHBONE slave 0 - Ethmac
787
    .o_s0_wb_adr            ( s_wb_adr   [0]    ),
788
    .o_s0_wb_sel            ( s_wb_sel   [0]    ),
789
    .o_s0_wb_we             ( s_wb_we    [0]    ),
790
    .i_s0_wb_dat            ( s_wb_dat_r [0]    ),
791
    .o_s0_wb_dat            ( s_wb_dat_w [0]    ),
792
    .o_s0_wb_cyc            ( s_wb_cyc   [0]    ),
793
    .o_s0_wb_stb            ( s_wb_stb   [0]    ),
794
    .i_s0_wb_ack            ( s_wb_ack   [0]    ),
795
    .i_s0_wb_err            ( s_wb_err   [0]    ),
796
 
797
 
798
    // WISHBONE slave 1 - Boot Memory
799
    .o_s1_wb_adr            ( s_wb_adr   [1]    ),
800
    .o_s1_wb_sel            ( s_wb_sel   [1]    ),
801
    .o_s1_wb_we             ( s_wb_we    [1]    ),
802
    .i_s1_wb_dat            ( s_wb_dat_r [1]    ),
803
    .o_s1_wb_dat            ( s_wb_dat_w [1]    ),
804
    .o_s1_wb_cyc            ( s_wb_cyc   [1]    ),
805
    .o_s1_wb_stb            ( s_wb_stb   [1]    ),
806
    .i_s1_wb_ack            ( s_wb_ack   [1]    ),
807
    .i_s1_wb_err            ( s_wb_err   [1]    ),
808
 
809
 
810
    // WISHBONE slave 2 - Main Memory
811
    .o_s2_wb_adr            ( s_wb_adr   [2]    ),
812
    .o_s2_wb_sel            ( s_wb_sel   [2]    ),
813
    .o_s2_wb_we             ( s_wb_we    [2]    ),
814
    .i_s2_wb_dat            ( s_wb_dat_r [2]    ),
815
    .o_s2_wb_dat            ( s_wb_dat_w [2]    ),
816
    .o_s2_wb_cyc            ( s_wb_cyc   [2]    ),
817
    .o_s2_wb_stb            ( s_wb_stb   [2]    ),
818
    .i_s2_wb_ack            ( s_wb_ack   [2]    ),
819
    .i_s2_wb_err            ( s_wb_err   [2]    ),
820
 
821
 
822
    // WISHBONE slave 3 - UART 0
823
    .o_s3_wb_adr            ( s_wb_adr   [3]    ),
824
    .o_s3_wb_sel            ( s_wb_sel   [3]    ),
825
    .o_s3_wb_we             ( s_wb_we    [3]    ),
826
    .i_s3_wb_dat            ( s_wb_dat_r [3]    ),
827
    .o_s3_wb_dat            ( s_wb_dat_w [3]    ),
828
    .o_s3_wb_cyc            ( s_wb_cyc   [3]    ),
829
    .o_s3_wb_stb            ( s_wb_stb   [3]    ),
830
    .i_s3_wb_ack            ( s_wb_ack   [3]    ),
831
    .i_s3_wb_err            ( s_wb_err   [3]    ),
832
 
833
 
834
    // WISHBONE slave 4 - UART 1
835
    .o_s4_wb_adr            ( s_wb_adr   [4]    ),
836
    .o_s4_wb_sel            ( s_wb_sel   [4]    ),
837
    .o_s4_wb_we             ( s_wb_we    [4]    ),
838
    .i_s4_wb_dat            ( s_wb_dat_r [4]    ),
839
    .o_s4_wb_dat            ( s_wb_dat_w [4]    ),
840
    .o_s4_wb_cyc            ( s_wb_cyc   [4]    ),
841
    .o_s4_wb_stb            ( s_wb_stb   [4]    ),
842
    .i_s4_wb_ack            ( s_wb_ack   [4]    ),
843
    .i_s4_wb_err            ( s_wb_err   [4]    ),
844
 
845
 
846
    // WISHBONE slave 5 - Test Module
847
    .o_s5_wb_adr            ( s_wb_adr   [5]    ),
848
    .o_s5_wb_sel            ( s_wb_sel   [5]    ),
849
    .o_s5_wb_we             ( s_wb_we    [5]    ),
850
    .i_s5_wb_dat            ( s_wb_dat_r [5]    ),
851
    .o_s5_wb_dat            ( s_wb_dat_w [5]    ),
852
    .o_s5_wb_cyc            ( s_wb_cyc   [5]    ),
853
    .o_s5_wb_stb            ( s_wb_stb   [5]    ),
854
    .i_s5_wb_ack            ( s_wb_ack   [5]    ),
855
    .i_s5_wb_err            ( s_wb_err   [5]    ),
856
 
857
 
858
    // WISHBONE slave 6 - Timer Module
859
    .o_s6_wb_adr            ( s_wb_adr   [6]    ),
860
    .o_s6_wb_sel            ( s_wb_sel   [6]    ),
861
    .o_s6_wb_we             ( s_wb_we    [6]    ),
862
    .i_s6_wb_dat            ( s_wb_dat_r [6]    ),
863
    .o_s6_wb_dat            ( s_wb_dat_w [6]    ),
864
    .o_s6_wb_cyc            ( s_wb_cyc   [6]    ),
865
    .o_s6_wb_stb            ( s_wb_stb   [6]    ),
866
    .i_s6_wb_ack            ( s_wb_ack   [6]    ),
867
    .i_s6_wb_err            ( s_wb_err   [6]    ),
868
 
869
 
870
    // WISHBONE slave 7 - Interrupt Controller
871
    .o_s7_wb_adr            ( s_wb_adr   [7]    ),
872
    .o_s7_wb_sel            ( s_wb_sel   [7]    ),
873
    .o_s7_wb_we             ( s_wb_we    [7]    ),
874
    .i_s7_wb_dat            ( s_wb_dat_r [7]    ),
875
    .o_s7_wb_dat            ( s_wb_dat_w [7]    ),
876
    .o_s7_wb_cyc            ( s_wb_cyc   [7]    ),
877
    .o_s7_wb_stb            ( s_wb_stb   [7]    ),
878
    .i_s7_wb_ack            ( s_wb_ack   [7]    ),
879
    .i_s7_wb_err            ( s_wb_err   [7]    )
880
    );
881
 
882
 
883 35 csantifort
ethmac_wb #(
884
    .WB_DWIDTH              ( WB_DWIDTH         ),
885
    .WB_SWIDTH              ( WB_SWIDTH         )
886
    )
887
u_ethmac_wb (
888
    // Wishbone arbiter side
889
    .o_m_wb_adr             ( m_wb_adr   [0]    ),
890
    .o_m_wb_sel             ( m_wb_sel   [0]    ),
891
    .o_m_wb_we              ( m_wb_we    [0]    ),
892
    .i_m_wb_rdat            ( m_wb_dat_r [0]    ),
893
    .o_m_wb_wdat            ( m_wb_dat_w [0]    ),
894
    .o_m_wb_cyc             ( m_wb_cyc   [0]    ),
895
    .o_m_wb_stb             ( m_wb_stb   [0]    ),
896
    .i_m_wb_ack             ( m_wb_ack   [0]    ),
897
    .i_m_wb_err             ( m_wb_err   [0]    ),
898 2 csantifort
 
899 35 csantifort
    // Wishbone arbiter side
900
    .i_s_wb_adr             ( s_wb_adr   [0]    ),
901
    .i_s_wb_sel             ( s_wb_sel   [0]    ),
902
    .i_s_wb_we              ( s_wb_we    [0]    ),
903
    .i_s_wb_cyc             ( s_wb_cyc   [0]    ),
904
    .i_s_wb_stb             ( s_wb_stb   [0]    ),
905
    .o_s_wb_ack             ( s_wb_ack   [0]    ),
906
    .i_s_wb_wdat            ( s_wb_dat_w [0]    ),
907
    .o_s_wb_rdat            ( s_wb_dat_r [0]    ),
908
    .o_s_wb_err             ( s_wb_err   [0]    ),
909
 
910
    // Ethmac side
911
    .i_m_wb_adr             ( emm_wb_adr        ),
912
    .i_m_wb_sel             ( emm_wb_sel        ),
913
    .i_m_wb_we              ( emm_wb_we         ),
914
    .o_m_wb_rdat            ( emm_wb_rdat       ),
915
    .i_m_wb_wdat            ( emm_wb_wdat       ),
916
    .i_m_wb_cyc             ( emm_wb_cyc        ),
917
    .i_m_wb_stb             ( emm_wb_stb        ),
918
    .o_m_wb_ack             ( emm_wb_ack        ),
919
    .o_m_wb_err             ( emm_wb_err        ),
920
 
921
    // Ethmac side
922
    .o_s_wb_adr             ( ems_wb_adr        ),
923
    .o_s_wb_sel             ( ems_wb_sel        ),
924
    .o_s_wb_we              ( ems_wb_we         ),
925
    .i_s_wb_rdat            ( ems_wb_rdat       ),
926
    .o_s_wb_wdat            ( ems_wb_wdat       ),
927
    .o_s_wb_cyc             ( ems_wb_cyc        ),
928
    .o_s_wb_stb             ( ems_wb_stb        ),
929
    .i_s_wb_ack             ( ems_wb_ack        ),
930
    .i_s_wb_err             ( ems_wb_err        )
931
);
932
 
933
 
934
 
935
 
936 2 csantifort
endmodule
937
 
938 35 csantifort
 

powered by: WebSVN 2.1.0

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