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 49

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

powered by: WebSVN 2.1.0

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