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 ll8_to_txmac 20 (input clk, input reset, input clear, 21 input [7:0] ll_data, input ll_sof, input ll_eof, input ll_src_rdy, output ll_dst_rdy, 22 output [7:0] tx_data, output tx_valid, output tx_error, input tx_ack ); 23 24 reg [2:0] xfer_state; 25 26 localparam XFER_IDLE = 0; 27 localparam XFER_ACTIVE = 1; 28 localparam XFER_WAIT1 = 2; 29 localparam XFER_UNDERRUN = 3; 30 localparam XFER_DROP = 4; 31 32 always @(posedge clk) 33 if(reset | clear) 34 xfer_state <= XFER_IDLE; 35 else 36 case(xfer_state) 37 XFER_IDLE : 38 if(tx_ack) 39 xfer_state <= XFER_ACTIVE; 40 XFER_ACTIVE : 41 if(~ll_src_rdy) 42 xfer_state <= XFER_UNDERRUN; 43 else if(ll_eof) 44 xfer_state <= XFER_WAIT1; 45 XFER_WAIT1 : 46 xfer_state <= XFER_IDLE; 47 XFER_UNDERRUN : 48 xfer_state <= XFER_DROP; 49 XFER_DROP : 50 if(ll_eof) 51 xfer_state <= XFER_IDLE; 52 endcase // case (xfer_state) 53 54 assign ll_dst_rdy = (xfer_state == XFER_ACTIVE) | tx_ack | (xfer_state == XFER_DROP); 55 assign tx_valid = (ll_src_rdy & (xfer_state == XFER_IDLE))|(xfer_state == XFER_ACTIVE); 56 assign tx_data = ll_data; 57 assign tx_error = (xfer_state == XFER_UNDERRUN); 58 59endmodule // ll8_to_txmac 60 61