//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// eth_wishbone.v ////
|
//// eth_wishbone.v ////
|
//// ////
|
//// ////
|
//// This file is part of the Ethernet IP core project ////
|
//// This file is part of the Ethernet IP core project ////
|
//// http://www.opencores.org/projects/ethmac/ ////
|
//// http://www.opencores.org/projects/ethmac/ ////
|
//// ////
|
//// ////
|
//// Author(s): ////
|
//// Author(s): ////
|
//// - Igor Mohor (igorM@opencores.org) ////
|
//// - Igor Mohor (igorM@opencores.org) ////
|
//// ////
|
//// ////
|
//// All additional information is available in the Readme.txt ////
|
//// All additional information is available in the Readme.txt ////
|
//// file. ////
|
//// file. ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2001, 2002 Authors ////
|
//// Copyright (C) 2001, 2002 Authors ////
|
//// ////
|
//// ////
|
//// 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 ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.45 2002/11/19 17:33:34 mohor
|
|
// AddressMiss status is connecting to the Rx BD. AddressMiss is identifying
|
|
// that a frame was received because of the promiscous mode.
|
|
//
|
// Revision 1.44 2002/11/13 22:21:40 tadejm
|
// Revision 1.44 2002/11/13 22:21:40 tadejm
|
// RxError is not generated when small frame reception is enabled and small
|
// RxError is not generated when small frame reception is enabled and small
|
// frames are received.
|
// frames are received.
|
//
|
//
|
// Revision 1.43 2002/10/18 20:53:34 mohor
|
// Revision 1.43 2002/10/18 20:53:34 mohor
|
// case changed to casex.
|
// case changed to casex.
|
//
|
//
|
// Revision 1.42 2002/10/18 17:04:20 tadejm
|
// Revision 1.42 2002/10/18 17:04:20 tadejm
|
// Changed BIST scan signals.
|
// Changed BIST scan signals.
|
//
|
//
|
// Revision 1.41 2002/10/18 15:42:09 tadejm
|
// Revision 1.41 2002/10/18 15:42:09 tadejm
|
// Igor added WB burst support and repaired BUG when handling TX under-run and retry.
|
// Igor added WB burst support and repaired BUG when handling TX under-run and retry.
|
//
|
//
|
// Revision 1.40 2002/10/14 16:07:02 mohor
|
// Revision 1.40 2002/10/14 16:07:02 mohor
|
// TxStatus is written after last access to the TX fifo is finished (in case of abort
|
// TxStatus is written after last access to the TX fifo is finished (in case of abort
|
// or retry). TxDone is fixed.
|
// or retry). TxDone is fixed.
|
//
|
//
|
// Revision 1.39 2002/10/11 15:35:20 mohor
|
// Revision 1.39 2002/10/11 15:35:20 mohor
|
// txfifo_cnt and rxfifo_cnt counters width is defined in the eth_define.v file,
|
// txfifo_cnt and rxfifo_cnt counters width is defined in the eth_define.v file,
|
// TxDone and TxRetry are generated after the current WISHBONE access is
|
// TxDone and TxRetry are generated after the current WISHBONE access is
|
// finished.
|
// finished.
|
//
|
//
|
// Revision 1.38 2002/10/10 16:29:30 mohor
|
// Revision 1.38 2002/10/10 16:29:30 mohor
|
// BIST added.
|
// BIST added.
|
//
|
//
|
// Revision 1.37 2002/09/11 14:18:46 mohor
|
// Revision 1.37 2002/09/11 14:18:46 mohor
|
// Sometimes both RxB_IRQ and RxE_IRQ were activated. Bug fixed.
|
// Sometimes both RxB_IRQ and RxE_IRQ were activated. Bug fixed.
|
//
|
//
|
// Revision 1.36 2002/09/10 13:48:46 mohor
|
// Revision 1.36 2002/09/10 13:48:46 mohor
|
// Reception is possible after RxPointer is read and not after BD is read. For
|
// Reception is possible after RxPointer is read and not after BD is read. For
|
// that reason RxBDReady is changed to RxReady.
|
// that reason RxBDReady is changed to RxReady.
|
// Busy_IRQ interrupt connected. When there is no RxBD ready and frame
|
// Busy_IRQ interrupt connected. When there is no RxBD ready and frame
|
// comes, interrupt is generated.
|
// comes, interrupt is generated.
|
//
|
//
|
// Revision 1.35 2002/09/10 10:35:23 mohor
|
// Revision 1.35 2002/09/10 10:35:23 mohor
|
// Ethernet debug registers removed.
|
// Ethernet debug registers removed.
|
//
|
//
|
// Revision 1.34 2002/09/08 16:31:49 mohor
|
// Revision 1.34 2002/09/08 16:31:49 mohor
|
// Async reset for WB_ACK_O removed (when core was in reset, it was
|
// Async reset for WB_ACK_O removed (when core was in reset, it was
|
// impossible to access BDs).
|
// impossible to access BDs).
|
// RxPointers and TxPointers names changed to be more descriptive.
|
// RxPointers and TxPointers names changed to be more descriptive.
|
// TxUnderRun synchronized.
|
// TxUnderRun synchronized.
|
//
|
//
|
// Revision 1.33 2002/09/04 18:47:57 mohor
|
// Revision 1.33 2002/09/04 18:47:57 mohor
|
// Debug registers reg1, 2, 3, 4 connected. Synchronization of many signals
|
// Debug registers reg1, 2, 3, 4 connected. Synchronization of many signals
|
// changed (bugs fixed). Access to un-alligned buffers fixed. RxAbort signal
|
// changed (bugs fixed). Access to un-alligned buffers fixed. RxAbort signal
|
// was not used OK.
|
// was not used OK.
|
//
|
//
|
// Revision 1.32 2002/08/14 19:31:48 mohor
|
// Revision 1.32 2002/08/14 19:31:48 mohor
|
// Register TX_BD_NUM is changed so it contains value of the Tx buffer descriptors. No
|
// Register TX_BD_NUM is changed so it contains value of the Tx buffer descriptors. No
|
// need to multiply or devide any more.
|
// need to multiply or devide any more.
|
//
|
//
|
// Revision 1.31 2002/07/25 18:29:01 mohor
|
// Revision 1.31 2002/07/25 18:29:01 mohor
|
// WriteRxDataToMemory signal changed so end of frame (when last word is
|
// WriteRxDataToMemory signal changed so end of frame (when last word is
|
// written to fifo) is changed.
|
// written to fifo) is changed.
|
//
|
//
|
// Revision 1.30 2002/07/23 15:28:31 mohor
|
// Revision 1.30 2002/07/23 15:28:31 mohor
|
// Ram , used for BDs changed from generic_spram to eth_spram_256x32.
|
// Ram , used for BDs changed from generic_spram to eth_spram_256x32.
|
//
|
//
|
// Revision 1.29 2002/07/20 00:41:32 mohor
|
// Revision 1.29 2002/07/20 00:41:32 mohor
|
// ShiftEnded synchronization changed.
|
// ShiftEnded synchronization changed.
|
//
|
//
|
// Revision 1.28 2002/07/18 16:11:46 mohor
|
// Revision 1.28 2002/07/18 16:11:46 mohor
|
// RxBDAddress takes `ETH_TX_BD_NUM_DEF value after reset.
|
// RxBDAddress takes `ETH_TX_BD_NUM_DEF value after reset.
|
//
|
//
|
// Revision 1.27 2002/07/11 02:53:20 mohor
|
// Revision 1.27 2002/07/11 02:53:20 mohor
|
// RxPointer bug fixed.
|
// RxPointer bug fixed.
|
//
|
//
|
// Revision 1.26 2002/07/10 13:12:38 mohor
|
// Revision 1.26 2002/07/10 13:12:38 mohor
|
// Previous bug wasn't succesfully removed. Now fixed.
|
// Previous bug wasn't succesfully removed. Now fixed.
|
//
|
//
|
// Revision 1.25 2002/07/09 23:53:24 mohor
|
// Revision 1.25 2002/07/09 23:53:24 mohor
|
// Master state machine had a bug when switching from master write to
|
// Master state machine had a bug when switching from master write to
|
// master read.
|
// master read.
|
//
|
//
|
// Revision 1.24 2002/07/09 20:44:41 mohor
|
// Revision 1.24 2002/07/09 20:44:41 mohor
|
// m_wb_cyc_o signal released after every single transfer.
|
// m_wb_cyc_o signal released after every single transfer.
|
//
|
//
|
// Revision 1.23 2002/05/03 10:15:50 mohor
|
// Revision 1.23 2002/05/03 10:15:50 mohor
|
// Outputs registered. Reset changed for eth_wishbone module.
|
// Outputs registered. Reset changed for eth_wishbone module.
|
//
|
//
|
// Revision 1.22 2002/04/24 08:52:19 mohor
|
// Revision 1.22 2002/04/24 08:52:19 mohor
|
// Compiler directives added. Tx and Rx fifo size incremented. A "late collision"
|
// Compiler directives added. Tx and Rx fifo size incremented. A "late collision"
|
// bug fixed.
|
// bug fixed.
|
//
|
//
|
// Revision 1.21 2002/03/29 16:18:11 lampret
|
// Revision 1.21 2002/03/29 16:18:11 lampret
|
// Small typo fixed.
|
// Small typo fixed.
|
//
|
//
|
// Revision 1.20 2002/03/25 16:19:12 mohor
|
// Revision 1.20 2002/03/25 16:19:12 mohor
|
// Any address can be used for Tx and Rx BD pointers. Address does not need
|
// Any address can be used for Tx and Rx BD pointers. Address does not need
|
// to be aligned.
|
// to be aligned.
|
//
|
//
|
// Revision 1.19 2002/03/19 12:51:50 mohor
|
// Revision 1.19 2002/03/19 12:51:50 mohor
|
// Comments in Slovene language removed.
|
// Comments in Slovene language removed.
|
//
|
//
|
// Revision 1.18 2002/03/19 12:46:52 mohor
|
// Revision 1.18 2002/03/19 12:46:52 mohor
|
// casex changed with case, fifo reset changed.
|
// casex changed with case, fifo reset changed.
|
//
|
//
|
// Revision 1.17 2002/03/09 16:08:45 mohor
|
// Revision 1.17 2002/03/09 16:08:45 mohor
|
// rx_fifo was not always cleared ok. Fixed.
|
// rx_fifo was not always cleared ok. Fixed.
|
//
|
//
|
// Revision 1.16 2002/03/09 13:51:20 mohor
|
// Revision 1.16 2002/03/09 13:51:20 mohor
|
// Status was not latched correctly sometimes. Fixed.
|
// Status was not latched correctly sometimes. Fixed.
|
//
|
//
|
// Revision 1.15 2002/03/08 06:56:46 mohor
|
// Revision 1.15 2002/03/08 06:56:46 mohor
|
// Big Endian problem when sending frames fixed.
|
// Big Endian problem when sending frames fixed.
|
//
|
//
|
// Revision 1.14 2002/03/02 19:12:40 mohor
|
// Revision 1.14 2002/03/02 19:12:40 mohor
|
// Byte ordering changed (Big Endian used). casex changed with case because
|
// Byte ordering changed (Big Endian used). casex changed with case because
|
// Xilinx Foundation had problems. Tested in HW. It WORKS.
|
// Xilinx Foundation had problems. Tested in HW. It WORKS.
|
//
|
//
|
// Revision 1.13 2002/02/26 16:59:55 mohor
|
// Revision 1.13 2002/02/26 16:59:55 mohor
|
// Small fixes for external/internal DMA missmatches.
|
// Small fixes for external/internal DMA missmatches.
|
//
|
//
|
// Revision 1.12 2002/02/26 16:22:07 mohor
|
// Revision 1.12 2002/02/26 16:22:07 mohor
|
// Interrupts changed
|
// Interrupts changed
|
//
|
//
|
// Revision 1.11 2002/02/15 17:07:39 mohor
|
// Revision 1.11 2002/02/15 17:07:39 mohor
|
// Status was not written correctly when frames were discarted because of
|
// Status was not written correctly when frames were discarted because of
|
// address mismatch.
|
// address mismatch.
|
//
|
//
|
// Revision 1.10 2002/02/15 12:17:39 mohor
|
// Revision 1.10 2002/02/15 12:17:39 mohor
|
// RxStartFrm cleared when abort or retry comes.
|
// RxStartFrm cleared when abort or retry comes.
|
//
|
//
|
// Revision 1.9 2002/02/15 11:59:10 mohor
|
// Revision 1.9 2002/02/15 11:59:10 mohor
|
// Changes that were lost when updating from 1.5 to 1.8 fixed.
|
// Changes that were lost when updating from 1.5 to 1.8 fixed.
|
//
|
//
|
// Revision 1.8 2002/02/14 20:54:33 billditt
|
// Revision 1.8 2002/02/14 20:54:33 billditt
|
// Addition of new module eth_addrcheck.v
|
// Addition of new module eth_addrcheck.v
|
//
|
//
|
// Revision 1.7 2002/02/12 17:03:47 mohor
|
// Revision 1.7 2002/02/12 17:03:47 mohor
|
// RxOverRun added to statuses.
|
// RxOverRun added to statuses.
|
//
|
//
|
// Revision 1.6 2002/02/11 09:18:22 mohor
|
// Revision 1.6 2002/02/11 09:18:22 mohor
|
// Tx status is written back to the BD.
|
// Tx status is written back to the BD.
|
//
|
//
|
// Revision 1.5 2002/02/08 16:21:54 mohor
|
// Revision 1.5 2002/02/08 16:21:54 mohor
|
// Rx status is written back to the BD.
|
// Rx status is written back to the BD.
|
//
|
//
|
// Revision 1.4 2002/02/06 14:10:21 mohor
|
// Revision 1.4 2002/02/06 14:10:21 mohor
|
// non-DMA host interface added. Select the right configutation in eth_defines.
|
// non-DMA host interface added. Select the right configutation in eth_defines.
|
//
|
//
|
// Revision 1.3 2002/02/05 16:44:39 mohor
|
// Revision 1.3 2002/02/05 16:44:39 mohor
|
// Both rx and tx part are finished. Tested with wb_clk_i between 10 and 200
|
// Both rx and tx part are finished. Tested with wb_clk_i between 10 and 200
|
// MHz. Statuses, overrun, control frame transmission and reception still need
|
// MHz. Statuses, overrun, control frame transmission and reception still need
|
// to be fixed.
|
// to be fixed.
|
//
|
//
|
// Revision 1.2 2002/02/01 12:46:51 mohor
|
// Revision 1.2 2002/02/01 12:46:51 mohor
|
// Tx part finished. TxStatus needs to be fixed. Pause request needs to be
|
// Tx part finished. TxStatus needs to be fixed. Pause request needs to be
|
// added.
|
// added.
|
//
|
//
|
// Revision 1.1 2002/01/23 10:47:59 mohor
|
// Revision 1.1 2002/01/23 10:47:59 mohor
|
// Initial version. Equals to eth_wishbonedma.v at this moment.
|
// Initial version. Equals to eth_wishbonedma.v at this moment.
|
//
|
//
|
//
|
//
|
//
|
//
|
|
|
`include "eth_defines.v"
|
`include "eth_defines.v"
|
`include "timescale.v"
|
`include "timescale.v"
|
|
|
|
|
module eth_wishbone
|
module eth_wishbone
|
(
|
(
|
|
|
// WISHBONE common
|
// WISHBONE common
|
WB_CLK_I, WB_DAT_I, WB_DAT_O,
|
WB_CLK_I, WB_DAT_I, WB_DAT_O,
|
|
|
// WISHBONE slave
|
// WISHBONE slave
|
WB_ADR_I, WB_WE_I, WB_ACK_O,
|
WB_ADR_I, WB_WE_I, WB_ACK_O,
|
BDCs,
|
BDCs,
|
|
|
Reset,
|
Reset,
|
|
|
// WISHBONE master
|
// WISHBONE master
|
m_wb_adr_o, m_wb_sel_o, m_wb_we_o,
|
m_wb_adr_o, m_wb_sel_o, m_wb_we_o,
|
m_wb_dat_o, m_wb_dat_i, m_wb_cyc_o,
|
m_wb_dat_o, m_wb_dat_i, m_wb_cyc_o,
|
m_wb_stb_o, m_wb_ack_i, m_wb_err_i,
|
m_wb_stb_o, m_wb_ack_i, m_wb_err_i,
|
|
|
`ifdef ETH_WISHBONE_B3
|
`ifdef ETH_WISHBONE_B3
|
m_wb_cti_o, m_wb_bte_o,
|
m_wb_cti_o, m_wb_bte_o,
|
`endif
|
`endif
|
|
|
//TX
|
//TX
|
MTxClk, TxStartFrm, TxEndFrm, TxUsedData, TxData,
|
MTxClk, TxStartFrm, TxEndFrm, TxUsedData, TxData,
|
TxRetry, TxAbort, TxUnderRun, TxDone, PerPacketCrcEn,
|
TxRetry, TxAbort, TxUnderRun, TxDone, PerPacketCrcEn,
|
PerPacketPad,
|
PerPacketPad,
|
|
|
//RX
|
//RX
|
MRxClk, RxData, RxValid, RxStartFrm, RxEndFrm, RxAbort,
|
MRxClk, RxData, RxValid, RxStartFrm, RxEndFrm, RxAbort,
|
|
|
// Register
|
// Register
|
r_TxEn, r_RxEn, r_TxBDNum, TX_BD_NUM_Wr,
|
r_TxEn, r_RxEn, r_TxBDNum, TX_BD_NUM_Wr, r_RxFlow,
|
|
|
// Interrupts
|
// Interrupts
|
TxB_IRQ, TxE_IRQ, RxB_IRQ, RxE_IRQ, Busy_IRQ,
|
TxB_IRQ, TxE_IRQ, RxB_IRQ, RxE_IRQ, Busy_IRQ,
|
|
|
// Rx Status
|
// Rx Status
|
InvalidSymbol, LatchedCrcError, RxLateCollision, ShortFrame, DribbleNibble,
|
InvalidSymbol, LatchedCrcError, RxLateCollision, ShortFrame, DribbleNibble,
|
ReceivedPacketTooBig, RxLength, LoadRxStatus, ReceivedPacketGood, AddressMiss,
|
ReceivedPacketTooBig, RxLength, LoadRxStatus, ReceivedPacketGood, AddressMiss,
|
|
ReceivedPauseFrm,
|
|
|
// Tx Status
|
// Tx Status
|
RetryCntLatched, RetryLimit, LateCollLatched, DeferLatched, CarrierSenseLost
|
RetryCntLatched, RetryLimit, LateCollLatched, DeferLatched, CarrierSenseLost
|
|
|
// Bist
|
// Bist
|
`ifdef ETH_BIST
|
`ifdef ETH_BIST
|
,
|
,
|
// debug chain signals
|
// debug chain signals
|
scanb_rst, // bist scan reset
|
scanb_rst, // bist scan reset
|
scanb_clk, // bist scan clock
|
scanb_clk, // bist scan clock
|
scanb_si, // bist scan serial in
|
scanb_si, // bist scan serial in
|
scanb_so, // bist scan serial out
|
scanb_so, // bist scan serial out
|
scanb_en // bist scan shift enable
|
scanb_en // bist scan shift enable
|
`endif
|
`endif
|
|
|
|
|
|
|
);
|
);
|
|
|
|
|
parameter Tp = 1;
|
parameter Tp = 1;
|
|
|
|
|
// WISHBONE common
|
// WISHBONE common
|
input WB_CLK_I; // WISHBONE clock
|
input WB_CLK_I; // WISHBONE clock
|
input [31:0] WB_DAT_I; // WISHBONE data input
|
input [31:0] WB_DAT_I; // WISHBONE data input
|
output [31:0] WB_DAT_O; // WISHBONE data output
|
output [31:0] WB_DAT_O; // WISHBONE data output
|
|
|
// WISHBONE slave
|
// WISHBONE slave
|
input [9:2] WB_ADR_I; // WISHBONE address input
|
input [9:2] WB_ADR_I; // WISHBONE address input
|
input WB_WE_I; // WISHBONE write enable input
|
input WB_WE_I; // WISHBONE write enable input
|
input BDCs; // Buffer descriptors are selected
|
input BDCs; // Buffer descriptors are selected
|
output WB_ACK_O; // WISHBONE acknowledge output
|
output WB_ACK_O; // WISHBONE acknowledge output
|
|
|
// WISHBONE master
|
// WISHBONE master
|
output [31:0] m_wb_adr_o; //
|
output [31:0] m_wb_adr_o; //
|
output [3:0] m_wb_sel_o; //
|
output [3:0] m_wb_sel_o; //
|
output m_wb_we_o; //
|
output m_wb_we_o; //
|
output [31:0] m_wb_dat_o; //
|
output [31:0] m_wb_dat_o; //
|
output m_wb_cyc_o; //
|
output m_wb_cyc_o; //
|
output m_wb_stb_o; //
|
output m_wb_stb_o; //
|
input [31:0] m_wb_dat_i; //
|
input [31:0] m_wb_dat_i; //
|
input m_wb_ack_i; //
|
input m_wb_ack_i; //
|
input m_wb_err_i; //
|
input m_wb_err_i; //
|
|
|
`ifdef ETH_WISHBONE_B3
|
`ifdef ETH_WISHBONE_B3
|
output [2:0] m_wb_cti_o; // Cycle Type Identifier
|
output [2:0] m_wb_cti_o; // Cycle Type Identifier
|
output [1:0] m_wb_bte_o; // Burst Type Extension
|
output [1:0] m_wb_bte_o; // Burst Type Extension
|
reg [2:0] m_wb_cti_o; // Cycle Type Identifier
|
reg [2:0] m_wb_cti_o; // Cycle Type Identifier
|
`endif
|
`endif
|
|
|
input Reset; // Reset signal
|
input Reset; // Reset signal
|
|
|
// Rx Status signals
|
// Rx Status signals
|
input InvalidSymbol; // Invalid symbol was received during reception in 100 Mbps mode
|
input InvalidSymbol; // Invalid symbol was received during reception in 100 Mbps mode
|
input LatchedCrcError; // CRC error
|
input LatchedCrcError; // CRC error
|
input RxLateCollision; // Late collision occured while receiving frame
|
input RxLateCollision; // Late collision occured while receiving frame
|
input ShortFrame; // Frame shorter then the minimum size (r_MinFL) was received while small packets are enabled (r_RecSmall)
|
input ShortFrame; // Frame shorter then the minimum size (r_MinFL) was received while small packets are enabled (r_RecSmall)
|
input DribbleNibble; // Extra nibble received
|
input DribbleNibble; // Extra nibble received
|
input ReceivedPacketTooBig;// Received packet is bigger than r_MaxFL
|
input ReceivedPacketTooBig;// Received packet is bigger than r_MaxFL
|
input [15:0] RxLength; // Length of the incoming frame
|
input [15:0] RxLength; // Length of the incoming frame
|
input LoadRxStatus; // Rx status was loaded
|
input LoadRxStatus; // Rx status was loaded
|
input ReceivedPacketGood;// Received packet's length and CRC are good
|
input ReceivedPacketGood;// Received packet's length and CRC are good
|
input AddressMiss; // When a packet is received AddressMiss status is written to the Rx BD
|
input AddressMiss; // When a packet is received AddressMiss status is written to the Rx BD
|
|
input r_RxFlow;
|
|
input ReceivedPauseFrm;
|
|
|
// Tx Status signals
|
// Tx Status signals
|
input [3:0] RetryCntLatched; // Latched Retry Counter
|
input [3:0] RetryCntLatched; // Latched Retry Counter
|
input RetryLimit; // Retry limit reached (Retry Max value + 1 attempts were made)
|
input RetryLimit; // Retry limit reached (Retry Max value + 1 attempts were made)
|
input LateCollLatched; // Late collision occured
|
input LateCollLatched; // Late collision occured
|
input DeferLatched; // Defer indication (Frame was defered before sucessfully sent)
|
input DeferLatched; // Defer indication (Frame was defered before sucessfully sent)
|
input CarrierSenseLost; // Carrier Sense was lost during the frame transmission
|
input CarrierSenseLost; // Carrier Sense was lost during the frame transmission
|
|
|
// Tx
|
// Tx
|
input MTxClk; // Transmit clock (from PHY)
|
input MTxClk; // Transmit clock (from PHY)
|
input TxUsedData; // Transmit packet used data
|
input TxUsedData; // Transmit packet used data
|
input TxRetry; // Transmit packet retry
|
input TxRetry; // Transmit packet retry
|
input TxAbort; // Transmit packet abort
|
input TxAbort; // Transmit packet abort
|
input TxDone; // Transmission ended
|
input TxDone; // Transmission ended
|
output TxStartFrm; // Transmit packet start frame
|
output TxStartFrm; // Transmit packet start frame
|
output TxEndFrm; // Transmit packet end frame
|
output TxEndFrm; // Transmit packet end frame
|
output [7:0] TxData; // Transmit packet data byte
|
output [7:0] TxData; // Transmit packet data byte
|
output TxUnderRun; // Transmit packet under-run
|
output TxUnderRun; // Transmit packet under-run
|
output PerPacketCrcEn; // Per packet crc enable
|
output PerPacketCrcEn; // Per packet crc enable
|
output PerPacketPad; // Per packet pading
|
output PerPacketPad; // Per packet pading
|
|
|
// Rx
|
// Rx
|
input MRxClk; // Receive clock (from PHY)
|
input MRxClk; // Receive clock (from PHY)
|
input [7:0] RxData; // Received data byte (from PHY)
|
input [7:0] RxData; // Received data byte (from PHY)
|
input RxValid; //
|
input RxValid; //
|
input RxStartFrm; //
|
input RxStartFrm; //
|
input RxEndFrm; //
|
input RxEndFrm; //
|
input RxAbort; // This signal is set when address doesn't match.
|
input RxAbort; // This signal is set when address doesn't match.
|
|
|
//Register
|
//Register
|
input r_TxEn; // Transmit enable
|
input r_TxEn; // Transmit enable
|
input r_RxEn; // Receive enable
|
input r_RxEn; // Receive enable
|
input [7:0] r_TxBDNum; // Receive buffer descriptor number
|
input [7:0] r_TxBDNum; // Receive buffer descriptor number
|
input TX_BD_NUM_Wr; // RxBDNumber written
|
input TX_BD_NUM_Wr; // RxBDNumber written
|
|
|
// Interrupts
|
// Interrupts
|
output TxB_IRQ;
|
output TxB_IRQ;
|
output TxE_IRQ;
|
output TxE_IRQ;
|
output RxB_IRQ;
|
output RxB_IRQ;
|
output RxE_IRQ;
|
output RxE_IRQ;
|
output Busy_IRQ;
|
output Busy_IRQ;
|
|
|
|
|
// Bist
|
// Bist
|
`ifdef ETH_BIST
|
`ifdef ETH_BIST
|
input scanb_rst; // bist scan reset
|
input scanb_rst; // bist scan reset
|
input scanb_clk; // bist scan clock
|
input scanb_clk; // bist scan clock
|
input scanb_si; // bist scan serial in
|
input scanb_si; // bist scan serial in
|
output scanb_so; // bist scan serial out
|
output scanb_so; // bist scan serial out
|
input scanb_en; // bist scan shift enable
|
input scanb_en; // bist scan shift enable
|
`endif
|
`endif
|
|
|
reg TxB_IRQ;
|
reg TxB_IRQ;
|
reg TxE_IRQ;
|
reg TxE_IRQ;
|
reg RxB_IRQ;
|
reg RxB_IRQ;
|
reg RxE_IRQ;
|
reg RxE_IRQ;
|
|
|
reg TxStartFrm;
|
reg TxStartFrm;
|
reg TxEndFrm;
|
reg TxEndFrm;
|
reg [7:0] TxData;
|
reg [7:0] TxData;
|
|
|
reg TxUnderRun;
|
reg TxUnderRun;
|
reg TxUnderRun_wb;
|
reg TxUnderRun_wb;
|
|
|
reg TxBDRead;
|
reg TxBDRead;
|
wire TxStatusWrite;
|
wire TxStatusWrite;
|
|
|
reg [1:0] TxValidBytesLatched;
|
reg [1:0] TxValidBytesLatched;
|
|
|
reg [15:0] TxLength;
|
reg [15:0] TxLength;
|
reg [15:0] LatchedTxLength;
|
reg [15:0] LatchedTxLength;
|
reg [14:11] TxStatus;
|
reg [14:11] TxStatus;
|
|
|
reg [14:13] RxStatus;
|
reg [14:13] RxStatus;
|
|
|
reg TxStartFrm_wb;
|
reg TxStartFrm_wb;
|
reg TxRetry_wb;
|
reg TxRetry_wb;
|
reg TxAbort_wb;
|
reg TxAbort_wb;
|
reg TxDone_wb;
|
reg TxDone_wb;
|
|
|
reg TxDone_wb_q;
|
reg TxDone_wb_q;
|
reg TxAbort_wb_q;
|
reg TxAbort_wb_q;
|
reg TxRetry_wb_q;
|
reg TxRetry_wb_q;
|
reg TxRetryPacket;
|
reg TxRetryPacket;
|
reg TxRetryPacket_NotCleared;
|
reg TxRetryPacket_NotCleared;
|
reg TxDonePacket;
|
reg TxDonePacket;
|
reg TxDonePacket_NotCleared;
|
reg TxDonePacket_NotCleared;
|
reg TxAbortPacket;
|
reg TxAbortPacket;
|
reg TxAbortPacket_NotCleared;
|
reg TxAbortPacket_NotCleared;
|
reg RxBDReady;
|
reg RxBDReady;
|
reg RxReady;
|
reg RxReady;
|
reg TxBDReady;
|
reg TxBDReady;
|
|
|
reg RxBDRead;
|
reg RxBDRead;
|
wire RxStatusWrite;
|
wire RxStatusWrite;
|
|
|
reg [31:0] TxDataLatched;
|
reg [31:0] TxDataLatched;
|
reg [1:0] TxByteCnt;
|
reg [1:0] TxByteCnt;
|
reg LastWord;
|
reg LastWord;
|
reg ReadTxDataFromFifo_tck;
|
reg ReadTxDataFromFifo_tck;
|
|
|
reg BlockingTxStatusWrite;
|
reg BlockingTxStatusWrite;
|
reg BlockingTxBDRead;
|
reg BlockingTxBDRead;
|
|
|
reg Flop;
|
reg Flop;
|
|
|
reg [7:0] TxBDAddress;
|
reg [7:0] TxBDAddress;
|
reg [7:0] RxBDAddress;
|
reg [7:0] RxBDAddress;
|
|
|
reg TxRetrySync1;
|
reg TxRetrySync1;
|
reg TxAbortSync1;
|
reg TxAbortSync1;
|
reg TxDoneSync1;
|
reg TxDoneSync1;
|
|
|
reg TxAbort_q;
|
reg TxAbort_q;
|
reg TxRetry_q;
|
reg TxRetry_q;
|
reg TxUsedData_q;
|
reg TxUsedData_q;
|
|
|
reg [31:0] RxDataLatched2;
|
reg [31:0] RxDataLatched2;
|
|
|
reg [31:8] RxDataLatched1; // Big Endian Byte Ordering
|
reg [31:8] RxDataLatched1; // Big Endian Byte Ordering
|
|
|
reg [1:0] RxValidBytes;
|
reg [1:0] RxValidBytes;
|
reg [1:0] RxByteCnt;
|
reg [1:0] RxByteCnt;
|
reg LastByteIn;
|
reg LastByteIn;
|
reg ShiftWillEnd;
|
reg ShiftWillEnd;
|
|
|
reg WriteRxDataToFifo;
|
reg WriteRxDataToFifo;
|
reg [15:0] LatchedRxLength;
|
reg [15:0] LatchedRxLength;
|
reg RxAbortLatched;
|
reg RxAbortLatched;
|
|
|
reg ShiftEnded;
|
reg ShiftEnded;
|
reg RxOverrun;
|
reg RxOverrun;
|
|
|
reg BDWrite; // BD Write Enable for access from WISHBONE side
|
reg BDWrite; // BD Write Enable for access from WISHBONE side
|
reg BDRead; // BD Read access from WISHBONE side
|
reg BDRead; // BD Read access from WISHBONE side
|
wire [31:0] RxBDDataIn; // Rx BD data in
|
wire [31:0] RxBDDataIn; // Rx BD data in
|
wire [31:0] TxBDDataIn; // Tx BD data in
|
wire [31:0] TxBDDataIn; // Tx BD data in
|
|
|
reg TxEndFrm_wb;
|
reg TxEndFrm_wb;
|
|
|
wire TxRetryPulse;
|
wire TxRetryPulse;
|
wire TxDonePulse;
|
wire TxDonePulse;
|
wire TxAbortPulse;
|
wire TxAbortPulse;
|
|
|
wire StartRxBDRead;
|
wire StartRxBDRead;
|
|
|
wire StartTxBDRead;
|
wire StartTxBDRead;
|
|
|
wire TxIRQEn;
|
wire TxIRQEn;
|
wire WrapTxStatusBit;
|
wire WrapTxStatusBit;
|
|
|
wire RxIRQEn;
|
wire RxIRQEn;
|
wire WrapRxStatusBit;
|
wire WrapRxStatusBit;
|
|
|
wire [1:0] TxValidBytes;
|
wire [1:0] TxValidBytes;
|
|
|
wire [7:0] TempTxBDAddress;
|
wire [7:0] TempTxBDAddress;
|
wire [7:0] TempRxBDAddress;
|
wire [7:0] TempRxBDAddress;
|
|
|
wire SetGotData;
|
wire SetGotData;
|
wire GotDataEvaluate;
|
wire GotDataEvaluate;
|
|
|
reg WB_ACK_O;
|
reg WB_ACK_O;
|
|
|
wire [7:0] RxStatusIn;
|
wire [8:0] RxStatusIn;
|
reg [7:0] RxStatusInLatched;
|
reg [8:0] RxStatusInLatched;
|
|
|
reg WbEn, WbEn_q;
|
reg WbEn, WbEn_q;
|
reg RxEn, RxEn_q;
|
reg RxEn, RxEn_q;
|
reg TxEn, TxEn_q;
|
reg TxEn, TxEn_q;
|
|
|
wire ram_ce;
|
wire ram_ce;
|
wire ram_we;
|
wire ram_we;
|
wire ram_oe;
|
wire ram_oe;
|
reg [7:0] ram_addr;
|
reg [7:0] ram_addr;
|
reg [31:0] ram_di;
|
reg [31:0] ram_di;
|
wire [31:0] ram_do;
|
wire [31:0] ram_do;
|
|
|
wire StartTxPointerRead;
|
wire StartTxPointerRead;
|
reg TxPointerRead;
|
reg TxPointerRead;
|
reg TxEn_needed;
|
reg TxEn_needed;
|
reg RxEn_needed;
|
reg RxEn_needed;
|
|
|
wire StartRxPointerRead;
|
wire StartRxPointerRead;
|
reg RxPointerRead;
|
reg RxPointerRead;
|
|
|
`ifdef ETH_WISHBONE_B3
|
`ifdef ETH_WISHBONE_B3
|
assign m_wb_bte_o = 2'b00; // Linear burst
|
assign m_wb_bte_o = 2'b00; // Linear burst
|
`endif
|
`endif
|
|
|
|
|
always @ (posedge WB_CLK_I)
|
always @ (posedge WB_CLK_I)
|
begin
|
begin
|
WB_ACK_O <=#Tp BDWrite & WbEn & WbEn_q | BDRead & WbEn & ~WbEn_q;
|
WB_ACK_O <=#Tp BDWrite & WbEn & WbEn_q | BDRead & WbEn & ~WbEn_q;
|
end
|
end
|
|
|
assign WB_DAT_O = ram_do;
|
assign WB_DAT_O = ram_do;
|
|
|
// Generic synchronous single-port RAM interface
|
// Generic synchronous single-port RAM interface
|
eth_spram_256x32 bd_ram (
|
eth_spram_256x32 bd_ram (
|
.clk(WB_CLK_I), .rst(Reset), .ce(ram_ce), .we(ram_we), .oe(ram_oe), .addr(ram_addr), .di(ram_di), .do(ram_do)
|
.clk(WB_CLK_I), .rst(Reset), .ce(ram_ce), .we(ram_we), .oe(ram_oe), .addr(ram_addr), .di(ram_di), .do(ram_do)
|
`ifdef ETH_BIST
|
`ifdef ETH_BIST
|
,
|
,
|
.scanb_rst (scanb_rst),
|
.scanb_rst (scanb_rst),
|
.scanb_clk (scanb_clk),
|
.scanb_clk (scanb_clk),
|
.scanb_si (scanb_si),
|
.scanb_si (scanb_si),
|
.scanb_so (scanb_so),
|
.scanb_so (scanb_so),
|
.scanb_en (scanb_en)
|
.scanb_en (scanb_en)
|
`endif
|
`endif
|
);
|
);
|
|
|
assign ram_ce = 1'b1;
|
assign ram_ce = 1'b1;
|
assign ram_we = BDWrite & WbEn & WbEn_q | TxStatusWrite | RxStatusWrite;
|
assign ram_we = BDWrite & WbEn & WbEn_q | TxStatusWrite | RxStatusWrite;
|
assign ram_oe = BDRead & WbEn & WbEn_q | TxEn & TxEn_q & (TxBDRead | TxPointerRead) | RxEn & RxEn_q & (RxBDRead | RxPointerRead);
|
assign ram_oe = BDRead & WbEn & WbEn_q | TxEn & TxEn_q & (TxBDRead | TxPointerRead) | RxEn & RxEn_q & (RxBDRead | RxPointerRead);
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxEn_needed <=#Tp 1'b0;
|
TxEn_needed <=#Tp 1'b0;
|
else
|
else
|
if(~TxBDReady & r_TxEn & WbEn & ~WbEn_q)
|
if(~TxBDReady & r_TxEn & WbEn & ~WbEn_q)
|
TxEn_needed <=#Tp 1'b1;
|
TxEn_needed <=#Tp 1'b1;
|
else
|
else
|
if(TxPointerRead & TxEn & TxEn_q)
|
if(TxPointerRead & TxEn & TxEn_q)
|
TxEn_needed <=#Tp 1'b0;
|
TxEn_needed <=#Tp 1'b0;
|
end
|
end
|
|
|
// Enabling access to the RAM for three devices.
|
// Enabling access to the RAM for three devices.
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
begin
|
begin
|
WbEn <=#Tp 1'b1;
|
WbEn <=#Tp 1'b1;
|
RxEn <=#Tp 1'b0;
|
RxEn <=#Tp 1'b0;
|
TxEn <=#Tp 1'b0;
|
TxEn <=#Tp 1'b0;
|
ram_addr <=#Tp 8'h0;
|
ram_addr <=#Tp 8'h0;
|
ram_di <=#Tp 32'h0;
|
ram_di <=#Tp 32'h0;
|
BDRead <=#Tp 1'b0;
|
BDRead <=#Tp 1'b0;
|
BDWrite <=#Tp 1'b0;
|
BDWrite <=#Tp 1'b0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
// Switching between three stages depends on enable signals
|
// Switching between three stages depends on enable signals
|
case ({WbEn_q, RxEn_q, TxEn_q, RxEn_needed, TxEn_needed}) // synopsys parallel_case
|
case ({WbEn_q, RxEn_q, TxEn_q, RxEn_needed, TxEn_needed}) // synopsys parallel_case
|
5'b100_10, 5'b100_11 :
|
5'b100_10, 5'b100_11 :
|
begin
|
begin
|
WbEn <=#Tp 1'b0;
|
WbEn <=#Tp 1'b0;
|
RxEn <=#Tp 1'b1; // wb access stage and r_RxEn is enabled
|
RxEn <=#Tp 1'b1; // wb access stage and r_RxEn is enabled
|
TxEn <=#Tp 1'b0;
|
TxEn <=#Tp 1'b0;
|
ram_addr <=#Tp RxBDAddress + RxPointerRead;
|
ram_addr <=#Tp RxBDAddress + RxPointerRead;
|
ram_di <=#Tp RxBDDataIn;
|
ram_di <=#Tp RxBDDataIn;
|
end
|
end
|
5'b100_01 :
|
5'b100_01 :
|
begin
|
begin
|
WbEn <=#Tp 1'b0;
|
WbEn <=#Tp 1'b0;
|
RxEn <=#Tp 1'b0;
|
RxEn <=#Tp 1'b0;
|
TxEn <=#Tp 1'b1; // wb access stage, r_RxEn is disabled but r_TxEn is enabled
|
TxEn <=#Tp 1'b1; // wb access stage, r_RxEn is disabled but r_TxEn is enabled
|
ram_addr <=#Tp TxBDAddress + TxPointerRead;
|
ram_addr <=#Tp TxBDAddress + TxPointerRead;
|
ram_di <=#Tp TxBDDataIn;
|
ram_di <=#Tp TxBDDataIn;
|
end
|
end
|
5'b010_00, 5'b010_10 :
|
5'b010_00, 5'b010_10 :
|
begin
|
begin
|
WbEn <=#Tp 1'b1; // RxEn access stage and r_TxEn is disabled
|
WbEn <=#Tp 1'b1; // RxEn access stage and r_TxEn is disabled
|
RxEn <=#Tp 1'b0;
|
RxEn <=#Tp 1'b0;
|
TxEn <=#Tp 1'b0;
|
TxEn <=#Tp 1'b0;
|
ram_addr <=#Tp WB_ADR_I[9:2];
|
ram_addr <=#Tp WB_ADR_I[9:2];
|
ram_di <=#Tp WB_DAT_I;
|
ram_di <=#Tp WB_DAT_I;
|
BDWrite <=#Tp BDCs & WB_WE_I;
|
BDWrite <=#Tp BDCs & WB_WE_I;
|
BDRead <=#Tp BDCs & ~WB_WE_I;
|
BDRead <=#Tp BDCs & ~WB_WE_I;
|
end
|
end
|
5'b010_01, 5'b010_11 :
|
5'b010_01, 5'b010_11 :
|
begin
|
begin
|
WbEn <=#Tp 1'b0;
|
WbEn <=#Tp 1'b0;
|
RxEn <=#Tp 1'b0;
|
RxEn <=#Tp 1'b0;
|
TxEn <=#Tp 1'b1; // RxEn access stage and r_TxEn is enabled
|
TxEn <=#Tp 1'b1; // RxEn access stage and r_TxEn is enabled
|
ram_addr <=#Tp TxBDAddress + TxPointerRead;
|
ram_addr <=#Tp TxBDAddress + TxPointerRead;
|
ram_di <=#Tp TxBDDataIn;
|
ram_di <=#Tp TxBDDataIn;
|
end
|
end
|
5'b001_00, 5'b001_01, 5'b001_10, 5'b001_11 :
|
5'b001_00, 5'b001_01, 5'b001_10, 5'b001_11 :
|
begin
|
begin
|
WbEn <=#Tp 1'b1; // TxEn access stage (we always go to wb access stage)
|
WbEn <=#Tp 1'b1; // TxEn access stage (we always go to wb access stage)
|
RxEn <=#Tp 1'b0;
|
RxEn <=#Tp 1'b0;
|
TxEn <=#Tp 1'b0;
|
TxEn <=#Tp 1'b0;
|
ram_addr <=#Tp WB_ADR_I[9:2];
|
ram_addr <=#Tp WB_ADR_I[9:2];
|
ram_di <=#Tp WB_DAT_I;
|
ram_di <=#Tp WB_DAT_I;
|
BDWrite <=#Tp BDCs & WB_WE_I;
|
BDWrite <=#Tp BDCs & WB_WE_I;
|
BDRead <=#Tp BDCs & ~WB_WE_I;
|
BDRead <=#Tp BDCs & ~WB_WE_I;
|
end
|
end
|
5'b100_00 :
|
5'b100_00 :
|
begin
|
begin
|
WbEn <=#Tp 1'b0; // WbEn access stage and there is no need for other stages. WbEn needs to be switched off for a bit
|
WbEn <=#Tp 1'b0; // WbEn access stage and there is no need for other stages. WbEn needs to be switched off for a bit
|
end
|
end
|
5'b000_00 :
|
5'b000_00 :
|
begin
|
begin
|
WbEn <=#Tp 1'b1; // Idle state. We go to WbEn access stage.
|
WbEn <=#Tp 1'b1; // Idle state. We go to WbEn access stage.
|
RxEn <=#Tp 1'b0;
|
RxEn <=#Tp 1'b0;
|
TxEn <=#Tp 1'b0;
|
TxEn <=#Tp 1'b0;
|
ram_addr <=#Tp WB_ADR_I[9:2];
|
ram_addr <=#Tp WB_ADR_I[9:2];
|
ram_di <=#Tp WB_DAT_I;
|
ram_di <=#Tp WB_DAT_I;
|
BDWrite <=#Tp BDCs & WB_WE_I;
|
BDWrite <=#Tp BDCs & WB_WE_I;
|
BDRead <=#Tp BDCs & ~WB_WE_I;
|
BDRead <=#Tp BDCs & ~WB_WE_I;
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
end
|
end
|
|
|
|
|
// Delayed stage signals
|
// Delayed stage signals
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
begin
|
begin
|
WbEn_q <=#Tp 1'b0;
|
WbEn_q <=#Tp 1'b0;
|
RxEn_q <=#Tp 1'b0;
|
RxEn_q <=#Tp 1'b0;
|
TxEn_q <=#Tp 1'b0;
|
TxEn_q <=#Tp 1'b0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
WbEn_q <=#Tp WbEn;
|
WbEn_q <=#Tp WbEn;
|
RxEn_q <=#Tp RxEn;
|
RxEn_q <=#Tp RxEn;
|
TxEn_q <=#Tp TxEn;
|
TxEn_q <=#Tp TxEn;
|
end
|
end
|
end
|
end
|
|
|
// Changes for tx occur every second clock. Flop is used for this manner.
|
// Changes for tx occur every second clock. Flop is used for this manner.
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
Flop <=#Tp 1'b0;
|
Flop <=#Tp 1'b0;
|
else
|
else
|
if(TxDone | TxAbort | TxRetry_q)
|
if(TxDone | TxAbort | TxRetry_q)
|
Flop <=#Tp 1'b0;
|
Flop <=#Tp 1'b0;
|
else
|
else
|
if(TxUsedData)
|
if(TxUsedData)
|
Flop <=#Tp ~Flop;
|
Flop <=#Tp ~Flop;
|
end
|
end
|
|
|
wire ResetTxBDReady;
|
wire ResetTxBDReady;
|
assign ResetTxBDReady = TxDonePulse | TxAbortPulse | TxRetryPulse;
|
assign ResetTxBDReady = TxDonePulse | TxAbortPulse | TxRetryPulse;
|
|
|
// Latching READY status of the Tx buffer descriptor
|
// Latching READY status of the Tx buffer descriptor
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxBDReady <=#Tp 1'b0;
|
TxBDReady <=#Tp 1'b0;
|
else
|
else
|
if(TxEn & TxEn_q & TxBDRead)
|
if(TxEn & TxEn_q & TxBDRead)
|
TxBDReady <=#Tp ram_do[15] & (ram_do[31:16] > 4); // TxBDReady is sampled only once at the beginning.
|
TxBDReady <=#Tp ram_do[15] & (ram_do[31:16] > 4); // TxBDReady is sampled only once at the beginning.
|
else // Only packets larger then 4 bytes are transmitted.
|
else // Only packets larger then 4 bytes are transmitted.
|
if(ResetTxBDReady)
|
if(ResetTxBDReady)
|
TxBDReady <=#Tp 1'b0;
|
TxBDReady <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
// Reading the Tx buffer descriptor
|
// Reading the Tx buffer descriptor
|
assign StartTxBDRead = (TxRetryPacket_NotCleared | TxStatusWrite) & ~BlockingTxBDRead & ~TxBDReady;
|
assign StartTxBDRead = (TxRetryPacket_NotCleared | TxStatusWrite) & ~BlockingTxBDRead & ~TxBDReady;
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxBDRead <=#Tp 1'b1;
|
TxBDRead <=#Tp 1'b1;
|
else
|
else
|
if(StartTxBDRead)
|
if(StartTxBDRead)
|
TxBDRead <=#Tp 1'b1;
|
TxBDRead <=#Tp 1'b1;
|
else
|
else
|
if(TxBDReady)
|
if(TxBDReady)
|
TxBDRead <=#Tp 1'b0;
|
TxBDRead <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
// Reading Tx BD pointer
|
// Reading Tx BD pointer
|
assign StartTxPointerRead = TxBDRead & TxBDReady;
|
assign StartTxPointerRead = TxBDRead & TxBDReady;
|
|
|
// Reading Tx BD Pointer
|
// Reading Tx BD Pointer
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxPointerRead <=#Tp 1'b0;
|
TxPointerRead <=#Tp 1'b0;
|
else
|
else
|
if(StartTxPointerRead)
|
if(StartTxPointerRead)
|
TxPointerRead <=#Tp 1'b1;
|
TxPointerRead <=#Tp 1'b1;
|
else
|
else
|
if(TxEn_q)
|
if(TxEn_q)
|
TxPointerRead <=#Tp 1'b0;
|
TxPointerRead <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
// Writing status back to the Tx buffer descriptor
|
// Writing status back to the Tx buffer descriptor
|
assign TxStatusWrite = (TxDonePacket_NotCleared | TxAbortPacket_NotCleared) & TxEn & TxEn_q & ~BlockingTxStatusWrite;
|
assign TxStatusWrite = (TxDonePacket_NotCleared | TxAbortPacket_NotCleared) & TxEn & TxEn_q & ~BlockingTxStatusWrite;
|
|
|
|
|
|
|
// Status writing must occur only once. Meanwhile it is blocked.
|
// Status writing must occur only once. Meanwhile it is blocked.
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
BlockingTxStatusWrite <=#Tp 1'b0;
|
BlockingTxStatusWrite <=#Tp 1'b0;
|
else
|
else
|
if(TxStatusWrite)
|
if(TxStatusWrite)
|
BlockingTxStatusWrite <=#Tp 1'b1;
|
BlockingTxStatusWrite <=#Tp 1'b1;
|
else
|
else
|
if(~TxDone_wb & ~TxAbort_wb)
|
if(~TxDone_wb & ~TxAbort_wb)
|
BlockingTxStatusWrite <=#Tp 1'b0;
|
BlockingTxStatusWrite <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
reg BlockingTxStatusWrite_sync1;
|
reg BlockingTxStatusWrite_sync1;
|
reg BlockingTxStatusWrite_sync2;
|
reg BlockingTxStatusWrite_sync2;
|
|
|
// Synchronizing BlockingTxStatusWrite to MTxClk
|
// Synchronizing BlockingTxStatusWrite to MTxClk
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
BlockingTxStatusWrite_sync1 <=#Tp 1'b0;
|
BlockingTxStatusWrite_sync1 <=#Tp 1'b0;
|
else
|
else
|
BlockingTxStatusWrite_sync1 <=#Tp BlockingTxStatusWrite;
|
BlockingTxStatusWrite_sync1 <=#Tp BlockingTxStatusWrite;
|
end
|
end
|
|
|
// Synchronizing BlockingTxStatusWrite to MTxClk
|
// Synchronizing BlockingTxStatusWrite to MTxClk
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
BlockingTxStatusWrite_sync2 <=#Tp 1'b0;
|
BlockingTxStatusWrite_sync2 <=#Tp 1'b0;
|
else
|
else
|
BlockingTxStatusWrite_sync2 <=#Tp BlockingTxStatusWrite_sync1;
|
BlockingTxStatusWrite_sync2 <=#Tp BlockingTxStatusWrite_sync1;
|
end
|
end
|
|
|
|
|
// TxBDRead state is activated only once.
|
// TxBDRead state is activated only once.
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
BlockingTxBDRead <=#Tp 1'b0;
|
BlockingTxBDRead <=#Tp 1'b0;
|
else
|
else
|
if(StartTxBDRead)
|
if(StartTxBDRead)
|
BlockingTxBDRead <=#Tp 1'b1;
|
BlockingTxBDRead <=#Tp 1'b1;
|
else
|
else
|
if(~StartTxBDRead & ~TxBDReady)
|
if(~StartTxBDRead & ~TxBDReady)
|
BlockingTxBDRead <=#Tp 1'b0;
|
BlockingTxBDRead <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
// Latching status from the tx buffer descriptor
|
// Latching status from the tx buffer descriptor
|
// Data is avaliable one cycle after the access is started (at that time signal TxEn is not active)
|
// Data is avaliable one cycle after the access is started (at that time signal TxEn is not active)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxStatus <=#Tp 4'h0;
|
TxStatus <=#Tp 4'h0;
|
else
|
else
|
if(TxEn & TxEn_q & TxBDRead)
|
if(TxEn & TxEn_q & TxBDRead)
|
TxStatus <=#Tp ram_do[14:11];
|
TxStatus <=#Tp ram_do[14:11];
|
end
|
end
|
|
|
reg ReadTxDataFromMemory;
|
reg ReadTxDataFromMemory;
|
wire WriteRxDataToMemory;
|
wire WriteRxDataToMemory;
|
|
|
reg MasterWbTX;
|
reg MasterWbTX;
|
reg MasterWbRX;
|
reg MasterWbRX;
|
|
|
reg [31:0] m_wb_adr_o;
|
reg [31:0] m_wb_adr_o;
|
reg m_wb_cyc_o;
|
reg m_wb_cyc_o;
|
reg m_wb_stb_o;
|
reg m_wb_stb_o;
|
reg [3:0] m_wb_sel_o;
|
reg [3:0] m_wb_sel_o;
|
reg m_wb_we_o;
|
reg m_wb_we_o;
|
|
|
wire TxLengthEq0;
|
wire TxLengthEq0;
|
wire TxLengthLt4;
|
wire TxLengthLt4;
|
|
|
reg BlockingIncrementTxPointer;
|
reg BlockingIncrementTxPointer;
|
reg [31:2] TxPointerMSB;
|
reg [31:2] TxPointerMSB;
|
reg [1:0] TxPointerLSB;
|
reg [1:0] TxPointerLSB;
|
reg [1:0] TxPointerLSB_rst;
|
reg [1:0] TxPointerLSB_rst;
|
reg [31:2] RxPointerMSB;
|
reg [31:2] RxPointerMSB;
|
reg [1:0] RxPointerLSB_rst;
|
reg [1:0] RxPointerLSB_rst;
|
|
|
wire RxBurstAcc;
|
wire RxBurstAcc;
|
wire RxWordAcc;
|
wire RxWordAcc;
|
wire RxHalfAcc;
|
wire RxHalfAcc;
|
wire RxByteAcc;
|
wire RxByteAcc;
|
|
|
//Latching length from the buffer descriptor;
|
//Latching length from the buffer descriptor;
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxLength <=#Tp 16'h0;
|
TxLength <=#Tp 16'h0;
|
else
|
else
|
if(TxEn & TxEn_q & TxBDRead)
|
if(TxEn & TxEn_q & TxBDRead)
|
TxLength <=#Tp ram_do[31:16];
|
TxLength <=#Tp ram_do[31:16];
|
else
|
else
|
if(MasterWbTX & m_wb_ack_i)
|
if(MasterWbTX & m_wb_ack_i)
|
begin
|
begin
|
if(TxLengthLt4)
|
if(TxLengthLt4)
|
TxLength <=#Tp 16'h0;
|
TxLength <=#Tp 16'h0;
|
else
|
else
|
if(TxPointerLSB_rst==2'h0)
|
if(TxPointerLSB_rst==2'h0)
|
TxLength <=#Tp TxLength - 3'h4; // Length is subtracted at the data request
|
TxLength <=#Tp TxLength - 3'h4; // Length is subtracted at the data request
|
else
|
else
|
if(TxPointerLSB_rst==2'h1)
|
if(TxPointerLSB_rst==2'h1)
|
TxLength <=#Tp TxLength - 3'h3; // Length is subtracted at the data request
|
TxLength <=#Tp TxLength - 3'h3; // Length is subtracted at the data request
|
else
|
else
|
if(TxPointerLSB_rst==2'h2)
|
if(TxPointerLSB_rst==2'h2)
|
TxLength <=#Tp TxLength - 3'h2; // Length is subtracted at the data request
|
TxLength <=#Tp TxLength - 3'h2; // Length is subtracted at the data request
|
else
|
else
|
if(TxPointerLSB_rst==2'h3)
|
if(TxPointerLSB_rst==2'h3)
|
TxLength <=#Tp TxLength - 3'h1; // Length is subtracted at the data request
|
TxLength <=#Tp TxLength - 3'h1; // Length is subtracted at the data request
|
end
|
end
|
end
|
end
|
|
|
|
|
|
|
//Latching length from the buffer descriptor;
|
//Latching length from the buffer descriptor;
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
LatchedTxLength <=#Tp 16'h0;
|
LatchedTxLength <=#Tp 16'h0;
|
else
|
else
|
if(TxEn & TxEn_q & TxBDRead)
|
if(TxEn & TxEn_q & TxBDRead)
|
LatchedTxLength <=#Tp ram_do[31:16];
|
LatchedTxLength <=#Tp ram_do[31:16];
|
end
|
end
|
|
|
assign TxLengthEq0 = TxLength == 0;
|
assign TxLengthEq0 = TxLength == 0;
|
assign TxLengthLt4 = TxLength < 4;
|
assign TxLengthLt4 = TxLength < 4;
|
|
|
reg cyc_cleared;
|
reg cyc_cleared;
|
reg IncrTxPointer;
|
reg IncrTxPointer;
|
|
|
|
|
// Latching Tx buffer pointer from buffer descriptor. Only 30 MSB bits are latched
|
// Latching Tx buffer pointer from buffer descriptor. Only 30 MSB bits are latched
|
// because TxPointerMSB is only used for word-aligned accesses.
|
// because TxPointerMSB is only used for word-aligned accesses.
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxPointerMSB <=#Tp 30'h0;
|
TxPointerMSB <=#Tp 30'h0;
|
else
|
else
|
if(TxEn & TxEn_q & TxPointerRead)
|
if(TxEn & TxEn_q & TxPointerRead)
|
TxPointerMSB <=#Tp ram_do[31:2];
|
TxPointerMSB <=#Tp ram_do[31:2];
|
else
|
else
|
if(IncrTxPointer & ~BlockingIncrementTxPointer)
|
if(IncrTxPointer & ~BlockingIncrementTxPointer)
|
TxPointerMSB <=#Tp TxPointerMSB + 1'b1; // TxPointer is word-aligned
|
TxPointerMSB <=#Tp TxPointerMSB + 1'b1; // TxPointer is word-aligned
|
end
|
end
|
|
|
|
|
// Latching 2 MSB bits of the buffer descriptor. Since word accesses are performed,
|
// Latching 2 MSB bits of the buffer descriptor. Since word accesses are performed,
|
// valid data does not necesserly start at byte 0 (could be byte 0, 1, 2 or 3). This
|
// valid data does not necesserly start at byte 0 (could be byte 0, 1, 2 or 3). This
|
// signals are used for proper selection of the start byte (TxData and TxByteCnt) are
|
// signals are used for proper selection of the start byte (TxData and TxByteCnt) are
|
// set by this two bits.
|
// set by this two bits.
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxPointerLSB[1:0] <=#Tp 0;
|
TxPointerLSB[1:0] <=#Tp 0;
|
else
|
else
|
if(TxEn & TxEn_q & TxPointerRead)
|
if(TxEn & TxEn_q & TxPointerRead)
|
TxPointerLSB[1:0] <=#Tp ram_do[1:0];
|
TxPointerLSB[1:0] <=#Tp ram_do[1:0];
|
end
|
end
|
|
|
|
|
// Latching 2 MSB bits of the buffer descriptor.
|
// Latching 2 MSB bits of the buffer descriptor.
|
// After the read access, TxLength needs to be decremented for the number of the valid
|
// After the read access, TxLength needs to be decremented for the number of the valid
|
// bytes (1 to 4 bytes are valid in the first word). After the first read all bytes are
|
// bytes (1 to 4 bytes are valid in the first word). After the first read all bytes are
|
// valid so this two bits are reset to zero.
|
// valid so this two bits are reset to zero.
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxPointerLSB_rst[1:0] <=#Tp 0;
|
TxPointerLSB_rst[1:0] <=#Tp 0;
|
else
|
else
|
if(TxEn & TxEn_q & TxPointerRead)
|
if(TxEn & TxEn_q & TxPointerRead)
|
TxPointerLSB_rst[1:0] <=#Tp ram_do[1:0];
|
TxPointerLSB_rst[1:0] <=#Tp ram_do[1:0];
|
else
|
else
|
if(MasterWbTX & m_wb_ack_i) // After first access pointer is word alligned
|
if(MasterWbTX & m_wb_ack_i) // After first access pointer is word alligned
|
TxPointerLSB_rst[1:0] <=#Tp 0;
|
TxPointerLSB_rst[1:0] <=#Tp 0;
|
end
|
end
|
|
|
|
|
reg [3:0] RxByteSel;
|
reg [3:0] RxByteSel;
|
wire MasterAccessFinished;
|
wire MasterAccessFinished;
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
BlockingIncrementTxPointer <=#Tp 0;
|
BlockingIncrementTxPointer <=#Tp 0;
|
else
|
else
|
if(MasterAccessFinished)
|
if(MasterAccessFinished)
|
BlockingIncrementTxPointer <=#Tp 0;
|
BlockingIncrementTxPointer <=#Tp 0;
|
else
|
else
|
if(IncrTxPointer)
|
if(IncrTxPointer)
|
BlockingIncrementTxPointer <=#Tp 1'b1;
|
BlockingIncrementTxPointer <=#Tp 1'b1;
|
end
|
end
|
|
|
|
|
wire TxBufferAlmostFull;
|
wire TxBufferAlmostFull;
|
wire TxBufferFull;
|
wire TxBufferFull;
|
wire TxBufferEmpty;
|
wire TxBufferEmpty;
|
wire TxBufferAlmostEmpty;
|
wire TxBufferAlmostEmpty;
|
wire SetReadTxDataFromMemory;
|
wire SetReadTxDataFromMemory;
|
|
|
reg BlockReadTxDataFromMemory;
|
reg BlockReadTxDataFromMemory;
|
|
|
assign SetReadTxDataFromMemory = TxEn & TxEn_q & TxPointerRead;
|
assign SetReadTxDataFromMemory = TxEn & TxEn_q & TxPointerRead;
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
ReadTxDataFromMemory <=#Tp 1'b0;
|
ReadTxDataFromMemory <=#Tp 1'b0;
|
else
|
else
|
if(TxLengthEq0 | TxAbortPacket | TxRetryPacket)
|
if(TxLengthEq0 | TxAbortPacket | TxRetryPacket)
|
ReadTxDataFromMemory <=#Tp 1'b0;
|
ReadTxDataFromMemory <=#Tp 1'b0;
|
else
|
else
|
if(SetReadTxDataFromMemory)
|
if(SetReadTxDataFromMemory)
|
ReadTxDataFromMemory <=#Tp 1'b1;
|
ReadTxDataFromMemory <=#Tp 1'b1;
|
end
|
end
|
|
|
reg tx_burst_en;
|
reg tx_burst_en;
|
reg rx_burst_en;
|
reg rx_burst_en;
|
reg BlockingLastReadOn_Abort_Retry;
|
reg BlockingLastReadOn_Abort_Retry;
|
|
|
wire ReadTxDataFromMemory_2 = ReadTxDataFromMemory & ~BlockReadTxDataFromMemory & ~BlockingLastReadOn_Abort_Retry;
|
wire ReadTxDataFromMemory_2 = ReadTxDataFromMemory & ~BlockReadTxDataFromMemory & ~BlockingLastReadOn_Abort_Retry;
|
wire tx_burst = ReadTxDataFromMemory_2 & tx_burst_en;
|
wire tx_burst = ReadTxDataFromMemory_2 & tx_burst_en;
|
|
|
wire [31:0] TxData_wb;
|
wire [31:0] TxData_wb;
|
wire ReadTxDataFromFifo_wb;
|
wire ReadTxDataFromFifo_wb;
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
BlockReadTxDataFromMemory <=#Tp 1'b0;
|
BlockReadTxDataFromMemory <=#Tp 1'b0;
|
else
|
else
|
if((TxBufferAlmostFull | TxLength <= 4)& MasterWbTX & (!(TxAbortPacket | TxRetryPacket)))
|
if((TxBufferAlmostFull | TxLength <= 4)& MasterWbTX & (!(TxAbortPacket | TxRetryPacket)))
|
BlockReadTxDataFromMemory <=#Tp 1'b1;
|
BlockReadTxDataFromMemory <=#Tp 1'b1;
|
else
|
else
|
if(ReadTxDataFromFifo_wb | TxDonePacket | TxAbortPacket | TxRetryPacket)
|
if(ReadTxDataFromFifo_wb | TxDonePacket | TxAbortPacket | TxRetryPacket)
|
BlockReadTxDataFromMemory <=#Tp 1'b0;
|
BlockReadTxDataFromMemory <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
BlockingLastReadOn_Abort_Retry <=#Tp 1'b0;
|
BlockingLastReadOn_Abort_Retry <=#Tp 1'b0;
|
else
|
else
|
if(TxAbortPacket | TxRetryPacket)
|
if(TxAbortPacket | TxRetryPacket)
|
BlockingLastReadOn_Abort_Retry <=#Tp 1'b0;
|
BlockingLastReadOn_Abort_Retry <=#Tp 1'b0;
|
else
|
else
|
if(((TxAbort_wb & !TxAbortPacket_NotCleared) | (TxRetry_wb & !TxRetryPacket_NotCleared)) & !TxBDReady)
|
if(((TxAbort_wb & !TxAbortPacket_NotCleared) | (TxRetry_wb & !TxRetryPacket_NotCleared)) & !TxBDReady)
|
BlockingLastReadOn_Abort_Retry <=#Tp 1'b1;
|
BlockingLastReadOn_Abort_Retry <=#Tp 1'b1;
|
end
|
end
|
|
|
|
|
|
|
|
|
assign MasterAccessFinished = m_wb_ack_i | m_wb_err_i;
|
assign MasterAccessFinished = m_wb_ack_i | m_wb_err_i;
|
wire [`ETH_TX_FIFO_CNT_WIDTH-1:0] txfifo_cnt;
|
wire [`ETH_TX_FIFO_CNT_WIDTH-1:0] txfifo_cnt;
|
wire [`ETH_RX_FIFO_CNT_WIDTH-1:0] rxfifo_cnt;
|
wire [`ETH_RX_FIFO_CNT_WIDTH-1:0] rxfifo_cnt;
|
reg [`ETH_BURST_CNT_WIDTH-1:0] tx_burst_cnt;
|
reg [`ETH_BURST_CNT_WIDTH-1:0] tx_burst_cnt;
|
reg [`ETH_BURST_CNT_WIDTH-1:0] rx_burst_cnt;
|
reg [`ETH_BURST_CNT_WIDTH-1:0] rx_burst_cnt;
|
|
|
wire rx_burst;
|
wire rx_burst;
|
wire enough_data_in_rxfifo_for_burst;
|
wire enough_data_in_rxfifo_for_burst;
|
wire enough_data_in_rxfifo_for_burst_plus1;
|
wire enough_data_in_rxfifo_for_burst_plus1;
|
|
|
// Enabling master wishbone access to the memory for two devices TX and RX.
|
// Enabling master wishbone access to the memory for two devices TX and RX.
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
begin
|
begin
|
MasterWbTX <=#Tp 1'b0;
|
MasterWbTX <=#Tp 1'b0;
|
MasterWbRX <=#Tp 1'b0;
|
MasterWbRX <=#Tp 1'b0;
|
m_wb_adr_o <=#Tp 32'h0;
|
m_wb_adr_o <=#Tp 32'h0;
|
m_wb_cyc_o <=#Tp 1'b0;
|
m_wb_cyc_o <=#Tp 1'b0;
|
m_wb_stb_o <=#Tp 1'b0;
|
m_wb_stb_o <=#Tp 1'b0;
|
m_wb_we_o <=#Tp 1'b0;
|
m_wb_we_o <=#Tp 1'b0;
|
m_wb_sel_o <=#Tp 4'h0;
|
m_wb_sel_o <=#Tp 4'h0;
|
cyc_cleared<=#Tp 1'b0;
|
cyc_cleared<=#Tp 1'b0;
|
tx_burst_cnt<=#Tp 0;
|
tx_burst_cnt<=#Tp 0;
|
rx_burst_cnt<=#Tp 0;
|
rx_burst_cnt<=#Tp 0;
|
IncrTxPointer<=#Tp 1'b0;
|
IncrTxPointer<=#Tp 1'b0;
|
tx_burst_en<=#Tp 1'b1;
|
tx_burst_en<=#Tp 1'b1;
|
rx_burst_en<=#Tp 1'b0;
|
rx_burst_en<=#Tp 1'b0;
|
`ifdef ETH_WISHBONE_B3
|
`ifdef ETH_WISHBONE_B3
|
m_wb_cti_o <=#Tp 3'b0;
|
m_wb_cti_o <=#Tp 3'b0;
|
`endif
|
`endif
|
end
|
end
|
else
|
else
|
begin
|
begin
|
// Switching between two stages depends on enable signals
|
// Switching between two stages depends on enable signals
|
casex ({MasterWbTX, MasterWbRX, ReadTxDataFromMemory_2, WriteRxDataToMemory, MasterAccessFinished, cyc_cleared, tx_burst, rx_burst}) // synopsys parallel_case
|
casex ({MasterWbTX, MasterWbRX, ReadTxDataFromMemory_2, WriteRxDataToMemory, MasterAccessFinished, cyc_cleared, tx_burst, rx_burst}) // synopsys parallel_case
|
8'b00_10_00_10, // Idle and MRB needed
|
8'b00_10_00_10, // Idle and MRB needed
|
8'b10_1x_10_1x, // MRB continues
|
8'b10_1x_10_1x, // MRB continues
|
8'b10_10_01_10, // Clear (previously MR) and MRB needed
|
8'b10_10_01_10, // Clear (previously MR) and MRB needed
|
8'b01_1x_01_1x : // Clear (previously MW) and MRB needed
|
8'b01_1x_01_1x : // Clear (previously MW) and MRB needed
|
begin
|
begin
|
MasterWbTX <=#Tp 1'b1; // tx burst
|
MasterWbTX <=#Tp 1'b1; // tx burst
|
MasterWbRX <=#Tp 1'b0;
|
MasterWbRX <=#Tp 1'b0;
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_we_o <=#Tp 1'b0;
|
m_wb_we_o <=#Tp 1'b0;
|
m_wb_sel_o <=#Tp 4'hf;
|
m_wb_sel_o <=#Tp 4'hf;
|
cyc_cleared<=#Tp 1'b0;
|
cyc_cleared<=#Tp 1'b0;
|
IncrTxPointer<=#Tp 1'b1;
|
IncrTxPointer<=#Tp 1'b1;
|
tx_burst_cnt <=#Tp tx_burst_cnt+1;
|
tx_burst_cnt <=#Tp tx_burst_cnt+1;
|
if(tx_burst_cnt==0)
|
if(tx_burst_cnt==0)
|
m_wb_adr_o <=#Tp {TxPointerMSB, 2'h0};
|
m_wb_adr_o <=#Tp {TxPointerMSB, 2'h0};
|
else
|
else
|
m_wb_adr_o <=#Tp m_wb_adr_o+3'h4;
|
m_wb_adr_o <=#Tp m_wb_adr_o+3'h4;
|
|
|
if(tx_burst_cnt==(`ETH_BURST_LENGTH-1))
|
if(tx_burst_cnt==(`ETH_BURST_LENGTH-1))
|
begin
|
begin
|
tx_burst_en<=#Tp 1'b0;
|
tx_burst_en<=#Tp 1'b0;
|
`ifdef ETH_WISHBONE_B3
|
`ifdef ETH_WISHBONE_B3
|
m_wb_cti_o <=#Tp 3'b111;
|
m_wb_cti_o <=#Tp 3'b111;
|
`endif
|
`endif
|
end
|
end
|
else
|
else
|
begin
|
begin
|
`ifdef ETH_WISHBONE_B3
|
`ifdef ETH_WISHBONE_B3
|
m_wb_cti_o <=#Tp 3'b010;
|
m_wb_cti_o <=#Tp 3'b010;
|
`endif
|
`endif
|
end
|
end
|
end
|
end
|
8'b00_x1_00_x1, // Idle and MWB needed
|
8'b00_x1_00_x1, // Idle and MWB needed
|
8'b01_x1_10_x1, // MWB continues
|
8'b01_x1_10_x1, // MWB continues
|
8'b01_01_01_01, // Clear (previously MW) and MWB needed
|
8'b01_01_01_01, // Clear (previously MW) and MWB needed
|
8'b10_x1_01_x1 : // Clear (previously MR) and MWB needed
|
8'b10_x1_01_x1 : // Clear (previously MR) and MWB needed
|
begin
|
begin
|
MasterWbTX <=#Tp 1'b0; // rx burst
|
MasterWbTX <=#Tp 1'b0; // rx burst
|
MasterWbRX <=#Tp 1'b1;
|
MasterWbRX <=#Tp 1'b1;
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_we_o <=#Tp 1'b1;
|
m_wb_we_o <=#Tp 1'b1;
|
m_wb_sel_o <=#Tp RxByteSel;
|
m_wb_sel_o <=#Tp RxByteSel;
|
IncrTxPointer<=#Tp 1'b0;
|
IncrTxPointer<=#Tp 1'b0;
|
cyc_cleared<=#Tp 1'b0;
|
cyc_cleared<=#Tp 1'b0;
|
rx_burst_cnt <=#Tp rx_burst_cnt+1;
|
rx_burst_cnt <=#Tp rx_burst_cnt+1;
|
|
|
if(rx_burst_cnt==0)
|
if(rx_burst_cnt==0)
|
m_wb_adr_o <=#Tp {RxPointerMSB, 2'h0};
|
m_wb_adr_o <=#Tp {RxPointerMSB, 2'h0};
|
else
|
else
|
m_wb_adr_o <=#Tp m_wb_adr_o+3'h4;
|
m_wb_adr_o <=#Tp m_wb_adr_o+3'h4;
|
|
|
if(rx_burst_cnt==(`ETH_BURST_LENGTH-1))
|
if(rx_burst_cnt==(`ETH_BURST_LENGTH-1))
|
begin
|
begin
|
rx_burst_en<=#Tp 1'b0;
|
rx_burst_en<=#Tp 1'b0;
|
`ifdef ETH_WISHBONE_B3
|
`ifdef ETH_WISHBONE_B3
|
m_wb_cti_o <=#Tp 3'b111;
|
m_wb_cti_o <=#Tp 3'b111;
|
`endif
|
`endif
|
end
|
end
|
else
|
else
|
begin
|
begin
|
`ifdef ETH_WISHBONE_B3
|
`ifdef ETH_WISHBONE_B3
|
m_wb_cti_o <=#Tp 3'b010;
|
m_wb_cti_o <=#Tp 3'b010;
|
`endif
|
`endif
|
end
|
end
|
end
|
end
|
8'b00_x1_00_x0 : // idle and MW is needed (data write to rx buffer)
|
8'b00_x1_00_x0 : // idle and MW is needed (data write to rx buffer)
|
begin
|
begin
|
MasterWbTX <=#Tp 1'b0;
|
MasterWbTX <=#Tp 1'b0;
|
MasterWbRX <=#Tp 1'b1;
|
MasterWbRX <=#Tp 1'b1;
|
m_wb_adr_o <=#Tp {RxPointerMSB, 2'h0};
|
m_wb_adr_o <=#Tp {RxPointerMSB, 2'h0};
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_we_o <=#Tp 1'b1;
|
m_wb_we_o <=#Tp 1'b1;
|
m_wb_sel_o <=#Tp RxByteSel;
|
m_wb_sel_o <=#Tp RxByteSel;
|
IncrTxPointer<=#Tp 1'b0;
|
IncrTxPointer<=#Tp 1'b0;
|
end
|
end
|
8'b00_10_00_00 : // idle and MR is needed (data read from tx buffer)
|
8'b00_10_00_00 : // idle and MR is needed (data read from tx buffer)
|
begin
|
begin
|
MasterWbTX <=#Tp 1'b1;
|
MasterWbTX <=#Tp 1'b1;
|
MasterWbRX <=#Tp 1'b0;
|
MasterWbRX <=#Tp 1'b0;
|
m_wb_adr_o <=#Tp {TxPointerMSB, 2'h0};
|
m_wb_adr_o <=#Tp {TxPointerMSB, 2'h0};
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_we_o <=#Tp 1'b0;
|
m_wb_we_o <=#Tp 1'b0;
|
m_wb_sel_o <=#Tp 4'hf;
|
m_wb_sel_o <=#Tp 4'hf;
|
IncrTxPointer<=#Tp 1'b1;
|
IncrTxPointer<=#Tp 1'b1;
|
end
|
end
|
8'b10_10_01_00, // MR and MR is needed (data read from tx buffer)
|
8'b10_10_01_00, // MR and MR is needed (data read from tx buffer)
|
8'b01_1x_01_0x : // MW and MR is needed (data read from tx buffer)
|
8'b01_1x_01_0x : // MW and MR is needed (data read from tx buffer)
|
begin
|
begin
|
MasterWbTX <=#Tp 1'b1;
|
MasterWbTX <=#Tp 1'b1;
|
MasterWbRX <=#Tp 1'b0;
|
MasterWbRX <=#Tp 1'b0;
|
m_wb_adr_o <=#Tp {TxPointerMSB, 2'h0};
|
m_wb_adr_o <=#Tp {TxPointerMSB, 2'h0};
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_we_o <=#Tp 1'b0;
|
m_wb_we_o <=#Tp 1'b0;
|
m_wb_sel_o <=#Tp 4'hf;
|
m_wb_sel_o <=#Tp 4'hf;
|
cyc_cleared<=#Tp 1'b0;
|
cyc_cleared<=#Tp 1'b0;
|
IncrTxPointer<=#Tp 1'b1;
|
IncrTxPointer<=#Tp 1'b1;
|
end
|
end
|
8'b01_01_01_00, // MW and MW needed (data write to rx buffer)
|
8'b01_01_01_00, // MW and MW needed (data write to rx buffer)
|
8'b10_x1_01_x0 : // MR and MW is needed (data write to rx buffer)
|
8'b10_x1_01_x0 : // MR and MW is needed (data write to rx buffer)
|
begin
|
begin
|
MasterWbTX <=#Tp 1'b0;
|
MasterWbTX <=#Tp 1'b0;
|
MasterWbRX <=#Tp 1'b1;
|
MasterWbRX <=#Tp 1'b1;
|
m_wb_adr_o <=#Tp {RxPointerMSB, 2'h0};
|
m_wb_adr_o <=#Tp {RxPointerMSB, 2'h0};
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_cyc_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_stb_o <=#Tp 1'b1;
|
m_wb_we_o <=#Tp 1'b1;
|
m_wb_we_o <=#Tp 1'b1;
|
m_wb_sel_o <=#Tp RxByteSel;
|
m_wb_sel_o <=#Tp RxByteSel;
|
cyc_cleared<=#Tp 1'b0;
|
cyc_cleared<=#Tp 1'b0;
|
IncrTxPointer<=#Tp 1'b0;
|
IncrTxPointer<=#Tp 1'b0;
|
end
|
end
|
8'b01_01_10_00, // MW and MW needed (cycle is cleared between previous and next access)
|
8'b01_01_10_00, // MW and MW needed (cycle is cleared between previous and next access)
|
8'b01_1x_10_x0, // MW and MW or MR or MRB needed (cycle is cleared between previous and next access)
|
8'b01_1x_10_x0, // MW and MW or MR or MRB needed (cycle is cleared between previous and next access)
|
8'b10_10_10_00, // MR and MR needed (cycle is cleared between previous and next access)
|
8'b10_10_10_00, // MR and MR needed (cycle is cleared between previous and next access)
|
8'b10_x1_10_0x : // MR and MR or MW or MWB (cycle is cleared between previous and next access)
|
8'b10_x1_10_0x : // MR and MR or MW or MWB (cycle is cleared between previous and next access)
|
begin
|
begin
|
m_wb_cyc_o <=#Tp 1'b0; // whatever and master read or write is needed. We need to clear m_wb_cyc_o before next access is started
|
m_wb_cyc_o <=#Tp 1'b0; // whatever and master read or write is needed. We need to clear m_wb_cyc_o before next access is started
|
m_wb_stb_o <=#Tp 1'b0;
|
m_wb_stb_o <=#Tp 1'b0;
|
cyc_cleared<=#Tp 1'b1;
|
cyc_cleared<=#Tp 1'b1;
|
IncrTxPointer<=#Tp 1'b0;
|
IncrTxPointer<=#Tp 1'b0;
|
tx_burst_cnt<=#Tp 0;
|
tx_burst_cnt<=#Tp 0;
|
tx_burst_en<=#Tp txfifo_cnt<(`ETH_TX_FIFO_DEPTH-`ETH_BURST_LENGTH) & (TxLength>(`ETH_BURST_LENGTH*4+4));
|
tx_burst_en<=#Tp txfifo_cnt<(`ETH_TX_FIFO_DEPTH-`ETH_BURST_LENGTH) & (TxLength>(`ETH_BURST_LENGTH*4+4));
|
rx_burst_cnt<=#Tp 0;
|
rx_burst_cnt<=#Tp 0;
|
rx_burst_en<=#Tp MasterWbRX ? enough_data_in_rxfifo_for_burst_plus1 : enough_data_in_rxfifo_for_burst; // Counter is not decremented, yet, so plus1 is used.
|
rx_burst_en<=#Tp MasterWbRX ? enough_data_in_rxfifo_for_burst_plus1 : enough_data_in_rxfifo_for_burst; // Counter is not decremented, yet, so plus1 is used.
|
`ifdef ETH_WISHBONE_B3
|
`ifdef ETH_WISHBONE_B3
|
m_wb_cti_o <=#Tp 3'b0;
|
m_wb_cti_o <=#Tp 3'b0;
|
`endif
|
`endif
|
end
|
end
|
8'bxx_00_10_00, // whatever and no master read or write is needed (ack or err comes finishing previous access)
|
8'bxx_00_10_00, // whatever and no master read or write is needed (ack or err comes finishing previous access)
|
8'bxx_00_01_00 : // Between cyc_cleared request was cleared
|
8'bxx_00_01_00 : // Between cyc_cleared request was cleared
|
begin
|
begin
|
MasterWbTX <=#Tp 1'b0;
|
MasterWbTX <=#Tp 1'b0;
|
MasterWbRX <=#Tp 1'b0;
|
MasterWbRX <=#Tp 1'b0;
|
m_wb_cyc_o <=#Tp 1'b0;
|
m_wb_cyc_o <=#Tp 1'b0;
|
m_wb_stb_o <=#Tp 1'b0;
|
m_wb_stb_o <=#Tp 1'b0;
|
cyc_cleared<=#Tp 1'b0;
|
cyc_cleared<=#Tp 1'b0;
|
IncrTxPointer<=#Tp 1'b0;
|
IncrTxPointer<=#Tp 1'b0;
|
rx_burst_cnt<=#Tp 0;
|
rx_burst_cnt<=#Tp 0;
|
rx_burst_en<=#Tp MasterWbRX ? enough_data_in_rxfifo_for_burst_plus1 : enough_data_in_rxfifo_for_burst; // Counter is not decremented, yet, so plus1 is used.
|
rx_burst_en<=#Tp MasterWbRX ? enough_data_in_rxfifo_for_burst_plus1 : enough_data_in_rxfifo_for_burst; // Counter is not decremented, yet, so plus1 is used.
|
`ifdef ETH_WISHBONE_B3
|
`ifdef ETH_WISHBONE_B3
|
m_wb_cti_o <=#Tp 3'b0;
|
m_wb_cti_o <=#Tp 3'b0;
|
`endif
|
`endif
|
end
|
end
|
8'b00_00_00_00: // whatever and no master read or write is needed (ack or err comes finishing previous access)
|
8'b00_00_00_00: // whatever and no master read or write is needed (ack or err comes finishing previous access)
|
begin
|
begin
|
tx_burst_cnt<=#Tp 0;
|
tx_burst_cnt<=#Tp 0;
|
tx_burst_en<=#Tp txfifo_cnt<(`ETH_TX_FIFO_DEPTH-`ETH_BURST_LENGTH) & (TxLength>(`ETH_BURST_LENGTH*4+4));
|
tx_burst_en<=#Tp txfifo_cnt<(`ETH_TX_FIFO_DEPTH-`ETH_BURST_LENGTH) & (TxLength>(`ETH_BURST_LENGTH*4+4));
|
end
|
end
|
default: // Don't touch
|
default: // Don't touch
|
begin
|
begin
|
MasterWbTX <=#Tp MasterWbTX;
|
MasterWbTX <=#Tp MasterWbTX;
|
MasterWbRX <=#Tp MasterWbRX;
|
MasterWbRX <=#Tp MasterWbRX;
|
m_wb_cyc_o <=#Tp m_wb_cyc_o;
|
m_wb_cyc_o <=#Tp m_wb_cyc_o;
|
m_wb_stb_o <=#Tp m_wb_stb_o;
|
m_wb_stb_o <=#Tp m_wb_stb_o;
|
m_wb_sel_o <=#Tp m_wb_sel_o;
|
m_wb_sel_o <=#Tp m_wb_sel_o;
|
IncrTxPointer<=#Tp IncrTxPointer;
|
IncrTxPointer<=#Tp IncrTxPointer;
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
end
|
end
|
|
|
|
|
wire TxFifoClear;
|
wire TxFifoClear;
|
|
|
assign TxFifoClear = (TxAbortPacket | TxRetryPacket);
|
assign TxFifoClear = (TxAbortPacket | TxRetryPacket);
|
|
|
eth_fifo #(`ETH_TX_FIFO_DATA_WIDTH, `ETH_TX_FIFO_DEPTH, `ETH_TX_FIFO_CNT_WIDTH)
|
eth_fifo #(`ETH_TX_FIFO_DATA_WIDTH, `ETH_TX_FIFO_DEPTH, `ETH_TX_FIFO_CNT_WIDTH)
|
tx_fifo ( .data_in(m_wb_dat_i), .data_out(TxData_wb),
|
tx_fifo ( .data_in(m_wb_dat_i), .data_out(TxData_wb),
|
.clk(WB_CLK_I), .reset(Reset),
|
.clk(WB_CLK_I), .reset(Reset),
|
.write(MasterWbTX & m_wb_ack_i), .read(ReadTxDataFromFifo_wb & ~TxBufferEmpty),
|
.write(MasterWbTX & m_wb_ack_i), .read(ReadTxDataFromFifo_wb & ~TxBufferEmpty),
|
.clear(TxFifoClear), .full(TxBufferFull),
|
.clear(TxFifoClear), .full(TxBufferFull),
|
.almost_full(TxBufferAlmostFull), .almost_empty(TxBufferAlmostEmpty),
|
.almost_full(TxBufferAlmostFull), .almost_empty(TxBufferAlmostEmpty),
|
.empty(TxBufferEmpty), .cnt(txfifo_cnt)
|
.empty(TxBufferEmpty), .cnt(txfifo_cnt)
|
);
|
);
|
|
|
|
|
reg StartOccured;
|
reg StartOccured;
|
reg TxStartFrm_sync1;
|
reg TxStartFrm_sync1;
|
reg TxStartFrm_sync2;
|
reg TxStartFrm_sync2;
|
reg TxStartFrm_syncb1;
|
reg TxStartFrm_syncb1;
|
reg TxStartFrm_syncb2;
|
reg TxStartFrm_syncb2;
|
|
|
|
|
|
|
// Start: Generation of the TxStartFrm_wb which is then synchronized to the MTxClk
|
// Start: Generation of the TxStartFrm_wb which is then synchronized to the MTxClk
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxStartFrm_wb <=#Tp 1'b0;
|
TxStartFrm_wb <=#Tp 1'b0;
|
else
|
else
|
if(TxBDReady & ~StartOccured & (TxBufferFull | TxLengthEq0))
|
if(TxBDReady & ~StartOccured & (TxBufferFull | TxLengthEq0))
|
TxStartFrm_wb <=#Tp 1'b1;
|
TxStartFrm_wb <=#Tp 1'b1;
|
else
|
else
|
if(TxStartFrm_syncb2)
|
if(TxStartFrm_syncb2)
|
TxStartFrm_wb <=#Tp 1'b0;
|
TxStartFrm_wb <=#Tp 1'b0;
|
end
|
end
|
|
|
// StartOccured: TxStartFrm_wb occurs only ones at the beginning. Then it's blocked.
|
// StartOccured: TxStartFrm_wb occurs only ones at the beginning. Then it's blocked.
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
StartOccured <=#Tp 1'b0;
|
StartOccured <=#Tp 1'b0;
|
else
|
else
|
if(TxStartFrm_wb)
|
if(TxStartFrm_wb)
|
StartOccured <=#Tp 1'b1;
|
StartOccured <=#Tp 1'b1;
|
else
|
else
|
if(ResetTxBDReady)
|
if(ResetTxBDReady)
|
StartOccured <=#Tp 1'b0;
|
StartOccured <=#Tp 1'b0;
|
end
|
end
|
|
|
// Synchronizing TxStartFrm_wb to MTxClk
|
// Synchronizing TxStartFrm_wb to MTxClk
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxStartFrm_sync1 <=#Tp 1'b0;
|
TxStartFrm_sync1 <=#Tp 1'b0;
|
else
|
else
|
TxStartFrm_sync1 <=#Tp TxStartFrm_wb;
|
TxStartFrm_sync1 <=#Tp TxStartFrm_wb;
|
end
|
end
|
|
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxStartFrm_sync2 <=#Tp 1'b0;
|
TxStartFrm_sync2 <=#Tp 1'b0;
|
else
|
else
|
TxStartFrm_sync2 <=#Tp TxStartFrm_sync1;
|
TxStartFrm_sync2 <=#Tp TxStartFrm_sync1;
|
end
|
end
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxStartFrm_syncb1 <=#Tp 1'b0;
|
TxStartFrm_syncb1 <=#Tp 1'b0;
|
else
|
else
|
TxStartFrm_syncb1 <=#Tp TxStartFrm_sync2;
|
TxStartFrm_syncb1 <=#Tp TxStartFrm_sync2;
|
end
|
end
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxStartFrm_syncb2 <=#Tp 1'b0;
|
TxStartFrm_syncb2 <=#Tp 1'b0;
|
else
|
else
|
TxStartFrm_syncb2 <=#Tp TxStartFrm_syncb1;
|
TxStartFrm_syncb2 <=#Tp TxStartFrm_syncb1;
|
end
|
end
|
|
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxStartFrm <=#Tp 1'b0;
|
TxStartFrm <=#Tp 1'b0;
|
else
|
else
|
if(TxStartFrm_sync2)
|
if(TxStartFrm_sync2)
|
TxStartFrm <=#Tp 1'b1;
|
TxStartFrm <=#Tp 1'b1;
|
else
|
else
|
if(TxUsedData_q | ~TxStartFrm_sync2 & (TxRetry | TxAbort))
|
if(TxUsedData_q | ~TxStartFrm_sync2 & (TxRetry | TxAbort))
|
TxStartFrm <=#Tp 1'b0;
|
TxStartFrm <=#Tp 1'b0;
|
end
|
end
|
// End: Generation of the TxStartFrm_wb which is then synchronized to the MTxClk
|
// End: Generation of the TxStartFrm_wb which is then synchronized to the MTxClk
|
|
|
|
|
// TxEndFrm_wb: indicator of the end of frame
|
// TxEndFrm_wb: indicator of the end of frame
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxEndFrm_wb <=#Tp 1'b0;
|
TxEndFrm_wb <=#Tp 1'b0;
|
else
|
else
|
if(TxLengthEq0 & TxBufferAlmostEmpty & TxUsedData)
|
if(TxLengthEq0 & TxBufferAlmostEmpty & TxUsedData)
|
TxEndFrm_wb <=#Tp 1'b1;
|
TxEndFrm_wb <=#Tp 1'b1;
|
else
|
else
|
if(TxRetryPulse | TxDonePulse | TxAbortPulse)
|
if(TxRetryPulse | TxDonePulse | TxAbortPulse)
|
TxEndFrm_wb <=#Tp 1'b0;
|
TxEndFrm_wb <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
// Marks which bytes are valid within the word.
|
// Marks which bytes are valid within the word.
|
assign TxValidBytes = TxLengthLt4 ? TxLength[1:0] : 2'b0;
|
assign TxValidBytes = TxLengthLt4 ? TxLength[1:0] : 2'b0;
|
|
|
reg LatchValidBytes;
|
reg LatchValidBytes;
|
reg LatchValidBytes_q;
|
reg LatchValidBytes_q;
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
LatchValidBytes <=#Tp 1'b0;
|
LatchValidBytes <=#Tp 1'b0;
|
else
|
else
|
if(TxLengthLt4 & TxBDReady)
|
if(TxLengthLt4 & TxBDReady)
|
LatchValidBytes <=#Tp 1'b1;
|
LatchValidBytes <=#Tp 1'b1;
|
else
|
else
|
LatchValidBytes <=#Tp 1'b0;
|
LatchValidBytes <=#Tp 1'b0;
|
end
|
end
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
LatchValidBytes_q <=#Tp 1'b0;
|
LatchValidBytes_q <=#Tp 1'b0;
|
else
|
else
|
LatchValidBytes_q <=#Tp LatchValidBytes;
|
LatchValidBytes_q <=#Tp LatchValidBytes;
|
end
|
end
|
|
|
|
|
// Latching valid bytes
|
// Latching valid bytes
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxValidBytesLatched <=#Tp 2'h0;
|
TxValidBytesLatched <=#Tp 2'h0;
|
else
|
else
|
if(LatchValidBytes & ~LatchValidBytes_q)
|
if(LatchValidBytes & ~LatchValidBytes_q)
|
TxValidBytesLatched <=#Tp TxValidBytes;
|
TxValidBytesLatched <=#Tp TxValidBytes;
|
else
|
else
|
if(TxRetryPulse | TxDonePulse | TxAbortPulse)
|
if(TxRetryPulse | TxDonePulse | TxAbortPulse)
|
TxValidBytesLatched <=#Tp 2'h0;
|
TxValidBytesLatched <=#Tp 2'h0;
|
end
|
end
|
|
|
|
|
assign TxIRQEn = TxStatus[14];
|
assign TxIRQEn = TxStatus[14];
|
assign WrapTxStatusBit = TxStatus[13];
|
assign WrapTxStatusBit = TxStatus[13];
|
assign PerPacketPad = TxStatus[12];
|
assign PerPacketPad = TxStatus[12];
|
assign PerPacketCrcEn = TxStatus[11];
|
assign PerPacketCrcEn = TxStatus[11];
|
|
|
|
|
assign RxIRQEn = RxStatus[14];
|
assign RxIRQEn = RxStatus[14];
|
assign WrapRxStatusBit = RxStatus[13];
|
assign WrapRxStatusBit = RxStatus[13];
|
|
|
|
|
// Temporary Tx and Rx buffer descriptor address
|
// Temporary Tx and Rx buffer descriptor address
|
assign TempTxBDAddress[7:0] = {8{ TxStatusWrite & ~WrapTxStatusBit}} & (TxBDAddress + 2'h2) ; // Tx BD increment or wrap (last BD)
|
assign TempTxBDAddress[7:0] = {8{ TxStatusWrite & ~WrapTxStatusBit}} & (TxBDAddress + 2'h2) ; // Tx BD increment or wrap (last BD)
|
assign TempRxBDAddress[7:0] = {8{ WrapRxStatusBit}} & (r_TxBDNum<<1) | // Using first Rx BD
|
assign TempRxBDAddress[7:0] = {8{ WrapRxStatusBit}} & (r_TxBDNum<<1) | // Using first Rx BD
|
{8{~WrapRxStatusBit}} & (RxBDAddress + 2'h2) ; // Using next Rx BD (incremenrement address)
|
{8{~WrapRxStatusBit}} & (RxBDAddress + 2'h2) ; // Using next Rx BD (incremenrement address)
|
|
|
|
|
// Latching Tx buffer descriptor address
|
// Latching Tx buffer descriptor address
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxBDAddress <=#Tp 8'h0;
|
TxBDAddress <=#Tp 8'h0;
|
else
|
else
|
if(TxStatusWrite)
|
if(TxStatusWrite)
|
TxBDAddress <=#Tp TempTxBDAddress;
|
TxBDAddress <=#Tp TempTxBDAddress;
|
end
|
end
|
|
|
|
|
// Latching Rx buffer descriptor address
|
// Latching Rx buffer descriptor address
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxBDAddress <=#Tp `ETH_TX_BD_NUM_DEF<<1;
|
RxBDAddress <=#Tp `ETH_TX_BD_NUM_DEF<<1;
|
else
|
else
|
if(TX_BD_NUM_Wr) // When r_TxBDNum is updated, RxBDAddress is also
|
if(TX_BD_NUM_Wr) // When r_TxBDNum is updated, RxBDAddress is also
|
RxBDAddress <=#Tp WB_DAT_I[7:0]<<1;
|
RxBDAddress <=#Tp WB_DAT_I[7:0]<<1;
|
else
|
else
|
if(RxStatusWrite)
|
if(RxStatusWrite)
|
RxBDAddress <=#Tp TempRxBDAddress;
|
RxBDAddress <=#Tp TempRxBDAddress;
|
end
|
end
|
|
|
wire [8:0] TxStatusInLatched = {TxUnderRun, RetryCntLatched[3:0], RetryLimit, LateCollLatched, DeferLatched, CarrierSenseLost};
|
wire [8:0] TxStatusInLatched = {TxUnderRun, RetryCntLatched[3:0], RetryLimit, LateCollLatched, DeferLatched, CarrierSenseLost};
|
|
|
assign RxBDDataIn = {LatchedRxLength, 1'b0, RxStatus, 5'h0, RxStatusInLatched};
|
assign RxBDDataIn = {LatchedRxLength, 1'b0, RxStatus, 4'h0, RxStatusInLatched};
|
assign TxBDDataIn = {LatchedTxLength, 1'b0, TxStatus, 2'h0, TxStatusInLatched};
|
assign TxBDDataIn = {LatchedTxLength, 1'b0, TxStatus, 2'h0, TxStatusInLatched};
|
|
|
|
|
// Signals used for various purposes
|
// Signals used for various purposes
|
assign TxRetryPulse = TxRetry_wb & ~TxRetry_wb_q;
|
assign TxRetryPulse = TxRetry_wb & ~TxRetry_wb_q;
|
assign TxDonePulse = TxDone_wb & ~TxDone_wb_q;
|
assign TxDonePulse = TxDone_wb & ~TxDone_wb_q;
|
assign TxAbortPulse = TxAbort_wb & ~TxAbort_wb_q;
|
assign TxAbortPulse = TxAbort_wb & ~TxAbort_wb_q;
|
|
|
|
|
|
|
// Generating delayed signals
|
// Generating delayed signals
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
begin
|
begin
|
TxAbort_q <=#Tp 1'b0;
|
TxAbort_q <=#Tp 1'b0;
|
TxRetry_q <=#Tp 1'b0;
|
TxRetry_q <=#Tp 1'b0;
|
TxUsedData_q <=#Tp 1'b0;
|
TxUsedData_q <=#Tp 1'b0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
TxAbort_q <=#Tp TxAbort;
|
TxAbort_q <=#Tp TxAbort;
|
TxRetry_q <=#Tp TxRetry;
|
TxRetry_q <=#Tp TxRetry;
|
TxUsedData_q <=#Tp TxUsedData;
|
TxUsedData_q <=#Tp TxUsedData;
|
end
|
end
|
end
|
end
|
|
|
// Generating delayed signals
|
// Generating delayed signals
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
begin
|
begin
|
TxDone_wb_q <=#Tp 1'b0;
|
TxDone_wb_q <=#Tp 1'b0;
|
TxAbort_wb_q <=#Tp 1'b0;
|
TxAbort_wb_q <=#Tp 1'b0;
|
TxRetry_wb_q <=#Tp 1'b0;
|
TxRetry_wb_q <=#Tp 1'b0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
TxDone_wb_q <=#Tp TxDone_wb;
|
TxDone_wb_q <=#Tp TxDone_wb;
|
TxAbort_wb_q <=#Tp TxAbort_wb;
|
TxAbort_wb_q <=#Tp TxAbort_wb;
|
TxRetry_wb_q <=#Tp TxRetry_wb;
|
TxRetry_wb_q <=#Tp TxRetry_wb;
|
end
|
end
|
end
|
end
|
|
|
|
|
reg TxAbortPacketBlocked;
|
reg TxAbortPacketBlocked;
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxAbortPacket <=#Tp 1'b0;
|
TxAbortPacket <=#Tp 1'b0;
|
else
|
else
|
if(TxAbort_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished & !TxAbortPacketBlocked |
|
if(TxAbort_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished & !TxAbortPacketBlocked |
|
TxAbort_wb & !MasterWbTX & !TxAbortPacketBlocked)
|
TxAbort_wb & !MasterWbTX & !TxAbortPacketBlocked)
|
TxAbortPacket <=#Tp 1'b1;
|
TxAbortPacket <=#Tp 1'b1;
|
else
|
else
|
TxAbortPacket <=#Tp 1'b0;
|
TxAbortPacket <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxAbortPacket_NotCleared <=#Tp 1'b0;
|
TxAbortPacket_NotCleared <=#Tp 1'b0;
|
else
|
else
|
if(TxAbort_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished |
|
if(TxAbort_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished |
|
TxAbort_wb & !MasterWbTX)
|
TxAbort_wb & !MasterWbTX)
|
TxAbortPacket_NotCleared <=#Tp 1'b1;
|
TxAbortPacket_NotCleared <=#Tp 1'b1;
|
else
|
else
|
TxAbortPacket_NotCleared <=#Tp 1'b0;
|
TxAbortPacket_NotCleared <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxAbortPacketBlocked <=#Tp 1'b0;
|
TxAbortPacketBlocked <=#Tp 1'b0;
|
else
|
else
|
if(TxAbortPacket)
|
if(TxAbortPacket)
|
TxAbortPacketBlocked <=#Tp 1'b1;
|
TxAbortPacketBlocked <=#Tp 1'b1;
|
else
|
else
|
if(!TxAbort_wb & TxAbort_wb_q)
|
if(!TxAbort_wb & TxAbort_wb_q)
|
TxAbortPacketBlocked <=#Tp 1'b0;
|
TxAbortPacketBlocked <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
reg TxRetryPacketBlocked;
|
reg TxRetryPacketBlocked;
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxRetryPacket <=#Tp 1'b0;
|
TxRetryPacket <=#Tp 1'b0;
|
else
|
else
|
if(TxRetry_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished & !TxRetryPacketBlocked |
|
if(TxRetry_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished & !TxRetryPacketBlocked |
|
TxRetry_wb & !MasterWbTX & !TxRetryPacketBlocked)
|
TxRetry_wb & !MasterWbTX & !TxRetryPacketBlocked)
|
TxRetryPacket <=#Tp 1'b1;
|
TxRetryPacket <=#Tp 1'b1;
|
else
|
else
|
TxRetryPacket <=#Tp 1'b0;
|
TxRetryPacket <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxRetryPacket_NotCleared <=#Tp 1'b0;
|
TxRetryPacket_NotCleared <=#Tp 1'b0;
|
else
|
else
|
if(TxRetry_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished |
|
if(TxRetry_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished |
|
TxRetry_wb & !MasterWbTX)
|
TxRetry_wb & !MasterWbTX)
|
TxRetryPacket_NotCleared <=#Tp 1'b1;
|
TxRetryPacket_NotCleared <=#Tp 1'b1;
|
else
|
else
|
TxRetryPacket_NotCleared <=#Tp 1'b0;
|
TxRetryPacket_NotCleared <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxRetryPacketBlocked <=#Tp 1'b0;
|
TxRetryPacketBlocked <=#Tp 1'b0;
|
else
|
else
|
if(TxRetryPacket)
|
if(TxRetryPacket)
|
TxRetryPacketBlocked <=#Tp 1'b1;
|
TxRetryPacketBlocked <=#Tp 1'b1;
|
else
|
else
|
if(!TxRetry_wb & TxRetry_wb_q)
|
if(!TxRetry_wb & TxRetry_wb_q)
|
TxRetryPacketBlocked <=#Tp 1'b0;
|
TxRetryPacketBlocked <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
reg TxDonePacketBlocked;
|
reg TxDonePacketBlocked;
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxDonePacket <=#Tp 1'b0;
|
TxDonePacket <=#Tp 1'b0;
|
else
|
else
|
if(TxDone_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished & !TxDonePacketBlocked |
|
if(TxDone_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished & !TxDonePacketBlocked |
|
TxDone_wb & !MasterWbTX & !TxDonePacketBlocked)
|
TxDone_wb & !MasterWbTX & !TxDonePacketBlocked)
|
TxDonePacket <=#Tp 1'b1;
|
TxDonePacket <=#Tp 1'b1;
|
else
|
else
|
TxDonePacket <=#Tp 1'b0;
|
TxDonePacket <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxDonePacket_NotCleared <=#Tp 1'b0;
|
TxDonePacket_NotCleared <=#Tp 1'b0;
|
else
|
else
|
if(TxDone_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished |
|
if(TxDone_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished |
|
TxDone_wb & !MasterWbTX)
|
TxDone_wb & !MasterWbTX)
|
TxDonePacket_NotCleared <=#Tp 1'b1;
|
TxDonePacket_NotCleared <=#Tp 1'b1;
|
else
|
else
|
TxDonePacket_NotCleared <=#Tp 1'b0;
|
TxDonePacket_NotCleared <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxDonePacketBlocked <=#Tp 1'b0;
|
TxDonePacketBlocked <=#Tp 1'b0;
|
else
|
else
|
if(TxDonePacket)
|
if(TxDonePacket)
|
TxDonePacketBlocked <=#Tp 1'b1;
|
TxDonePacketBlocked <=#Tp 1'b1;
|
else
|
else
|
if(!TxDone_wb & TxDone_wb_q)
|
if(!TxDone_wb & TxDone_wb_q)
|
TxDonePacketBlocked <=#Tp 1'b0;
|
TxDonePacketBlocked <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
// Sinchronizing and evaluating tx data
|
// Sinchronizing and evaluating tx data
|
//assign SetGotData = (TxStartFrm_wb | NewTxDataAvaliable_wb & ~TxAbort_wb & ~TxRetry_wb) & ~WB_CLK_I;
|
//assign SetGotData = (TxStartFrm_wb | NewTxDataAvaliable_wb & ~TxAbort_wb & ~TxRetry_wb) & ~WB_CLK_I;
|
assign SetGotData = (TxStartFrm_wb);
|
assign SetGotData = (TxStartFrm_wb);
|
|
|
// Evaluating data. If abort or retry occured meanwhile than data is ignored.
|
// Evaluating data. If abort or retry occured meanwhile than data is ignored.
|
//assign GotDataEvaluate = GotDataSync3 & ~GotData & (~TxRetry & ~TxAbort | (TxRetry | TxAbort) & (TxStartFrm));
|
//assign GotDataEvaluate = GotDataSync3 & ~GotData & (~TxRetry & ~TxAbort | (TxRetry | TxAbort) & (TxStartFrm));
|
assign GotDataEvaluate = (~TxRetry & ~TxAbort | (TxRetry | TxAbort) & (TxStartFrm));
|
assign GotDataEvaluate = (~TxRetry & ~TxAbort | (TxRetry | TxAbort) & (TxStartFrm));
|
|
|
|
|
// Indication of the last word
|
// Indication of the last word
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
LastWord <=#Tp 1'b0;
|
LastWord <=#Tp 1'b0;
|
else
|
else
|
if((TxEndFrm | TxAbort | TxRetry) & Flop)
|
if((TxEndFrm | TxAbort | TxRetry) & Flop)
|
LastWord <=#Tp 1'b0;
|
LastWord <=#Tp 1'b0;
|
else
|
else
|
if(TxUsedData & Flop & TxByteCnt == 2'h3)
|
if(TxUsedData & Flop & TxByteCnt == 2'h3)
|
LastWord <=#Tp TxEndFrm_wb;
|
LastWord <=#Tp TxEndFrm_wb;
|
end
|
end
|
|
|
|
|
// Tx end frame generation
|
// Tx end frame generation
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxEndFrm <=#Tp 1'b0;
|
TxEndFrm <=#Tp 1'b0;
|
else
|
else
|
if(Flop & TxEndFrm | TxAbort | TxRetry_q)
|
if(Flop & TxEndFrm | TxAbort | TxRetry_q)
|
TxEndFrm <=#Tp 1'b0;
|
TxEndFrm <=#Tp 1'b0;
|
else
|
else
|
if(Flop & LastWord)
|
if(Flop & LastWord)
|
begin
|
begin
|
case (TxValidBytesLatched) // synopsys parallel_case
|
case (TxValidBytesLatched) // synopsys parallel_case
|
1 : TxEndFrm <=#Tp TxByteCnt == 2'h0;
|
1 : TxEndFrm <=#Tp TxByteCnt == 2'h0;
|
2 : TxEndFrm <=#Tp TxByteCnt == 2'h1;
|
2 : TxEndFrm <=#Tp TxByteCnt == 2'h1;
|
3 : TxEndFrm <=#Tp TxByteCnt == 2'h2;
|
3 : TxEndFrm <=#Tp TxByteCnt == 2'h2;
|
0 : TxEndFrm <=#Tp TxByteCnt == 2'h3;
|
0 : TxEndFrm <=#Tp TxByteCnt == 2'h3;
|
default : TxEndFrm <=#Tp 1'b0;
|
default : TxEndFrm <=#Tp 1'b0;
|
endcase
|
endcase
|
end
|
end
|
end
|
end
|
|
|
|
|
// Tx data selection (latching)
|
// Tx data selection (latching)
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxData <=#Tp 0;
|
TxData <=#Tp 0;
|
else
|
else
|
if(TxStartFrm_sync2 & ~TxStartFrm)
|
if(TxStartFrm_sync2 & ~TxStartFrm)
|
case(TxPointerLSB) // synopsys parallel_case
|
case(TxPointerLSB) // synopsys parallel_case
|
2'h0 : TxData <=#Tp TxData_wb[31:24]; // Big Endian Byte Ordering
|
2'h0 : TxData <=#Tp TxData_wb[31:24]; // Big Endian Byte Ordering
|
2'h1 : TxData <=#Tp TxData_wb[23:16]; // Big Endian Byte Ordering
|
2'h1 : TxData <=#Tp TxData_wb[23:16]; // Big Endian Byte Ordering
|
2'h2 : TxData <=#Tp TxData_wb[15:08]; // Big Endian Byte Ordering
|
2'h2 : TxData <=#Tp TxData_wb[15:08]; // Big Endian Byte Ordering
|
2'h3 : TxData <=#Tp TxData_wb[07:00]; // Big Endian Byte Ordering
|
2'h3 : TxData <=#Tp TxData_wb[07:00]; // Big Endian Byte Ordering
|
endcase
|
endcase
|
else
|
else
|
if(TxStartFrm & TxUsedData & TxPointerLSB==2'h3)
|
if(TxStartFrm & TxUsedData & TxPointerLSB==2'h3)
|
TxData <=#Tp TxData_wb[31:24]; // Big Endian Byte Ordering
|
TxData <=#Tp TxData_wb[31:24]; // Big Endian Byte Ordering
|
else
|
else
|
if(TxUsedData & Flop)
|
if(TxUsedData & Flop)
|
begin
|
begin
|
case(TxByteCnt) // synopsys parallel_case
|
case(TxByteCnt) // synopsys parallel_case
|
0 : TxData <=#Tp TxDataLatched[31:24]; // Big Endian Byte Ordering
|
0 : TxData <=#Tp TxDataLatched[31:24]; // Big Endian Byte Ordering
|
1 : TxData <=#Tp TxDataLatched[23:16];
|
1 : TxData <=#Tp TxDataLatched[23:16];
|
2 : TxData <=#Tp TxDataLatched[15:8];
|
2 : TxData <=#Tp TxDataLatched[15:8];
|
3 : TxData <=#Tp TxDataLatched[7:0];
|
3 : TxData <=#Tp TxDataLatched[7:0];
|
endcase
|
endcase
|
end
|
end
|
end
|
end
|
|
|
|
|
// Latching tx data
|
// Latching tx data
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxDataLatched[31:0] <=#Tp 32'h0;
|
TxDataLatched[31:0] <=#Tp 32'h0;
|
else
|
else
|
if(TxStartFrm_sync2 & ~TxStartFrm | TxUsedData & Flop & TxByteCnt == 2'h3 | TxStartFrm & TxUsedData & Flop & TxByteCnt == 2'h0)
|
if(TxStartFrm_sync2 & ~TxStartFrm | TxUsedData & Flop & TxByteCnt == 2'h3 | TxStartFrm & TxUsedData & Flop & TxByteCnt == 2'h0)
|
TxDataLatched[31:0] <=#Tp TxData_wb[31:0];
|
TxDataLatched[31:0] <=#Tp TxData_wb[31:0];
|
end
|
end
|
|
|
|
|
// Tx under run
|
// Tx under run
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxUnderRun_wb <=#Tp 1'b0;
|
TxUnderRun_wb <=#Tp 1'b0;
|
else
|
else
|
if(TxAbortPulse)
|
if(TxAbortPulse)
|
TxUnderRun_wb <=#Tp 1'b0;
|
TxUnderRun_wb <=#Tp 1'b0;
|
else
|
else
|
if(TxBufferEmpty & ReadTxDataFromFifo_wb)
|
if(TxBufferEmpty & ReadTxDataFromFifo_wb)
|
TxUnderRun_wb <=#Tp 1'b1;
|
TxUnderRun_wb <=#Tp 1'b1;
|
end
|
end
|
|
|
|
|
reg TxUnderRun_sync1;
|
reg TxUnderRun_sync1;
|
|
|
// Tx under run
|
// Tx under run
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxUnderRun_sync1 <=#Tp 1'b0;
|
TxUnderRun_sync1 <=#Tp 1'b0;
|
else
|
else
|
if(TxUnderRun_wb)
|
if(TxUnderRun_wb)
|
TxUnderRun_sync1 <=#Tp 1'b1;
|
TxUnderRun_sync1 <=#Tp 1'b1;
|
else
|
else
|
if(BlockingTxStatusWrite_sync2)
|
if(BlockingTxStatusWrite_sync2)
|
TxUnderRun_sync1 <=#Tp 1'b0;
|
TxUnderRun_sync1 <=#Tp 1'b0;
|
end
|
end
|
|
|
// Tx under run
|
// Tx under run
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxUnderRun <=#Tp 1'b0;
|
TxUnderRun <=#Tp 1'b0;
|
else
|
else
|
if(BlockingTxStatusWrite_sync2)
|
if(BlockingTxStatusWrite_sync2)
|
TxUnderRun <=#Tp 1'b0;
|
TxUnderRun <=#Tp 1'b0;
|
else
|
else
|
if(TxUnderRun_sync1)
|
if(TxUnderRun_sync1)
|
TxUnderRun <=#Tp 1'b1;
|
TxUnderRun <=#Tp 1'b1;
|
end
|
end
|
|
|
|
|
// Tx Byte counter
|
// Tx Byte counter
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxByteCnt <=#Tp 2'h0;
|
TxByteCnt <=#Tp 2'h0;
|
else
|
else
|
if(TxAbort_q | TxRetry_q)
|
if(TxAbort_q | TxRetry_q)
|
TxByteCnt <=#Tp 2'h0;
|
TxByteCnt <=#Tp 2'h0;
|
else
|
else
|
if(TxStartFrm & ~TxUsedData)
|
if(TxStartFrm & ~TxUsedData)
|
case(TxPointerLSB) // synopsys parallel_case
|
case(TxPointerLSB) // synopsys parallel_case
|
2'h0 : TxByteCnt <=#Tp 2'h1;
|
2'h0 : TxByteCnt <=#Tp 2'h1;
|
2'h1 : TxByteCnt <=#Tp 2'h2;
|
2'h1 : TxByteCnt <=#Tp 2'h2;
|
2'h2 : TxByteCnt <=#Tp 2'h3;
|
2'h2 : TxByteCnt <=#Tp 2'h3;
|
2'h3 : TxByteCnt <=#Tp 2'h0;
|
2'h3 : TxByteCnt <=#Tp 2'h0;
|
endcase
|
endcase
|
else
|
else
|
if(TxUsedData & Flop)
|
if(TxUsedData & Flop)
|
TxByteCnt <=#Tp TxByteCnt + 1'b1;
|
TxByteCnt <=#Tp TxByteCnt + 1'b1;
|
end
|
end
|
|
|
|
|
// Start: Generation of the ReadTxDataFromFifo_tck signal and synchronization to the WB_CLK_I
|
// Start: Generation of the ReadTxDataFromFifo_tck signal and synchronization to the WB_CLK_I
|
reg ReadTxDataFromFifo_sync1;
|
reg ReadTxDataFromFifo_sync1;
|
reg ReadTxDataFromFifo_sync2;
|
reg ReadTxDataFromFifo_sync2;
|
reg ReadTxDataFromFifo_sync3;
|
reg ReadTxDataFromFifo_sync3;
|
reg ReadTxDataFromFifo_syncb1;
|
reg ReadTxDataFromFifo_syncb1;
|
reg ReadTxDataFromFifo_syncb2;
|
reg ReadTxDataFromFifo_syncb2;
|
reg ReadTxDataFromFifo_syncb3;
|
reg ReadTxDataFromFifo_syncb3;
|
|
|
|
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
ReadTxDataFromFifo_tck <=#Tp 1'b0;
|
ReadTxDataFromFifo_tck <=#Tp 1'b0;
|
else
|
else
|
if(TxStartFrm_sync2 & ~TxStartFrm | TxUsedData & Flop & TxByteCnt == 2'h3 & ~LastWord | TxStartFrm & TxUsedData & Flop & TxByteCnt == 2'h0)
|
if(TxStartFrm_sync2 & ~TxStartFrm | TxUsedData & Flop & TxByteCnt == 2'h3 & ~LastWord | TxStartFrm & TxUsedData & Flop & TxByteCnt == 2'h0)
|
ReadTxDataFromFifo_tck <=#Tp 1'b1;
|
ReadTxDataFromFifo_tck <=#Tp 1'b1;
|
else
|
else
|
if(ReadTxDataFromFifo_syncb2 & ~ReadTxDataFromFifo_syncb3)
|
if(ReadTxDataFromFifo_syncb2 & ~ReadTxDataFromFifo_syncb3)
|
ReadTxDataFromFifo_tck <=#Tp 1'b0;
|
ReadTxDataFromFifo_tck <=#Tp 1'b0;
|
end
|
end
|
|
|
// Synchronizing TxStartFrm_wb to MTxClk
|
// Synchronizing TxStartFrm_wb to MTxClk
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
ReadTxDataFromFifo_sync1 <=#Tp 1'b0;
|
ReadTxDataFromFifo_sync1 <=#Tp 1'b0;
|
else
|
else
|
ReadTxDataFromFifo_sync1 <=#Tp ReadTxDataFromFifo_tck;
|
ReadTxDataFromFifo_sync1 <=#Tp ReadTxDataFromFifo_tck;
|
end
|
end
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
ReadTxDataFromFifo_sync2 <=#Tp 1'b0;
|
ReadTxDataFromFifo_sync2 <=#Tp 1'b0;
|
else
|
else
|
ReadTxDataFromFifo_sync2 <=#Tp ReadTxDataFromFifo_sync1;
|
ReadTxDataFromFifo_sync2 <=#Tp ReadTxDataFromFifo_sync1;
|
end
|
end
|
|
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
ReadTxDataFromFifo_syncb1 <=#Tp 1'b0;
|
ReadTxDataFromFifo_syncb1 <=#Tp 1'b0;
|
else
|
else
|
ReadTxDataFromFifo_syncb1 <=#Tp ReadTxDataFromFifo_sync2;
|
ReadTxDataFromFifo_syncb1 <=#Tp ReadTxDataFromFifo_sync2;
|
end
|
end
|
|
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
ReadTxDataFromFifo_syncb2 <=#Tp 1'b0;
|
ReadTxDataFromFifo_syncb2 <=#Tp 1'b0;
|
else
|
else
|
ReadTxDataFromFifo_syncb2 <=#Tp ReadTxDataFromFifo_syncb1;
|
ReadTxDataFromFifo_syncb2 <=#Tp ReadTxDataFromFifo_syncb1;
|
end
|
end
|
|
|
always @ (posedge MTxClk or posedge Reset)
|
always @ (posedge MTxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
ReadTxDataFromFifo_syncb3 <=#Tp 1'b0;
|
ReadTxDataFromFifo_syncb3 <=#Tp 1'b0;
|
else
|
else
|
ReadTxDataFromFifo_syncb3 <=#Tp ReadTxDataFromFifo_syncb2;
|
ReadTxDataFromFifo_syncb3 <=#Tp ReadTxDataFromFifo_syncb2;
|
end
|
end
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
ReadTxDataFromFifo_sync3 <=#Tp 1'b0;
|
ReadTxDataFromFifo_sync3 <=#Tp 1'b0;
|
else
|
else
|
ReadTxDataFromFifo_sync3 <=#Tp ReadTxDataFromFifo_sync2;
|
ReadTxDataFromFifo_sync3 <=#Tp ReadTxDataFromFifo_sync2;
|
end
|
end
|
|
|
assign ReadTxDataFromFifo_wb = ReadTxDataFromFifo_sync2 & ~ReadTxDataFromFifo_sync3;
|
assign ReadTxDataFromFifo_wb = ReadTxDataFromFifo_sync2 & ~ReadTxDataFromFifo_sync3;
|
// End: Generation of the ReadTxDataFromFifo_tck signal and synchronization to the WB_CLK_I
|
// End: Generation of the ReadTxDataFromFifo_tck signal and synchronization to the WB_CLK_I
|
|
|
|
|
// Synchronizing TxRetry signal (synchronized to WISHBONE clock)
|
// Synchronizing TxRetry signal (synchronized to WISHBONE clock)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxRetrySync1 <=#Tp 1'b0;
|
TxRetrySync1 <=#Tp 1'b0;
|
else
|
else
|
TxRetrySync1 <=#Tp TxRetry;
|
TxRetrySync1 <=#Tp TxRetry;
|
end
|
end
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxRetry_wb <=#Tp 1'b0;
|
TxRetry_wb <=#Tp 1'b0;
|
else
|
else
|
TxRetry_wb <=#Tp TxRetrySync1;
|
TxRetry_wb <=#Tp TxRetrySync1;
|
end
|
end
|
|
|
|
|
// Synchronized TxDone_wb signal (synchronized to WISHBONE clock)
|
// Synchronized TxDone_wb signal (synchronized to WISHBONE clock)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxDoneSync1 <=#Tp 1'b0;
|
TxDoneSync1 <=#Tp 1'b0;
|
else
|
else
|
TxDoneSync1 <=#Tp TxDone;
|
TxDoneSync1 <=#Tp TxDone;
|
end
|
end
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxDone_wb <=#Tp 1'b0;
|
TxDone_wb <=#Tp 1'b0;
|
else
|
else
|
TxDone_wb <=#Tp TxDoneSync1;
|
TxDone_wb <=#Tp TxDoneSync1;
|
end
|
end
|
|
|
// Synchronizing TxAbort signal (synchronized to WISHBONE clock)
|
// Synchronizing TxAbort signal (synchronized to WISHBONE clock)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxAbortSync1 <=#Tp 1'b0;
|
TxAbortSync1 <=#Tp 1'b0;
|
else
|
else
|
TxAbortSync1 <=#Tp TxAbort;
|
TxAbortSync1 <=#Tp TxAbort;
|
end
|
end
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
TxAbort_wb <=#Tp 1'b0;
|
TxAbort_wb <=#Tp 1'b0;
|
else
|
else
|
TxAbort_wb <=#Tp TxAbortSync1;
|
TxAbort_wb <=#Tp TxAbortSync1;
|
end
|
end
|
|
|
|
|
reg RxAbortSync1;
|
reg RxAbortSync1;
|
reg RxAbortSync2;
|
reg RxAbortSync2;
|
reg RxAbortSync3;
|
reg RxAbortSync3;
|
reg RxAbortSync4;
|
reg RxAbortSync4;
|
reg RxAbortSyncb1;
|
reg RxAbortSyncb1;
|
reg RxAbortSyncb2;
|
reg RxAbortSyncb2;
|
|
|
//assign StartRxBDRead = RxStatusWrite | RxAbortLatched;
|
//assign StartRxBDRead = RxStatusWrite | RxAbortLatched;
|
assign StartRxBDRead = RxStatusWrite | RxAbortSync3 & ~RxAbortSync4;
|
assign StartRxBDRead = RxStatusWrite | RxAbortSync3 & ~RxAbortSync4;
|
|
|
// Reading the Rx buffer descriptor
|
// Reading the Rx buffer descriptor
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxBDRead <=#Tp 1'b1;
|
RxBDRead <=#Tp 1'b1;
|
else
|
else
|
if(StartRxBDRead & ~RxReady)
|
if(StartRxBDRead & ~RxReady)
|
RxBDRead <=#Tp 1'b1;
|
RxBDRead <=#Tp 1'b1;
|
else
|
else
|
if(RxBDReady)
|
if(RxBDReady)
|
RxBDRead <=#Tp 1'b0;
|
RxBDRead <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
// Reading of the next receive buffer descriptor starts after reception status is
|
// Reading of the next receive buffer descriptor starts after reception status is
|
// written to the previous one.
|
// written to the previous one.
|
|
|
// Latching READY status of the Rx buffer descriptor
|
// Latching READY status of the Rx buffer descriptor
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxBDReady <=#Tp 1'b0;
|
RxBDReady <=#Tp 1'b0;
|
else
|
else
|
if(RxPointerRead)
|
if(RxPointerRead)
|
RxBDReady <=#Tp 1'b0;
|
RxBDReady <=#Tp 1'b0;
|
else
|
else
|
if(RxEn & RxEn_q & RxBDRead)
|
if(RxEn & RxEn_q & RxBDRead)
|
RxBDReady <=#Tp ram_do[15]; // RxBDReady is sampled only once at the beginning
|
RxBDReady <=#Tp ram_do[15]; // RxBDReady is sampled only once at the beginning
|
end
|
end
|
|
|
// Latching Rx buffer descriptor status
|
// Latching Rx buffer descriptor status
|
// Data is avaliable one cycle after the access is started (at that time signal RxEn is not active)
|
// Data is avaliable one cycle after the access is started (at that time signal RxEn is not active)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxStatus <=#Tp 2'h0;
|
RxStatus <=#Tp 2'h0;
|
else
|
else
|
if(RxEn & RxEn_q & RxBDRead)
|
if(RxEn & RxEn_q & RxBDRead)
|
RxStatus <=#Tp ram_do[14:13];
|
RxStatus <=#Tp ram_do[14:13];
|
end
|
end
|
|
|
|
|
// RxReady generation
|
// RxReady generation
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxReady <=#Tp 1'b0;
|
RxReady <=#Tp 1'b0;
|
else
|
else
|
if(ShiftEnded | RxAbortSync2 & ~RxAbortSync3)
|
if(ShiftEnded | RxAbortSync2 & ~RxAbortSync3)
|
RxReady <=#Tp 1'b0;
|
RxReady <=#Tp 1'b0;
|
else
|
else
|
if(RxEn & RxEn_q & RxPointerRead)
|
if(RxEn & RxEn_q & RxPointerRead)
|
RxReady <=#Tp 1'b1;
|
RxReady <=#Tp 1'b1;
|
end
|
end
|
|
|
|
|
// Reading Rx BD pointer
|
// Reading Rx BD pointer
|
|
|
|
|
assign StartRxPointerRead = RxBDRead & RxBDReady;
|
assign StartRxPointerRead = RxBDRead & RxBDReady;
|
|
|
// Reading Tx BD Pointer
|
// Reading Tx BD Pointer
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxPointerRead <=#Tp 1'b0;
|
RxPointerRead <=#Tp 1'b0;
|
else
|
else
|
if(StartRxPointerRead)
|
if(StartRxPointerRead)
|
RxPointerRead <=#Tp 1'b1;
|
RxPointerRead <=#Tp 1'b1;
|
else
|
else
|
if(RxEn & RxEn_q)
|
if(RxEn & RxEn_q)
|
RxPointerRead <=#Tp 1'b0;
|
RxPointerRead <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
//Latching Rx buffer pointer from buffer descriptor;
|
//Latching Rx buffer pointer from buffer descriptor;
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxPointerMSB <=#Tp 30'h0;
|
RxPointerMSB <=#Tp 30'h0;
|
else
|
else
|
if(RxEn & RxEn_q & RxPointerRead)
|
if(RxEn & RxEn_q & RxPointerRead)
|
RxPointerMSB <=#Tp ram_do[31:2];
|
RxPointerMSB <=#Tp ram_do[31:2];
|
else
|
else
|
if(MasterWbRX & m_wb_ack_i)
|
if(MasterWbRX & m_wb_ack_i)
|
RxPointerMSB <=#Tp RxPointerMSB + 1; // Word access (always word access. m_wb_sel_o are used for selecting bytes)
|
RxPointerMSB <=#Tp RxPointerMSB + 1; // Word access (always word access. m_wb_sel_o are used for selecting bytes)
|
end
|
end
|
|
|
|
|
//Latching last addresses from buffer descriptor (used as byte-half-word indicator);
|
//Latching last addresses from buffer descriptor (used as byte-half-word indicator);
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxPointerLSB_rst[1:0] <=#Tp 0;
|
RxPointerLSB_rst[1:0] <=#Tp 0;
|
else
|
else
|
if(MasterWbRX & m_wb_ack_i) // After first write all RxByteSel are active
|
if(MasterWbRX & m_wb_ack_i) // After first write all RxByteSel are active
|
RxPointerLSB_rst[1:0] <=#Tp 0;
|
RxPointerLSB_rst[1:0] <=#Tp 0;
|
else
|
else
|
if(RxEn & RxEn_q & RxPointerRead)
|
if(RxEn & RxEn_q & RxPointerRead)
|
RxPointerLSB_rst[1:0] <=#Tp ram_do[1:0];
|
RxPointerLSB_rst[1:0] <=#Tp ram_do[1:0];
|
end
|
end
|
|
|
|
|
always @ (RxPointerLSB_rst)
|
always @ (RxPointerLSB_rst)
|
begin
|
begin
|
case(RxPointerLSB_rst[1:0]) // synopsys parallel_case
|
case(RxPointerLSB_rst[1:0]) // synopsys parallel_case
|
2'h0 : RxByteSel[3:0] = 4'hf;
|
2'h0 : RxByteSel[3:0] = 4'hf;
|
2'h1 : RxByteSel[3:0] = 4'h7;
|
2'h1 : RxByteSel[3:0] = 4'h7;
|
2'h2 : RxByteSel[3:0] = 4'h3;
|
2'h2 : RxByteSel[3:0] = 4'h3;
|
2'h3 : RxByteSel[3:0] = 4'h1;
|
2'h3 : RxByteSel[3:0] = 4'h1;
|
endcase
|
endcase
|
end
|
end
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxEn_needed <=#Tp 1'b0;
|
RxEn_needed <=#Tp 1'b0;
|
else
|
else
|
if(~RxReady & r_RxEn & WbEn & ~WbEn_q)
|
if(~RxReady & r_RxEn & WbEn & ~WbEn_q)
|
RxEn_needed <=#Tp 1'b1;
|
RxEn_needed <=#Tp 1'b1;
|
else
|
else
|
if(RxPointerRead & RxEn & RxEn_q)
|
if(RxPointerRead & RxEn & RxEn_q)
|
RxEn_needed <=#Tp 1'b0;
|
RxEn_needed <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
// Reception status is written back to the buffer descriptor after the end of frame is detected.
|
// Reception status is written back to the buffer descriptor after the end of frame is detected.
|
assign RxStatusWrite = ShiftEnded & RxEn & RxEn_q;
|
assign RxStatusWrite = ShiftEnded & RxEn & RxEn_q;
|
|
|
reg RxStatusWriteLatched;
|
reg RxStatusWriteLatched;
|
reg RxStatusWrite_rck;
|
reg RxStatusWrite_rck;
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxStatusWriteLatched <=#Tp 1'b0;
|
RxStatusWriteLatched <=#Tp 1'b0;
|
else
|
else
|
if(RxStatusWrite & ~RxStatusWrite_rck)
|
if(RxStatusWrite & ~RxStatusWrite_rck)
|
RxStatusWriteLatched <=#Tp 1'b1;
|
RxStatusWriteLatched <=#Tp 1'b1;
|
else
|
else
|
if(RxStatusWrite_rck)
|
if(RxStatusWrite_rck)
|
RxStatusWriteLatched <=#Tp 1'b0;
|
RxStatusWriteLatched <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
always @ (posedge MRxClk or posedge Reset)
|
always @ (posedge MRxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxStatusWrite_rck <=#Tp 1'b0;
|
RxStatusWrite_rck <=#Tp 1'b0;
|
else
|
else
|
if(RxStatusWriteLatched)
|
if(RxStatusWriteLatched)
|
RxStatusWrite_rck <=#Tp 1'b1;
|
RxStatusWrite_rck <=#Tp 1'b1;
|
else
|
else
|
RxStatusWrite_rck <=#Tp 1'b0;
|
RxStatusWrite_rck <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
reg RxEnableWindow;
|
reg RxEnableWindow;
|
|
|
// Indicating that last byte is being reveived
|
// Indicating that last byte is being reveived
|
always @ (posedge MRxClk or posedge Reset)
|
always @ (posedge MRxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
LastByteIn <=#Tp 1'b0;
|
LastByteIn <=#Tp 1'b0;
|
else
|
else
|
if(ShiftWillEnd & (&RxByteCnt) | RxAbort)
|
if(ShiftWillEnd & (&RxByteCnt) | RxAbort)
|
LastByteIn <=#Tp 1'b0;
|
LastByteIn <=#Tp 1'b0;
|
else
|
else
|
if(RxValid & RxReady & RxEndFrm & ~(&RxByteCnt) & RxEnableWindow)
|
if(RxValid & RxReady & RxEndFrm & ~(&RxByteCnt) & RxEnableWindow)
|
LastByteIn <=#Tp 1'b1;
|
LastByteIn <=#Tp 1'b1;
|
end
|
end
|
|
|
reg ShiftEnded_rck;
|
reg ShiftEnded_rck;
|
reg ShiftEndedSync1;
|
reg ShiftEndedSync1;
|
reg ShiftEndedSync2;
|
reg ShiftEndedSync2;
|
reg ShiftEndedSync3;
|
reg ShiftEndedSync3;
|
reg ShiftEndedSync_c1;
|
reg ShiftEndedSync_c1;
|
reg ShiftEndedSync_c2;
|
reg ShiftEndedSync_c2;
|
|
|
wire StartShiftWillEnd;
|
wire StartShiftWillEnd;
|
assign StartShiftWillEnd = LastByteIn | RxValid & RxEndFrm & (&RxByteCnt) & RxEnableWindow;
|
assign StartShiftWillEnd = LastByteIn | RxValid & RxEndFrm & (&RxByteCnt) & RxEnableWindow;
|
|
|
// Indicating that data reception will end
|
// Indicating that data reception will end
|
always @ (posedge MRxClk or posedge Reset)
|
always @ (posedge MRxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
ShiftWillEnd <=#Tp 1'b0;
|
ShiftWillEnd <=#Tp 1'b0;
|
else
|
else
|
if(ShiftEnded_rck | RxAbort)
|
if(ShiftEnded_rck | RxAbort)
|
ShiftWillEnd <=#Tp 1'b0;
|
ShiftWillEnd <=#Tp 1'b0;
|
else
|
else
|
if(StartShiftWillEnd)
|
if(StartShiftWillEnd)
|
ShiftWillEnd <=#Tp 1'b1;
|
ShiftWillEnd <=#Tp 1'b1;
|
end
|
end
|
|
|
|
|
|
|
// Receive byte counter
|
// Receive byte counter
|
always @ (posedge MRxClk or posedge Reset)
|
always @ (posedge MRxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxByteCnt <=#Tp 2'h0;
|
RxByteCnt <=#Tp 2'h0;
|
else
|
else
|
if(ShiftEnded_rck | RxAbort)
|
if(ShiftEnded_rck | RxAbort)
|
RxByteCnt <=#Tp 2'h0;
|
RxByteCnt <=#Tp 2'h0;
|
else
|
else
|
if(RxValid & RxStartFrm & RxReady)
|
if(RxValid & RxStartFrm & RxReady)
|
case(RxPointerLSB_rst) // synopsys parallel_case
|
case(RxPointerLSB_rst) // synopsys parallel_case
|
2'h0 : RxByteCnt <=#Tp 2'h1;
|
2'h0 : RxByteCnt <=#Tp 2'h1;
|
2'h1 : RxByteCnt <=#Tp 2'h2;
|
2'h1 : RxByteCnt <=#Tp 2'h2;
|
2'h2 : RxByteCnt <=#Tp 2'h3;
|
2'h2 : RxByteCnt <=#Tp 2'h3;
|
2'h3 : RxByteCnt <=#Tp 2'h0;
|
2'h3 : RxByteCnt <=#Tp 2'h0;
|
endcase
|
endcase
|
else
|
else
|
if(RxValid & RxEnableWindow & RxReady | LastByteIn)
|
if(RxValid & RxEnableWindow & RxReady | LastByteIn)
|
RxByteCnt <=#Tp RxByteCnt + 1'b1;
|
RxByteCnt <=#Tp RxByteCnt + 1'b1;
|
end
|
end
|
|
|
|
|
// Indicates how many bytes are valid within the last word
|
// Indicates how many bytes are valid within the last word
|
always @ (posedge MRxClk or posedge Reset)
|
always @ (posedge MRxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxValidBytes <=#Tp 2'h1;
|
RxValidBytes <=#Tp 2'h1;
|
else
|
else
|
if(RxValid & RxStartFrm)
|
if(RxValid & RxStartFrm)
|
case(RxPointerLSB_rst) // synopsys parallel_case
|
case(RxPointerLSB_rst) // synopsys parallel_case
|
2'h0 : RxValidBytes <=#Tp 2'h1;
|
2'h0 : RxValidBytes <=#Tp 2'h1;
|
2'h1 : RxValidBytes <=#Tp 2'h2;
|
2'h1 : RxValidBytes <=#Tp 2'h2;
|
2'h2 : RxValidBytes <=#Tp 2'h3;
|
2'h2 : RxValidBytes <=#Tp 2'h3;
|
2'h3 : RxValidBytes <=#Tp 2'h0;
|
2'h3 : RxValidBytes <=#Tp 2'h0;
|
endcase
|
endcase
|
else
|
else
|
if(RxValid & ~LastByteIn & ~RxStartFrm & RxEnableWindow)
|
if(RxValid & ~LastByteIn & ~RxStartFrm & RxEnableWindow)
|
RxValidBytes <=#Tp RxValidBytes + 1;
|
RxValidBytes <=#Tp RxValidBytes + 1;
|
end
|
end
|
|
|
|
|
always @ (posedge MRxClk or posedge Reset)
|
always @ (posedge MRxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxDataLatched1 <=#Tp 24'h0;
|
RxDataLatched1 <=#Tp 24'h0;
|
else
|
else
|
if(RxValid & RxReady & ~LastByteIn)
|
if(RxValid & RxReady & ~LastByteIn)
|
if(RxStartFrm)
|
if(RxStartFrm)
|
begin
|
begin
|
case(RxPointerLSB_rst) // synopsys parallel_case
|
case(RxPointerLSB_rst) // synopsys parallel_case
|
2'h0: RxDataLatched1[31:24] <=#Tp RxData; // Big Endian Byte Ordering
|
2'h0: RxDataLatched1[31:24] <=#Tp RxData; // Big Endian Byte Ordering
|
2'h1: RxDataLatched1[23:16] <=#Tp RxData;
|
2'h1: RxDataLatched1[23:16] <=#Tp RxData;
|
2'h2: RxDataLatched1[15:8] <=#Tp RxData;
|
2'h2: RxDataLatched1[15:8] <=#Tp RxData;
|
2'h3: RxDataLatched1 <=#Tp RxDataLatched1;
|
2'h3: RxDataLatched1 <=#Tp RxDataLatched1;
|
endcase
|
endcase
|
end
|
end
|
else if (RxEnableWindow)
|
else if (RxEnableWindow)
|
begin
|
begin
|
case(RxByteCnt) // synopsys parallel_case
|
case(RxByteCnt) // synopsys parallel_case
|
2'h0: RxDataLatched1[31:24] <=#Tp RxData; // Big Endian Byte Ordering
|
2'h0: RxDataLatched1[31:24] <=#Tp RxData; // Big Endian Byte Ordering
|
2'h1: RxDataLatched1[23:16] <=#Tp RxData;
|
2'h1: RxDataLatched1[23:16] <=#Tp RxData;
|
2'h2: RxDataLatched1[15:8] <=#Tp RxData;
|
2'h2: RxDataLatched1[15:8] <=#Tp RxData;
|
2'h3: RxDataLatched1 <=#Tp RxDataLatched1;
|
2'h3: RxDataLatched1 <=#Tp RxDataLatched1;
|
endcase
|
endcase
|
end
|
end
|
end
|
end
|
|
|
wire SetWriteRxDataToFifo;
|
wire SetWriteRxDataToFifo;
|
|
|
// Assembling data that will be written to the rx_fifo
|
// Assembling data that will be written to the rx_fifo
|
always @ (posedge MRxClk or posedge Reset)
|
always @ (posedge MRxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
RxDataLatched2 <=#Tp 32'h0;
|
RxDataLatched2 <=#Tp 32'h0;
|
else
|
else
|
if(SetWriteRxDataToFifo & ~ShiftWillEnd)
|
if(SetWriteRxDataToFifo & ~ShiftWillEnd)
|
RxDataLatched2 <=#Tp {RxDataLatched1[31:8], RxData}; // Big Endian Byte Ordering
|
RxDataLatched2 <=#Tp {RxDataLatched1[31:8], RxData}; // Big Endian Byte Ordering
|
else
|
else
|
if(SetWriteRxDataToFifo & ShiftWillEnd)
|
if(SetWriteRxDataToFifo & ShiftWillEnd)
|
case(RxValidBytes) // synopsys parallel_case
|
case(RxValidBytes) // synopsys parallel_case
|
0 : RxDataLatched2 <=#Tp {RxDataLatched1[31:8], RxData}; // Big Endian Byte Ordering
|
0 : RxDataLatched2 <=#Tp {RxDataLatched1[31:8], RxData}; // Big Endian Byte Ordering
|
1 : RxDataLatched2 <=#Tp {RxDataLatched1[31:24], 24'h0};
|
1 : RxDataLatched2 <=#Tp {RxDataLatched1[31:24], 24'h0};
|
2 : RxDataLatched2 <=#Tp {RxDataLatched1[31:16], 16'h0};
|
2 : RxDataLatched2 <=#Tp {RxDataLatched1[31:16], 16'h0};
|
3 : RxDataLatched2 <=#Tp {RxDataLatched1[31:8], 8'h0};
|
3 : RxDataLatched2 <=#Tp {RxDataLatched1[31:8], 8'h0};
|
endcase
|
endcase
|
end
|
end
|
|
|
|
|
reg WriteRxDataToFifoSync1;
|
reg WriteRxDataToFifoSync1;
|
reg WriteRxDataToFifoSync2;
|
reg WriteRxDataToFifoSync2;
|
reg WriteRxDataToFifoSync3;
|
reg WriteRxDataToFifoSync3;
|
|
|
|
|
// Indicating start of the reception process
|
// Indicating start of the reception process
|
assign SetWriteRxDataToFifo = (RxValid & RxReady & ~RxStartFrm & RxEnableWindow & (&RxByteCnt)) |
|
assign SetWriteRxDataToFifo = (RxValid & RxReady & ~RxStartFrm & RxEnableWindow & (&RxByteCnt)) |
|
(RxValid & RxReady & RxStartFrm & (&RxPointerLSB_rst)) |
|
(RxValid & RxReady & RxStartFrm & (&RxPointerLSB_rst)) |
|
(ShiftWillEnd & LastByteIn & (&RxByteCnt));
|
(ShiftWillEnd & LastByteIn & (&RxByteCnt));
|
|
|
always @ (posedge MRxClk or posedge Reset)
|
always @ (posedge MRxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
WriteRxDataToFifo <=#Tp 1'b0;
|
WriteRxDataToFifo <=#Tp 1'b0;
|
else
|
else
|
if(SetWriteRxDataToFifo & ~RxAbort)
|
if(SetWriteRxDataToFifo & ~RxAbort)
|
WriteRxDataToFifo <=#Tp 1'b1;
|
WriteRxDataToFifo <=#Tp 1'b1;
|
else
|
else
|
if(WriteRxDataToFifoSync2 | RxAbort)
|
if(WriteRxDataToFifoSync2 | RxAbort)
|
WriteRxDataToFifo <=#Tp 1'b0;
|
WriteRxDataToFifo <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
WriteRxDataToFifoSync1 <=#Tp 1'b0;
|
WriteRxDataToFifoSync1 <=#Tp 1'b0;
|
else
|
else
|
if(WriteRxDataToFifo)
|
if(WriteRxDataToFifo)
|
WriteRxDataToFifoSync1 <=#Tp 1'b1;
|
WriteRxDataToFifoSync1 <=#Tp 1'b1;
|
else
|
else
|
WriteRxDataToFifoSync1 <=#Tp 1'b0;
|
WriteRxDataToFifoSync1 <=#Tp 1'b0;
|
end
|
end
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
WriteRxDataToFifoSync2 <=#Tp 1'b0;
|
WriteRxDataToFifoSync2 <=#Tp 1'b0;
|
else
|
else
|
WriteRxDataToFifoSync2 <=#Tp WriteRxDataToFifoSync1;
|
WriteRxDataToFifoSync2 <=#Tp WriteRxDataToFifoSync1;
|
end
|
end
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
WriteRxDataToFifoSync3 <=#Tp 1'b0;
|
WriteRxDataToFifoSync3 <=#Tp 1'b0;
|
else
|
else
|
WriteRxDataToFifoSync3 <=#Tp WriteRxDataToFifoSync2;
|
WriteRxDataToFifoSync3 <=#Tp WriteRxDataToFifoSync2;
|
end
|
end
|
|
|
wire WriteRxDataToFifo_wb;
|
wire WriteRxDataToFifo_wb;
|
assign WriteRxDataToFifo_wb = WriteRxDataToFifoSync2 & ~WriteRxDataToFifoSync3;
|
assign WriteRxDataToFifo_wb = WriteRxDataToFifoSync2 & ~WriteRxDataToFifoSync3;
|
|
|
|
|
reg LatchedRxStartFrm;
|
reg LatchedRxStartFrm;
|
reg SyncRxStartFrm;
|
reg SyncRxStartFrm;
|
reg SyncRxStartFrm_q;
|
reg SyncRxStartFrm_q;
|
reg SyncRxStartFrm_q2;
|
reg SyncRxStartFrm_q2;
|
wire RxFifoReset;
|
wire RxFifoReset;
|
|
|
always @ (posedge MRxClk or posedge Reset)
|
always @ (posedge MRxClk or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
LatchedRxStartFrm <=#Tp 0;
|
LatchedRxStartFrm <=#Tp 0;
|
else
|
else
|
if(RxStartFrm & ~SyncRxStartFrm_q)
|
if(RxStartFrm & ~SyncRxStartFrm_q)
|
LatchedRxStartFrm <=#Tp 1;
|
LatchedRxStartFrm <=#Tp 1;
|
else
|
else
|
if(SyncRxStartFrm_q)
|
if(SyncRxStartFrm_q)
|
LatchedRxStartFrm <=#Tp 0;
|
LatchedRxStartFrm <=#Tp 0;
|
end
|
end
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Reset)
|
SyncRxStartFrm <=#Tp 0;
|
SyncRxStartFrm <=#Tp 0;
|
else
|
else
|
if(LatchedRxStartFrm)
|
if(LatchedRxStartFrm)
|
SyncRxStartFrm <=#Tp 1;
|
SyncRxStartFrm <=#Tp 1;
|
else
|
else
|
SyncRxStartFrm <=#Tp 0;
|
SyncRxStartFrm <=#Tp 0;
|
end
|
end
|
|
|
|
|
always @ (posedge WB_CLK_I or posedge Reset)
|
always @ (posedge WB_CLK_I or posedge Reset)
|
begin
|
begin
|
if(Reset)
|
if(Rese
|