//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// File name "tx_enqueue.v" ////
|
//// File name "tx_enqueue.v" ////
|
//// ////
|
//// ////
|
//// This file is part of the "10GE MAC" project ////
|
//// This file is part of the "10GE MAC" project ////
|
//// http://www.opencores.org/cores/xge_mac/ ////
|
//// http://www.opencores.org/cores/xge_mac/ ////
|
//// ////
|
//// ////
|
//// Author(s): ////
|
//// Author(s): ////
|
//// - A. Tanguay (antanguay@opencores.org) ////
|
//// - A. Tanguay (antanguay@opencores.org) ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2008 AUTHORS. All rights reserved. ////
|
//// Copyright (C) 2008 AUTHORS. All rights reserved. ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed without ////
|
//// This source file may be used and distributed without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and that any derivative work contains ////
|
//// removed from the file and that any derivative work contains ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// ////
|
//// ////
|
//// This source file is free software; you can redistribute it ////
|
//// This source file is free software; you can redistribute it ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// later version. ////
|
//// later version. ////
|
//// ////
|
//// ////
|
//// This source is distributed in the hope that it will be ////
|
//// This source is distributed in the hope that it will be ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// details. ////
|
//// details. ////
|
//// ////
|
//// ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// Public License along with this source; if not, download it ////
|
//// Public License along with this source; if not, download it ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
`include "defines.v"
|
`include "defines.v"
|
|
|
module tx_enqueue(/*AUTOARG*/
|
module tx_enqueue(/*AUTOARG*/
|
// Outputs
|
// Outputs
|
pkt_tx_full, txdfifo_wdata, txdfifo_wstatus, txdfifo_wen,
|
pkt_tx_full, txdfifo_wdata, txdfifo_wstatus, txdfifo_wen,
|
status_txdfifo_ovflow_tog,
|
status_txdfifo_ovflow_tog,
|
// Inputs
|
// Inputs
|
clk_156m25, reset_156m25_n, pkt_tx_data, pkt_tx_val, pkt_tx_sop,
|
clk_156m25, reset_156m25_n, pkt_tx_data, pkt_tx_val, pkt_tx_sop,
|
pkt_tx_eop, txdfifo_wfull, txdfifo_walmost_full
|
pkt_tx_eop, txdfifo_wfull, txdfifo_walmost_full
|
);
|
);
|
|
|
`include "CRC32_D64.v"
|
`include "CRC32_D64.v"
|
`include "CRC32_D8.v"
|
`include "CRC32_D8.v"
|
`include "utils.v"
|
`include "utils.v"
|
|
|
input clk_156m25;
|
input clk_156m25;
|
input reset_156m25_n;
|
input reset_156m25_n;
|
|
|
input [63:0] pkt_tx_data;
|
input [63:0] pkt_tx_data;
|
input pkt_tx_val;
|
input pkt_tx_val;
|
input pkt_tx_sop;
|
input pkt_tx_sop;
|
input [7:0] pkt_tx_eop;
|
input [7:0] pkt_tx_eop;
|
|
|
input txdfifo_wfull;
|
input txdfifo_wfull;
|
input txdfifo_walmost_full;
|
input txdfifo_walmost_full;
|
|
|
output pkt_tx_full;
|
output pkt_tx_full;
|
|
|
output [63:0] txdfifo_wdata;
|
output [63:0] txdfifo_wdata;
|
output [7:0] txdfifo_wstatus;
|
output [7:0] txdfifo_wstatus;
|
output txdfifo_wen;
|
output txdfifo_wen;
|
|
|
output status_txdfifo_ovflow_tog;
|
output status_txdfifo_ovflow_tog;
|
|
|
/*AUTOREG*/
|
/*AUTOREG*/
|
// Beginning of automatic regs (for this module's undeclared outputs)
|
// Beginning of automatic regs (for this module's undeclared outputs)
|
reg status_txdfifo_ovflow_tog;
|
reg status_txdfifo_ovflow_tog;
|
reg [63:0] txdfifo_wdata;
|
reg [63:0] txdfifo_wdata;
|
reg txdfifo_wen;
|
reg txdfifo_wen;
|
reg [7:0] txdfifo_wstatus;
|
reg [7:0] txdfifo_wstatus;
|
// End of automatics
|
// End of automatics
|
|
|
/*AUTOWIRE*/
|
/*AUTOWIRE*/
|
// Beginning of automatic wires (for undeclared instantiated-module outputs)
|
// Beginning of automatic wires (for undeclared instantiated-module outputs)
|
// End of automatics
|
// End of automatics
|
|
|
|
|
reg txd_ovflow;
|
reg txd_ovflow;
|
reg next_txd_ovflow;
|
reg next_txd_ovflow;
|
|
|
|
|
|
|
// Full status if data fifo is almost full.
|
// Full status if data fifo is almost full.
|
// Current packet can complete transfer since data input rate
|
// Current packet can complete transfer since data input rate
|
// matches output rate. But next packet must wait for more headroom.
|
// matches output rate. But next packet must wait for more headroom.
|
|
|
assign pkt_tx_full = txdfifo_walmost_full;
|
assign pkt_tx_full = txdfifo_walmost_full;
|
|
|
|
|
|
|
always @(posedge clk_156m25 or negedge reset_156m25_n) begin
|
always @(posedge clk_156m25 or negedge reset_156m25_n) begin
|
|
|
if (reset_156m25_n == 1'b0) begin
|
if (reset_156m25_n == 1'b0) begin
|
|
|
txd_ovflow <= 1'b0;
|
txd_ovflow <= 1'b0;
|
|
|
status_txdfifo_ovflow_tog <= 1'b0;
|
status_txdfifo_ovflow_tog <= 1'b0;
|
|
|
end
|
end
|
else begin
|
else begin
|
|
|
txd_ovflow <= next_txd_ovflow;
|
txd_ovflow <= next_txd_ovflow;
|
|
|
//---
|
//---
|
// FIFO errors, used to generate interrupts
|
// FIFO errors, used to generate interrupts
|
|
|
if (next_txd_ovflow && !txd_ovflow) begin
|
if (next_txd_ovflow && !txd_ovflow) begin
|
status_txdfifo_ovflow_tog <= ~status_txdfifo_ovflow_tog;
|
status_txdfifo_ovflow_tog <= ~status_txdfifo_ovflow_tog;
|
end
|
end
|
|
|
end
|
end
|
|
|
end
|
end
|
|
|
always @(/*AS*/pkt_tx_data or pkt_tx_eop or pkt_tx_sop or pkt_tx_val
|
always @(/*AS*/pkt_tx_data or pkt_tx_eop or pkt_tx_sop or pkt_tx_val
|
or txd_ovflow or txdfifo_wfull) begin
|
or txd_ovflow or txdfifo_wfull) begin
|
|
|
txdfifo_wstatus = `TXSTATUS_NONE;
|
txdfifo_wstatus = `TXSTATUS_NONE;
|
txdfifo_wdata = pkt_tx_data;
|
txdfifo_wdata = pkt_tx_data;
|
txdfifo_wen = pkt_tx_val;
|
txdfifo_wen = pkt_tx_val;
|
|
|
next_txd_ovflow = txd_ovflow;
|
next_txd_ovflow = txd_ovflow;
|
|
|
|
|
// Write SOP marker to fifo.
|
// Write SOP marker to fifo.
|
|
|
if (pkt_tx_val && pkt_tx_sop) begin
|
if (pkt_tx_val && pkt_tx_sop) begin
|
|
|
txdfifo_wstatus = `TXSTATUS_SOP;
|
txdfifo_wstatus = `TXSTATUS_SOP;
|
|
|
end
|
end
|
|
|
|
|
// Write EOP marker to fifo.
|
// Write EOP marker to fifo.
|
|
|
if (pkt_tx_val) begin
|
if (pkt_tx_val) begin
|
|
|
if (pkt_tx_eop[0]) begin
|
if (pkt_tx_eop[0]) begin
|
txdfifo_wstatus = `TXSTATUS_EOP0;
|
txdfifo_wstatus = `TXSTATUS_EOP0;
|
end
|
end
|
else if (pkt_tx_eop[1]) begin
|
else if (pkt_tx_eop[1]) begin
|
txdfifo_wstatus = `TXSTATUS_EOP1;
|
txdfifo_wstatus = `TXSTATUS_EOP1;
|
end
|
end
|
else if (pkt_tx_eop[2]) begin
|
else if (pkt_tx_eop[2]) begin
|
txdfifo_wstatus = `TXSTATUS_EOP2;
|
txdfifo_wstatus = `TXSTATUS_EOP2;
|
end
|
end
|
else if (pkt_tx_eop[3]) begin
|
else if (pkt_tx_eop[3]) begin
|
txdfifo_wstatus = `TXSTATUS_EOP3;
|
txdfifo_wstatus = `TXSTATUS_EOP3;
|
end
|
end
|
else if (pkt_tx_eop[4]) begin
|
else if (pkt_tx_eop[4]) begin
|
txdfifo_wstatus = `TXSTATUS_EOP4;
|
txdfifo_wstatus = `TXSTATUS_EOP4;
|
end
|
end
|
else if (pkt_tx_eop[5]) begin
|
else if (pkt_tx_eop[5]) begin
|
txdfifo_wstatus = `TXSTATUS_EOP5;
|
txdfifo_wstatus = `TXSTATUS_EOP5;
|
end
|
end
|
else if (pkt_tx_eop[6]) begin
|
else if (pkt_tx_eop[6]) begin
|
txdfifo_wstatus = `TXSTATUS_EOP6;
|
txdfifo_wstatus = `TXSTATUS_EOP6;
|
end
|
end
|
else if (pkt_tx_eop[7]) begin
|
else if (pkt_tx_eop[7]) begin
|
txdfifo_wstatus = `TXSTATUS_EOP7;
|
txdfifo_wstatus = `TXSTATUS_EOP7;
|
end
|
end
|
|
|
end
|
end
|
|
|
|
|
// Overflow indication
|
// Overflow indication
|
|
|
if (pkt_tx_val) begin
|
if (pkt_tx_val) begin
|
|
|
if (txdfifo_wfull) begin
|
if (txdfifo_wfull) begin
|
|
|
next_txd_ovflow = 1'b1;
|
next_txd_ovflow = 1'b1;
|
|
|
end
|
end
|
else if (pkt_tx_sop) begin
|
else if (pkt_tx_sop) begin
|
|
|
next_txd_ovflow = 1'b0;
|
next_txd_ovflow = 1'b0;
|
|
|
end
|
end
|
end
|
end
|
|
|
end
|
end
|
|
|
|
|
endmodule
|
endmodule
|
|
|
|
|