OpenCores
URL https://opencores.org/ocsvn/ts7300_opencore/ts7300_opencore/trunk

Subversion Repositories ts7300_opencore

[/] [ts7300_opencore/] [trunk/] [ethernet/] [eth_txstatem.v] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 joff
//////////////////////////////////////////////////////////////////////
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: not supported by cvs2svn $
46
// Revision 1.6  2003/01/30 13:29:08  tadejm
47
// Defer indication changed.
48
//
49
// Revision 1.5  2002/10/30 12:54:50  mohor
50
// 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.
51
//
52
// Revision 1.4  2002/01/23 10:28:16  mohor
53
// Link in the header changed.
54
//
55
// Revision 1.3  2001/10/19 08:43:51  mohor
56
// eth_timescale.v changed to timescale.v This is done because of the
57
// simulation of the few cores in a one joined project.
58
//
59
// Revision 1.2  2001/09/11 14:17:00  mohor
60
// Few little NCSIM warnings fixed.
61
//
62
// Revision 1.1  2001/08/06 14:44:29  mohor
63
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
64
// Include files fixed to contain no path.
65
// File names and module names changed ta have a eth_ prologue in the name.
66
// File eth_timescale.v is used to define timescale
67
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
68
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
69
// and Mdo_OE. The bidirectional signal must be created on the top level. This
70
// is done due to the ASIC tools.
71
//
72
// Revision 1.1  2001/07/30 21:23:42  mohor
73
// Directory structure changed. Files checked and joind together.
74
//
75
// Revision 1.3  2001/06/19 18:16:40  mohor
76
// TxClk changed to MTxClk (as discribed in the documentation).
77
// Crc changed so only one file can be used instead of two.
78
//
79
// Revision 1.2  2001/06/19 10:38:07  mohor
80
// Minor changes in header.
81
//
82
// Revision 1.1  2001/06/19 10:27:57  mohor
83
// TxEthMAC initial release.
84
//
85
//
86
//
87
//
88
 
89
 
90
`include "timescale.v"
91
 
92
 
93
module eth_txstatem  (MTxClk, Reset, ExcessiveDefer, CarrierSense, NibCnt, IPGT, IPGR1,
94
                      IPGR2, FullD, TxStartFrm, TxEndFrm, TxUnderRun, Collision, UnderRun,
95
                      StartTxDone, TooBig, NibCntEq7, NibCntEq15, MaxFrame, Pad, CrcEn,
96
                      NibbleMinFl, RandomEq0, ColWindow, RetryMax, NoBckof, RandomEqByteCnt,
97
                      StateIdle, StateIPG, StatePreamble, StateData, StatePAD, StateFCS,
98
                      StateJam, StateJam_q, StateBackOff, StateDefer, StartFCS, StartJam,
99
                      StartBackoff, StartDefer, DeferIndication, StartPreamble, StartData, StartIPG
100
                     );
101
 
102
parameter Tp = 1;
103
 
104
input MTxClk;
105
input Reset;
106
input ExcessiveDefer;
107
input CarrierSense;
108
input [6:0] NibCnt;
109
input [6:0] IPGT;
110
input [6:0] IPGR1;
111
input [6:0] IPGR2;
112
input FullD;
113
input TxStartFrm;
114
input TxEndFrm;
115
input TxUnderRun;
116
input Collision;
117
input UnderRun;
118
input StartTxDone;
119
input TooBig;
120
input NibCntEq7;
121
input NibCntEq15;
122
input MaxFrame;
123
input Pad;
124
input CrcEn;
125
input NibbleMinFl;
126
input RandomEq0;
127
input ColWindow;
128
input RetryMax;
129
input NoBckof;
130
input RandomEqByteCnt;
131
 
132
 
133
output StateIdle;         // Idle state
134
output StateIPG;          // IPG state
135
output StatePreamble;     // Preamble state
136
output [1:0] StateData;   // Data state
137
output StatePAD;          // PAD state
138
output StateFCS;          // FCS state
139
output StateJam;          // Jam state
140
output StateJam_q;        // Delayed Jam state
141
output StateBackOff;      // Backoff state
142
output StateDefer;        // Defer state
143
 
144
output StartFCS;          // FCS state will be activated in next clock
145
output StartJam;          // Jam state will be activated in next clock
146
output StartBackoff;      // Backoff state will be activated in next clock
147
output StartDefer;        // Defer state will be activated in next clock
148
output DeferIndication;
149
output StartPreamble;     // Preamble state will be activated in next clock
150
output [1:0] StartData;   // Data state will be activated in next clock
151
output StartIPG;          // IPG state will be activated in next clock
152
 
153
wire StartIdle;           // Idle state will be activated in next clock
154
wire StartPAD;            // PAD state will be activated in next clock
155
 
156
 
157
reg StateIdle;
158
reg StateIPG;
159
reg StatePreamble;
160
reg [1:0] StateData;
161
reg StatePAD;
162
reg StateFCS;
163
reg StateJam;
164
reg StateJam_q;
165
reg StateBackOff;
166
reg StateDefer;
167
reg Rule1;
168
 
169
 
170
// Defining the next state
171
assign StartIPG = StateDefer & ~ExcessiveDefer & ~CarrierSense;
172
 
173
assign StartIdle = StateIPG & (Rule1 & NibCnt[6:0] >= IPGT | ~Rule1 & NibCnt[6:0] >= IPGR2);
174
 
175
assign StartPreamble = StateIdle & TxStartFrm & ~CarrierSense;
176
 
177
assign StartData[0] = ~Collision & (StatePreamble & NibCntEq15 | StateData[1] & ~TxEndFrm);
178
 
179
assign StartData[1] = ~Collision & StateData[0] & ~TxUnderRun & ~MaxFrame;
180
 
181
assign StartPAD = ~Collision & StateData[1] & TxEndFrm & Pad & ~NibbleMinFl;
182
 
183
assign StartFCS = ~Collision & StateData[1] & TxEndFrm & (~Pad | Pad & NibbleMinFl) & CrcEn
184
                | ~Collision & StatePAD & NibbleMinFl & CrcEn;
185
 
186
assign StartJam = (Collision | UnderRun) & ((StatePreamble & NibCntEq15) | (|StateData[1:0]) | StatePAD | StateFCS);
187
 
188
assign StartBackoff = StateJam & ~RandomEq0 & ColWindow & ~RetryMax & NibCntEq7 & ~NoBckof;
189
 
190
assign StartDefer = StateIPG & ~Rule1 & CarrierSense & NibCnt[6:0] <= IPGR1 & NibCnt[6:0] != IPGR2
191
                  | StateIdle & CarrierSense
192
                  | StateJam & NibCntEq7 & (NoBckof | RandomEq0 | ~ColWindow | RetryMax)
193
                  | StateBackOff & (TxUnderRun | RandomEqByteCnt)
194
                  | StartTxDone | TooBig;
195
 
196
assign DeferIndication = StateIdle & CarrierSense;
197
 
198
// Tx State Machine
199
always @ (posedge MTxClk or posedge Reset)
200
begin
201
  if(Reset)
202
    begin
203
      StateIPG        <= #Tp 1'b0;
204
      StateIdle       <= #Tp 1'b0;
205
      StatePreamble   <= #Tp 1'b0;
206
      StateData[1:0]  <= #Tp 2'b0;
207
      StatePAD        <= #Tp 1'b0;
208
      StateFCS        <= #Tp 1'b0;
209
      StateJam        <= #Tp 1'b0;
210
      StateJam_q      <= #Tp 1'b0;
211
      StateBackOff    <= #Tp 1'b0;
212
      StateDefer      <= #Tp 1'b1;
213
    end
214
  else
215
    begin
216
      StateData[1:0] <= #Tp StartData[1:0];
217
      StateJam_q <= #Tp StateJam;
218
 
219
      if(StartDefer | StartIdle)
220
        StateIPG <= #Tp 1'b0;
221
      else
222
      if(StartIPG)
223
        StateIPG <= #Tp 1'b1;
224
 
225
      if(StartDefer | StartPreamble)
226
        StateIdle <= #Tp 1'b0;
227
      else
228
      if(StartIdle)
229
        StateIdle <= #Tp 1'b1;
230
 
231
      if(StartData[0] | StartJam)
232
        StatePreamble <= #Tp 1'b0;
233
      else
234
      if(StartPreamble)
235
        StatePreamble <= #Tp 1'b1;
236
 
237
      if(StartFCS | StartJam)
238
        StatePAD <= #Tp 1'b0;
239
      else
240
      if(StartPAD)
241
        StatePAD <= #Tp 1'b1;
242
 
243
      if(StartJam | StartDefer)
244
        StateFCS <= #Tp 1'b0;
245
      else
246
      if(StartFCS)
247
        StateFCS <= #Tp 1'b1;
248
 
249
      if(StartBackoff | StartDefer)
250
        StateJam <= #Tp 1'b0;
251
      else
252
      if(StartJam)
253
        StateJam <= #Tp 1'b1;
254
 
255
      if(StartDefer)
256
        StateBackOff <= #Tp 1'b0;
257
      else
258
      if(StartBackoff)
259
        StateBackOff <= #Tp 1'b1;
260
 
261
      if(StartIPG)
262
        StateDefer <= #Tp 1'b0;
263
      else
264
      if(StartDefer)
265
        StateDefer <= #Tp 1'b1;
266
    end
267
end
268
 
269
 
270
// This sections defines which interpack gap rule to use
271
always @ (posedge MTxClk or posedge Reset)
272
begin
273
  if(Reset)
274
    Rule1 <= #Tp 1'b0;
275
  else
276
    begin
277
      if(StateIdle | StateBackOff)
278
        Rule1 <= #Tp 1'b0;
279
      else
280
      if(StatePreamble | FullD)
281
        Rule1 <= #Tp 1'b1;
282
    end
283
end
284
 
285
 
286
 
287
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.