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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_14/] [rtl/] [verilog/] [eth_txstatem.v] - Blame information for rev 15

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

Line No. Rev Author Line
1 15 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_txstatem.v                                              ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/cores/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.1  2001/07/30 21:23:42  mohor
47
// Directory structure changed. Files checked and joind together.
48
//
49
// Revision 1.3  2001/06/19 18:16:40  mohor
50
// TxClk changed to MTxClk (as discribed in the documentation).
51
// Crc changed so only one file can be used instead of two.
52
//
53
// Revision 1.2  2001/06/19 10:38:07  mohor
54
// Minor changes in header.
55
//
56
// Revision 1.1  2001/06/19 10:27:57  mohor
57
// TxEthMAC initial release.
58
//
59
//
60
//
61
//
62
 
63
 
64
`include "eth_timescale.v"
65
 
66
 
67
module eth_txstatem  (MTxClk, Reset, ExcessiveDefer, CarrierSense, NibCnt, IPGT, IPGR1,
68
                      IPGR2, FullD, TxStartFrm, TxEndFrm, TxUnderRun, Collision, UnderRun,
69
                      StartTxDone, TooBig, NibCntEq7, NibCntEq15, MaxFrame, Pad, CrcEn,
70
                      NibbleMinFl, RandomEq0, ColWindow, RetryMax, NoBckof, RandomEqByteCnt,
71
                      StateIdle, StateIPG, StatePreamble, StateData, StatePAD, StateFCS,
72
                      StateJam, StateJam_q, StateBackOff, StateDefer, StartFCS, StartJam,
73
                      StartBackoff, StartDefer, StartPreamble, StartData, StartIPG
74
                     );
75
 
76
parameter Tp = 1;
77
 
78
input MTxClk;
79
input Reset;
80
input ExcessiveDefer;
81
input CarrierSense;
82
input [6:0] NibCnt;
83
input [6:0] IPGT;
84
input [6:0] IPGR1;
85
input [6:0] IPGR2;
86
input FullD;
87
input TxStartFrm;
88
input TxEndFrm;
89
input TxUnderRun;
90
input Collision;
91
input UnderRun;
92
input StartTxDone;
93
input TooBig;
94
input NibCntEq7;
95
input NibCntEq15;
96
input MaxFrame;
97
input Pad;
98
input CrcEn;
99
input NibbleMinFl;
100
input RandomEq0;
101
input ColWindow;
102
input RetryMax;
103
input NoBckof;
104
input RandomEqByteCnt;
105
 
106
 
107
output StateIdle;         // Idle state
108
output StateIPG;          // IPG state
109
output StatePreamble;     // Preamble state
110
output [1:0] StateData;   // Data state
111
output StatePAD;          // PAD state
112
output StateFCS;          // FCS state
113
output StateJam;          // Jam state
114
output StateJam_q;        // Delayed Jam state
115
output StateBackOff;      // Backoff state
116
output StateDefer;        // Defer state
117
 
118
output StartFCS;          // FCS state will be activated in next clock
119
output StartJam;          // Jam state will be activated in next clock
120
output StartBackoff;      // Backoff state will be activated in next clock
121
output StartDefer;        // Defer state will be activated in next clock
122
output StartPreamble;     // Preamble state will be activated in next clock
123
output [1:0] StartData;   // Data state will be activated in next clock
124
output StartIPG;          // IPG state will be activated in next clock
125
 
126
wire StartIdle;           // Idle state will be activated in next clock
127
wire StartPAD;            // PAD state will be activated in next clock
128
 
129
 
130
reg StateIdle;
131
reg StateIPG;
132
reg StatePreamble;
133
reg [1:0] StateData;
134
reg StatePAD;
135
reg StateFCS;
136
reg StateJam;
137
reg StateJam_q;
138
reg StateBackOff;
139
reg StateDefer;
140
reg Rule1;
141
 
142
 
143
// Defining the next state
144
assign StartIPG = StateDefer & ~ExcessiveDefer & ~CarrierSense;
145
 
146
assign StartIdle = StateIPG & (Rule1 & NibCnt[6:0] >= IPGT | ~Rule1 & NibCnt[6:0] >= IPGR2);
147
 
148
assign StartPreamble = StateIdle & TxStartFrm;
149
 
150
assign StartData[0] = ~Collision & (StatePreamble & NibCntEq15 | StateData[1] & ~TxEndFrm);
151
 
152
assign StartData[1] = ~Collision & StateData[0] & ~TxUnderRun & ~MaxFrame;
153
 
154
assign StartPAD = ~Collision & StateData[1] & TxEndFrm & Pad & ~NibbleMinFl;
155
 
156
assign StartFCS = ~Collision & StateData[1] & TxEndFrm & (~Pad & CrcEn | Pad & NibbleMinFl)
157
                | ~Collision & StatePAD & NibbleMinFl;
158
 
159
assign StartJam = (Collision | UnderRun) & ((StatePreamble & NibCntEq15) | |StateData[1:0] | StatePAD | StateFCS);
160
 
161
assign StartBackoff = StateJam & ~RandomEq0 & ColWindow & ~RetryMax & NibCntEq7 & ~NoBckof;
162
 
163
assign StartDefer = StateIPG & ~Rule1 & CarrierSense & NibCnt[6:0] <= IPGR1 & NibCnt[6:0] != IPGR2
164
                  | StateIdle & ~TxStartFrm & CarrierSense
165
                  | StateJam & NibCntEq7 & (NoBckof | RandomEq0 | ~ColWindow | RetryMax)
166
                  | StateBackOff & (TxUnderRun | RandomEqByteCnt)
167
                  | StartTxDone | TooBig;
168
 
169
 
170
 
171
// Tx State Machine
172
always @ (posedge MTxClk or posedge Reset)
173
begin
174
  if(Reset)
175
    begin
176
      StateIPG        <= #Tp 1'b0;
177
      StateIdle       <= #Tp 1'b0;
178
      StatePreamble   <= #Tp 1'b0;
179
      StateData[1:0]  <= #Tp 2'b0;
180
      StatePAD        <= #Tp 1'b0;
181
      StateFCS        <= #Tp 1'b0;
182
      StateJam        <= #Tp 1'b0;
183
      StateJam_q      <= #Tp 1'b0;
184
      StateBackOff    <= #Tp 1'b0;
185
      StateDefer      <= #Tp 1'b1;
186
    end
187
  else
188
    begin
189
      StateData[1:0] <= #Tp StartData[1:0];
190
      StateJam_q <= #Tp StateJam;
191
 
192
      if(StartDefer | StartIdle)
193
        StateIPG <= #Tp 1'b0;
194
      else
195
      if(StartIPG)
196
        StateIPG <= #Tp 1'b1;
197
 
198
      if(StartDefer | StartPreamble)
199
        StateIdle <= #Tp 1'b0;
200
      else
201
      if(StartIdle)
202
        StateIdle <= #Tp 1'b1;
203
 
204
      if(StartData[0] | StartJam)
205
        StatePreamble <= #Tp 1'b0;
206
      else
207
      if(StartPreamble)
208
        StatePreamble <= #Tp 1'b1;
209
 
210
      if(StartFCS | StartJam)
211
        StatePAD <= #Tp 1'b0;
212
      else
213
      if(StartPAD)
214
        StatePAD <= #Tp 1'b1;
215
 
216
      if(StartJam | StartDefer)
217
        StateFCS <= #Tp 1'b0;
218
      else
219
      if(StartFCS)
220
        StateFCS <= #Tp 1'b1;
221
 
222
      if(StartBackoff | StartDefer)
223
        StateJam <= #Tp 1'b0;
224
      else
225
      if(StartJam)
226
        StateJam <= #Tp 1'b1;
227
 
228
      if(StartDefer)
229
        StateBackOff <= #Tp 1'b0;
230
      else
231
      if(StartBackoff)
232
        StateBackOff <= #Tp 1'b1;
233
 
234
      if(StartIPG)
235
        StateDefer <= #Tp 1'b0;
236
      else
237
      if(StartDefer)
238
        StateDefer <= #Tp 1'b1;
239
    end
240
end
241
 
242
 
243
// This sections defines which interpack gap rule to use
244
always @ (posedge MTxClk or posedge Reset)
245
begin
246
  if(Reset)
247
    Rule1 <= #Tp 1'b0;
248
  else
249
    begin
250
      if(StateIdle | StateBackOff)
251
        Rule1 <= #Tp 1'b0;
252
      else
253
      if(StatePreamble | FullD)
254
        Rule1 <= #Tp 1'b1;
255
    end
256
end
257
 
258
 
259
 
260
endmodule

powered by: WebSVN 2.1.0

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