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

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [hdl/] [boardsupport/] [enetplatformv4.v] - Blame information for rev 12

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

Line No. Rev Author Line
1 2 peteralieb
//-----------------------------------------------------------------------------
2
// Title      : Virtex-4 Ethernet MAC Example Design Wrapper
3
// Project    : Virtex-4 Embedded Tri-Mode Ethernet MAC Wrapper
4
// File       : v4_emac_v4_8_example_design.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 Verilog example design for the Virtex-4 
56
//               Embedded Ethernet MAC.  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
//               This level:
61
//
62
//               * instantiates the TEMAC local link file that instantiates 
63
//                 the TEMAC top level together with a RX and TX FIFO with a 
64
//                 local link interface;
65
//
66
//               * instantiates a simple client I/F side example design,
67
//                 providing an address swap and a simple
68
//                 loopback function;
69
//
70
//               * Instantiates IBUFs on the GTX_CLK, REFCLK and HOSTCLK inputs 
71
//                 if required;
72
//
73
//               Please refer to the Datasheet, Getting Started Guide, and
74
//               the Virtex-4 Embedded Tri-Mode Ethernet MAC User Gude for
75
//               further information.
76
//
77
//
78
//
79
//    ---------------------------------------------------------------------
80
//    | EXAMPLE DESIGN WRAPPER                                            |
81
//    |           --------------------------------------------------------|
82
//    |           |LOCAL LINK WRAPPER                                     |
83
//    |           |              -----------------------------------------|
84
//    |           |              |BLOCK LEVEL WRAPPER                     |
85
//    |           |              |    ---------------------               |
86
//    | --------  |  ----------  |    | ETHERNET MAC      |               |
87
//    | |      |  |  |        |  |    | WRAPPER           |  ---------    |
88
//    | |      |->|->|        |--|--->| Tx            Tx  |--|       |--->|
89
//    | |      |  |  |        |  |    | client        PHY |  |       |    |
90
//    | | ADDR |  |  | LOCAL  |  |    | I/F           I/F |  |       |    |  
91
//    | | SWAP |  |  |  LINK  |  |    |                   |  | PHY   |    |
92
//    | |      |  |  |  FIFO  |  |    |                   |  | I/F   |    |
93
//    | |      |  |  |        |  |    |                   |  |       |    |
94
//    | |      |  |  |        |  |    | Rx            Rx  |  |       |    |
95
//    | |      |  |  |        |  |    | client        PHY |  |       |    |
96
//    | |      |<-|<-|        |<-|----| I/F           I/F |<-|       |<---|
97
//    | |      |  |  |        |  |    |                   |  ---------    |
98
//    | --------  |  ----------  |    ---------------------               |
99
//    |           |              -----------------------------------------|
100
//    |           --------------------------------------------------------|
101
//    ---------------------------------------------------------------------
102
//
103
//-----------------------------------------------------------------------------
104
 
105
 
106
`timescale 1 ps / 1 ps
107
 
108
 
109
//-----------------------------------------------------------------------------
110
// The module declaration for the example design.
111
//-----------------------------------------------------------------------------
112
module enetplatform
113
(
114
    // MII Interface - EMAC0
115
    MII_COL_0,
116
    MII_CRS_0,
117
    MII_TXD_0,
118
    MII_TX_EN_0,
119
    MII_TX_ER_0,
120
    MII_TX_CLK_0,
121
    MII_RXD_0,
122
    MII_RX_DV_0,
123
    MII_RX_ER_0,
124
    MII_RX_CLK_0,
125
 
126
    // Preserved Tie-Off Pins for EMAC0
127
    //SPEED_VECTOR_IN_0,
128
    HOSTCLK,
129
         PHY_RESET_0,
130
    // Asynchronous Reset
131
    RESET,
132
 
133
        // User Connections
134
        in_src_rdy_usr,
135
        out_dst_rdy_usr,
136
        in_data_usr,
137
        in_sof_usr,
138
        in_eof_usr,
139
        in_dst_rdy_usr,
140
        out_src_rdy_usr,
141
        out_data_usr,
142
        out_sof_usr,
143
        out_eof_usr,
144
        outport_usr,
145
        inport_usr,
146
        clk_local
147
);
148
 
149
 
150
//-----------------------------------------------------------------------------
151
// Port Declarations 
152
//-----------------------------------------------------------------------------
153
    // MII Interface - EMAC0
154
    input           MII_COL_0;
155
    input           MII_CRS_0;
156
    output   [3:0]  MII_TXD_0;
157
    output          MII_TX_EN_0;
158
    output          MII_TX_ER_0;
159
    input           MII_TX_CLK_0;
160
    input    [3:0]  MII_RXD_0;
161
    input           MII_RX_DV_0;
162
    input           MII_RX_ER_0;
163
    input           MII_RX_CLK_0;
164
 
165
    // Preserved Tie-Off Pins for EMAC0
166
    //input    [1:0]  SPEED_VECTOR_IN_0;
167
    input           HOSTCLK;
168
         output                         PHY_RESET_0;
169
 
170
    // Asynchronous Reset
171
    input           RESET;
172
 
173
         // User Connections
174
         input in_src_rdy_usr;
175
         input out_dst_rdy_usr;
176
         input [7:0] in_data_usr;
177
         input in_sof_usr;
178
         input in_eof_usr;
179
         output in_dst_rdy_usr;
180
         output out_src_rdy_usr;
181
         output [7:0] out_data_usr;
182
         output out_sof_usr;
183
         output out_eof_usr;
184
         output [3:0] outport_usr;
185
         output [3:0] inport_usr;
186
         output clk_local;
187
 
188
 
189
//-----------------------------------------------------------------------------
190
// Wire and Reg Declarations 
191
//-----------------------------------------------------------------------------
192
 
193
    // Global asynchronous reset
194
    wire            reset_i;
195
    // Client Interface Clocking Signals - EMAC0
196
    wire            tx_clk_0_i;
197
    wire            rx_clk_0_i;
198
 
199
    // address swap transmitter connections - EMAC0
200
    wire      [7:0] tx_ll_data_0_i;
201
    wire            tx_ll_sof_n_0_i;
202
    wire            tx_ll_eof_n_0_i;
203
    wire            tx_ll_src_rdy_n_0_i;
204
    wire            tx_ll_dst_rdy_n_0_i;
205
 
206
    // address swap receiver connections - EMAC0
207
    wire      [7:0] rx_ll_data_0_i;
208
    wire            rx_ll_sof_n_0_i;
209
    wire            rx_ll_eof_n_0_i;
210
    wire            rx_ll_src_rdy_n_0_i;
211
    wire            rx_ll_dst_rdy_n_0_i;
212
 
213
    // create a synchronous reset in the transmitter clock domain
214
    reg       [5:0] tx_pre_reset_0_i;
215
    reg             tx_reset_0_i;
216
 
217
    // synthesis attribute ASYNC_REG of tx_pre_reset_0_i is "TRUE";
218
 
219
    wire host_clk_i;
220
 
221
         wire [1:0] SPEED_VECTOR_IN_0;
222
 
223
     // synthesis attribute buffer_type of host_clk_i is none;
224
 
225
//-----------------------------------------------------------------------------
226
// Main Body of Code 
227
//-----------------------------------------------------------------------------
228
 
229
   wire [7:0]  CLIENTEMAC0TXIFGDELAY;
230
   wire [7:0]  CLIENTEMAC1TXIFGDELAY;
231
   wire        CLIENTEMAC0PAUSEREQ;
232
   wire        CLIENTEMAC1PAUSEREQ;
233
   wire [15:0] CLIENTEMAC0PAUSEVAL;
234
   wire [15:0] CLIENTEMAC1PAUSEVAL;
235
 
236
   assign  CLIENTEMAC0TXIFGDELAY = 8'h3F;
237
   assign  CLIENTEMAC1TXIFGDELAY = 8'h3F;
238
   assign  CLIENTEMAC0PAUSEREQ = 0;
239
   assign  CLIENTEMAC1PAUSEREQ = 0;
240
   assign  CLIENTEMAC0PAUSEVAL = 0;
241
   assign  CLIENTEMAC1PAUSEVAL = 0;
242
 
243
    // Reset input buffer
244
 
245
         assign PHY_RESET_0 = ~RESET;
246
         assign reset_i = RESET;
247
 
248
    //------------------------------------------------------------------------
249
    // Instantiate the EMAC Wrapper with LL FIFO 
250
    // (v4_emac_v4_8_locallink.v) 
251
    //------------------------------------------------------------------------
252
    v4_emac_v4_8_locallink v4_emac_ll
253
    (
254
    // Local link Receiver Interface - EMAC0
255
    .RX_LL_CLOCK_0                       (clk_local),
256
    .RX_LL_RESET_0                       (tx_reset_0_i),
257
    .RX_LL_DATA_0                        (rx_ll_data_0_i),
258
    .RX_LL_SOF_N_0                       (rx_ll_sof_n_0_i),
259
    .RX_LL_EOF_N_0                       (rx_ll_eof_n_0_i),
260
    .RX_LL_SRC_RDY_N_0                   (rx_ll_src_rdy_n_0_i),
261
    .RX_LL_DST_RDY_N_0                   (rx_ll_dst_rdy_n_0_i),
262
    .RX_LL_FIFO_STATUS_0                 (),
263
 
264
    // Client Clocks and Unused Receiver signals - EMAC0
265
    .RX_CLIENT_CLK_0                     (rx_clk_0_i),
266
    .EMAC0CLIENTRXDVLD                   (EMAC0CLIENTRXDVLD),
267
    .EMAC0CLIENTRXFRAMEDROP              (EMAC0CLIENTRXFRAMEDROP),
268
    .EMAC0CLIENTRXSTATS                  (EMAC0CLIENTRXSTATS),
269
    .EMAC0CLIENTRXSTATSVLD               (EMAC0CLIENTRXSTATSVLD),
270
    .EMAC0CLIENTRXSTATSBYTEVLD           (EMAC0CLIENTRXSTATSBYTEVLD),
271
 
272
    // Local link Transmitter Interface - EMAC0
273
    .TX_LL_CLOCK_0                       (clk_local),
274
    .TX_LL_RESET_0                       (tx_reset_0_i),
275
    .TX_LL_DATA_0                        (tx_ll_data_0_i),
276
    .TX_LL_SOF_N_0                       (tx_ll_sof_n_0_i),
277
    .TX_LL_EOF_N_0                       (tx_ll_eof_n_0_i),
278
    .TX_LL_SRC_RDY_N_0                   (tx_ll_src_rdy_n_0_i),
279
    .TX_LL_DST_RDY_N_0                   (tx_ll_dst_rdy_n_0_i),
280
 
281
    // Client Clocks and Unused Transmitter signals - EMAC0
282
    .TX_CLIENT_CLK_0                     (tx_clk_0_i),
283
    .CLIENTEMAC0TXIFGDELAY               (CLIENTEMAC0TXIFGDELAY),
284
    .EMAC0CLIENTTXSTATS                  (EMAC0CLIENTTXSTATS),
285
    .EMAC0CLIENTTXSTATSVLD               (EMAC0CLIENTTXSTATSVLD),
286
    .EMAC0CLIENTTXSTATSBYTEVLD           (EMAC0CLIENTTXSTATSBYTEVLD),
287
 
288
    // MAC Control Interface - EMAC0
289
    .CLIENTEMAC0PAUSEREQ                 (CLIENTEMAC0PAUSEREQ),
290
    .CLIENTEMAC0PAUSEVAL                 (CLIENTEMAC0PAUSEVAL),
291
 
292
 
293
 
294
 
295
    // MII Interface - EMAC0
296
    .MII_COL_0                           (MII_COL_0),
297
    .MII_CRS_0                           (MII_CRS_0),
298
    .MII_TXD_0                           (MII_TXD_0),
299
    .MII_TX_EN_0                         (MII_TX_EN_0),
300
    .MII_TX_ER_0                         (MII_TX_ER_0),
301
    .MII_TX_CLK_0                        (MII_TX_CLK_0),
302
    .MII_RXD_0                           (MII_RXD_0),
303
    .MII_RX_DV_0                         (MII_RX_DV_0),
304
    .MII_RX_ER_0                         (MII_RX_ER_0),
305
    .MII_RX_CLK_0                        (MII_RX_CLK_0),
306
 
307
    // Preserved Tie-Off Pins for EMAC0
308
    .SPEED_VECTOR_IN_0                  (SPEED_VECTOR_IN_0),
309
    .HOSTCLK                             (host_clk_i),
310
    // Asynchronous Reset Input
311
    .RESET                               (reset_i));
312
 
313
         assign SPEED_VECTOR_IN_0 = 2'b01;
314
 
315
    //-------------------------------------------------------------------
316
    //  Instatiate the address swapping module
317
    //-------------------------------------------------------------------
318
    /*address_swap_module_8 client_side_asm_emac0
319
      (.rx_ll_clock(tx_clk_0_i),
320
       .rx_ll_reset(tx_reset_0_i),
321
       .rx_ll_data_in(rx_ll_data_0_i),
322
       .rx_ll_sof_in_n(rx_ll_sof_n_0_i),
323
       .rx_ll_eof_in_n(rx_ll_eof_n_0_i),
324
       .rx_ll_src_rdy_in_n(rx_ll_src_rdy_n_0_i),
325
       .rx_ll_data_out(tx_ll_data_0_i),
326
       .rx_ll_sof_out_n(tx_ll_sof_n_0_i),
327
       .rx_ll_eof_out_n(tx_ll_eof_n_0_i),
328
       .rx_ll_src_rdy_out_n(tx_ll_src_rdy_n_0_i),
329
       .rx_ll_dst_rdy_in_n(tx_ll_dst_rdy_n_0_i)
330
    );*/
331
 
332
        wire out_sof_p, out_eof_p, out_src_rdy_p, out_dst_rdy_p;
333
        wire in_sof_p, in_eof_p, in_src_rdy_p, in_dst_rdy_p;
334
        wire pp_enable;
335
        wire [3:0] port_addr;
336
        wire [3:0] outport_addr;
337
        wire [3:0] inport_addr;
338
        reg [7:0] in_data_p;
339
        reg [7:0] DIP_r;
340
 
341
        reg out_sof_pr, out_eof_pr, out_src_rdy_pr, out_dst_rdy_pr;
342
        reg in_sof_pr, in_eof_pr, in_src_rdy_pr, in_dst_rdy_pr;
343
 
344
        assign pp_enable = 1;
345
 
346
         patlpp pp
347
         (
348
                 .en(pp_enable),
349
                 .clk(clk_local),
350
                 .rst(reset_i),
351
                 .in_sof(in_sof_p),
352
                 .in_eof(in_eof_p),
353
                 .in_src_rdy(in_src_rdy_p),
354
                 .in_dst_rdy(in_dst_rdy_p),
355
                 .out_sof(out_sof_p),
356
                 .out_eof(out_eof_p),
357
                 .out_src_rdy(out_src_rdy_p),
358
                 .out_dst_rdy(out_dst_rdy_p),
359
                 .in_data(in_data_p),
360
                 .out_data(tx_ll_data_0_i),
361
                 .outport_addr(outport_addr),
362
                 .inport_addr(inport_addr)//,
363
                 //.chipscope_data(chipscope_data_pp)
364
         );
365
 
366
         assign tx_ll_sof_n_0_i = ~out_sof_p;
367
         assign tx_ll_eof_n_0_i = ~out_eof_p;
368
         assign tx_ll_src_rdy_n_0_i = ~out_src_rdy_pr;
369
         assign rx_ll_dst_rdy_n_0_i = ~in_dst_rdy_pr;
370
         assign in_sof_p = in_sof_pr;
371
         assign in_eof_p = in_eof_pr;
372
         assign in_src_rdy_p = in_src_rdy_pr;
373
         assign out_dst_rdy_p = out_dst_rdy_pr;
374
 
375
         assign in_dst_rdy_usr = in_dst_rdy_p;
376
         assign out_src_rdy_usr = out_src_rdy_p;
377
         assign outport_usr = outport_addr;
378
         assign inport_usr = inport_addr;
379
         assign out_data_usr = tx_ll_data_0_i;
380
         assign out_sof_usr = out_sof_p;
381
         assign out_eof_usr = out_eof_p;
382
 
383
         // Processor Clock Generation
384
 
385
        wire    sysclk_u;
386
        wire    sysclk_l;
387
        wire    dcmreset;
388
 
389
         DCM_BASE #(
390
                .CLKIN_PERIOD(10),
391
                .CLK_FEEDBACK("NONE"),
392
                .CLKFX_DIVIDE(4),
393
                .CLKFX_MULTIPLY(2)
394
         ) dcm_patlpp (
395
                .CLKFX(sysclk_u),
396
                .LOCKED(sysclk_l),
397
                .CLKIN(host_clk_i),
398
                .RST(reset_i)
399
         );
400
         BUFG bufg_ll_clk (.I(sysclk_u), .O(clk_local));
401
 
402
         dcm_reset dcm_reset_inst (
403
                .ref_reset(reset_i),
404
                .ref_clk(host_clk_i),
405
                .dcm_locked(sysclk_l),
406
                .dcm_reset(dcmreset)
407
        );
408
 
409
         //assign clk_local = host_clk_i;
410
 
411
         // In Port
412
         always @(inport_addr or rx_ll_src_rdy_n_0_i or rx_ll_data_0_i or in_dst_rdy_p or rx_ll_sof_n_0_i or rx_ll_eof_n_0_i or in_src_rdy_usr or in_data_usr or in_sof_usr or in_eof_usr)
413
         begin
414
                case (inport_addr)
415
                        0:
416
                        begin
417
                                in_src_rdy_pr <= ~rx_ll_src_rdy_n_0_i;
418
                                in_dst_rdy_pr <= in_dst_rdy_p;
419
                                in_data_p <= rx_ll_data_0_i;
420
                                in_sof_pr <= ~rx_ll_sof_n_0_i;
421
                                in_eof_pr <= ~rx_ll_eof_n_0_i;
422
                        end
423
                        default:
424
                        begin
425
                                in_src_rdy_pr <= in_src_rdy_usr;
426
                                in_dst_rdy_pr <= 0;
427
                                in_data_p <= in_data_usr;
428
                                in_sof_pr <= in_sof_usr;
429
                                in_eof_pr <= in_eof_usr;
430
                        end
431
                endcase
432
         end
433
 
434
         // Out Port
435
         always @(outport_addr or out_src_rdy_p or tx_ll_dst_rdy_n_0_i or out_dst_rdy_usr)
436
         begin
437
                case (outport_addr)
438
                        0:
439
                        begin
440
                                out_src_rdy_pr <= out_src_rdy_p;
441
                                out_dst_rdy_pr <= ~tx_ll_dst_rdy_n_0_i;
442
                        end
443
                        default:
444
                        begin
445
                                out_src_rdy_pr <= 0;
446
                                out_dst_rdy_pr <= out_dst_rdy_usr;
447
                        end
448
                endcase
449
         end
450
 
451
    //assign rx_ll_dst_rdy_n_0_i   = tx_ll_dst_rdy_n_0_i;
452
 
453
    // Create synchronous reset in the transmitter clock domain.
454
    always @(posedge clk_local, posedge reset_i)
455
    begin
456
      if (reset_i === 1'b1)
457
      begin
458
        tx_pre_reset_0_i <= 6'h3F;
459
        tx_reset_0_i     <= 1'b1;
460
      end
461
      else
462
      begin
463
        tx_pre_reset_0_i[0]   <= 1'b0;
464
        tx_pre_reset_0_i[5:1] <= tx_pre_reset_0_i[4:0];
465
        tx_reset_0_i          <= tx_pre_reset_0_i[5];
466
      end
467
    end
468
 
469
 
470
 
471
    //----------------------------------------------------------------------
472
    // HOSTCLK Clock Management - Clock input for the generic management 
473
    // interface. This clock could be tied to a 125MHz reference clock 
474
    // to save on clocking resources
475
    //----------------------------------------------------------------------
476
   IBUF host_clk      (.I(HOSTCLK),              .O(host_clk_i));
477
 
478
//    assign host_clk_i = HOSTCLK;
479
 
480
 
481
endmodule

powered by: WebSVN 2.1.0

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