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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_txstatem.v] - Blame information for rev 37

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

powered by: WebSVN 2.1.0

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