| 1 |
15 |
mohor |
//////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
//// ////
|
| 3 |
|
|
//// eth_top.v ////
|
| 4 |
|
|
//// ////
|
| 5 |
|
|
//// This file is part of the Ethernet IP core project ////
|
| 6 |
37 |
mohor |
//// http://www.opencores.org/projects/ethmac/ ////
|
| 7 |
15 |
mohor |
//// ////
|
| 8 |
|
|
//// Author(s): ////
|
| 9 |
|
|
//// - Igor Mohor (igorM@opencores.org) ////
|
| 10 |
|
|
//// ////
|
| 11 |
202 |
mohor |
//// All additional information is available in the Readme.txt ////
|
| 12 |
15 |
mohor |
//// file. ////
|
| 13 |
|
|
//// ////
|
| 14 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 15 |
|
|
//// ////
|
| 16 |
202 |
mohor |
//// Copyright (C) 2001, 2002 Authors ////
|
| 17 |
15 |
mohor |
//// ////
|
| 18 |
|
|
//// This source file may be used and distributed without ////
|
| 19 |
|
|
//// restriction provided that this copyright statement is not ////
|
| 20 |
|
|
//// removed from the file and that any derivative work contains ////
|
| 21 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
| 22 |
|
|
//// ////
|
| 23 |
|
|
//// This source file is free software; you can redistribute it ////
|
| 24 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
| 25 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
| 26 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
| 27 |
|
|
//// later version. ////
|
| 28 |
|
|
//// ////
|
| 29 |
|
|
//// This source is distributed in the hope that it will be ////
|
| 30 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
| 31 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
| 32 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
| 33 |
|
|
//// details. ////
|
| 34 |
|
|
//// ////
|
| 35 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
| 36 |
|
|
//// Public License along with this source; if not, download it ////
|
| 37 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
| 38 |
|
|
//// ////
|
| 39 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 40 |
|
|
//
|
| 41 |
|
|
// CVS Revision History
|
| 42 |
|
|
//
|
| 43 |
|
|
// $Log: not supported by cvs2svn $
|
| 44 |
202 |
mohor |
// Revision 1.31 2002/09/12 14:50:17 mohor
|
| 45 |
|
|
// CarrierSenseLost bug fixed when operating in full duplex mode.
|
| 46 |
|
|
//
|
| 47 |
168 |
mohor |
// Revision 1.30 2002/09/10 10:35:23 mohor
|
| 48 |
|
|
// Ethernet debug registers removed.
|
| 49 |
|
|
//
|
| 50 |
164 |
mohor |
// Revision 1.29 2002/09/09 13:03:13 mohor
|
| 51 |
|
|
// Error acknowledge is generated when accessing BDs and RST bit in the
|
| 52 |
|
|
// MODER register (r_Rst) is set.
|
| 53 |
|
|
//
|
| 54 |
161 |
mohor |
// Revision 1.28 2002/09/04 18:44:10 mohor
|
| 55 |
|
|
// Signals related to the control frames connected. Debug registers reg1, 2, 3, 4
|
| 56 |
|
|
// connected.
|
| 57 |
|
|
//
|
| 58 |
149 |
mohor |
// Revision 1.27 2002/07/25 18:15:37 mohor
|
| 59 |
|
|
// RxAbort changed. Packets received with MRxErr (from PHY) are also
|
| 60 |
|
|
// aborted.
|
| 61 |
|
|
//
|
| 62 |
125 |
mohor |
// Revision 1.26 2002/07/17 18:51:50 mohor
|
| 63 |
|
|
// EXTERNAL_DMA removed. External DMA not supported.
|
| 64 |
|
|
//
|
| 65 |
114 |
mohor |
// Revision 1.25 2002/05/03 10:15:50 mohor
|
| 66 |
|
|
// Outputs registered. Reset changed for eth_wishbone module.
|
| 67 |
|
|
//
|
| 68 |
106 |
mohor |
// Revision 1.24 2002/04/22 14:15:42 mohor
|
| 69 |
|
|
// Wishbone signals are registered when ETH_REGISTERED_OUTPUTS is
|
| 70 |
|
|
// selected in eth_defines.v
|
| 71 |
|
|
//
|
| 72 |
103 |
mohor |
// Revision 1.23 2002/03/25 13:33:53 mohor
|
| 73 |
|
|
// md_padoen_o changed to md_padoe_o. Signal was always active high, just
|
| 74 |
|
|
// name was incorrect.
|
| 75 |
|
|
//
|
| 76 |
95 |
mohor |
// Revision 1.22 2002/02/26 16:59:54 mohor
|
| 77 |
|
|
// Small fixes for external/internal DMA missmatches.
|
| 78 |
|
|
//
|
| 79 |
80 |
mohor |
// Revision 1.21 2002/02/26 16:21:00 mohor
|
| 80 |
|
|
// Interrupts changed in the top file
|
| 81 |
|
|
//
|
| 82 |
76 |
mohor |
// Revision 1.20 2002/02/18 10:40:17 mohor
|
| 83 |
|
|
// Small fixes.
|
| 84 |
|
|
//
|
| 85 |
70 |
mohor |
// Revision 1.19 2002/02/16 14:03:44 mohor
|
| 86 |
|
|
// Registered trimmed. Unused registers removed.
|
| 87 |
|
|
//
|
| 88 |
68 |
mohor |
// Revision 1.18 2002/02/16 13:06:33 mohor
|
| 89 |
|
|
// EXTERNAL_DMA used instead of WISHBONE_DMA.
|
| 90 |
|
|
//
|
| 91 |
67 |
mohor |
// Revision 1.17 2002/02/16 07:15:27 mohor
|
| 92 |
|
|
// Testbench fixed, code simplified, unused signals removed.
|
| 93 |
|
|
//
|
| 94 |
65 |
mohor |
// Revision 1.16 2002/02/15 13:49:39 mohor
|
| 95 |
|
|
// RxAbort is connected differently.
|
| 96 |
|
|
//
|
| 97 |
63 |
mohor |
// Revision 1.15 2002/02/15 11:38:26 mohor
|
| 98 |
|
|
// Changes that were lost when updating from 1.11 to 1.14 fixed.
|
| 99 |
|
|
//
|
| 100 |
59 |
mohor |
// Revision 1.14 2002/02/14 20:19:11 billditt
|
| 101 |
|
|
// Modified for Address Checking,
|
| 102 |
|
|
// addition of eth_addrcheck.v
|
| 103 |
|
|
//
|
| 104 |
|
|
// Revision 1.13 2002/02/12 17:03:03 mohor
|
| 105 |
|
|
// HASH0 and HASH1 registers added. Registers address width was
|
| 106 |
|
|
// changed to 8 bits.
|
| 107 |
|
|
//
|
| 108 |
|
|
// Revision 1.12 2002/02/11 09:18:22 mohor
|
| 109 |
|
|
// Tx status is written back to the BD.
|
| 110 |
|
|
//
|
| 111 |
43 |
mohor |
// Revision 1.11 2002/02/08 16:21:54 mohor
|
| 112 |
|
|
// Rx status is written back to the BD.
|
| 113 |
|
|
//
|
| 114 |
42 |
mohor |
// Revision 1.10 2002/02/06 14:10:21 mohor
|
| 115 |
|
|
// non-DMA host interface added. Select the right configutation in eth_defines.
|
| 116 |
|
|
//
|
| 117 |
41 |
mohor |
// Revision 1.9 2002/01/23 10:28:16 mohor
|
| 118 |
|
|
// Link in the header changed.
|
| 119 |
|
|
//
|
| 120 |
37 |
mohor |
// Revision 1.8 2001/12/05 15:00:16 mohor
|
| 121 |
|
|
// RX_BD_NUM changed to TX_BD_NUM (holds number of TX descriptors
|
| 122 |
|
|
// instead of the number of RX descriptors).
|
| 123 |
|
|
//
|
| 124 |
34 |
mohor |
// Revision 1.7 2001/12/05 10:45:59 mohor
|
| 125 |
|
|
// ETH_RX_BD_ADR register deleted. ETH_RX_BD_NUM is used instead.
|
| 126 |
|
|
//
|
| 127 |
33 |
mohor |
// Revision 1.6 2001/10/19 11:24:29 mohor
|
| 128 |
|
|
// Number of addresses (wb_adr_i) minimized.
|
| 129 |
|
|
//
|
| 130 |
23 |
mohor |
// Revision 1.5 2001/10/19 08:43:51 mohor
|
| 131 |
|
|
// eth_timescale.v changed to timescale.v This is done because of the
|
| 132 |
|
|
// simulation of the few cores in a one joined project.
|
| 133 |
|
|
//
|
| 134 |
22 |
mohor |
// Revision 1.4 2001/10/18 12:07:11 mohor
|
| 135 |
|
|
// Status signals changed, Adress decoding changed, interrupt controller
|
| 136 |
|
|
// added.
|
| 137 |
|
|
//
|
| 138 |
21 |
mohor |
// Revision 1.3 2001/09/24 15:02:56 mohor
|
| 139 |
|
|
// Defines changed (All precede with ETH_). Small changes because some
|
| 140 |
|
|
// tools generate warnings when two operands are together. Synchronization
|
| 141 |
|
|
// between two clocks domains in eth_wishbonedma.v is changed (due to ASIC
|
| 142 |
|
|
// demands).
|
| 143 |
|
|
//
|
| 144 |
20 |
mohor |
// Revision 1.2 2001/08/15 14:03:59 mohor
|
| 145 |
|
|
// Signal names changed on the top level for easier pad insertion (ASIC).
|
| 146 |
|
|
//
|
| 147 |
17 |
mohor |
// Revision 1.1 2001/08/06 14:44:29 mohor
|
| 148 |
|
|
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
|
| 149 |
|
|
// Include files fixed to contain no path.
|
| 150 |
|
|
// File names and module names changed ta have a eth_ prologue in the name.
|
| 151 |
|
|
// File eth_timescale.v is used to define timescale
|
| 152 |
|
|
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
|
| 153 |
|
|
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
|
| 154 |
|
|
// and Mdo_OE. The bidirectional signal must be created on the top level. This
|
| 155 |
|
|
// is done due to the ASIC tools.
|
| 156 |
|
|
//
|
| 157 |
15 |
mohor |
// Revision 1.2 2001/08/02 09:25:31 mohor
|
| 158 |
|
|
// Unconnected signals are now connected.
|
| 159 |
|
|
//
|
| 160 |
|
|
// Revision 1.1 2001/07/30 21:23:42 mohor
|
| 161 |
|
|
// Directory structure changed. Files checked and joind together.
|
| 162 |
|
|
//
|
| 163 |
|
|
//
|
| 164 |
|
|
//
|
| 165 |
20 |
mohor |
//
|
| 166 |
15 |
mohor |
|
| 167 |
|
|
|
| 168 |
|
|
`include "eth_defines.v"
|
| 169 |
22 |
mohor |
`include "timescale.v"
|
| 170 |
15 |
mohor |
|
| 171 |
|
|
|
| 172 |
|
|
module eth_top
|
| 173 |
|
|
(
|
| 174 |
|
|
// WISHBONE common
|
| 175 |
17 |
mohor |
wb_clk_i, wb_rst_i, wb_dat_i, wb_dat_o,
|
| 176 |
15 |
mohor |
|
| 177 |
|
|
// WISHBONE slave
|
| 178 |
17 |
mohor |
wb_adr_i, wb_sel_i, wb_we_i, wb_cyc_i, wb_stb_i, wb_ack_o, wb_err_o,
|
| 179 |
15 |
mohor |
|
| 180 |
41 |
mohor |
// WISHBONE master
|
| 181 |
|
|
m_wb_adr_o, m_wb_sel_o, m_wb_we_o,
|
| 182 |
|
|
m_wb_dat_o, m_wb_dat_i, m_wb_cyc_o,
|
| 183 |
|
|
m_wb_stb_o, m_wb_ack_i, m_wb_err_i,
|
| 184 |
|
|
|
| 185 |
15 |
mohor |
//TX
|
| 186 |
20 |
mohor |
mtx_clk_pad_i, mtxd_pad_o, mtxen_pad_o, mtxerr_pad_o,
|
| 187 |
15 |
mohor |
|
| 188 |
|
|
//RX
|
| 189 |
20 |
mohor |
mrx_clk_pad_i, mrxd_pad_i, mrxdv_pad_i, mrxerr_pad_i, mcoll_pad_i, mcrs_pad_i,
|
| 190 |
15 |
mohor |
|
| 191 |
|
|
// MIIM
|
| 192 |
95 |
mohor |
mdc_pad_o, md_pad_i, md_pad_o, md_padoe_o,
|
| 193 |
17 |
mohor |
|
| 194 |
21 |
mohor |
int_o
|
| 195 |
17 |
mohor |
|
| 196 |
21 |
mohor |
|
| 197 |
15 |
mohor |
);
|
| 198 |
|
|
|
| 199 |
|
|
|
| 200 |
|
|
parameter Tp = 1;
|
| 201 |
|
|
|
| 202 |
|
|
|
| 203 |
|
|
// WISHBONE common
|
| 204 |
17 |
mohor |
input wb_clk_i; // WISHBONE clock
|
| 205 |
|
|
input wb_rst_i; // WISHBONE reset
|
| 206 |
|
|
input [31:0] wb_dat_i; // WISHBONE data input
|
| 207 |
|
|
output [31:0] wb_dat_o; // WISHBONE data output
|
| 208 |
|
|
output wb_err_o; // WISHBONE error output
|
| 209 |
15 |
mohor |
|
| 210 |
|
|
// WISHBONE slave
|
| 211 |
23 |
mohor |
input [11:2] wb_adr_i; // WISHBONE address input
|
| 212 |
17 |
mohor |
input [3:0] wb_sel_i; // WISHBONE byte select input
|
| 213 |
|
|
input wb_we_i; // WISHBONE write enable input
|
| 214 |
|
|
input wb_cyc_i; // WISHBONE cycle input
|
| 215 |
|
|
input wb_stb_i; // WISHBONE strobe input
|
| 216 |
|
|
output wb_ack_o; // WISHBONE acknowledge output
|
| 217 |
15 |
mohor |
|
| 218 |
41 |
mohor |
// WISHBONE master
|
| 219 |
|
|
output [31:0] m_wb_adr_o;
|
| 220 |
|
|
output [3:0] m_wb_sel_o;
|
| 221 |
|
|
output m_wb_we_o;
|
| 222 |
|
|
input [31:0] m_wb_dat_i;
|
| 223 |
|
|
output [31:0] m_wb_dat_o;
|
| 224 |
|
|
output m_wb_cyc_o;
|
| 225 |
|
|
output m_wb_stb_o;
|
| 226 |
|
|
input m_wb_ack_i;
|
| 227 |
|
|
input m_wb_err_i;
|
| 228 |
15 |
mohor |
|
| 229 |
41 |
mohor |
|
| 230 |
15 |
mohor |
// Tx
|
| 231 |
20 |
mohor |
input mtx_clk_pad_i; // Transmit clock (from PHY)
|
| 232 |
21 |
mohor |
output [3:0] mtxd_pad_o; // Transmit nibble (to PHY)
|
| 233 |
|
|
output mtxen_pad_o; // Transmit enable (to PHY)
|
| 234 |
|
|
output mtxerr_pad_o; // Transmit error (to PHY)
|
| 235 |
15 |
mohor |
|
| 236 |
|
|
// Rx
|
| 237 |
20 |
mohor |
input mrx_clk_pad_i; // Receive clock (from PHY)
|
| 238 |
21 |
mohor |
input [3:0] mrxd_pad_i; // Receive nibble (from PHY)
|
| 239 |
|
|
input mrxdv_pad_i; // Receive data valid (from PHY)
|
| 240 |
|
|
input mrxerr_pad_i; // Receive data error (from PHY)
|
| 241 |
15 |
mohor |
|
| 242 |
|
|
// Common Tx and Rx
|
| 243 |
21 |
mohor |
input mcoll_pad_i; // Collision (from PHY)
|
| 244 |
|
|
input mcrs_pad_i; // Carrier sense (from PHY)
|
| 245 |
15 |
mohor |
|
| 246 |
|
|
// MII Management interface
|
| 247 |
21 |
mohor |
input md_pad_i; // MII data input (from I/O cell)
|
| 248 |
|
|
output mdc_pad_o; // MII Management data clock (to PHY)
|
| 249 |
|
|
output md_pad_o; // MII data output (to I/O cell)
|
| 250 |
95 |
mohor |
output md_padoe_o; // MII data output enable (to I/O cell)
|
| 251 |
15 |
mohor |
|
| 252 |
21 |
mohor |
output int_o; // Interrupt output
|
| 253 |
15 |
mohor |
|
| 254 |
|
|
wire [7:0] r_ClkDiv;
|
| 255 |
|
|
wire r_MiiNoPre;
|
| 256 |
|
|
wire [15:0] r_CtrlData;
|
| 257 |
|
|
wire [4:0] r_FIAD;
|
| 258 |
|
|
wire [4:0] r_RGAD;
|
| 259 |
|
|
wire r_WCtrlData;
|
| 260 |
|
|
wire r_RStat;
|
| 261 |
|
|
wire r_ScanStat;
|
| 262 |
|
|
wire NValid_stat;
|
| 263 |
|
|
wire Busy_stat;
|
| 264 |
|
|
wire LinkFail;
|
| 265 |
|
|
wire r_MiiMRst;
|
| 266 |
|
|
wire [15:0] Prsd; // Read Status Data (data read from the PHY)
|
| 267 |
|
|
wire WCtrlDataStart;
|
| 268 |
|
|
wire RStatStart;
|
| 269 |
|
|
wire UpdateMIIRX_DATAReg;
|
| 270 |
|
|
|
| 271 |
|
|
wire TxStartFrm;
|
| 272 |
|
|
wire TxEndFrm;
|
| 273 |
|
|
wire TxUsedData;
|
| 274 |
|
|
wire [7:0] TxData;
|
| 275 |
|
|
wire TxRetry;
|
| 276 |
|
|
wire TxAbort;
|
| 277 |
|
|
wire TxUnderRun;
|
| 278 |
|
|
wire TxDone;
|
| 279 |
42 |
mohor |
wire [5:0] CollValid;
|
| 280 |
15 |
mohor |
|
| 281 |
|
|
|
| 282 |
149 |
mohor |
reg WillSendControlFrame_sync1;
|
| 283 |
|
|
reg WillSendControlFrame_sync2;
|
| 284 |
|
|
reg WillSendControlFrame_sync3;
|
| 285 |
|
|
reg RstTxPauseRq;
|
| 286 |
15 |
mohor |
|
| 287 |
|
|
|
| 288 |
|
|
// Connecting Miim module
|
| 289 |
|
|
eth_miim miim1
|
| 290 |
|
|
(
|
| 291 |
17 |
mohor |
.Clk(wb_clk_i), .Reset(r_MiiMRst), .Divider(r_ClkDiv),
|
| 292 |
15 |
mohor |
.NoPre(r_MiiNoPre), .CtrlData(r_CtrlData), .Rgad(r_RGAD),
|
| 293 |
|
|
.Fiad(r_FIAD), .WCtrlData(r_WCtrlData), .RStat(r_RStat),
|
| 294 |
17 |
mohor |
.ScanStat(r_ScanStat), .Mdi(md_pad_i), .Mdo(md_pad_o),
|
| 295 |
95 |
mohor |
.MdoEn(md_padoe_o), .Mdc(mdc_pad_o), .Busy(Busy_stat),
|
| 296 |
15 |
mohor |
.Prsd(Prsd), .LinkFail(LinkFail), .Nvalid(NValid_stat),
|
| 297 |
|
|
.WCtrlDataStart(WCtrlDataStart), .RStatStart(RStatStart), .UpdateMIIRX_DATAReg(UpdateMIIRX_DATAReg)
|
| 298 |
|
|
);
|
| 299 |
|
|
|
| 300 |
|
|
|
| 301 |
|
|
|
| 302 |
|
|
|
| 303 |
|
|
wire RegCs; // Connected to registers
|
| 304 |
17 |
mohor |
wire [31:0] RegDataOut; // Multiplexed to wb_dat_o
|
| 305 |
42 |
mohor |
wire r_RecSmall; // Receive small frames
|
| 306 |
15 |
mohor |
wire r_Rst; // Reset
|
| 307 |
|
|
wire r_LoopBck; // Loopback
|
| 308 |
|
|
wire r_TxEn; // Tx Enable
|
| 309 |
|
|
wire r_RxEn; // Rx Enable
|
| 310 |
|
|
|
| 311 |
|
|
wire MRxDV_Lb; // Muxed MII receive data valid
|
| 312 |
|
|
wire MRxErr_Lb; // Muxed MII Receive Error
|
| 313 |
|
|
wire [3:0] MRxD_Lb; // Muxed MII Receive Data
|
| 314 |
|
|
wire Transmitting; // Indication that TxEthMAC is transmitting
|
| 315 |
|
|
wire r_HugEn; // Huge packet enable
|
| 316 |
|
|
wire r_DlyCrcEn; // Delayed CRC enabled
|
| 317 |
|
|
wire [15:0] r_MaxFL; // Maximum frame length
|
| 318 |
|
|
|
| 319 |
|
|
wire [15:0] r_MinFL; // Minimum frame length
|
| 320 |
42 |
mohor |
wire ShortFrame;
|
| 321 |
|
|
wire DribbleNibble; // Extra nibble received
|
| 322 |
|
|
wire ReceivedPacketTooBig; // Received packet is too big
|
| 323 |
15 |
mohor |
wire [47:0] r_MAC; // MAC address
|
| 324 |
42 |
mohor |
wire LoadRxStatus; // Rx status was loaded
|
| 325 |
52 |
billditt |
wire [31:0] r_HASH0; // HASH table, lower 4 bytes
|
| 326 |
|
|
wire [31:0] r_HASH1; // HASH table, upper 4 bytes
|
| 327 |
34 |
mohor |
wire [7:0] r_TxBDNum; // Receive buffer descriptor number
|
| 328 |
15 |
mohor |
wire [6:0] r_IPGT; //
|
| 329 |
|
|
wire [6:0] r_IPGR1; //
|
| 330 |
|
|
wire [6:0] r_IPGR2; //
|
| 331 |
|
|
wire [5:0] r_CollValid; //
|
| 332 |
149 |
mohor |
wire [15:0] r_TxPauseTV; // Transmit PAUSE value
|
| 333 |
|
|
wire r_TxPauseRq; // Transmit PAUSE request
|
| 334 |
15 |
mohor |
|
| 335 |
|
|
wire [3:0] r_MaxRet; //
|
| 336 |
|
|
wire r_NoBckof; //
|
| 337 |
|
|
wire r_ExDfrEn; //
|
| 338 |
34 |
mohor |
wire TX_BD_NUM_Wr; // Write enable that writes RX_BD_NUM to the registers.
|
| 339 |
15 |
mohor |
wire r_TxFlow; // Tx flow control enable
|
| 340 |
|
|
wire r_IFG; // Minimum interframe gap for incoming packets
|
| 341 |
|
|
|
| 342 |
21 |
mohor |
wire TxB_IRQ; // Interrupt Tx Buffer
|
| 343 |
|
|
wire TxE_IRQ; // Interrupt Tx Error
|
| 344 |
|
|
wire RxB_IRQ; // Interrupt Rx Buffer
|
| 345 |
76 |
mohor |
wire RxE_IRQ; // Interrupt Rx Error
|
| 346 |
21 |
mohor |
wire Busy_IRQ; // Interrupt Busy (lack of buffers)
|
| 347 |
15 |
mohor |
|
| 348 |
|
|
wire DWord;
|
| 349 |
|
|
wire BDAck;
|
| 350 |
103 |
mohor |
wire [31:0] BD_WB_DAT_O; // wb_dat_o that comes from the Wishbone module (for buffer descriptors read/write)
|
| 351 |
21 |
mohor |
wire BDCs; // Buffer descriptor CS
|
| 352 |
202 |
mohor |
wire CsMiss; // When access to the address between 0x800 and 0xfff occurs, acknowledge is set
|
| 353 |
|
|
// but data is not valid.
|
| 354 |
15 |
mohor |
|
| 355 |
103 |
mohor |
wire temp_wb_ack_o;
|
| 356 |
|
|
wire [31:0] temp_wb_dat_o;
|
| 357 |
|
|
wire temp_wb_err_o;
|
| 358 |
15 |
mohor |
|
| 359 |
103 |
mohor |
`ifdef ETH_REGISTERED_OUTPUTS
|
| 360 |
|
|
reg temp_wb_ack_o_reg;
|
| 361 |
|
|
reg [31:0] temp_wb_dat_o_reg;
|
| 362 |
|
|
reg temp_wb_err_o_reg;
|
| 363 |
|
|
`endif
|
| 364 |
|
|
|
| 365 |
17 |
mohor |
assign DWord = &wb_sel_i;
|
| 366 |
103 |
mohor |
assign RegCs = wb_stb_i & wb_cyc_i & DWord & ~wb_adr_i[11] & ~wb_adr_i[10]; // 0x0 - 0x3FF
|
| 367 |
114 |
mohor |
assign BDCs = wb_stb_i & wb_cyc_i & DWord & ~wb_adr_i[11] & wb_adr_i[10]; // 0x400 - 0x7FF
|
| 368 |
202 |
mohor |
assign CsMiss = wb_stb_i & wb_cyc_i & DWord & wb_adr_i[11]; // 0x800 - 0xfFF
|
| 369 |
103 |
mohor |
assign temp_wb_ack_o = RegCs | BDAck;
|
| 370 |
|
|
assign temp_wb_dat_o = (RegCs & ~wb_we_i)? RegDataOut : BD_WB_DAT_O;
|
| 371 |
202 |
mohor |
assign temp_wb_err_o = wb_stb_i & wb_cyc_i & (~DWord | BDCs & r_Rst | CsMiss);
|
| 372 |
15 |
mohor |
|
| 373 |
103 |
mohor |
`ifdef ETH_REGISTERED_OUTPUTS
|
| 374 |
|
|
assign wb_ack_o = temp_wb_ack_o_reg;
|
| 375 |
|
|
assign wb_dat_o[31:0] = temp_wb_dat_o_reg;
|
| 376 |
|
|
assign wb_err_o = temp_wb_err_o_reg;
|
| 377 |
|
|
`else
|
| 378 |
|
|
assign wb_ack_o = temp_wb_ack_o;
|
| 379 |
|
|
assign wb_dat_o[31:0] = temp_wb_dat_o;
|
| 380 |
|
|
assign wb_err_o = temp_wb_err_o;
|
| 381 |
|
|
`endif
|
| 382 |
15 |
mohor |
|
| 383 |
|
|
|
| 384 |
|
|
|
| 385 |
103 |
mohor |
`ifdef ETH_REGISTERED_OUTPUTS
|
| 386 |
|
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
| 387 |
|
|
begin
|
| 388 |
|
|
if(wb_rst_i)
|
| 389 |
|
|
begin
|
| 390 |
|
|
temp_wb_ack_o_reg <=#Tp 1'b0;
|
| 391 |
|
|
temp_wb_dat_o_reg <=#Tp 32'h0;
|
| 392 |
|
|
temp_wb_err_o_reg <=#Tp 1'b0;
|
| 393 |
|
|
end
|
| 394 |
|
|
else
|
| 395 |
|
|
begin
|
| 396 |
106 |
mohor |
temp_wb_ack_o_reg <=#Tp temp_wb_ack_o & ~temp_wb_ack_o_reg;
|
| 397 |
103 |
mohor |
temp_wb_dat_o_reg <=#Tp temp_wb_dat_o;
|
| 398 |
106 |
mohor |
temp_wb_err_o_reg <=#Tp temp_wb_err_o & ~temp_wb_err_o_reg;
|
| 399 |
103 |
mohor |
end
|
| 400 |
|
|
end
|
| 401 |
|
|
`endif
|
| 402 |
|
|
|
| 403 |
|
|
|
| 404 |
15 |
mohor |
// Connecting Ethernet registers
|
| 405 |
|
|
eth_registers ethreg1
|
| 406 |
|
|
(
|
| 407 |
47 |
mohor |
.DataIn(wb_dat_i), .Address(wb_adr_i[9:2]), .Rw(wb_we_i),
|
| 408 |
17 |
mohor |
.Cs(RegCs), .Clk(wb_clk_i), .Reset(wb_rst_i),
|
| 409 |
68 |
mohor |
.DataOut(RegDataOut), .r_RecSmall(r_RecSmall),
|
| 410 |
15 |
mohor |
.r_Pad(r_Pad), .r_HugEn(r_HugEn), .r_CrcEn(r_CrcEn),
|
| 411 |
|
|
.r_DlyCrcEn(r_DlyCrcEn), .r_Rst(r_Rst), .r_FullD(r_FullD),
|
| 412 |
|
|
.r_ExDfrEn(r_ExDfrEn), .r_NoBckof(r_NoBckof), .r_LoopBck(r_LoopBck),
|
| 413 |
52 |
billditt |
.r_IFG(r_IFG), .r_Pro(r_Pro), .r_Iam(),
|
| 414 |
|
|
.r_Bro(r_Bro), .r_NoPre(r_NoPre), .r_TxEn(r_TxEn),
|
| 415 |
76 |
mohor |
.r_RxEn(r_RxEn), .Busy_IRQ(Busy_IRQ), .RxE_IRQ(RxE_IRQ),
|
| 416 |
21 |
mohor |
.RxB_IRQ(RxB_IRQ), .TxE_IRQ(TxE_IRQ), .TxB_IRQ(TxB_IRQ),
|
| 417 |
149 |
mohor |
.r_IPGT(r_IPGT),
|
| 418 |
15 |
mohor |
.r_IPGR1(r_IPGR1), .r_IPGR2(r_IPGR2), .r_MinFL(r_MinFL),
|
| 419 |
|
|
.r_MaxFL(r_MaxFL), .r_MaxRet(r_MaxRet), .r_CollValid(r_CollValid),
|
| 420 |
|
|
.r_TxFlow(r_TxFlow), .r_RxFlow(r_RxFlow), .r_PassAll(r_PassAll),
|
| 421 |
|
|
.r_MiiMRst(r_MiiMRst), .r_MiiNoPre(r_MiiNoPre), .r_ClkDiv(r_ClkDiv),
|
| 422 |
|
|
.r_WCtrlData(r_WCtrlData), .r_RStat(r_RStat), .r_ScanStat(r_ScanStat),
|
| 423 |
|
|
.r_RGAD(r_RGAD), .r_FIAD(r_FIAD), .r_CtrlData(r_CtrlData),
|
| 424 |
|
|
.NValid_stat(NValid_stat), .Busy_stat(Busy_stat),
|
| 425 |
|
|
.LinkFail(LinkFail), .r_MAC(r_MAC), .WCtrlDataStart(WCtrlDataStart),
|
| 426 |
|
|
.RStatStart(RStatStart), .UpdateMIIRX_DATAReg(UpdateMIIRX_DATAReg), .Prsd(Prsd),
|
| 427 |
47 |
mohor |
.r_TxBDNum(r_TxBDNum), .TX_BD_NUM_Wr(TX_BD_NUM_Wr), .int_o(int_o),
|
| 428 |
149 |
mohor |
.r_HASH0(r_HASH0), .r_HASH1(r_HASH1), .r_TxPauseRq(r_TxPauseRq),
|
| 429 |
|
|
.r_TxPauseTV(r_TxPauseTV), .RstTxPauseRq(RstTxPauseRq), .TxCtrlEndFrm(TxCtrlEndFrm),
|
| 430 |
|
|
.StartTxDone(StartTxDone), .TxClk(mtx_clk_pad_i), .RxClk(mrx_clk_pad_i),
|
| 431 |
164 |
mohor |
.ReceivedPauseFrm(ReceivedPauseFrm)
|
| 432 |
149 |
mohor |
|
| 433 |
15 |
mohor |
);
|
| 434 |
|
|
|
| 435 |
|
|
|
| 436 |
|
|
|
| 437 |
|
|
wire [7:0] RxData;
|
| 438 |
|
|
wire RxValid;
|
| 439 |
|
|
wire RxStartFrm;
|
| 440 |
|
|
wire RxEndFrm;
|
| 441 |
41 |
mohor |
wire RxAbort;
|
| 442 |
15 |
mohor |
|
| 443 |
|
|
wire WillTransmit; // Will transmit (to RxEthMAC)
|
| 444 |
|
|
wire ResetCollision; // Reset Collision (for synchronizing collision)
|
| 445 |
|
|
wire [7:0] TxDataOut; // Transmit Packet Data (to TxEthMAC)
|
| 446 |
|
|
wire WillSendControlFrame;
|
| 447 |
|
|
wire ReceiveEnd;
|
| 448 |
|
|
wire ReceivedPacketGood;
|
| 449 |
|
|
wire ReceivedLengthOK;
|
| 450 |
42 |
mohor |
wire InvalidSymbol;
|
| 451 |
|
|
wire LatchedCrcError;
|
| 452 |
|
|
wire RxLateCollision;
|
| 453 |
59 |
mohor |
wire [3:0] RetryCntLatched;
|
| 454 |
|
|
wire [3:0] RetryCnt;
|
| 455 |
|
|
wire StartTxAbort;
|
| 456 |
|
|
wire MaxCollisionOccured;
|
| 457 |
|
|
wire RetryLimit;
|
| 458 |
|
|
wire StatePreamble;
|
| 459 |
|
|
wire [1:0] StateData;
|
| 460 |
15 |
mohor |
|
| 461 |
|
|
// Connecting MACControl
|
| 462 |
|
|
eth_maccontrol maccontrol1
|
| 463 |
|
|
(
|
| 464 |
149 |
mohor |
.MTxClk(mtx_clk_pad_i), .TPauseRq(r_TxPauseRq),
|
| 465 |
|
|
.TxPauseTV(r_TxPauseTV), .TxDataIn(TxData),
|
| 466 |
15 |
mohor |
.TxStartFrmIn(TxStartFrm), .TxEndFrmIn(TxEndFrm),
|
| 467 |
|
|
.TxUsedDataIn(TxUsedDataIn), .TxDoneIn(TxDoneIn),
|
| 468 |
20 |
mohor |
.TxAbortIn(TxAbortIn), .MRxClk(mrx_clk_pad_i),
|
| 469 |
15 |
mohor |
.RxData(RxData), .RxValid(RxValid),
|
| 470 |
|
|
.RxStartFrm(RxStartFrm), .RxEndFrm(RxEndFrm),
|
| 471 |
|
|
.ReceiveEnd(ReceiveEnd), .ReceivedPacketGood(ReceivedPacketGood),
|
| 472 |
|
|
.PassAll(r_PassAll), .TxFlow(r_TxFlow),
|
| 473 |
|
|
.RxFlow(r_RxFlow), .DlyCrcEn(r_DlyCrcEn),
|
| 474 |
|
|
.MAC(r_MAC), .PadIn(r_Pad | PerPacketPad),
|
| 475 |
|
|
.PadOut(PadOut), .CrcEnIn(r_CrcEn | PerPacketCrcEn),
|
| 476 |
|
|
.CrcEnOut(CrcEnOut), .TxReset(r_Rst),
|
| 477 |
|
|
.RxReset(r_Rst), .ReceivedLengthOK(ReceivedLengthOK),
|
| 478 |
|
|
.TxDataOut(TxDataOut), .TxStartFrmOut(TxStartFrmOut),
|
| 479 |
|
|
.TxEndFrmOut(TxEndFrmOut), .TxUsedDataOut(TxUsedData),
|
| 480 |
|
|
.TxDoneOut(TxDone), .TxAbortOut(TxAbort),
|
| 481 |
|
|
.WillSendControlFrame(WillSendControlFrame), .TxCtrlEndFrm(TxCtrlEndFrm),
|
| 482 |
|
|
.ReceivedPauseFrm(ReceivedPauseFrm)
|
| 483 |
|
|
);
|
| 484 |
|
|
|
| 485 |
|
|
|
| 486 |
|
|
|
| 487 |
|
|
wire TxCarrierSense; // Synchronized CarrierSense (to Tx clock)
|
| 488 |
|
|
wire Collision; // Synchronized Collision
|
| 489 |
|
|
|
| 490 |
|
|
reg CarrierSense_Tx1;
|
| 491 |
|
|
reg CarrierSense_Tx2;
|
| 492 |
|
|
reg Collision_Tx1;
|
| 493 |
|
|
reg Collision_Tx2;
|
| 494 |
|
|
|
| 495 |
|
|
reg RxEnSync; // Synchronized Receive Enable
|
| 496 |
|
|
reg CarrierSense_Rx1;
|
| 497 |
|
|
reg RxCarrierSense; // Synchronized CarrierSense (to Rx clock)
|
| 498 |
|
|
reg WillTransmit_q;
|
| 499 |
|
|
reg WillTransmit_q2;
|
| 500 |
|
|
|
| 501 |
|
|
|
| 502 |
|
|
|
| 503 |
|
|
// Muxed MII receive data valid
|
| 504 |
17 |
mohor |
assign MRxDV_Lb = r_LoopBck? mtxen_pad_o : mrxdv_pad_i & RxEnSync;
|
| 505 |
15 |
mohor |
|
| 506 |
|
|
// Muxed MII Receive Error
|
| 507 |
17 |
mohor |
assign MRxErr_Lb = r_LoopBck? mtxerr_pad_o : mrxerr_pad_i & RxEnSync;
|
| 508 |
15 |
mohor |
|
| 509 |
|
|
// Muxed MII Receive Data
|
| 510 |
17 |
mohor |
assign MRxD_Lb[3:0] = r_LoopBck? mtxd_pad_o[3:0] : mrxd_pad_i[3:0];
|
| 511 |
15 |
mohor |
|
| 512 |
|
|
|
| 513 |
|
|
|
| 514 |
|
|
// Connecting TxEthMAC
|
| 515 |
|
|
eth_txethmac txethmac1
|
| 516 |
|
|
(
|
| 517 |
21 |
mohor |
.MTxClk(mtx_clk_pad_i), .Reset(r_Rst), .CarrierSense(TxCarrierSense),
|
| 518 |
15 |
mohor |
.Collision(Collision), .TxData(TxDataOut), .TxStartFrm(TxStartFrmOut),
|
| 519 |
|
|
.TxUnderRun(TxUnderRun), .TxEndFrm(TxEndFrmOut), .Pad(PadOut),
|
| 520 |
|
|
.MinFL(r_MinFL), .CrcEn(CrcEnOut), .FullD(r_FullD),
|
| 521 |
|
|
.HugEn(r_HugEn), .DlyCrcEn(r_DlyCrcEn), .IPGT(r_IPGT),
|
| 522 |
|
|
.IPGR1(r_IPGR1), .IPGR2(r_IPGR2), .CollValid(r_CollValid),
|
| 523 |
|
|
.MaxRet(r_MaxRet), .NoBckof(r_NoBckof), .ExDfrEn(r_ExDfrEn),
|
| 524 |
17 |
mohor |
.MaxFL(r_MaxFL), .MTxEn(mtxen_pad_o), .MTxD(mtxd_pad_o),
|
| 525 |
|
|
.MTxErr(mtxerr_pad_o), .TxUsedData(TxUsedDataIn), .TxDone(TxDoneIn),
|
| 526 |
15 |
mohor |
.TxRetry(TxRetry), .TxAbort(TxAbortIn), .WillTransmit(WillTransmit),
|
| 527 |
59 |
mohor |
.ResetCollision(ResetCollision), .RetryCnt(RetryCnt), .StartTxDone(StartTxDone),
|
| 528 |
|
|
.StartTxAbort(StartTxAbort), .MaxCollisionOccured(MaxCollisionOccured), .LateCollision(LateCollision),
|
| 529 |
|
|
.StartDefer(StartDefer), .StatePreamble(StatePreamble), .StateData(StateData)
|
| 530 |
15 |
mohor |
);
|
| 531 |
|
|
|
| 532 |
|
|
|
| 533 |
|
|
|
| 534 |
|
|
|
| 535 |
|
|
wire [15:0] RxByteCnt;
|
| 536 |
|
|
wire RxByteCntEq0;
|
| 537 |
|
|
wire RxByteCntGreat2;
|
| 538 |
|
|
wire RxByteCntMaxFrame;
|
| 539 |
|
|
wire RxCrcError;
|
| 540 |
|
|
wire RxStateIdle;
|
| 541 |
|
|
wire RxStatePreamble;
|
| 542 |
|
|
wire RxStateSFD;
|
| 543 |
|
|
wire [1:0] RxStateData;
|
| 544 |
|
|
|
| 545 |
|
|
|
| 546 |
|
|
|
| 547 |
|
|
|
| 548 |
|
|
// Connecting RxEthMAC
|
| 549 |
|
|
eth_rxethmac rxethmac1
|
| 550 |
|
|
(
|
| 551 |
21 |
mohor |
.MRxClk(mrx_clk_pad_i), .MRxDV(MRxDV_Lb), .MRxD(MRxD_Lb),
|
| 552 |
15 |
mohor |
.Transmitting(Transmitting), .HugEn(r_HugEn), .DlyCrcEn(r_DlyCrcEn),
|
| 553 |
|
|
.MaxFL(r_MaxFL), .r_IFG(r_IFG), .Reset(r_Rst),
|
| 554 |
|
|
.RxData(RxData), .RxValid(RxValid), .RxStartFrm(RxStartFrm),
|
| 555 |
65 |
mohor |
.RxEndFrm(RxEndFrm), .ByteCnt(RxByteCnt),
|
| 556 |
15 |
mohor |
.ByteCntEq0(RxByteCntEq0), .ByteCntGreat2(RxByteCntGreat2), .ByteCntMaxFrame(RxByteCntMaxFrame),
|
| 557 |
|
|
.CrcError(RxCrcError), .StateIdle(RxStateIdle), .StatePreamble(RxStatePreamble),
|
| 558 |
52 |
billditt |
.StateSFD(RxStateSFD), .StateData(RxStateData),
|
| 559 |
63 |
mohor |
.MAC(r_MAC), .r_Pro(r_Pro), .r_Bro(r_Bro),
|
| 560 |
|
|
.r_HASH0(r_HASH0), .r_HASH1(r_HASH1), .RxAbort(RxAbort)
|
| 561 |
15 |
mohor |
);
|
| 562 |
|
|
|
| 563 |
|
|
|
| 564 |
|
|
// MII Carrier Sense Synchronization
|
| 565 |
20 |
mohor |
always @ (posedge mtx_clk_pad_i or posedge r_Rst)
|
| 566 |
15 |
mohor |
begin
|
| 567 |
|
|
if(r_Rst)
|
| 568 |
|
|
begin
|
| 569 |
|
|
CarrierSense_Tx1 <= #Tp 1'b0;
|
| 570 |
|
|
CarrierSense_Tx2 <= #Tp 1'b0;
|
| 571 |
|
|
end
|
| 572 |
|
|
else
|
| 573 |
|
|
begin
|
| 574 |
17 |
mohor |
CarrierSense_Tx1 <= #Tp mcrs_pad_i;
|
| 575 |
15 |
mohor |
CarrierSense_Tx2 <= #Tp CarrierSense_Tx1;
|
| 576 |
|
|
end
|
| 577 |
|
|
end
|
| 578 |
|
|
|
| 579 |
|
|
assign TxCarrierSense = ~r_FullD & CarrierSense_Tx2;
|
| 580 |
|
|
|
| 581 |
|
|
|
| 582 |
|
|
// MII Collision Synchronization
|
| 583 |
20 |
mohor |
always @ (posedge mtx_clk_pad_i or posedge r_Rst)
|
| 584 |
15 |
mohor |
begin
|
| 585 |
|
|
if(r_Rst)
|
| 586 |
|
|
begin
|
| 587 |
|
|
Collision_Tx1 <= #Tp 1'b0;
|
| 588 |
|
|
Collision_Tx2 <= #Tp 1'b0;
|
| 589 |
|
|
end
|
| 590 |
|
|
else
|
| 591 |
|
|
begin
|
| 592 |
17 |
mohor |
Collision_Tx1 <= #Tp mcoll_pad_i;
|
| 593 |
15 |
mohor |
if(ResetCollision)
|
| 594 |
|
|
Collision_Tx2 <= #Tp 1'b0;
|
| 595 |
|
|
else
|
| 596 |
|
|
if(Collision_Tx1)
|
| 597 |
|
|
Collision_Tx2 <= #Tp 1'b1;
|
| 598 |
|
|
end
|
| 599 |
|
|
end
|
| 600 |
|
|
|
| 601 |
|
|
|
| 602 |
|
|
// Synchronized Collision
|
| 603 |
|
|
assign Collision = ~r_FullD & Collision_Tx2;
|
| 604 |
|
|
|
| 605 |
|
|
|
| 606 |
|
|
|
| 607 |
|
|
// Carrier sense is synchronized to receive clock.
|
| 608 |
20 |
mohor |
always @ (posedge mrx_clk_pad_i or posedge r_Rst)
|
| 609 |
15 |
mohor |
begin
|
| 610 |
|
|
if(r_Rst)
|
| 611 |
|
|
begin
|
| 612 |
|
|
CarrierSense_Rx1 <= #Tp 1'h0;
|
| 613 |
|
|
RxCarrierSense <= #Tp 1'h0;
|
| 614 |
|
|
end
|
| 615 |
|
|
else
|
| 616 |
|
|
begin
|
| 617 |
17 |
mohor |
CarrierSense_Rx1 <= #Tp mcrs_pad_i;
|
| 618 |
15 |
mohor |
RxCarrierSense <= #Tp CarrierSense_Rx1;
|
| 619 |
|
|
end
|
| 620 |
|
|
end
|
| 621 |
|
|
|
| 622 |
|
|
|
| 623 |
|
|
// Delayed WillTransmit
|
| 624 |
20 |
mohor |
always @ (posedge mrx_clk_pad_i)
|
| 625 |
15 |
mohor |
begin
|
| 626 |
|
|
WillTransmit_q <= #Tp WillTransmit;
|
| 627 |
|
|
WillTransmit_q2 <= #Tp WillTransmit_q;
|
| 628 |
|
|
end
|
| 629 |
|
|
|
| 630 |
|
|
|
| 631 |
|
|
assign Transmitting = ~r_FullD & WillTransmit_q2;
|
| 632 |
|
|
|
| 633 |
|
|
|
| 634 |
|
|
|
| 635 |
|
|
// Synchronized Receive Enable
|
| 636 |
20 |
mohor |
always @ (posedge mrx_clk_pad_i or posedge r_Rst)
|
| 637 |
15 |
mohor |
begin
|
| 638 |
|
|
if(r_Rst)
|
| 639 |
|
|
RxEnSync <= #Tp 1'b0;
|
| 640 |
|
|
else
|
| 641 |
|
|
if(~RxCarrierSense | RxCarrierSense & Transmitting)
|
| 642 |
|
|
RxEnSync <= #Tp r_RxEn;
|
| 643 |
|
|
end
|
| 644 |
|
|
|
| 645 |
|
|
|
| 646 |
|
|
|
| 647 |
149 |
mohor |
// Synchronizing WillSendControlFrame to WB_CLK;
|
| 648 |
|
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
| 649 |
|
|
begin
|
| 650 |
|
|
if(wb_rst_i)
|
| 651 |
|
|
WillSendControlFrame_sync1 <= 1'b0;
|
| 652 |
|
|
else
|
| 653 |
|
|
WillSendControlFrame_sync1 <=#Tp WillSendControlFrame;
|
| 654 |
|
|
end
|
| 655 |
15 |
mohor |
|
| 656 |
149 |
mohor |
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
| 657 |
|
|
begin
|
| 658 |
|
|
if(wb_rst_i)
|
| 659 |
|
|
WillSendControlFrame_sync2 <= 1'b0;
|
| 660 |
|
|
else
|
| 661 |
|
|
WillSendControlFrame_sync2 <=#Tp WillSendControlFrame_sync1;
|
| 662 |
|
|
end
|
| 663 |
|
|
|
| 664 |
|
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
| 665 |
|
|
begin
|
| 666 |
|
|
if(wb_rst_i)
|
| 667 |
|
|
WillSendControlFrame_sync3 <= 1'b0;
|
| 668 |
|
|
else
|
| 669 |
|
|
WillSendControlFrame_sync3 <=#Tp WillSendControlFrame_sync2;
|
| 670 |
|
|
end
|
| 671 |
|
|
|
| 672 |
|
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
| 673 |
|
|
begin
|
| 674 |
|
|
if(wb_rst_i)
|
| 675 |
|
|
RstTxPauseRq <= 1'b0;
|
| 676 |
|
|
else
|
| 677 |
|
|
RstTxPauseRq <=#Tp WillSendControlFrame_sync2 & ~WillSendControlFrame_sync3;
|
| 678 |
|
|
end
|
| 679 |
|
|
|
| 680 |
|
|
|
| 681 |
114 |
mohor |
// Connecting Wishbone module
|
| 682 |
41 |
mohor |
eth_wishbone wishbone
|
| 683 |
15 |
mohor |
(
|
| 684 |
41 |
mohor |
.WB_CLK_I(wb_clk_i), .WB_DAT_I(wb_dat_i),
|
| 685 |
103 |
mohor |
.WB_DAT_O(BD_WB_DAT_O),
|
| 686 |
15 |
mohor |
|
| 687 |
|
|
// WISHBONE slave
|
| 688 |
76 |
mohor |
.WB_ADR_I(wb_adr_i[9:2]), .WB_WE_I(wb_we_i),
|
| 689 |
21 |
mohor |
.BDCs(BDCs), .WB_ACK_O(BDAck),
|
| 690 |
15 |
mohor |
|
| 691 |
106 |
mohor |
.Reset(r_Rst),
|
| 692 |
41 |
mohor |
|
| 693 |
|
|
// WISHBONE master
|
| 694 |
|
|
.m_wb_adr_o(m_wb_adr_o), .m_wb_sel_o(m_wb_sel_o), .m_wb_we_o(m_wb_we_o),
|
| 695 |
|
|
.m_wb_dat_i(m_wb_dat_i), .m_wb_dat_o(m_wb_dat_o), .m_wb_cyc_o(m_wb_cyc_o),
|
| 696 |
|
|
.m_wb_stb_o(m_wb_stb_o), .m_wb_ack_i(m_wb_ack_i), .m_wb_err_i(m_wb_err_i),
|
| 697 |
|
|
|
| 698 |
15 |
mohor |
//TX
|
| 699 |
21 |
mohor |
.MTxClk(mtx_clk_pad_i), .TxStartFrm(TxStartFrm), .TxEndFrm(TxEndFrm),
|
| 700 |
59 |
mohor |
.TxUsedData(TxUsedData), .TxData(TxData),
|
| 701 |
15 |
mohor |
.TxRetry(TxRetry), .TxAbort(TxAbort), .TxUnderRun(TxUnderRun),
|
| 702 |
149 |
mohor |
.TxDone(TxDone),
|
| 703 |
|
|
.PerPacketCrcEn(PerPacketCrcEn), .PerPacketPad(PerPacketPad),
|
| 704 |
15 |
mohor |
|
| 705 |
|
|
// Register
|
| 706 |
34 |
mohor |
.r_TxEn(r_TxEn), .r_RxEn(r_RxEn), .r_TxBDNum(r_TxBDNum),
|
| 707 |
149 |
mohor |
.TX_BD_NUM_Wr(TX_BD_NUM_Wr),
|
| 708 |
15 |
mohor |
|
| 709 |
|
|
//RX
|
| 710 |
21 |
mohor |
.MRxClk(mrx_clk_pad_i), .RxData(RxData), .RxValid(RxValid),
|
| 711 |
41 |
mohor |
.RxStartFrm(RxStartFrm), .RxEndFrm(RxEndFrm),
|
| 712 |
76 |
mohor |
.Busy_IRQ(Busy_IRQ), .RxE_IRQ(RxE_IRQ), .RxB_IRQ(RxB_IRQ),
|
| 713 |
149 |
mohor |
.TxE_IRQ(TxE_IRQ), .TxB_IRQ(TxB_IRQ),
|
| 714 |
21 |
mohor |
|
| 715 |
149 |
mohor |
.RxAbort(RxAbort | (ShortFrame & ~r_RecSmall) | LatchedMRxErr & ~InvalidSymbol | ReceivedPauseFrm & ~r_PassAll),
|
| 716 |
41 |
mohor |
|
| 717 |
42 |
mohor |
.InvalidSymbol(InvalidSymbol), .LatchedCrcError(LatchedCrcError), .RxLength(RxByteCnt),
|
| 718 |
|
|
.RxLateCollision(RxLateCollision), .ShortFrame(ShortFrame), .DribbleNibble(DribbleNibble),
|
| 719 |
59 |
mohor |
.ReceivedPacketTooBig(ReceivedPacketTooBig), .LoadRxStatus(LoadRxStatus), .RetryCntLatched(RetryCntLatched),
|
| 720 |
|
|
.RetryLimit(RetryLimit), .LateCollLatched(LateCollLatched), .DeferLatched(DeferLatched),
|
| 721 |
164 |
mohor |
.CarrierSenseLost(CarrierSenseLost),.ReceivedPacketGood(ReceivedPacketGood)
|
| 722 |
59 |
mohor |
|
| 723 |
15 |
mohor |
);
|
| 724 |
|
|
|
| 725 |
|
|
|
| 726 |
|
|
|
| 727 |
|
|
// Connecting MacStatus module
|
| 728 |
|
|
eth_macstatus macstatus1
|
| 729 |
|
|
(
|
| 730 |
42 |
mohor |
.MRxClk(mrx_clk_pad_i), .Reset(r_Rst),
|
| 731 |
|
|
.ReceiveEnd(ReceiveEnd), .ReceivedPacketGood(ReceivedPacketGood), .ReceivedLengthOK(ReceivedLengthOK),
|
| 732 |
|
|
.RxCrcError(RxCrcError), .MRxErr(MRxErr_Lb), .MRxDV(MRxDV_Lb),
|
| 733 |
|
|
.RxStateSFD(RxStateSFD), .RxStateData(RxStateData), .RxStatePreamble(RxStatePreamble),
|
| 734 |
|
|
.RxStateIdle(RxStateIdle), .Transmitting(Transmitting), .RxByteCnt(RxByteCnt),
|
| 735 |
|
|
.RxByteCntEq0(RxByteCntEq0), .RxByteCntGreat2(RxByteCntGreat2), .RxByteCntMaxFrame(RxByteCntMaxFrame),
|
| 736 |
|
|
.ReceivedPauseFrm(ReceivedPauseFrm),.InvalidSymbol(InvalidSymbol),
|
| 737 |
|
|
.MRxD(MRxD_Lb), .LatchedCrcError(LatchedCrcError), .Collision(mcoll_pad_i),
|
| 738 |
|
|
.CollValid(r_CollValid), .RxLateCollision(RxLateCollision), .r_RecSmall(r_RecSmall),
|
| 739 |
|
|
.r_MinFL(r_MinFL), .r_MaxFL(r_MaxFL), .ShortFrame(ShortFrame),
|
| 740 |
|
|
.DribbleNibble(DribbleNibble), .ReceivedPacketTooBig(ReceivedPacketTooBig), .r_HugEn(r_HugEn),
|
| 741 |
59 |
mohor |
.LoadRxStatus(LoadRxStatus), .RetryCnt(RetryCnt), .StartTxDone(StartTxDone),
|
| 742 |
|
|
.StartTxAbort(StartTxAbort), .RetryCntLatched(RetryCntLatched), .MTxClk(mtx_clk_pad_i),
|
| 743 |
|
|
.MaxCollisionOccured(MaxCollisionOccured), .RetryLimit(RetryLimit), .LateCollision(LateCollision),
|
| 744 |
|
|
.LateCollLatched(LateCollLatched), .StartDefer(StartDefer), .DeferLatched(DeferLatched),
|
| 745 |
|
|
.TxStartFrm(TxStartFrmOut), .StatePreamble(StatePreamble), .StateData(StateData),
|
| 746 |
125 |
mohor |
.CarrierSense(CarrierSense_Tx2), .CarrierSenseLost(CarrierSenseLost), .TxUsedData(TxUsedDataIn),
|
| 747 |
168 |
mohor |
.LatchedMRxErr(LatchedMRxErr), .Loopback(r_LoopBck), .r_FullD(r_FullD)
|
| 748 |
15 |
mohor |
);
|
| 749 |
|
|
|
| 750 |
|
|
|
| 751 |
|
|
endmodule
|