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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [gmac/] [top/] [g_mac_top.v] - Blame information for rev 57

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Tubo 8051 cores MAC Interface Module                        ////
4
////                                                              ////
5
////  This file is part of the Turbo 8051 cores project           ////
6
////  http://www.opencores.org/cores/turbo8051/                   ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Turbo 8051 definitions.                                     ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
 
44
// ------------------------------------------------------------------------
45
// Description      : 
46
//   This module instantiates the MAC block and the FIFO interface
47
//
48
// ------------------------------------------------------------------------
49
module  g_mac_top (
50
                    scan_mode,
51
                    s_reset_n,
52
                    tx_reset_n,
53
                    rx_reset_n,
54
                    reset_mdio_clk_n,
55
                    app_reset_n,
56
 
57
                    app_clk,
58
 
59
                    // Application RX FIFO Interface
60
                    app_txfifo_wren_i,
61
                    app_txfifo_wrdata_i,
62 50 dinesha
                    app_txfifo_addr,
63 12 dinesha
                    app_txfifo_full_o,
64 19 dinesha
                    app_txfifo_afull_o,
65 12 dinesha
                    app_txfifo_space_o,
66
 
67
                    // Application TX FIFO Interface
68
                    app_rxfifo_rden_i,
69
                    app_rxfifo_empty_o,
70 19 dinesha
                    app_rxfifo_aempty_o,
71 12 dinesha
                    app_rxfifo_cnt_o,
72
                    app_rxfifo_rdata_o,
73 50 dinesha
                    app_rxfifo_addr,
74 12 dinesha
 
75 50 dinesha
                    app_rx_desc_req     ,
76
                    app_rx_desc_ack     ,
77
                    app_rx_desc_discard ,
78
                    app_rx_desc_data    ,
79
 
80 12 dinesha
                    // Conntrol Bus Sync with Application Clock
81
                    reg_cs,
82
                    reg_wr,
83
                    reg_addr,
84
                    reg_wdata,
85
                    reg_be,
86
 
87
                     // Outputs
88
                    reg_rdata,
89
                    reg_ack,
90
 
91
 
92
                    // Phy Signals 
93
 
94
                    // Line Side Interface TX Path
95
                    phy_tx_en,
96
                    phy_tx_er,
97
                    phy_txd,
98
                    phy_tx_clk,
99
 
100
                    // Line Side Interface RX Path
101
                    phy_rx_clk,
102
                    phy_rx_er,
103
                    phy_rx_dv,
104
                    phy_rxd,
105
                    phy_crs,
106
 
107
                    //MDIO interface
108
                    mdio_clk,
109
                    mdio_in,
110
                    mdio_out_en,
111 50 dinesha
                    mdio_out,
112
 
113
            // QCounter
114
                    rx_buf_qbase_addr,
115
                    tx_buf_qbase_addr,
116
 
117
                    tx_qcnt_inc,
118
                    tx_qcnt_dec,
119
                    rx_qcnt_inc,
120
                    rx_qcnt_dec,
121
 
122
                    tx_qcnt,
123
                    rx_qcnt
124
 
125 12 dinesha
       );
126
 
127
parameter W  = 8'd9;
128
parameter DP = 8'd32;
129
parameter AW = (DP == 2)   ? 1 :
130
               (DP == 4)   ? 2 :
131
               (DP == 8)   ? 3 :
132
               (DP == 16)  ? 4 :
133
               (DP == 32)  ? 5 :
134
               (DP == 64)  ? 6 :
135
               (DP == 128) ? 7 :
136
               (DP == 256) ? 8 : 0;
137
 
138
 
139
//-----------------------------------------------------------------------
140
// INPUT/OUTPUT DECLARATIONS
141
//-----------------------------------------------------------------------
142
input                    scan_mode;
143
input                    s_reset_n;
144
input                    tx_reset_n;
145
input                    rx_reset_n;
146
input                    reset_mdio_clk_n;
147
input                    app_reset_n;
148
 
149
//-----------------------------------------------------------------------
150
// Application Clock Related Declaration
151
//-----------------------------------------------------------------------
152
input                    app_clk;
153
 
154
 
155
// Application RX FIFO Interface
156
input                    app_txfifo_wren_i;
157
input  [8:0]             app_txfifo_wrdata_i;
158 50 dinesha
output [15:0]            app_txfifo_addr;
159
 
160 12 dinesha
output                   app_txfifo_full_o;
161 19 dinesha
output                   app_txfifo_afull_o;
162 12 dinesha
output [AW:0]            app_txfifo_space_o;
163
 
164
// Application TX FIFO Interface
165
input                    app_rxfifo_rden_i;
166
output                   app_rxfifo_empty_o;
167 19 dinesha
output                   app_rxfifo_aempty_o;
168 12 dinesha
output [AW:0]            app_rxfifo_cnt_o;
169
output [8:0]             app_rxfifo_rdata_o;
170 50 dinesha
output [15:0]            app_rxfifo_addr;
171 12 dinesha
 
172 50 dinesha
// descriptor interface
173
output                   app_rx_desc_req     ; // descriptor request
174
input                    app_rx_desc_ack     ; // descriptor ack
175
output                   app_rx_desc_discard ; // descriptor discard
176
output [31:0]            app_rx_desc_data    ; // descriptor data
177
 
178 12 dinesha
// Conntrol Bus Sync with Application Clock
179
//---------------------------------
180
// Reg Bus Interface Signal
181
//---------------------------------
182
input             reg_cs         ;
183
input             reg_wr         ;
184
input [3:0]       reg_addr       ;
185
input [31:0]      reg_wdata      ;
186
input [3:0]       reg_be         ;
187
 
188
   // Outputs
189
output [31:0]     reg_rdata      ;
190
output            reg_ack        ;
191
 
192
//-----------------------------------------------------------------------
193
// Line-Tx Signal
194
//-----------------------------------------------------------------------
195
output            phy_tx_en;
196
output            phy_tx_er;
197
output [7:0]      phy_txd;
198
input             phy_tx_clk;
199
 
200
//-----------------------------------------------------------------------
201
// Line-Rx Signal
202
//-----------------------------------------------------------------------
203
input             phy_rx_clk;
204
input             phy_rx_er;
205
input             phy_rx_dv;
206
input [7:0]       phy_rxd;
207
input             phy_crs;
208
 
209
 
210
//-----------------------------------------------------------------------
211
// MDIO Signal
212
//-----------------------------------------------------------------------
213
  input        mdio_clk;
214
  input        mdio_in;
215
  output       mdio_out_en;
216
  output       mdio_out;
217
 
218 50 dinesha
//--------------------------------------
219
// QCounter, Better to move to seperate global reg block
220
//-------------------------------------
221
output  [9:0]  rx_buf_qbase_addr; // Rx QBase Address
222
output  [9:0]  tx_buf_qbase_addr; // TX QBase Address
223
 
224
input          tx_qcnt_inc;       // Tx QCounter Increment indication
225
input          tx_qcnt_dec;       // Tx QCounter Decrement indication
226
input          rx_qcnt_inc;       // Rx QCounter Increment indication
227
input          rx_qcnt_dec;       // Rx QCounter Decrement indication
228
 
229
output [3:0]   tx_qcnt    ;
230
output [3:0]   rx_qcnt    ;
231
 
232 12 dinesha
//---------------------
233
// RX FIFO Interface Signal
234
  wire         clr_rx_error_from_rx_fsm_o;
235
  wire         rx_fifo_full_i;
236
  wire         rx_fifo_wr_o;
237
  wire  [8:0]  rx_fifo_data_o;
238
  wire         rx_commit_wr_o;
239
  wire         rx_commit_write_done_o;
240
  wire         rx_rewind_wr_o;
241
  wire         rx_fifo_error = 1'b0;
242
 
243
//-----------------------------------------------------------------------
244
// TX-Clock Domain Status Signal
245
//-----------------------------------------------------------------------
246
  wire        tx_commit_read;
247
  wire        tx_fifo_rd;
248
 
249
  wire [8:0]  tx_fifo_data;
250
  wire        tx_fifo_empty;
251
  wire        tx_fifo_rdy;
252
  wire [AW:0]  tx_fifo_aval;
253
 
254 36 dinesha
  wire [47:0]   cf_mac_sa;
255
  wire [31:0]   cfg_ip_sa;
256
  wire [31:0]   cfg_mac_filter;
257 50 dinesha
  wire [3:0]    tx_buf_base_addr;
258
  wire [3:0]    rx_buf_base_addr;
259
  wire [11:0]   g_rx_pkt_len;
260
  wire [15:0]   pkt_status;
261
  wire          app_rxfifo_empty;
262
  wire          g_rx_block_rxrd;
263 57 dinesha
  wire [15:0]   g_rx_pkt_status       ; // Packet Status
264 36 dinesha
 
265 50 dinesha
assign app_rxfifo_empty_o = app_rxfifo_empty | g_rx_block_rxrd;
266
g_dpath_ctrl m_g_dpath_ctrl (
267
           .rst_n               ( s_reset_n             ),
268
           .clk                 ( app_clk               ),
269 36 dinesha
 
270 50 dinesha
           .rx_buf_base_addr    (rx_buf_base_addr       ),
271
           .tx_buf_base_addr    (tx_buf_base_addr       ),
272
 
273
    // gmac core to memory write interface
274
           .g_rx_mem_rd         ( app_rxfifo_rden_i      ),
275
           .g_rx_mem_eop        ( app_rxfifo_rdata_o[8]  ),
276
           .g_rx_mem_addr       ( app_rxfifo_addr        ),
277
           .g_rx_block_rxrd     ( g_rx_block_rxrd        ),
278
 
279
       // descr handshake    
280
           .g_rx_desc_req       (app_rx_desc_req         ),
281
           .g_rx_desc_discard   (app_rx_desc_discard     ),
282
           .g_rx_desc_data      (app_rx_desc_data        ),
283
           .g_rx_desc_ack       (app_rx_desc_ack         ),
284
 
285
 
286
           .g_rx_pkt_done       (g_rx_pkt_done           ),
287
           .g_rx_pkt_len        (g_rx_pkt_len            ),
288
           .g_rx_pkt_status     (g_rx_pkt_status         ),
289
           .g_rx_pkt_drop       (g_rx_pkt_drop           )
290
 
291
 
292
      );
293
 
294
 
295 36 dinesha
g_eth_parser u_eth_parser (
296
                    .s_reset_n        (app_reset_n),
297
                    .app_clk          (app_clk),
298
 
299
               // Configuration
300 50 dinesha
                    .cfg_filters      (cfg_mac_filter),
301 36 dinesha
                    .cfg_mac_sa       (cf_mac_sa),
302
                    .cfg_ip_sa        (cfg_ip_sa),
303
 
304
               // Input Control Information
305
                    .eop               (app_rxfifo_rdata_o[8]),
306
                    .dval              (app_rxfifo_rden_i),
307
                    .data              (app_rxfifo_rdata_o[7:0]),
308
 
309
                // output status 
310 50 dinesha
                    .pkt_done          (g_rx_pkt_done    ),
311
                    .pkt_len           (g_rx_pkt_len     ),
312
                    .pkt_status        (g_rx_pkt_status  ),
313
                    .pkt_drop_ind      (g_rx_pkt_drop    ),
314 36 dinesha
                    .pkt_drop_reason   ()
315
               );
316
 
317
 
318
 
319 12 dinesha
g_mac_core u_mac_core  (
320
                    .scan_mode               (scan_mode),
321
                    .s_reset_n               (s_reset_n) ,
322
                    .tx_reset_n              (tx_reset_n) ,
323
                    .rx_reset_n              (rx_reset_n) ,
324
                    .reset_mdio_clk_n        (reset_mdio_clk_n) ,
325
                    .app_reset_n             (app_reset_n) ,
326
 
327
                 // Reg Bus Interface Signal
328
                    . reg_cs                 (reg_cs),
329
                    . reg_wr                 (reg_wr),
330
                    . reg_addr               (reg_addr),
331
                    . reg_wdata              (reg_wdata),
332
                    . reg_be                 (reg_be),
333
 
334
                     // Outputs
335
                     . reg_rdata             (reg_rdata),
336
                     . reg_ack               (reg_ack),
337
 
338
                    .app_clk                 (app_clk) ,
339
 
340
                    // Conntrol Bus Sync with Application Clock
341
 
342
 
343
 
344
                  // RX FIFO Interface Signal
345
                    .rx_fifo_full_i          (rx_fifo_full_i) ,
346
                    .rx_fifo_wr_o            (rx_fifo_wr_o) ,
347
                    .rx_fifo_data_o          (rx_fifo_data_o) ,
348
                    .rx_commit_wr_o          (rx_commit_wr_o) ,
349
                    .rx_rewind_wr_o          (rx_rewind_wr_o) ,
350
                    .rx_commit_write_done_o  (rx_commit_write_done_o) ,
351
                    .clr_rx_error_from_rx_fsm_o(clr_rx_error_from_rx_fsm_o) ,
352
                    .rx_fifo_error_i         (rx_fifo_error) ,
353
 
354
                  // TX FIFO Interface Signal
355
                    .tx_fifo_data_i          (tx_fifo_data) ,
356
                    .tx_fifo_empty_i         (tx_fifo_empty) ,
357
                    .tx_fifo_rdy_i           (tx_fifo_rdy) , // See to connect to config
358
                    .tx_fifo_rd_o            (tx_fifo_rd) ,
359
                    .tx_commit_read_o        (tx_commit_read) ,
360
 
361
                    // Phy Signals 
362
 
363
                    // Line Side Interface TX Path
364
                    .phy_tx_en               (phy_tx_en) ,
365
                    .phy_tx_er               (phy_tx_er) ,
366
                    .phy_txd                 (phy_txd) ,
367
                    .phy_tx_clk              (phy_tx_clk) ,
368
 
369
                    // Line Side Interface RX Path
370
                    .phy_rx_clk              (phy_rx_clk) ,
371
                    .phy_rx_er               (phy_rx_er) ,
372
                    .phy_rx_dv               (phy_rx_dv) ,
373
                    .phy_rxd                 (phy_rxd) ,
374
                    .phy_crs                 (phy_crs) ,
375
 
376
                    //MDIO interface
377
                    .mdio_clk                (mdio_clk) ,
378
                    .mdio_in                 (mdio_in) ,
379
                    .mdio_out_en             (mdio_out_en) ,
380 36 dinesha
                    .mdio_out                (mdio_out),
381
 
382
                    .cf_mac_sa               (cf_mac_sa),
383
                    .cfg_ip_sa               (cfg_ip_sa),
384 50 dinesha
                    .cfg_mac_filter          (cfg_mac_filter),
385 36 dinesha
 
386 50 dinesha
                    .rx_buf_base_addr        (rx_buf_base_addr),
387
                    .tx_buf_base_addr        (tx_buf_base_addr),
388
 
389
                    .rx_buf_qbase_addr       (rx_buf_qbase_addr),
390
                    .tx_buf_qbase_addr       (tx_buf_qbase_addr),
391
 
392
                    .tx_qcnt_inc             (tx_qcnt_inc),
393
                    .tx_qcnt_dec             (tx_qcnt_dec),
394
                    .tx_qcnt                 (tx_qcnt),
395
 
396
                    .rx_qcnt_inc             (rx_qcnt_inc),
397
                    .rx_qcnt_dec             (rx_qcnt_dec),
398
                    .rx_qcnt                 (rx_qcnt)
399
 
400 12 dinesha
       );
401
 
402
assign tx_fifo_rdy = (tx_fifo_aval > 8) ; // Dinesh-A Change it to config
403
 
404
async_fifo #(W,DP,0,0) u_mac_txfifo  (
405
                   .wr_clk                   (app_clk),
406
                   .wr_reset_n               (app_reset_n),
407
                   .wr_en                    (app_txfifo_wren_i),
408
                   .wr_data                  (app_txfifo_wrdata_i),
409
                   .full                     (app_txfifo_full_o), // sync'ed to wr_clk
410 19 dinesha
                   .afull                    (app_txfifo_afull_o), // sync'ed to wr_clk
411 12 dinesha
                   .wr_total_free_space      (app_txfifo_space_o),
412
 
413
                   .rd_clk                   (phy_tx_clk),
414
                   .rd_reset_n               (tx_reset_n),
415
                   .rd_en                    (tx_fifo_rd),
416
                   .empty                    (tx_fifo_empty),  // sync'ed to rd_clk
417 19 dinesha
                   .aempty                   (tx_fifo_aempty), // sync'ed to rd_clk
418 12 dinesha
                   .rd_total_aval            (tx_fifo_aval),
419
                   .rd_data                  (tx_fifo_data)
420
                   );
421
 
422
async_fifo #(W,DP,0,0) u_mac_rxfifo (
423
                   .wr_clk                   (phy_rx_clk),
424
                   .wr_reset_n               (rx_reset_n),
425
                   .wr_en                    (rx_fifo_wr_o),
426
                   .wr_data                  (rx_fifo_data_o),
427
                   .full                     (rx_fifo_full_i), // sync'ed to wr_clk
428 19 dinesha
                   .afull                    (rx_fifo_afull_i), // sync'ed to wr_clk
429 12 dinesha
                   .wr_total_free_space      (),
430
 
431
                   .rd_clk                   (app_clk),
432
                   .rd_reset_n               (app_reset_n),
433
                   .rd_en                    (app_rxfifo_rden_i),
434 50 dinesha
                   .empty                    (app_rxfifo_empty),  // sync'ed to rd_clk
435 19 dinesha
                   .aempty                   (app_rxfifo_aempty_o), // sync'ed to rd_clk
436 12 dinesha
                   .rd_total_aval            (app_rxfifo_cnt_o),
437
                   .rd_data                  (app_rxfifo_rdata_o)
438
                   );
439
 
440
 
441
 
442
endmodule
443
 

powered by: WebSVN 2.1.0

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