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 22

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

powered by: WebSVN 2.1.0

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