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 18

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

powered by: WebSVN 2.1.0

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