1//
2// Copyright 2011 Ettus Research LLC
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16//
17
18
19module simple_gemac
20  (input clk125, input reset,
21   // GMII
22   output GMII_GTX_CLK, output GMII_TX_EN, output GMII_TX_ER, output [7:0] GMII_TXD,
23   input GMII_RX_CLK, input GMII_RX_DV, input GMII_RX_ER, input [7:0] GMII_RXD,
24
25   // Flow Control Interface
26   input pause_req, input [15:0] pause_time_req, input pause_respect_en,
27
28   // Settings
29   input [47:0] ucast_addr, input [47:0] mcast_addr,
30   input pass_ucast, input pass_mcast, input pass_bcast, input pass_pause, input pass_all,
31
32   // RX Client Interface
33   output rx_clk, output [7:0] rx_data, output rx_valid, output rx_error, output rx_ack,
34
35   // TX Client Interface
36   output tx_clk, input [7:0] tx_data, input tx_valid, input tx_error, output tx_ack,
37
38   output [31:0] debug
39   );
40
41   localparam SGE_IFG 		     = 8'd12;  // 12 should be the absolute minimum
42
43   wire rst_rxclk, rst_txclk;
44   reset_sync reset_sync_tx (.clk(tx_clk),.reset_in(reset),.reset_out(rst_txclk));
45   reset_sync reset_sync_rx (.clk(rx_clk),.reset_in(reset),.reset_out(rst_rxclk));
46
47   wire [15:0] pause_quanta_rcvd;
48   wire        pause_rcvd, pause_apply, paused;
49
50   simple_gemac_tx simple_gemac_tx
51     (.clk125(clk125),.reset(rst_txclk),
52      .GMII_GTX_CLK(GMII_GTX_CLK), .GMII_TX_EN(GMII_TX_EN),
53      .GMII_TX_ER(GMII_TX_ER), .GMII_TXD(GMII_TXD),
54      .tx_clk(tx_clk), .tx_data(tx_data), .tx_valid(tx_valid), .tx_error(tx_error), .tx_ack(tx_ack),
55      .ifg(SGE_IFG), .mac_addr(ucast_addr),
56      .pause_req(pause_req), .pause_time(pause_time_req),  // We request flow control
57      .pause_apply(pause_apply), .paused(paused)  // We respect flow control
58      );
59
60   simple_gemac_rx simple_gemac_rx
61     (.reset(rst_rxclk),
62      .GMII_RX_CLK(GMII_RX_CLK), .GMII_RX_DV(GMII_RX_DV),
63      .GMII_RX_ER(GMII_RX_ER), .GMII_RXD(GMII_RXD),
64      .rx_clk(rx_clk), .rx_data(rx_data), .rx_valid(rx_valid), .rx_error(rx_error), .rx_ack(rx_ack),
65      .ucast_addr(ucast_addr), .mcast_addr(mcast_addr),
66      .pass_ucast(pass_ucast), .pass_mcast(pass_mcast), .pass_bcast(pass_bcast),
67      .pass_pause(pass_pause), .pass_all(pass_all),
68      .pause_quanta_rcvd(pause_quanta_rcvd), .pause_rcvd(pause_rcvd),
69      .debug(debug)
70      );
71
72   flow_ctrl_tx flow_ctrl_tx
73     (.rst(rst_txclk), .tx_clk(tx_clk),
74      .tx_pause_en(pause_respect_en),
75      .pause_quanta(pause_quanta_rcvd), // 16 bit value
76      .pause_quanta_val(pause_rcvd),
77      .pause_apply(pause_apply),
78      .paused(paused)
79      );
80
81endmodule // simple_gemac
82