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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_macstatus.v] - Blame information for rev 64

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

Line No. Rev Author Line
1 15 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_macstatus.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
////                                                              ////
11
////  All additional information is avaliable in the Readme.txt   ////
12
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16
//// Copyright (C) 2001 Authors                                   ////
17
////                                                              ////
18
//// This source file may be used and distributed without         ////
19
//// restriction provided that this copyright statement is not    ////
20
//// removed from the file and that any derivative work contains  ////
21
//// the original copyright notice and the associated disclaimer. ////
22
////                                                              ////
23
//// This source file is free software; you can redistribute it   ////
24
//// and/or modify it under the terms of the GNU Lesser General   ////
25
//// Public License as published by the Free Software Foundation; ////
26
//// either version 2.1 of the License, or (at your option) any   ////
27
//// later version.                                               ////
28
////                                                              ////
29
//// This source is distributed in the hope that it will be       ////
30
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
31
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
32
//// PURPOSE.  See the GNU Lesser General Public License for more ////
33
//// details.                                                     ////
34
////                                                              ////
35
//// You should have received a copy of the GNU Lesser General    ////
36
//// Public License along with this source; if not, download it   ////
37
//// from http://www.opencores.org/lgpl.shtml                     ////
38
////                                                              ////
39
//////////////////////////////////////////////////////////////////////
40
//
41
// CVS Revision History
42
//
43
// $Log: not supported by cvs2svn $
44 64 mohor
// Revision 1.6  2002/02/11 09:18:21  mohor
45
// Tx status is written back to the BD.
46
//
47 43 mohor
// Revision 1.5  2002/02/08 16:21:54  mohor
48
// Rx status is written back to the BD.
49
//
50 42 mohor
// Revision 1.4  2002/01/23 10:28:16  mohor
51
// Link in the header changed.
52
//
53 37 mohor
// Revision 1.3  2001/10/19 08:43:51  mohor
54
// eth_timescale.v changed to timescale.v This is done because of the
55
// simulation of the few cores in a one joined project.
56
//
57 22 mohor
// Revision 1.2  2001/09/11 14:17:00  mohor
58
// Few little NCSIM warnings fixed.
59
//
60 18 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
61
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
62
// Include files fixed to contain no path.
63
// File names and module names changed ta have a eth_ prologue in the name.
64
// File eth_timescale.v is used to define timescale
65
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
66
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
67
// and Mdo_OE. The bidirectional signal must be created on the top level. This
68
// is done due to the ASIC tools.
69
//
70 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
71
// Directory structure changed. Files checked and joind together.
72
//
73
//
74
//
75
//
76
//
77
 
78 22 mohor
`include "timescale.v"
79 15 mohor
 
80
 
81
module eth_macstatus(
82 42 mohor
                      MRxClk, Reset, ReceivedLengthOK, ReceiveEnd, ReceivedPacketGood, RxCrcError,
83 15 mohor
                      MRxErr, MRxDV, RxStateSFD, RxStateData, RxStatePreamble, RxStateIdle, Transmitting,
84 42 mohor
                      RxByteCnt, RxByteCntEq0, RxByteCntGreat2, RxByteCntMaxFrame, ReceivedPauseFrm,
85
                      InvalidSymbol, MRxD, LatchedCrcError, Collision, CollValid, RxLateCollision,
86
                      r_RecSmall, r_MinFL, r_MaxFL, ShortFrame, DribbleNibble, ReceivedPacketTooBig, r_HugEn,
87 43 mohor
                      LoadRxStatus, StartTxDone, StartTxAbort, RetryCnt, RetryCntLatched, MTxClk, MaxCollisionOccured,
88
                      RetryLimit, LateCollision, LateCollLatched, StartDefer, DeferLatched, TxStartFrm,
89
                      StatePreamble, StateData, CarrierSense, CarrierSenseLost, TxUsedData
90 15 mohor
                    );
91
 
92
 
93
 
94
parameter Tp = 1;
95
 
96
 
97
input         MRxClk;
98
input         Reset;
99
input         RxCrcError;
100
input         MRxErr;
101
input         MRxDV;
102
 
103
input         RxStateSFD;
104
input   [1:0] RxStateData;
105
input         RxStatePreamble;
106
input         RxStateIdle;
107
input         Transmitting;
108
input  [15:0] RxByteCnt;
109
input         RxByteCntEq0;
110
input         RxByteCntGreat2;
111
input         RxByteCntMaxFrame;
112
input         ReceivedPauseFrm;
113 42 mohor
input   [3:0] MRxD;
114
input         Collision;
115
input   [5:0] CollValid;
116
input         r_RecSmall;
117
input  [15:0] r_MinFL;
118
input  [15:0] r_MaxFL;
119
input         r_HugEn;
120 43 mohor
input         StartTxDone;
121
input         StartTxAbort;
122
input   [3:0] RetryCnt;
123
input         MTxClk;
124
input         MaxCollisionOccured;
125
input         LateCollision;
126
input         StartDefer;
127
input         TxStartFrm;
128
input         StatePreamble;
129
input   [1:0] StateData;
130
input         CarrierSense;
131
input         TxUsedData;
132 15 mohor
 
133 43 mohor
 
134 15 mohor
output        ReceivedLengthOK;
135
output        ReceiveEnd;
136
output        ReceivedPacketGood;
137 42 mohor
output        InvalidSymbol;
138
output        LatchedCrcError;
139
output        RxLateCollision;
140
output        ShortFrame;
141
output        DribbleNibble;
142
output        ReceivedPacketTooBig;
143
output        LoadRxStatus;
144 43 mohor
output  [3:0] RetryCntLatched;
145
output        RetryLimit;
146
output        LateCollLatched;
147
output        DeferLatched;
148
output        CarrierSenseLost;
149 15 mohor
 
150 43 mohor
 
151 15 mohor
reg           ReceiveEnd;
152
 
153
reg           LatchedCrcError;
154
reg           LatchedMRxErr;
155 42 mohor
reg           LoadRxStatus;
156
reg           InvalidSymbol;
157 43 mohor
reg     [3:0] RetryCntLatched;
158
reg           RetryLimit;
159
reg           LateCollLatched;
160
reg           DeferLatched;
161
reg           CarrierSenseLost;
162 15 mohor
 
163
wire          TakeSample;
164 42 mohor
wire          SetInvalidSymbol; // Invalid symbol was received during reception in 100Mbps 
165 15 mohor
 
166
// Crc error
167
always @ (posedge MRxClk or posedge Reset)
168
begin
169
  if(Reset)
170
    LatchedCrcError <=#Tp 1'b0;
171
  else
172 42 mohor
  if(RxStateSFD)
173
    LatchedCrcError <=#Tp 1'b0;
174
  else
175
  if(RxStateData[0])
176
    LatchedCrcError <=#Tp RxCrcError & ~RxByteCntEq0;
177 15 mohor
end
178
 
179
 
180
// LatchedMRxErr
181
always @ (posedge MRxClk or posedge Reset)
182
begin
183
  if(Reset)
184
    LatchedMRxErr <=#Tp 1'b0;
185
  else
186
  if(~MRxErr & MRxDV & RxStateIdle & ~Transmitting)
187
    LatchedMRxErr <=#Tp 1'b0;
188
  else
189 18 mohor
  if(MRxErr & MRxDV & (RxStatePreamble | RxStateSFD | (|RxStateData) | RxStateIdle & ~Transmitting))
190 15 mohor
    LatchedMRxErr <=#Tp 1'b1;
191
end
192
 
193
 
194
// ReceivedPacketGood
195
assign ReceivedPacketGood = ~LatchedCrcError & ~LatchedMRxErr;
196
 
197
 
198
// ReceivedLengthOK
199 42 mohor
assign ReceivedLengthOK = RxByteCnt[15:0] > 63 & RxByteCnt[15:0] < 1519;
200 15 mohor
 
201
 
202
 
203 42 mohor
 
204
 
205
// Time to take a sample
206
assign TakeSample = |RxStateData     & ~MRxDV & RxByteCntGreat2  |
207
                     RxStateData[0]  &  MRxDV & RxByteCntMaxFrame;
208
 
209
 
210
// LoadRxStatus
211 15 mohor
always @ (posedge MRxClk or posedge Reset)
212
begin
213
  if(Reset)
214 42 mohor
    LoadRxStatus <=#Tp 1'b0;
215 15 mohor
  else
216 42 mohor
    LoadRxStatus <=#Tp TakeSample;
217 15 mohor
end
218
 
219
 
220
 
221 42 mohor
// ReceiveEnd
222
always @ (posedge MRxClk or posedge Reset)
223
begin
224
  if(Reset)
225
    ReceiveEnd  <=#Tp 1'b0;
226
  else
227
    ReceiveEnd  <=#Tp LoadRxStatus;
228
end
229 15 mohor
 
230
 
231 42 mohor
// Invalid Symbol received during 100Mbps mode
232
assign SetInvalidSymbol = MRxDV & MRxErr & ~LatchedMRxErr & MRxD[3:0] == 4'he;
233
 
234
 
235
// InvalidSymbol
236 15 mohor
always @ (posedge MRxClk or posedge Reset)
237
begin
238
  if(Reset)
239 42 mohor
    InvalidSymbol <=#Tp 1'b0;
240 15 mohor
  else
241 42 mohor
  if(LoadRxStatus & ~SetInvalidSymbol)
242
    InvalidSymbol <=#Tp 1'b0;
243
  else
244
  if(SetInvalidSymbol)
245
    InvalidSymbol <=#Tp 1'b1;
246 15 mohor
end
247
 
248
 
249 42 mohor
// Late Collision
250 15 mohor
 
251 42 mohor
reg RxLateCollision;
252
reg RxColWindow;
253
// Collision Window
254 15 mohor
always @ (posedge MRxClk or posedge Reset)
255
begin
256
  if(Reset)
257 42 mohor
    RxLateCollision <=#Tp 1'b0;
258 15 mohor
  else
259 42 mohor
  if(LoadRxStatus)
260
    RxLateCollision <=#Tp 1'b0;
261
  else
262
  if(Collision & (~RxColWindow | r_RecSmall))
263
    RxLateCollision <=#Tp 1'b1;
264 15 mohor
end
265
 
266 42 mohor
// Collision Window
267
always @ (posedge MRxClk or posedge Reset)
268
begin
269
  if(Reset)
270
    RxColWindow <=#Tp 1'b1;
271
  else
272
  if(~Collision & RxByteCnt[5:0] == CollValid[5:0] & RxStateData[1])
273
    RxColWindow <=#Tp 1'b0;
274
  else
275
  if(RxStateIdle)
276
    RxColWindow <=#Tp 1'b1;
277
end
278 15 mohor
 
279 42 mohor
 
280
// ShortFrame
281
reg ShortFrame;
282
always @ (posedge MRxClk or posedge Reset)
283
begin
284
  if(Reset)
285
    ShortFrame <=#Tp 1'b0;
286
  else
287
  if(LoadRxStatus)
288
    ShortFrame <=#Tp 1'b0;
289
  else
290
  if(TakeSample)
291
    ShortFrame <=#Tp r_RecSmall & RxByteCnt[15:0] < r_MinFL[15:0];
292
end
293
 
294
 
295
// DribbleNibble
296
reg DribbleNibble;
297
always @ (posedge MRxClk or posedge Reset)
298
begin
299
  if(Reset)
300
    DribbleNibble <=#Tp 1'b0;
301
  else
302
  if(RxStateSFD)
303
    DribbleNibble <=#Tp 1'b0;
304
  else
305
  if(~MRxDV & RxStateData[1])
306
    DribbleNibble <=#Tp 1'b1;
307
end
308
 
309
 
310
reg ReceivedPacketTooBig;
311
assign ReceivedLengthOK = RxByteCnt[15:0] > 63 & RxByteCnt[15:0] < 1519;
312
always @ (posedge MRxClk or posedge Reset)
313
begin
314
  if(Reset)
315
    ReceivedPacketTooBig <=#Tp 1'b0;
316
  else
317
  if(LoadRxStatus)
318
    ReceivedPacketTooBig <=#Tp 1'b0;
319
  else
320
  if(TakeSample)
321
    ReceivedPacketTooBig <=#Tp ~r_HugEn & RxByteCnt[15:0] > r_MaxFL[15:0];
322
end
323
 
324 43 mohor
 
325
 
326
// Latched Retry counter for tx status
327
always @ (posedge MTxClk or posedge Reset)
328
begin
329
  if(Reset)
330
    RetryCntLatched <=#Tp 4'h0;
331
  else
332
  if(StartTxDone | StartTxAbort)
333
    RetryCntLatched <=#Tp RetryCnt;
334
end
335
 
336
 
337
// Latched Retransmission limit
338
always @ (posedge MTxClk or posedge Reset)
339
begin
340
  if(Reset)
341
    RetryLimit <=#Tp 4'h0;
342
  else
343
  if(StartTxDone | StartTxAbort)
344
    RetryLimit <=#Tp MaxCollisionOccured;
345
end
346
 
347
 
348
// Latched Late Collision
349
always @ (posedge MTxClk or posedge Reset)
350
begin
351
  if(Reset)
352
    LateCollLatched <=#Tp 1'b0;
353
  else
354
  if(StartTxDone | StartTxAbort)
355
    LateCollLatched <=#Tp LateCollision;
356
end
357
 
358
 
359
 
360
// Latched Defer state
361
always @ (posedge MTxClk or posedge Reset)
362
begin
363
  if(Reset)
364
    DeferLatched <=#Tp 1'b0;
365
  else
366
  if(StartDefer & TxUsedData)
367
    DeferLatched <=#Tp 1'b1;
368
  else
369
  if(TxStartFrm)
370
    DeferLatched <=#Tp 1'b0;
371
end
372
 
373
 
374
// CarrierSenseLost
375
always @ (posedge MTxClk or posedge Reset)
376
begin
377
  if(Reset)
378
    CarrierSenseLost <=#Tp 1'b0;
379
  else
380 64 mohor
  if((StatePreamble | (|StateData)) & ~CarrierSense & ~Collision)
381 43 mohor
    CarrierSenseLost <=#Tp 1'b1;
382
  else
383
  if(TxStartFrm)
384
    CarrierSenseLost <=#Tp 1'b0;
385
end
386
 
387
 
388 15 mohor
endmodule

powered by: WebSVN 2.1.0

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