OpenCores
URL https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [hdl/] [boardsupport/] [v5/] [v5_emac_v1_6_block.v] - Blame information for rev 9

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

Line No. Rev Author Line
1 2 peteralieb
//-----------------------------------------------------------------------------
2
// Title      : Virtex-5 Ethernet MAC Wrapper Top Level
3
// Project    : Virtex-5 Ethernet MAC Wrappers
4
//-----------------------------------------------------------------------------
5
// File       : v5_emac_v1_6_block.v
6
//-----------------------------------------------------------------------------
7
// Copyright (c) 2004-2008 by Xilinx, Inc. All rights reserved.
8
// This text/file contains proprietary, confidential
9
// information of Xilinx, Inc., is distributed under license
10
// from Xilinx, Inc., and may be used, copied and/or
11
// disclosed only pursuant to the terms of a valid license
12
// agreement with Xilinx, Inc. Xilinx hereby grants you
13
// a license to use this text/file solely for design, simulation,
14
// implementation and creation of design files limited
15
// to Xilinx devices or technologies. Use with non-Xilinx
16
// devices or technologies is expressly prohibited and
17
// immediately terminates your license unless covered by
18
// a separate agreement.
19
//
20
// Xilinx is providing this design, code, or information
21
// "as is" solely for use in developing programs and
22
// solutions for Xilinx devices. By providing this design,
23
// code, or information as one possible implementation of
24
// this feature, application or standard, Xilinx is making no
25
// representation that this implementation is free from any
26
// claims of infringement. You are responsible for
27
// obtaining any rights you may require for your implementation.
28
// Xilinx expressly disclaims any warranty whatsoever with
29
// respect to the adequacy of the implementation, including
30
// but not limited to any warranties or representations that this
31
// implementation is free from claims of infringement, implied
32
// warranties of merchantability or fitness for a particular
33
// purpose.
34
//
35
// Xilinx products are not intended for use in life support
36
// appliances, devices, or systems. Use in such applications are
37
// expressly prohibited.
38
//
39
// This copyright and support notice must be retained as part
40
// of this text at all times. (c) Copyright 2004-2008 Xilinx, Inc.
41
// All rights reserved.
42
//
43
//-----------------------------------------------------------------------------
44
// Description:  This is the EMAC block level Verilog design for the Virtex-5 
45
//               Embedded Ethernet MAC Example Design.  It is intended that
46
//               this example design can be quickly adapted and downloaded onto
47
//               an FPGA to provide a real hardware test environment.
48
//
49
//               The block level:
50
//
51
//               * instantiates all clock management logic required (BUFGs, 
52
//                 DCMs) to operate the EMAC and its example design;
53
//
54
//               * instantiates appropriate PHY interface modules (GMII, MII,
55
//                 RGMII, SGMII or 1000BASE-X) as required based on the user
56
//                 configuration.
57
//
58
//
59
//               Please refer to the Datasheet, Getting Started Guide, and
60
//               the Virtex-5 Embedded Tri-Mode Ethernet MAC User Gude for
61
//               further information.
62
//-----------------------------------------------------------------------------
63
 
64
 
65
`timescale 1 ps / 1 ps
66
 
67
 
68
//-----------------------------------------------------------------------------
69
// The module declaration for the top level design.
70
//-----------------------------------------------------------------------------
71
module v5_emac_v1_6_block
72
(
73
    // EMAC0 Clocking
74
    // 125MHz clock output from transceiver
75
    CLK125_OUT,
76
    // 125MHz clock input from BUFG
77
    CLK125,
78
    // Tri-speed clock output from EMAC0
79
    CLIENT_CLK_OUT_0,
80
    // EMAC0 Tri-speed clock input from BUFG
81
    CLIENT_CLK_0,
82
 
83
    // Client Receiver Interface - EMAC0
84
    EMAC0CLIENTRXD,
85
    EMAC0CLIENTRXDVLD,
86
    EMAC0CLIENTRXGOODFRAME,
87
    EMAC0CLIENTRXBADFRAME,
88
    EMAC0CLIENTRXFRAMEDROP,
89
    EMAC0CLIENTRXSTATS,
90
    EMAC0CLIENTRXSTATSVLD,
91
    EMAC0CLIENTRXSTATSBYTEVLD,
92
 
93
    // Client Transmitter Interface - EMAC0
94
    CLIENTEMAC0TXD,
95
    CLIENTEMAC0TXDVLD,
96
    EMAC0CLIENTTXACK,
97
    CLIENTEMAC0TXFIRSTBYTE,
98
    CLIENTEMAC0TXUNDERRUN,
99
    EMAC0CLIENTTXCOLLISION,
100
    EMAC0CLIENTTXRETRANSMIT,
101
    CLIENTEMAC0TXIFGDELAY,
102
    EMAC0CLIENTTXSTATS,
103
    EMAC0CLIENTTXSTATSVLD,
104
    EMAC0CLIENTTXSTATSBYTEVLD,
105
 
106
    // MAC Control Interface - EMAC0
107
    CLIENTEMAC0PAUSEREQ,
108
    CLIENTEMAC0PAUSEVAL,
109
 
110
    //EMAC-MGT link status
111
    EMAC0CLIENTSYNCACQSTATUS,
112
    //EMAC0 Interrupt
113
    EMAC0ANINTERRUPT,
114
 
115
 
116
    // SGMII Interface - EMAC0
117
    TXP_0,
118
    TXN_0,
119
    RXP_0,
120
    RXN_0,
121
    PHYAD_0,
122
    RESETDONE_0,
123
 
124
    // unused transceiver
125
    TXN_1_UNUSED,
126
    TXP_1_UNUSED,
127
    RXN_1_UNUSED,
128
    RXP_1_UNUSED,
129
 
130
    // SGMII MGT Clock buffer inputs 
131
    CLK_DS,
132
    GTRESET,
133
 
134
    // Asynchronous Reset Input
135
    RESET
136
);
137
 
138
 
139
//-----------------------------------------------------------------------------
140
// Port Declarations 
141
//-----------------------------------------------------------------------------
142
    // EMAC0 Clocking
143
    // 125MHz clock output from transceiver
144
    output          CLK125_OUT;
145
    // 125MHz clock input from BUFG
146
    input           CLK125;
147
    // Tri-speed clock output from EMAC0
148
    output          CLIENT_CLK_OUT_0;
149
    // EMAC0 Tri-speed clock input from BUFG
150
    input           CLIENT_CLK_0;
151
 
152
    // Client Receiver Interface - EMAC0
153
    output   [7:0]  EMAC0CLIENTRXD;
154
    output          EMAC0CLIENTRXDVLD;
155
    output          EMAC0CLIENTRXGOODFRAME;
156
    output          EMAC0CLIENTRXBADFRAME;
157
    output          EMAC0CLIENTRXFRAMEDROP;
158
    output   [6:0]  EMAC0CLIENTRXSTATS;
159
    output          EMAC0CLIENTRXSTATSVLD;
160
    output          EMAC0CLIENTRXSTATSBYTEVLD;
161
 
162
    // Client Transmitter Interface - EMAC0
163
    input    [7:0]  CLIENTEMAC0TXD;
164
    input           CLIENTEMAC0TXDVLD;
165
    output          EMAC0CLIENTTXACK;
166
    input           CLIENTEMAC0TXFIRSTBYTE;
167
    input           CLIENTEMAC0TXUNDERRUN;
168
    output          EMAC0CLIENTTXCOLLISION;
169
    output          EMAC0CLIENTTXRETRANSMIT;
170
    input    [7:0]  CLIENTEMAC0TXIFGDELAY;
171
    output          EMAC0CLIENTTXSTATS;
172
    output          EMAC0CLIENTTXSTATSVLD;
173
    output          EMAC0CLIENTTXSTATSBYTEVLD;
174
 
175
    // MAC Control Interface - EMAC0
176
    input           CLIENTEMAC0PAUSEREQ;
177
    input   [15:0]  CLIENTEMAC0PAUSEVAL;
178
 
179
    //EMAC-MGT link status
180
    output          EMAC0CLIENTSYNCACQSTATUS;
181
    //EMAC0 Interrupt
182
    output          EMAC0ANINTERRUPT;
183
 
184
 
185
    // SGMII Interface - EMAC0
186
    output          TXP_0;
187
    output          TXN_0;
188
    input           RXP_0;
189
    input           RXN_0;
190
    input           [4:0] PHYAD_0;
191
    output          RESETDONE_0;
192
 
193
    // unused transceiver
194
    output          TXN_1_UNUSED;
195
    output          TXP_1_UNUSED;
196
    input           RXN_1_UNUSED;
197
    input           RXP_1_UNUSED;
198
 
199
    // SGMII MGT Clock buffer inputs 
200
    input           CLK_DS;
201
    input           GTRESET;
202
 
203
    // Asynchronous Reset
204
    input           RESET;
205
 
206
//-----------------------------------------------------------------------------
207
// Wire and Reg Declarations 
208
//-----------------------------------------------------------------------------
209
 
210
    // Asynchronous reset signals
211
    wire            reset_ibuf_i;
212
    wire            reset_i;
213
    reg      [3:0]  reset_r;
214
 
215
    // EMAC0 client clocking signals
216
    wire            rx_client_clk_out_0_i;
217
    wire            rx_client_clk_in_0_i;
218
    wire            tx_client_clk_out_0_i;
219
    wire            tx_client_clk_in_0_i;
220
 
221
    // EMAC0 Physical interface signals
222
    wire            emac_locked_0_i;
223
    wire     [7:0]  mgt_rx_data_0_i;
224
    wire     [7:0]  mgt_tx_data_0_i;
225
    wire            signal_detect_0_i;
226
    wire            rxelecidle_0_i;
227
    wire            encommaalign_0_i;
228
    wire            loopback_0_i;
229
    wire            mgt_rx_reset_0_i;
230
    wire            mgt_tx_reset_0_i;
231
    wire            powerdown_0_i;
232
    wire     [2:0]  rxclkcorcnt_0_i;
233
    wire            rxbuferr_0_i;
234
    wire            rxchariscomma_0_i;
235
    wire            rxcharisk_0_i;
236
    wire            rxdisperr_0_i;
237
    wire     [1:0]  rxlossofsync_0_i;
238
    wire            rxnotintable_0_i;
239
    wire            rxrundisp_0_i;
240
    wire            txbuferr_0_i;
241
    wire            txchardispmode_0_i;
242
    wire            txchardispval_0_i;
243
    wire            txcharisk_0_i;
244
    wire     [1:0]  rxbufstatus_0_i;
245
    reg      [3:0]  tx_reset_sm_0_r;
246
    reg             tx_pcs_reset_0_r;
247
    reg      [3:0]  rx_reset_sm_0_r;
248
    reg             rx_pcs_reset_0_r;
249
 
250
 
251
    // Transceiver clocking signals
252
    wire            usrclk2;
253
 
254
    wire            refclkout;
255
    wire            dcm_locked_gtp;
256
    wire            plllock_0_i;
257
 
258
    // Speed output from EMAC0 for physical interface clocking
259
    wire [1:0]      speed_vector_0_i;
260
    wire            speed_vector_0_int;
261
 
262
 
263
//-----------------------------------------------------------------------------
264
// Main Body of Code 
265
//-----------------------------------------------------------------------------
266
 
267
 
268
    //-------------------------------------------------------------------------
269
    // Main Reset Circuitry
270
    //-------------------------------------------------------------------------
271
 
272
    assign reset_ibuf_i = RESET;
273
 
274
    // Asserting the reset of the EMAC for a few clock cycles
275
    always @(posedge usrclk2 or posedge reset_ibuf_i)
276
    begin
277
        if (reset_ibuf_i == 1)
278
        begin
279
            reset_r <= 4'b1111;
280
        end
281
        else
282
        begin
283
          if (plllock_0_i == 1)
284
            reset_r <= {reset_r[2:0], reset_ibuf_i};
285
        end
286
    end
287
    // synthesis attribute async_reg of reset_r is "TRUE";
288
 
289
    // The reset pulse is now several clock cycles in duration
290
    assign reset_i = reset_r[3];
291
 
292
 
293
 
294
    //-------------------------------------------------------------------------
295
    // Instantiate RocketIO tile for SGMII or 1000BASE-X PCS/PMA Physical I/F
296
    //-------------------------------------------------------------------------
297
 
298
    //EMAC0-only instance
299
    GTP_dual_1000X GTP_DUAL_1000X_inst
300
 
301
         (
302
         .RESETDONE_0           (RESETDONE_0),
303
         .ENMCOMMAALIGN_0       (encommaalign_0_i),
304
         .ENPCOMMAALIGN_0       (encommaalign_0_i),
305
         .LOOPBACK_0            (loopback_0_i),
306
         .POWERDOWN_0           (powerdown_0_i),
307
         .RXUSRCLK_0            (usrclk2),
308
         .RXUSRCLK2_0           (usrclk2),
309
         .RXRESET_0             (mgt_rx_reset_0_i),
310
         .TXCHARDISPMODE_0      (txchardispmode_0_i),
311
         .TXCHARDISPVAL_0       (txchardispval_0_i),
312
         .TXCHARISK_0           (txcharisk_0_i),
313
         .TXDATA_0              (mgt_tx_data_0_i),
314
 
315
         .TXUSRCLK_0            (usrclk2),
316
         .TXUSRCLK2_0           (usrclk2),
317
         .TXRESET_0             (mgt_tx_reset_0_i),
318
         .RXCHARISCOMMA_0       (rxchariscomma_0_i),
319
         .RXCHARISK_0           (rxcharisk_0_i),
320
         .RXCLKCORCNT_0         (rxclkcorcnt_0_i),
321
         .RXDATA_0              (mgt_rx_data_0_i),
322
         .RXDISPERR_0           (rxdisperr_0_i),
323
         .RXNOTINTABLE_0        (rxnotintable_0_i),
324
         .RXRUNDISP_0           (rxrundisp_0_i),
325
         .RXBUFERR_0            (rxbuferr_0_i),
326
         .TXBUFERR_0            (txbuferr_0_i),
327
         .PLLLKDET_0            (plllock_0_i),
328
         .TXOUTCLK_0            (),
329
         .RXELECIDLE_0          (rxelecidle_0_i),
330
         .RX1P_0                (RXP_0),
331
         .RX1N_0                (RXN_0),
332
         .TX1N_0                (TXN_0),
333
         .TX1P_0                (TXP_0),
334
         .TX1N_1_UNUSED         (TXN_1_UNUSED),
335
         .TX1P_1_UNUSED         (TXP_1_UNUSED),
336
         .RX1N_1_UNUSED         (RXN_1_UNUSED),
337
         .RX1P_1_UNUSED         (RXP_1_UNUSED),
338
         .CLK_DS                (CLK_DS),
339
         .GTRESET               (GTRESET),
340
         .REFCLKOUT             (refclkout),
341
         .PMARESET              (reset_ibuf_i),
342
         .DCM_LOCKED            (dcm_locked_gtp));
343
 
344
 
345
 
346
    //-------------------------------------------------------------------------
347
    // Generate the buffer status input to the EMAC0 from the buffer error 
348
    // output of the transceiver
349
    //-------------------------------------------------------------------------
350
    assign rxbufstatus_0_i[1] = rxbuferr_0_i;
351
 
352
    //-------------------------------------------------------------------------
353
    // Detect when there has been a disconnect
354
    //-------------------------------------------------------------------------
355
    assign signal_detect_0_i = ~(rxelecidle_0_i);
356
 
357
 
358
 
359
 
360
 
361
 
362
    //--------------------------------------------------------------------
363
    // Virtex5 Rocket I/O Clock Management
364
    //--------------------------------------------------------------------
365
 
366
    // The RocketIO transceivers are available in pairs with shared
367
    // clock resources
368
    // 125MHz clock is used for GTP user clocks and used
369
    // to clock all Ethernet core logic.
370
    assign usrclk2                   = CLK125;
371
 
372
    assign dcm_locked_gtp            = 1'b1;
373
 
374
    //------------------------------------------------------------------------
375
    // GTX_CLK Clock Management for EMAC0 - 125 MHz clock frequency
376
    // (Connected to PHYEMAC0GTXCLK of the EMAC primitive)
377
    //------------------------------------------------------------------------
378
    assign gtx_clk_ibufg_0_i         = usrclk2;
379
 
380
 
381
    // EMAC0: PLL locks
382
    assign emac_locked_0_i           = plllock_0_i;
383
 
384
 
385
    //------------------------------------------------------------------------
386
    // SGMII client side transmit clock for EMAC0
387
    //------------------------------------------------------------------------
388
    assign tx_client_clk_in_0_i      = CLIENT_CLK_0;
389
 
390
    //------------------------------------------------------------------------
391
    // SGMII client side receive clock for EMAC0
392
    //------------------------------------------------------------------------
393
    assign rx_client_clk_in_0_i      = CLIENT_CLK_0;
394
 
395
 
396
    //------------------------------------------------------------------------
397
    // Connect previously derived client clocks to example design output ports
398
    //------------------------------------------------------------------------
399
    // EMAC0 Clocking
400
    // 125MHz clock output from transceiver
401
    assign CLK125_OUT                = refclkout;
402
    // Tri-speed clock output from EMAC0
403
    assign CLIENT_CLK_OUT_0          = tx_client_clk_out_0_i;
404
 
405
 
406
 
407
 
408
    //------------------------------------------------------------------------
409
    // Instantiate the EMAC Wrapper (v5_emac_v1_6.v) 
410
    //------------------------------------------------------------------------
411
    v5_emac_v1_6 v5_emac_wrapper_inst
412
    (
413
        // Client Receiver Interface - EMAC0
414
        .EMAC0CLIENTRXCLIENTCLKOUT      (rx_client_clk_out_0_i),
415
        .CLIENTEMAC0RXCLIENTCLKIN       (rx_client_clk_in_0_i),
416
        .EMAC0CLIENTRXD                 (EMAC0CLIENTRXD),
417
        .EMAC0CLIENTRXDVLD              (EMAC0CLIENTRXDVLD),
418
        .EMAC0CLIENTRXDVLDMSW           (),
419
        .EMAC0CLIENTRXGOODFRAME         (EMAC0CLIENTRXGOODFRAME),
420
        .EMAC0CLIENTRXBADFRAME          (EMAC0CLIENTRXBADFRAME),
421
        .EMAC0CLIENTRXFRAMEDROP         (EMAC0CLIENTRXFRAMEDROP),
422
        .EMAC0CLIENTRXSTATS             (EMAC0CLIENTRXSTATS),
423
        .EMAC0CLIENTRXSTATSVLD          (EMAC0CLIENTRXSTATSVLD),
424
        .EMAC0CLIENTRXSTATSBYTEVLD      (EMAC0CLIENTRXSTATSBYTEVLD),
425
 
426
        // Client Transmitter Interface - EMAC0
427
        .EMAC0CLIENTTXCLIENTCLKOUT      (tx_client_clk_out_0_i),
428
        .CLIENTEMAC0TXCLIENTCLKIN       (tx_client_clk_in_0_i),
429
        .CLIENTEMAC0TXD                 (CLIENTEMAC0TXD),
430
        .CLIENTEMAC0TXDVLD              (CLIENTEMAC0TXDVLD),
431
        .CLIENTEMAC0TXDVLDMSW           (1'b0),
432
        .EMAC0CLIENTTXACK               (EMAC0CLIENTTXACK),
433
        .CLIENTEMAC0TXFIRSTBYTE         (CLIENTEMAC0TXFIRSTBYTE),
434
        .CLIENTEMAC0TXUNDERRUN          (CLIENTEMAC0TXUNDERRUN),
435
        .EMAC0CLIENTTXCOLLISION         (EMAC0CLIENTTXCOLLISION),
436
        .EMAC0CLIENTTXRETRANSMIT        (EMAC0CLIENTTXRETRANSMIT),
437
        .CLIENTEMAC0TXIFGDELAY          (CLIENTEMAC0TXIFGDELAY),
438
        .EMAC0CLIENTTXSTATS             (EMAC0CLIENTTXSTATS),
439
        .EMAC0CLIENTTXSTATSVLD          (EMAC0CLIENTTXSTATSVLD),
440
        .EMAC0CLIENTTXSTATSBYTEVLD      (EMAC0CLIENTTXSTATSBYTEVLD),
441
 
442
        // MAC Control Interface - EMAC0
443
        .CLIENTEMAC0PAUSEREQ            (CLIENTEMAC0PAUSEREQ),
444
        .CLIENTEMAC0PAUSEVAL            (CLIENTEMAC0PAUSEVAL),
445
 
446
        // Clock Signals - EMAC0
447
        .GTX_CLK_0                      (usrclk2),
448
        .EMAC0PHYTXGMIIMIICLKOUT        (),
449
        .PHYEMAC0TXGMIIMIICLKIN         (1'b0),
450
 
451
        // SGMII Interface - EMAC0
452
        .RXDATA_0                       (mgt_rx_data_0_i),
453
        .TXDATA_0                       (mgt_tx_data_0_i),
454
        .DCM_LOCKED_0                   (emac_locked_0_i  ),
455
        .AN_INTERRUPT_0                 (EMAC0ANINTERRUPT),
456
        .SIGNAL_DETECT_0                (signal_detect_0_i),
457
        .PHYAD_0                        (PHYAD_0),
458
        .ENCOMMAALIGN_0                 (encommaalign_0_i),
459
        .LOOPBACKMSB_0                  (loopback_0_i),
460
        .MGTRXRESET_0                   (mgt_rx_reset_0_i),
461
        .MGTTXRESET_0                   (mgt_tx_reset_0_i),
462
        .POWERDOWN_0                    (powerdown_0_i),
463
        .SYNCACQSTATUS_0                (EMAC0CLIENTSYNCACQSTATUS),
464
        .RXCLKCORCNT_0                  (rxclkcorcnt_0_i),
465
        .RXBUFSTATUS_0                  (rxbufstatus_0_i),
466
        .RXCHARISCOMMA_0                (rxchariscomma_0_i),
467
        .RXCHARISK_0                    (rxcharisk_0_i),
468
        .RXDISPERR_0                    (rxdisperr_0_i),
469
        .RXNOTINTABLE_0                 (rxnotintable_0_i),
470
        .RXREALIGN_0                    (1'b0),
471
        .RXRUNDISP_0                    (rxrundisp_0_i),
472
        .TXBUFERR_0                     (txbuferr_0_i),
473
        .TXRUNDISP_0                    (1'b0),
474
        .TXCHARDISPMODE_0               (txchardispmode_0_i),
475
        .TXCHARDISPVAL_0                (txchardispval_0_i),
476
        .TXCHARISK_0                    (txcharisk_0_i),
477
 
478
        .EMAC0SPEEDIS10100              (speed_vector_0_int),
479
 
480
 
481
        // Asynchronous Reset
482
        .RESET                          (reset_i)
483
        );
484
 
485
 
486
 
487
 
488
 
489
 
490
 
491
endmodule

powered by: WebSVN 2.1.0

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