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

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [hdl/] [boardsupport/] [v4/] [v4_emac_v4_8_block.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 peteralieb
//-----------------------------------------------------------------------------
2
// Title      : Virtex-4 Ethernet MAC Wrapper Top Level
3
// Project    : Virtex-4 Embedded Tri-Mode Ethernet MAC Wrapper
4
// File       : v4_emac_v4_8_block.v
5
// Version    : 4.8
6
//-----------------------------------------------------------------------------
7
//
8
// (c) Copyright 2004-2010 Xilinx, Inc. All rights reserved.
9
//
10
// This file contains confidential and proprietary information
11
// of Xilinx, Inc. and is protected under U.S. and
12
// international copyright and other intellectual property
13
// laws.
14
//
15
// DISCLAIMER
16
// This disclaimer is not a license and does not grant any
17
// rights to the materials distributed herewith. Except as
18
// otherwise provided in a valid license issued to you by
19
// Xilinx, and to the maximum extent permitted by applicable
20
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
21
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
22
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
23
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
24
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
25
// (2) Xilinx shall not be liable (whether in contract or tort,
26
// including negligence, or under any other theory of
27
// liability) for any loss or damage of any kind or nature
28
// related to, arising under or in connection with these
29
// materials, including for any direct, or any indirect,
30
// special, incidental, or consequential loss or damage
31
// (including loss of data, profits, goodwill, or any type of
32
// loss or damage suffered as a result of any action brought
33
// by a third party) even if such damage or loss was
34
// reasonably foreseeable or Xilinx had been advised of the
35
// possibility of the same.
36
//
37
// CRITICAL APPLICATIONS
38
// Xilinx products are not designed or intended to be fail-
39
// safe, or for use in any application requiring fail-safe
40
// performance, such as life-support or safety devices or
41
// systems, Class III medical devices, nuclear facilities,
42
// applications related to the deployment of airbags, or any
43
// other applications that could lead to death, personal
44
// injury, or severe property or environmental damage
45
// (individually and collectively, "Critical
46
// Applications"). Customer assumes the sole risk and
47
// liability of any use of Xilinx products in Critical
48
// Applications, subject only to applicable laws and
49
// regulations governing limitations on product liability.
50
//
51
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
52
// PART OF THIS FILE AT ALL TIMES.
53
//
54
//-----------------------------------------------------------------------------
55
// Description:  This is the EMAC block level Verilog design for the Virtex-4 
56
//               Embedded Ethernet MAC Example Design.  It is intended that
57
//               this example design can be quickly adapted and downloaded onto
58
//               an FPGA to provide a real hardware test environment.
59
//
60
//               The block level:
61
//
62
//               * instantiates all clock management logic required (BUFGs, 
63
//                 DCMs) to operate the EMAC and its example design;
64
//
65
//               * instantiates appropriate PHY interface modules (GMII, MII,
66
//                 RGMII, SGMII or 1000BASE-X) as required based on the user
67
//                 configuration.
68
//
69
//               Please refer to the Datasheet, Getting Started Guide, and
70
//               the Virtex-4 Embedded Tri-Mode Ethernet MAC User Gude for
71
//               further information.
72
//-----------------------------------------------------------------------------
73
 
74
 
75
`timescale 1 ps / 1 ps
76
 
77
 
78
//-----------------------------------------------------------------------------
79
// The module declaration for the top level design.
80
//-----------------------------------------------------------------------------
81
module v4_emac_v4_8_block
82
(
83
    // Client Receiver Interface - EMAC0
84
    RX_CLIENT_CLK_0,
85
    EMAC0CLIENTRXD,
86
    EMAC0CLIENTRXDVLD,
87
    EMAC0CLIENTRXGOODFRAME,
88
    EMAC0CLIENTRXBADFRAME,
89
    EMAC0CLIENTRXFRAMEDROP,
90
    EMAC0CLIENTRXSTATS,
91
    EMAC0CLIENTRXSTATSVLD,
92
    EMAC0CLIENTRXSTATSBYTEVLD,
93
 
94
    // Client Transmitter Interface - EMAC0
95
    TX_CLIENT_CLK_0,
96
    CLIENTEMAC0TXD,
97
    CLIENTEMAC0TXDVLD,
98
    EMAC0CLIENTTXACK,
99
    CLIENTEMAC0TXFIRSTBYTE,
100
    CLIENTEMAC0TXUNDERRUN,
101
    EMAC0CLIENTTXCOLLISION,
102
    EMAC0CLIENTTXRETRANSMIT,
103
    CLIENTEMAC0TXIFGDELAY,
104
    EMAC0CLIENTTXSTATS,
105
    EMAC0CLIENTTXSTATSVLD,
106
    EMAC0CLIENTTXSTATSBYTEVLD,
107
 
108
    // MAC Control Interface - EMAC0
109
    CLIENTEMAC0PAUSEREQ,
110
    CLIENTEMAC0PAUSEVAL,
111
 
112
 
113
    // MII Interface - EMAC0
114
    MII_COL_0,
115
    MII_CRS_0,
116
    MII_TXD_0,
117
    MII_TX_EN_0,
118
    MII_TX_ER_0,
119
    MII_TX_CLK_0,
120
    MII_RXD_0,
121
    MII_RX_DV_0,
122
    MII_RX_ER_0,
123
    MII_RX_CLK_0,
124
 
125
    // Preserved Tie-Off Pins for EMAC0
126
    SPEED_VECTOR_IN_0,
127
    HOSTCLK,
128
   // Asynchronous Reset Input
129
    RESET
130
);
131
 
132
 
133
//-----------------------------------------------------------------------------
134
// Port Declarations 
135
//-----------------------------------------------------------------------------
136
    // Client Receiver Interface - EMAC0
137
    output          RX_CLIENT_CLK_0;
138
    output   [7:0]  EMAC0CLIENTRXD;
139
    output          EMAC0CLIENTRXDVLD;
140
    output          EMAC0CLIENTRXGOODFRAME;
141
    output          EMAC0CLIENTRXBADFRAME;
142
    output          EMAC0CLIENTRXFRAMEDROP;
143
    output   [6:0]  EMAC0CLIENTRXSTATS;
144
    output          EMAC0CLIENTRXSTATSVLD;
145
    output          EMAC0CLIENTRXSTATSBYTEVLD;
146
 
147
    // Client Transmitter Interface - EMAC0
148
    output          TX_CLIENT_CLK_0;
149
    input    [7:0]  CLIENTEMAC0TXD;
150
    input           CLIENTEMAC0TXDVLD;
151
    output          EMAC0CLIENTTXACK;
152
    input           CLIENTEMAC0TXFIRSTBYTE;
153
    input           CLIENTEMAC0TXUNDERRUN;
154
    output          EMAC0CLIENTTXCOLLISION;
155
    output          EMAC0CLIENTTXRETRANSMIT;
156
    input    [7:0]  CLIENTEMAC0TXIFGDELAY;
157
    output          EMAC0CLIENTTXSTATS;
158
    output          EMAC0CLIENTTXSTATSVLD;
159
    output          EMAC0CLIENTTXSTATSBYTEVLD;
160
 
161
    // MAC Control Interface - EMAC0
162
    input           CLIENTEMAC0PAUSEREQ;
163
    input   [15:0]  CLIENTEMAC0PAUSEVAL;
164
 
165
 
166
    // MII Interface - EMAC0
167
    input           MII_COL_0;
168
    input           MII_CRS_0;
169
    output   [3:0]  MII_TXD_0;
170
    output          MII_TX_EN_0;
171
    output          MII_TX_ER_0;
172
    input           MII_TX_CLK_0;
173
    input    [3:0]  MII_RXD_0;
174
    input           MII_RX_DV_0;
175
    input           MII_RX_ER_0;
176
    input           MII_RX_CLK_0;
177
 
178
    // Preserved Tie-Off Pins for EMAC0
179
    input    [1:0]  SPEED_VECTOR_IN_0;
180
    input           HOSTCLK;
181
 
182
    // Asynchronous Reset
183
    input           RESET;
184
 
185
//-----------------------------------------------------------------------------
186
// Wire and Reg Declarations
187
//-----------------------------------------------------------------------------
188
 
189
    wire            reset_ibuf_i;
190
    wire            reset_i;
191
    wire            emac_reset;
192
 
193
    wire            rx_client_clk_out_0_i;
194
    wire            rx_client_clk_in_0_i;
195
    wire            tx_client_clk_out_0_i;
196
    wire            tx_client_clk_in_0_i;
197
    wire            tx_gmii_mii_clk_out_0_i;
198
    wire            tx_gmii_mii_clk_in_0_i;
199
    wire            mii_tx_clk_0_i;
200
    wire            mii_tx_en_0_i;
201
    wire            mii_tx_er_0_i;
202
    wire     [3:0]  mii_txd_0_i;
203
    wire            mii_tx_en_fa_0_i;
204
    wire            mii_tx_er_fa_0_i;
205
    wire     [3:0]  mii_txd_fa_0_i;
206
    wire            mii_crs_0_i;
207
    wire            mii_rx_clk_ibufg_0_i;
208
    wire            mii_rx_clk_0_i;
209
 
210
 
211
    wire     [7:0]  tx_data_0_i;
212
    wire            tx_data_valid_0_i;
213
    wire     [7:0]  rx_data_0_i;
214
    wire            rx_data_valid_0_i;
215
    wire            tx_underrun_0_i;
216
    wire            tx_ack_0_i;
217
    wire            rx_good_frame_0_i;
218
    wire            rx_bad_frame_0_i;
219
    wire            tx_retransmit_0_i;
220
 
221
    wire            host_clk_i;
222
    wire     [1:0]  speed_vector_0_i;
223
    wire     [1:0]  speed_vector_1_i;
224
    reg      [3:0]  reset_r;
225
 
226
    wire            mii_rx_dv_0_r;
227
    wire            mii_rx_er_0_r;
228
    wire     [3:0]  mii_rxd_0_r;
229
 
230
 
231
 
232
 
233
    // EMAC0 FCS block signals
234
    wire            tx_stats_byte_valid_0_i;
235
    wire            tx_collision_0_i;
236
 
237
//-----------------------------------------------------------------------------
238
// Main Body of Code
239
//-----------------------------------------------------------------------------
240
 
241
 
242
    //-------------------------------------------------------------------------
243
    // Main Reset Circuitry
244
    //-------------------------------------------------------------------------
245
    assign reset_ibuf_i = RESET;
246
 
247
    // Asserting the reset of the EMAC for a few clock cycles
248
    // (Any clock can be used besides the HOSTCLK)
249
    always @(posedge host_clk_i or posedge reset_ibuf_i)
250
    begin
251
        if (reset_ibuf_i == 1)
252
            reset_r <= 4'b1111;
253
        else
254
            reset_r <= {reset_r[2:0], reset_ibuf_i};
255
    end
256
    //synthesis attribute ASYNC_REG of reset_r is "TRUE"
257
 
258
    // The reset pulse is now several clock cycles in duration
259
    assign reset_i = reset_r[3];
260
 
261
 
262
 
263
    //-------------------------------------------------------------------------
264
    // MII circuitry for the Physical Interface of EMAC0
265
    //-------------------------------------------------------------------------
266
 
267
    mii_if mii0 (
268
        .RESET(reset_i),
269
        .MII_TXD(MII_TXD_0),
270
        .MII_TX_EN(MII_TX_EN_0),
271
        .MII_TX_ER(MII_TX_ER_0),
272
        .MII_RXD(MII_RXD_0),
273
        .MII_RX_DV(MII_RX_DV_0),
274
        .MII_RX_ER(MII_RX_ER_0),
275
        .MII_COL(MII_COL_0),
276
        .MII_CRS(MII_CRS_0),
277
        .TXD_FROM_MAC(mii_txd_0_i),
278
        .TX_EN_FROM_MAC(mii_tx_en_0_i),
279
        .TX_ER_FROM_MAC(mii_tx_er_0_i),
280
        .TX_CLK(tx_gmii_mii_clk_in_0_i),
281
        .RXD_TO_MAC(mii_rxd_0_r),
282
        .RX_DV_TO_MAC(mii_rx_dv_0_r),
283
        .RX_ER_TO_MAC(mii_rx_er_0_r),
284
        .RX_CLK(mii_rx_clk_0_i),
285
        .MII_COL_TO_MAC(mii_col_int_0),
286
        .MII_CRS_TO_MAC(mii_crs_0_i));
287
 
288
    // Instantiate the FCS block to correct possible duplicate
289
    // transmission of the final FCS byte
290
    emac0_fcs_blk_mii emac0_fcs_blk_inst (
291
        .reset               (reset_i),
292
        .tx_phy_clk          (tx_gmii_mii_clk_in_0_i),
293
        .txd_from_mac        (mii_txd_fa_0_i),
294
        .tx_en_from_mac      (mii_tx_en_fa_0_i),
295
        .tx_er_from_mac      (mii_tx_er_fa_0_i),
296
        .tx_client_clk       (tx_client_clk_in_0_i),
297
        .tx_stats_byte_valid (tx_stats_byte_valid_0_i),
298
        .tx_collision        (tx_collision_0_i),
299
        .speed_is_10_100     (1'b1),
300
        .txd                 (mii_txd_0_i),
301
        .tx_en               (mii_tx_en_0_i),
302
        .tx_er               (mii_tx_er_0_i)
303
    );
304
 
305
    assign EMAC0CLIENTTXCOLLISION    = tx_collision_0_i;
306
    assign EMAC0CLIENTTXSTATSBYTEVLD = tx_stats_byte_valid_0_i;
307
 
308
 
309
 
310
 
311
 
312
 
313
    //------------------------------------------------------------------------
314
    // MII PHY side transmit clock for EMAC0
315
    //------------------------------------------------------------------------
316
    //synthesis attribute keep of tx_gmii_mii_clk_in_0_i is "true"
317
 
318
    BUFG tx_gmii_mii_clk_0_bufg (
319
        //.I(tx_gmii_mii_clk_out_0_i),
320
        .I(mii_tx_clk_0_i),
321
        .O(tx_gmii_mii_clk_in_0_i)
322
        );
323
 
324
    //------------------------------------------------------------------------
325
    // MII PHY side Receiver Clock Management for EMAC0
326
    //------------------------------------------------------------------------
327
    IBUFG gmii_rx_clk_0_ibufg (
328
        .I(MII_RX_CLK_0),
329
        .O(mii_rx_clk_ibufg_0_i)
330
        );
331
 
332
    //synthesis attribute keep of mii_rx_clk_0_i is "true"
333
    BUFG gmii_rx_clk_0_bufg (
334
        .I(mii_rx_clk_ibufg_0_i),
335
        .O(mii_rx_clk_0_i)
336
        );
337
 
338
 
339
    //------------------------------------------------------------------------
340
    // MII client side transmit clock for EMAC0
341
    //------------------------------------------------------------------------
342
    //synthesis attribute keep of tx_client_clk_in_0_i is "true"
343
    BUFG tx_client_clk_0_bufg (
344
        .I(tx_client_clk_out_0_i),
345
        .O(tx_client_clk_in_0_i)
346
        );
347
 
348
 
349
    //------------------------------------------------------------------------
350
    // MII client side receive clock for EMAC0
351
    //------------------------------------------------------------------------
352
    //synthesis attribute keep of rx_client_clk_in_0_i is "true"
353
    BUFG rx_client_clk_0_bufg (
354
        .I(rx_client_clk_out_0_i),
355
        .O(rx_client_clk_in_0_i)
356
        );
357
 
358
 
359
    //------------------------------------------------------------------------
360
    // MII PHY side Transmitter Clock Management for EMAC0
361
    //------------------------------------------------------------------------
362
    IBUFG mii_tx_clk_0_ibufg (
363
        .I(MII_TX_CLK_0),
364
        .O(mii_tx_clk_0_i)
365
        );
366
 
367
 
368
 
369
    //------------------------------------------------------------------------
370
    // Connect previously derived client clocks to example design output ports
371
    //------------------------------------------------------------------------
372
    assign RX_CLIENT_CLK_0 = rx_client_clk_in_0_i;
373
    assign TX_CLIENT_CLK_0 = tx_client_clk_in_0_i;
374
 
375
 
376
    //------------------------------------------------------------------------
377
    // Instantiate the EMAC Wrapper (v4_emac_v4_8.v)
378
    //------------------------------------------------------------------------
379
    v4_emac_v4_8 v4_emac_top
380
    (
381
        // Client Receiver Interface - EMAC0
382
        .EMAC0CLIENTRXCLIENTCLKOUT      (rx_client_clk_out_0_i),
383
        .CLIENTEMAC0RXCLIENTCLKIN       (rx_client_clk_in_0_i),
384
        .EMAC0CLIENTRXD                 (EMAC0CLIENTRXD),
385
        .EMAC0CLIENTRXDVLD              (EMAC0CLIENTRXDVLD),
386
        .EMAC0CLIENTRXDVLDMSW           (),
387
        .EMAC0CLIENTRXGOODFRAME         (EMAC0CLIENTRXGOODFRAME),
388
        .EMAC0CLIENTRXBADFRAME          (EMAC0CLIENTRXBADFRAME),
389
        .EMAC0CLIENTRXFRAMEDROP         (EMAC0CLIENTRXFRAMEDROP),
390
        .EMAC0CLIENTRXDVREG6            (),
391
        .EMAC0CLIENTRXSTATS             (EMAC0CLIENTRXSTATS),
392
        .EMAC0CLIENTRXSTATSVLD          (EMAC0CLIENTRXSTATSVLD),
393
        .EMAC0CLIENTRXSTATSBYTEVLD      (EMAC0CLIENTRXSTATSBYTEVLD),
394
 
395
        // Client Transmitter Interface - EMAC0
396
        .EMAC0CLIENTTXCLIENTCLKOUT      (tx_client_clk_out_0_i),
397
        .CLIENTEMAC0TXCLIENTCLKIN       (tx_client_clk_in_0_i),
398
        .CLIENTEMAC0TXD                 (CLIENTEMAC0TXD),
399
        .CLIENTEMAC0TXDVLD              (CLIENTEMAC0TXDVLD),
400
        .CLIENTEMAC0TXDVLDMSW           (1'b0),
401
        .EMAC0CLIENTTXACK               (EMAC0CLIENTTXACK),
402
        .CLIENTEMAC0TXFIRSTBYTE         (CLIENTEMAC0TXFIRSTBYTE),
403
        .CLIENTEMAC0TXUNDERRUN          (CLIENTEMAC0TXUNDERRUN),
404
        .EMAC0CLIENTTXCOLLISION         (tx_collision_0_i),
405
        .EMAC0CLIENTTXRETRANSMIT        (EMAC0CLIENTTXRETRANSMIT),
406
        .CLIENTEMAC0TXIFGDELAY          (CLIENTEMAC0TXIFGDELAY),
407
        .EMAC0CLIENTTXSTATS             (EMAC0CLIENTTXSTATS),
408
        .EMAC0CLIENTTXSTATSVLD          (EMAC0CLIENTTXSTATSVLD),
409
        .EMAC0CLIENTTXSTATSBYTEVLD      (tx_stats_byte_valid_0_i),
410
 
411
        // MAC Control Interface - EMAC0
412
        .CLIENTEMAC0PAUSEREQ            (CLIENTEMAC0PAUSEREQ),
413
        .CLIENTEMAC0PAUSEVAL            (CLIENTEMAC0PAUSEVAL),
414
 
415
        // Clock Signals - EMAC0
416
        .GTX_CLK_0                      (1'b0),
417
 
418
        .EMAC0CLIENTTXGMIIMIICLKOUT     (tx_gmii_mii_clk_out_0_i),
419
        .CLIENTEMAC0TXGMIIMIICLKIN      (tx_gmii_mii_clk_in_0_i),
420
 
421
        // MII Interface - EMAC0
422
        .MII_COL_0                      (mii_col_int_0),
423
        .MII_CRS_0                      (mii_crs_0_i),
424
        .MII_TXD_0                      (mii_txd_fa_0_i),
425
        .MII_TX_EN_0                    (mii_tx_en_fa_0_i),
426
        .MII_TX_ER_0                    (mii_tx_er_fa_0_i),
427
      //.MII_TX_CLK_0                   (mii_tx_clk_0_i),
428
        .MII_TX_CLK_0                   (tx_gmii_mii_clk_in_0_i),
429
        .MII_RXD_0                      (mii_rxd_0_r),
430
        .MII_RX_DV_0                    (mii_rx_dv_0_r),
431
        .MII_RX_ER_0                    (mii_rx_er_0_r),
432
        .MII_RX_CLK_0                   (mii_rx_clk_0_i),
433
 
434
        // Preserved Tie-Off Pins for EMAC0
435
        .SPEED_VECTOR_IN_0              (speed_vector_0_i),
436
 
437
        .HOSTCLK                        (HOSTCLK),
438
 
439
        .DCM_LOCKED_0                   (1'b1  ),
440
 
441
        // Asynchronous Reset
442
        .RESET                          (reset_i)
443
        );
444
 
445
 
446
 
447
 
448
 
449
  // The Host clock (HOSTCLK on EMAC primitive) must always be driven.
450
  // In this example design it is kept as a standalone signal.  However,
451
  // this can be shared with one of the other clock sources, for
452
  // example, one of the 125MHz PHYEMAC#GTX clock inputs.
453
 
454
    assign host_clk_i = HOSTCLK;
455
 
456
 
457
  //--------------------------------------------------------------------
458
  // EMAC0 Tie-Off Pins
459
  //--------------------------------------------------------------------
460
  // All other Tie-Off Pins for EMAC0 are tied to a logic level in the
461
  // EMAC wrapper file (v4_emac_v4_8.v).  The exception is
462
  // the following signals: by routing them to Input Buffers, the
463
  // demonstration testbench is able to perform speed changes during
464
  // simulation.
465
  assign speed_vector_0_i = SPEED_VECTOR_IN_0;
466
 
467
 
468
 
469
 
470
 
471
 
472
endmodule

powered by: WebSVN 2.1.0

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