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 25

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
g_mac_core u_mac_core  (
218
                    .scan_mode               (scan_mode),
219
                    .s_reset_n               (s_reset_n) ,
220
                    .tx_reset_n              (tx_reset_n) ,
221
                    .rx_reset_n              (rx_reset_n) ,
222
                    .reset_mdio_clk_n        (reset_mdio_clk_n) ,
223
                    .app_reset_n             (app_reset_n) ,
224
 
225
                 // Reg Bus Interface Signal
226
                    . reg_cs                 (reg_cs),
227
                    . reg_wr                 (reg_wr),
228
                    . reg_addr               (reg_addr),
229
                    . reg_wdata              (reg_wdata),
230
                    . reg_be                 (reg_be),
231
 
232
                     // Outputs
233
                     . reg_rdata             (reg_rdata),
234
                     . reg_ack               (reg_ack),
235
 
236
                    .app_clk                 (app_clk) ,
237
                    .app_send_pause_i        (app_send_pause_i) ,
238
                    .app_send_pause_active_o (app_send_pause_active_o) ,
239
                    .app_send_jam_i          (app_send_jam_i) ,
240
 
241
                    // Conntrol Bus Sync with Application Clock
242
 
243
 
244
 
245
                  // RX FIFO Interface Signal
246
                    .rx_fifo_full_i          (rx_fifo_full_i) ,
247
                    .rx_fifo_wr_o            (rx_fifo_wr_o) ,
248
                    .rx_fifo_data_o          (rx_fifo_data_o) ,
249
                    .rx_commit_wr_o          (rx_commit_wr_o) ,
250
                    .rx_rewind_wr_o          (rx_rewind_wr_o) ,
251
                    .rx_commit_write_done_o  (rx_commit_write_done_o) ,
252
                    .clr_rx_error_from_rx_fsm_o(clr_rx_error_from_rx_fsm_o) ,
253
                    .rx_fifo_error_i         (rx_fifo_error) ,
254
 
255
                  // TX FIFO Interface Signal
256
                    .tx_fifo_data_i          (tx_fifo_data) ,
257
                    .tx_fifo_empty_i         (tx_fifo_empty) ,
258
                    .tx_fifo_rdy_i           (tx_fifo_rdy) , // See to connect to config
259
                    .tx_fifo_rd_o            (tx_fifo_rd) ,
260
                    .tx_commit_read_o        (tx_commit_read) ,
261
 
262
                    // Phy Signals 
263
 
264
                    // Line Side Interface TX Path
265
                    .phy_tx_en               (phy_tx_en) ,
266
                    .phy_tx_er               (phy_tx_er) ,
267
                    .phy_txd                 (phy_txd) ,
268
                    .phy_tx_clk              (phy_tx_clk) ,
269
 
270
                    // Line Side Interface RX Path
271
                    .phy_rx_clk              (phy_rx_clk) ,
272
                    .phy_rx_er               (phy_rx_er) ,
273
                    .phy_rx_dv               (phy_rx_dv) ,
274
                    .phy_rxd                 (phy_rxd) ,
275
                    .phy_crs                 (phy_crs) ,
276
 
277
                    //MDIO interface
278
                    .mdio_clk                (mdio_clk) ,
279
                    .mdio_in                 (mdio_in) ,
280
                    .mdio_out_en             (mdio_out_en) ,
281
                    .mdio_out                (mdio_out)
282
       );
283
 
284
assign tx_fifo_rdy = (tx_fifo_aval > 8) ; // Dinesh-A Change it to config
285
 
286
async_fifo #(W,DP,0,0) u_mac_txfifo  (
287
                   .wr_clk                   (app_clk),
288
                   .wr_reset_n               (app_reset_n),
289
                   .wr_en                    (app_txfifo_wren_i),
290
                   .wr_data                  (app_txfifo_wrdata_i),
291
                   .full                     (app_txfifo_full_o), // sync'ed to wr_clk
292 19 dinesha
                   .afull                    (app_txfifo_afull_o), // sync'ed to wr_clk
293 12 dinesha
                   .wr_total_free_space      (app_txfifo_space_o),
294
 
295
                   .rd_clk                   (phy_tx_clk),
296
                   .rd_reset_n               (tx_reset_n),
297
                   .rd_en                    (tx_fifo_rd),
298
                   .empty                    (tx_fifo_empty),  // sync'ed to rd_clk
299 19 dinesha
                   .aempty                   (tx_fifo_aempty), // sync'ed to rd_clk
300 12 dinesha
                   .rd_total_aval            (tx_fifo_aval),
301
                   .rd_data                  (tx_fifo_data)
302
                   );
303
 
304
async_fifo #(W,DP,0,0) u_mac_rxfifo (
305
                   .wr_clk                   (phy_rx_clk),
306
                   .wr_reset_n               (rx_reset_n),
307
                   .wr_en                    (rx_fifo_wr_o),
308
                   .wr_data                  (rx_fifo_data_o),
309
                   .full                     (rx_fifo_full_i), // sync'ed to wr_clk
310 19 dinesha
                   .afull                    (rx_fifo_afull_i), // sync'ed to wr_clk
311 12 dinesha
                   .wr_total_free_space      (),
312
 
313
                   .rd_clk                   (app_clk),
314
                   .rd_reset_n               (app_reset_n),
315
                   .rd_en                    (app_rxfifo_rden_i),
316
                   .empty                    (app_rxfifo_empty_o),  // sync'ed to rd_clk
317 19 dinesha
                   .aempty                   (app_rxfifo_aempty_o), // sync'ed to rd_clk
318 12 dinesha
                   .rd_total_aval            (app_rxfifo_cnt_o),
319
                   .rd_data                  (app_rxfifo_rdata_o)
320
                   );
321
 
322
 
323
 
324
endmodule
325
 

powered by: WebSVN 2.1.0

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