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 36

Go to most recent revision | 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
                    app_send_pause_i,
59
                    app_send_pause_active_o,
60
                    app_send_jam_i,
61
 
62
                    // Application RX FIFO Interface
63
                    app_txfifo_wren_i,
64
                    app_txfifo_wrdata_i,
65
                    app_txfifo_full_o,
66 19 dinesha
                    app_txfifo_afull_o,
67 12 dinesha
                    app_txfifo_space_o,
68
 
69
                    // Application TX FIFO Interface
70
                    app_rxfifo_rden_i,
71
                    app_rxfifo_empty_o,
72 19 dinesha
                    app_rxfifo_aempty_o,
73 12 dinesha
                    app_rxfifo_cnt_o,
74
                    app_rxfifo_rdata_o,
75
 
76
                    // Conntrol Bus Sync with Application Clock
77
                    reg_cs,
78
                    reg_wr,
79
                    reg_addr,
80
                    reg_wdata,
81
                    reg_be,
82
 
83
                     // Outputs
84
                    reg_rdata,
85
                    reg_ack,
86
 
87
 
88
                    // Phy Signals 
89
 
90
                    // Line Side Interface TX Path
91
                    phy_tx_en,
92
                    phy_tx_er,
93
                    phy_txd,
94
                    phy_tx_clk,
95
 
96
                    // Line Side Interface RX Path
97
                    phy_rx_clk,
98
                    phy_rx_er,
99
                    phy_rx_dv,
100
                    phy_rxd,
101
                    phy_crs,
102
 
103
                    //MDIO interface
104
                    mdio_clk,
105
                    mdio_in,
106
                    mdio_out_en,
107
                    mdio_out
108
       );
109
 
110
parameter W  = 8'd9;
111
parameter DP = 8'd32;
112
parameter AW = (DP == 2)   ? 1 :
113
               (DP == 4)   ? 2 :
114
               (DP == 8)   ? 3 :
115
               (DP == 16)  ? 4 :
116
               (DP == 32)  ? 5 :
117
               (DP == 64)  ? 6 :
118
               (DP == 128) ? 7 :
119
               (DP == 256) ? 8 : 0;
120
 
121
 
122
//-----------------------------------------------------------------------
123
// INPUT/OUTPUT DECLARATIONS
124
//-----------------------------------------------------------------------
125
input                    scan_mode;
126
input                    s_reset_n;
127
input                    tx_reset_n;
128
input                    rx_reset_n;
129
input                    reset_mdio_clk_n;
130
input                    app_reset_n;
131
 
132
//-----------------------------------------------------------------------
133
// Application Clock Related Declaration
134
//-----------------------------------------------------------------------
135
input                    app_clk;
136
input                    app_send_pause_i;
137
output                   app_send_pause_active_o;
138
input                    app_send_jam_i;
139
 
140
 
141
// Application RX FIFO Interface
142
input                    app_txfifo_wren_i;
143
input  [8:0]             app_txfifo_wrdata_i;
144
output                   app_txfifo_full_o;
145 19 dinesha
output                   app_txfifo_afull_o;
146 12 dinesha
output [AW:0]            app_txfifo_space_o;
147
 
148
// Application TX FIFO Interface
149
input                    app_rxfifo_rden_i;
150
output                   app_rxfifo_empty_o;
151 19 dinesha
output                   app_rxfifo_aempty_o;
152 12 dinesha
output [AW:0]            app_rxfifo_cnt_o;
153
output [8:0]             app_rxfifo_rdata_o;
154
 
155
// Conntrol Bus Sync with Application Clock
156
//---------------------------------
157
// Reg Bus Interface Signal
158
//---------------------------------
159
input             reg_cs         ;
160
input             reg_wr         ;
161
input [3:0]       reg_addr       ;
162
input [31:0]      reg_wdata      ;
163
input [3:0]       reg_be         ;
164
 
165
   // Outputs
166
output [31:0]     reg_rdata      ;
167
output            reg_ack        ;
168
 
169
//-----------------------------------------------------------------------
170
// Line-Tx Signal
171
//-----------------------------------------------------------------------
172
output            phy_tx_en;
173
output            phy_tx_er;
174
output [7:0]      phy_txd;
175
input             phy_tx_clk;
176
 
177
//-----------------------------------------------------------------------
178
// Line-Rx Signal
179
//-----------------------------------------------------------------------
180
input             phy_rx_clk;
181
input             phy_rx_er;
182
input             phy_rx_dv;
183
input [7:0]       phy_rxd;
184
input             phy_crs;
185
 
186
 
187
//-----------------------------------------------------------------------
188
// MDIO Signal
189
//-----------------------------------------------------------------------
190
  input        mdio_clk;
191
  input        mdio_in;
192
  output       mdio_out_en;
193
  output       mdio_out;
194
 
195
//---------------------
196
// RX FIFO Interface Signal
197
  wire         clr_rx_error_from_rx_fsm_o;
198
  wire         rx_fifo_full_i;
199
  wire         rx_fifo_wr_o;
200
  wire  [8:0]  rx_fifo_data_o;
201
  wire         rx_commit_wr_o;
202
  wire         rx_commit_write_done_o;
203
  wire         rx_rewind_wr_o;
204
  wire         rx_fifo_error = 1'b0;
205
 
206
//-----------------------------------------------------------------------
207
// TX-Clock Domain Status Signal
208
//-----------------------------------------------------------------------
209
  wire        tx_commit_read;
210
  wire        tx_fifo_rd;
211
 
212
  wire [8:0]  tx_fifo_data;
213
  wire        tx_fifo_empty;
214
  wire        tx_fifo_rdy;
215
  wire [AW:0]  tx_fifo_aval;
216
 
217 36 dinesha
  wire [47:0]   cf_mac_sa;
218
  wire [31:0]   cfg_ip_sa;
219
  wire [31:0]   cfg_mac_filter;
220
 
221
 
222
g_eth_parser u_eth_parser (
223
                    .s_reset_n        (app_reset_n),
224
                    .app_clk          (app_clk),
225
 
226
               // Configuration
227
                    .cfg_filters      (cfg_filters),
228
                    .cfg_mac_sa       (cf_mac_sa),
229
                    .cfg_ip_sa        (cfg_ip_sa),
230
 
231
               // Input Control Information
232
                    .eop               (app_rxfifo_rdata_o[8]),
233
                    .dval              (app_rxfifo_rden_i),
234
                    .data              (app_rxfifo_rdata_o[7:0]),
235
 
236
                // output status 
237
                    .pkt_done          (),
238
                    .pkt_len           (),
239
                    .pkt_status        (),
240
                    .pkt_drop_ind      (),
241
                    .pkt_drop_reason   ()
242
               );
243
 
244
 
245
 
246 12 dinesha
g_mac_core u_mac_core  (
247
                    .scan_mode               (scan_mode),
248
                    .s_reset_n               (s_reset_n) ,
249
                    .tx_reset_n              (tx_reset_n) ,
250
                    .rx_reset_n              (rx_reset_n) ,
251
                    .reset_mdio_clk_n        (reset_mdio_clk_n) ,
252
                    .app_reset_n             (app_reset_n) ,
253
 
254
                 // Reg Bus Interface Signal
255
                    . reg_cs                 (reg_cs),
256
                    . reg_wr                 (reg_wr),
257
                    . reg_addr               (reg_addr),
258
                    . reg_wdata              (reg_wdata),
259
                    . reg_be                 (reg_be),
260
 
261
                     // Outputs
262
                     . reg_rdata             (reg_rdata),
263
                     . reg_ack               (reg_ack),
264
 
265
                    .app_clk                 (app_clk) ,
266
                    .app_send_pause_i        (app_send_pause_i) ,
267
                    .app_send_pause_active_o (app_send_pause_active_o) ,
268
                    .app_send_jam_i          (app_send_jam_i) ,
269
 
270
                    // Conntrol Bus Sync with Application Clock
271
 
272
 
273
 
274
                  // RX FIFO Interface Signal
275
                    .rx_fifo_full_i          (rx_fifo_full_i) ,
276
                    .rx_fifo_wr_o            (rx_fifo_wr_o) ,
277
                    .rx_fifo_data_o          (rx_fifo_data_o) ,
278
                    .rx_commit_wr_o          (rx_commit_wr_o) ,
279
                    .rx_rewind_wr_o          (rx_rewind_wr_o) ,
280
                    .rx_commit_write_done_o  (rx_commit_write_done_o) ,
281
                    .clr_rx_error_from_rx_fsm_o(clr_rx_error_from_rx_fsm_o) ,
282
                    .rx_fifo_error_i         (rx_fifo_error) ,
283
 
284
                  // TX FIFO Interface Signal
285
                    .tx_fifo_data_i          (tx_fifo_data) ,
286
                    .tx_fifo_empty_i         (tx_fifo_empty) ,
287
                    .tx_fifo_rdy_i           (tx_fifo_rdy) , // See to connect to config
288
                    .tx_fifo_rd_o            (tx_fifo_rd) ,
289
                    .tx_commit_read_o        (tx_commit_read) ,
290
 
291
                    // Phy Signals 
292
 
293
                    // Line Side Interface TX Path
294
                    .phy_tx_en               (phy_tx_en) ,
295
                    .phy_tx_er               (phy_tx_er) ,
296
                    .phy_txd                 (phy_txd) ,
297
                    .phy_tx_clk              (phy_tx_clk) ,
298
 
299
                    // Line Side Interface RX Path
300
                    .phy_rx_clk              (phy_rx_clk) ,
301
                    .phy_rx_er               (phy_rx_er) ,
302
                    .phy_rx_dv               (phy_rx_dv) ,
303
                    .phy_rxd                 (phy_rxd) ,
304
                    .phy_crs                 (phy_crs) ,
305
 
306
                    //MDIO interface
307
                    .mdio_clk                (mdio_clk) ,
308
                    .mdio_in                 (mdio_in) ,
309
                    .mdio_out_en             (mdio_out_en) ,
310 36 dinesha
                    .mdio_out                (mdio_out),
311
 
312
                    .cf_mac_sa               (cf_mac_sa),
313
                    .cfg_ip_sa               (cfg_ip_sa),
314
                    .cfg_mac_filter          (cfg_mac_filter)
315
 
316 12 dinesha
       );
317
 
318
assign tx_fifo_rdy = (tx_fifo_aval > 8) ; // Dinesh-A Change it to config
319
 
320
async_fifo #(W,DP,0,0) u_mac_txfifo  (
321
                   .wr_clk                   (app_clk),
322
                   .wr_reset_n               (app_reset_n),
323
                   .wr_en                    (app_txfifo_wren_i),
324
                   .wr_data                  (app_txfifo_wrdata_i),
325
                   .full                     (app_txfifo_full_o), // sync'ed to wr_clk
326 19 dinesha
                   .afull                    (app_txfifo_afull_o), // sync'ed to wr_clk
327 12 dinesha
                   .wr_total_free_space      (app_txfifo_space_o),
328
 
329
                   .rd_clk                   (phy_tx_clk),
330
                   .rd_reset_n               (tx_reset_n),
331
                   .rd_en                    (tx_fifo_rd),
332
                   .empty                    (tx_fifo_empty),  // sync'ed to rd_clk
333 19 dinesha
                   .aempty                   (tx_fifo_aempty), // sync'ed to rd_clk
334 12 dinesha
                   .rd_total_aval            (tx_fifo_aval),
335
                   .rd_data                  (tx_fifo_data)
336
                   );
337
 
338
async_fifo #(W,DP,0,0) u_mac_rxfifo (
339
                   .wr_clk                   (phy_rx_clk),
340
                   .wr_reset_n               (rx_reset_n),
341
                   .wr_en                    (rx_fifo_wr_o),
342
                   .wr_data                  (rx_fifo_data_o),
343
                   .full                     (rx_fifo_full_i), // sync'ed to wr_clk
344 19 dinesha
                   .afull                    (rx_fifo_afull_i), // sync'ed to wr_clk
345 12 dinesha
                   .wr_total_free_space      (),
346
 
347
                   .rd_clk                   (app_clk),
348
                   .rd_reset_n               (app_reset_n),
349
                   .rd_en                    (app_rxfifo_rden_i),
350
                   .empty                    (app_rxfifo_empty_o),  // sync'ed to rd_clk
351 19 dinesha
                   .aempty                   (app_rxfifo_aempty_o), // sync'ed to rd_clk
352 12 dinesha
                   .rd_total_aval            (app_rxfifo_cnt_o),
353
                   .rd_data                  (app_rxfifo_rdata_o)
354
                   );
355
 
356
 
357
 
358
endmodule
359
 

powered by: WebSVN 2.1.0

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