]> git.zerfleddert.de Git - raggedstone/blame - ethernet/source/ethernet/eth_txstatem.v
white space; fixme
[raggedstone] / ethernet / source / ethernet / eth_txstatem.v
CommitLineData
40a1f26c 1//////////////////////////////////////////////////////////////////////
2//// ////
3//// eth_txstatem.v ////
4//// ////
5//// This file is part of the Ethernet IP core project ////
6//// http://www.opencores.org/projects/ethmac/ ////
7//// ////
8//// Author(s): ////
9//// - Igor Mohor (igorM@opencores.org) ////
10//// - Novan Hartadi (novan@vlsi.itb.ac.id) ////
11//// - Mahmud Galela (mgalela@vlsi.itb.ac.id) ////
12//// ////
13//// All additional information is avaliable in the Readme.txt ////
14//// file. ////
15//// ////
16//////////////////////////////////////////////////////////////////////
17//// ////
18//// Copyright (C) 2001 Authors ////
19//// ////
20//// This source file may be used and distributed without ////
21//// restriction provided that this copyright statement is not ////
22//// removed from the file and that any derivative work contains ////
23//// the original copyright notice and the associated disclaimer. ////
24//// ////
25//// This source file is free software; you can redistribute it ////
26//// and/or modify it under the terms of the GNU Lesser General ////
27//// Public License as published by the Free Software Foundation; ////
28//// either version 2.1 of the License, or (at your option) any ////
29//// later version. ////
30//// ////
31//// This source is distributed in the hope that it will be ////
32//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
33//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
34//// PURPOSE. See the GNU Lesser General Public License for more ////
35//// details. ////
36//// ////
37//// You should have received a copy of the GNU Lesser General ////
38//// Public License along with this source; if not, download it ////
39//// from http://www.opencores.org/lgpl.shtml ////
40//// ////
41//////////////////////////////////////////////////////////////////////
42//
43// CVS Revision History
44//
45// $Log: eth_txstatem.v,v $
46// Revision 1.1 2007-03-20 17:50:56 sithglan
47// add shit
48//
49// Revision 1.6 2003/01/30 13:29:08 tadejm
50// Defer indication changed.
51//
52// Revision 1.5 2002/10/30 12:54:50 mohor
53// State machine goes from idle to the defer state when CarrierSense is 1. FCS (CRC appending) fixed to check the CrcEn bit also when padding is necessery.
54//
55// Revision 1.4 2002/01/23 10:28:16 mohor
56// Link in the header changed.
57//
58// Revision 1.3 2001/10/19 08:43:51 mohor
59// eth_timescale.v changed to timescale.v This is done because of the
60// simulation of the few cores in a one joined project.
61//
62// Revision 1.2 2001/09/11 14:17:00 mohor
63// Few little NCSIM warnings fixed.
64//
65// Revision 1.1 2001/08/06 14:44:29 mohor
66// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
67// Include files fixed to contain no path.
68// File names and module names changed ta have a eth_ prologue in the name.
69// File eth_timescale.v is used to define timescale
70// All pin names on the top module are changed to contain _I, _O or _OE at the end.
71// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
72// and Mdo_OE. The bidirectional signal must be created on the top level. This
73// is done due to the ASIC tools.
74//
75// Revision 1.1 2001/07/30 21:23:42 mohor
76// Directory structure changed. Files checked and joind together.
77//
78// Revision 1.3 2001/06/19 18:16:40 mohor
79// TxClk changed to MTxClk (as discribed in the documentation).
80// Crc changed so only one file can be used instead of two.
81//
82// Revision 1.2 2001/06/19 10:38:07 mohor
83// Minor changes in header.
84//
85// Revision 1.1 2001/06/19 10:27:57 mohor
86// TxEthMAC initial release.
87//
88//
89//
90//
91
92
93`include "timescale.v"
94
95
96module eth_txstatem (MTxClk, Reset, ExcessiveDefer, CarrierSense, NibCnt, IPGT, IPGR1,
97 IPGR2, FullD, TxStartFrm, TxEndFrm, TxUnderRun, Collision, UnderRun,
98 StartTxDone, TooBig, NibCntEq7, NibCntEq15, MaxFrame, Pad, CrcEn,
99 NibbleMinFl, RandomEq0, ColWindow, RetryMax, NoBckof, RandomEqByteCnt,
100 StateIdle, StateIPG, StatePreamble, StateData, StatePAD, StateFCS,
101 StateJam, StateJam_q, StateBackOff, StateDefer, StartFCS, StartJam,
102 StartBackoff, StartDefer, DeferIndication, StartPreamble, StartData, StartIPG
103 );
104
105parameter Tp = 1;
106
107input MTxClk;
108input Reset;
109input ExcessiveDefer;
110input CarrierSense;
111input [6:0] NibCnt;
112input [6:0] IPGT;
113input [6:0] IPGR1;
114input [6:0] IPGR2;
115input FullD;
116input TxStartFrm;
117input TxEndFrm;
118input TxUnderRun;
119input Collision;
120input UnderRun;
121input StartTxDone;
122input TooBig;
123input NibCntEq7;
124input NibCntEq15;
125input MaxFrame;
126input Pad;
127input CrcEn;
128input NibbleMinFl;
129input RandomEq0;
130input ColWindow;
131input RetryMax;
132input NoBckof;
133input RandomEqByteCnt;
134
135
136output StateIdle; // Idle state
137output StateIPG; // IPG state
138output StatePreamble; // Preamble state
139output [1:0] StateData; // Data state
140output StatePAD; // PAD state
141output StateFCS; // FCS state
142output StateJam; // Jam state
143output StateJam_q; // Delayed Jam state
144output StateBackOff; // Backoff state
145output StateDefer; // Defer state
146
147output StartFCS; // FCS state will be activated in next clock
148output StartJam; // Jam state will be activated in next clock
149output StartBackoff; // Backoff state will be activated in next clock
150output StartDefer; // Defer state will be activated in next clock
151output DeferIndication;
152output StartPreamble; // Preamble state will be activated in next clock
153output [1:0] StartData; // Data state will be activated in next clock
154output StartIPG; // IPG state will be activated in next clock
155
156wire StartIdle; // Idle state will be activated in next clock
157wire StartPAD; // PAD state will be activated in next clock
158
159
160reg StateIdle;
161reg StateIPG;
162reg StatePreamble;
163reg [1:0] StateData;
164reg StatePAD;
165reg StateFCS;
166reg StateJam;
167reg StateJam_q;
168reg StateBackOff;
169reg StateDefer;
170reg Rule1;
171
172
173// Defining the next state
174assign StartIPG = StateDefer & ~ExcessiveDefer & ~CarrierSense;
175
176assign StartIdle = StateIPG & (Rule1 & NibCnt[6:0] >= IPGT | ~Rule1 & NibCnt[6:0] >= IPGR2);
177
178assign StartPreamble = StateIdle & TxStartFrm & ~CarrierSense;
179
180assign StartData[0] = ~Collision & (StatePreamble & NibCntEq15 | StateData[1] & ~TxEndFrm);
181
182assign StartData[1] = ~Collision & StateData[0] & ~TxUnderRun & ~MaxFrame;
183
184assign StartPAD = ~Collision & StateData[1] & TxEndFrm & Pad & ~NibbleMinFl;
185
186assign StartFCS = ~Collision & StateData[1] & TxEndFrm & (~Pad | Pad & NibbleMinFl) & CrcEn
187 | ~Collision & StatePAD & NibbleMinFl & CrcEn;
188
189assign StartJam = (Collision | UnderRun) & ((StatePreamble & NibCntEq15) | (|StateData[1:0]) | StatePAD | StateFCS);
190
191assign StartBackoff = StateJam & ~RandomEq0 & ColWindow & ~RetryMax & NibCntEq7 & ~NoBckof;
192
193assign StartDefer = StateIPG & ~Rule1 & CarrierSense & NibCnt[6:0] <= IPGR1 & NibCnt[6:0] != IPGR2
194 | StateIdle & CarrierSense
195 | StateJam & NibCntEq7 & (NoBckof | RandomEq0 | ~ColWindow | RetryMax)
196 | StateBackOff & (TxUnderRun | RandomEqByteCnt)
197 | StartTxDone | TooBig;
198
199assign DeferIndication = StateIdle & CarrierSense;
200
201// Tx State Machine
202always @ (posedge MTxClk or posedge Reset)
203begin
204 if(Reset)
205 begin
206 StateIPG <= #Tp 1'b0;
207 StateIdle <= #Tp 1'b0;
208 StatePreamble <= #Tp 1'b0;
209 StateData[1:0] <= #Tp 2'b0;
210 StatePAD <= #Tp 1'b0;
211 StateFCS <= #Tp 1'b0;
212 StateJam <= #Tp 1'b0;
213 StateJam_q <= #Tp 1'b0;
214 StateBackOff <= #Tp 1'b0;
215 StateDefer <= #Tp 1'b1;
216 end
217 else
218 begin
219 StateData[1:0] <= #Tp StartData[1:0];
220 StateJam_q <= #Tp StateJam;
221
222 if(StartDefer | StartIdle)
223 StateIPG <= #Tp 1'b0;
224 else
225 if(StartIPG)
226 StateIPG <= #Tp 1'b1;
227
228 if(StartDefer | StartPreamble)
229 StateIdle <= #Tp 1'b0;
230 else
231 if(StartIdle)
232 StateIdle <= #Tp 1'b1;
233
234 if(StartData[0] | StartJam)
235 StatePreamble <= #Tp 1'b0;
236 else
237 if(StartPreamble)
238 StatePreamble <= #Tp 1'b1;
239
240 if(StartFCS | StartJam)
241 StatePAD <= #Tp 1'b0;
242 else
243 if(StartPAD)
244 StatePAD <= #Tp 1'b1;
245
246 if(StartJam | StartDefer)
247 StateFCS <= #Tp 1'b0;
248 else
249 if(StartFCS)
250 StateFCS <= #Tp 1'b1;
251
252 if(StartBackoff | StartDefer)
253 StateJam <= #Tp 1'b0;
254 else
255 if(StartJam)
256 StateJam <= #Tp 1'b1;
257
258 if(StartDefer)
259 StateBackOff <= #Tp 1'b0;
260 else
261 if(StartBackoff)
262 StateBackOff <= #Tp 1'b1;
263
264 if(StartIPG)
265 StateDefer <= #Tp 1'b0;
266 else
267 if(StartDefer)
268 StateDefer <= #Tp 1'b1;
269 end
270end
271
272
273// This sections defines which interpack gap rule to use
274always @ (posedge MTxClk or posedge Reset)
275begin
276 if(Reset)
277 Rule1 <= #Tp 1'b0;
278 else
279 begin
280 if(StateIdle | StateBackOff)
281 Rule1 <= #Tp 1'b0;
282 else
283 if(StatePreamble | FullD)
284 Rule1 <= #Tp 1'b1;
285 end
286end
287
288
289
290endmodule
Impressum, Datenschutz