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

Subversion Repositories ethmac

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

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 168 mohor
////  All additional information is available in the Readme.txt   ////
12 15 mohor
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16 168 mohor
//// Copyright (C) 2001, 2002 Authors                             ////
17 15 mohor
////                                                              ////
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 325 igorm
// Revision 1.15  2003/01/30 13:28:19  tadejm
45
// Defer indication changed.
46
//
47 276 tadejm
// Revision 1.14  2002/11/22 01:57:06  mohor
48
// Rx Flow control fixed. CF flag added to the RX buffer descriptor. RxAbort
49
// synchronized.
50
//
51 261 mohor
// Revision 1.13  2002/11/13 22:30:58  tadejm
52
// Late collision is reported only when not in the full duplex.
53
// Sample is taken (for status) as soon as MRxDV is not valid (regardless
54
// of the received byte cnt).
55
//
56 242 tadejm
// Revision 1.12  2002/09/12 14:50:16  mohor
57
// CarrierSenseLost bug fixed when operating in full duplex mode.
58
//
59 168 mohor
// Revision 1.11  2002/09/04 18:38:03  mohor
60
// CarrierSenseLost status is not set when working in loopback mode.
61
//
62 146 mohor
// Revision 1.10  2002/07/25 18:17:46  mohor
63
// InvalidSymbol generation changed.
64
//
65 126 mohor
// Revision 1.9  2002/04/22 13:51:44  mohor
66
// Short frame and ReceivedLengthOK were not detected correctly.
67
//
68 101 mohor
// Revision 1.8  2002/02/18 10:40:17  mohor
69
// Small fixes.
70
//
71 70 mohor
// Revision 1.7  2002/02/15 17:07:39  mohor
72
// Status was not written correctly when frames were discarted because of
73
// address mismatch.
74
//
75 64 mohor
// Revision 1.6  2002/02/11 09:18:21  mohor
76
// Tx status is written back to the BD.
77
//
78 43 mohor
// Revision 1.5  2002/02/08 16:21:54  mohor
79
// Rx status is written back to the BD.
80
//
81 42 mohor
// Revision 1.4  2002/01/23 10:28:16  mohor
82
// Link in the header changed.
83
//
84 37 mohor
// Revision 1.3  2001/10/19 08:43:51  mohor
85
// eth_timescale.v changed to timescale.v This is done because of the
86
// simulation of the few cores in a one joined project.
87
//
88 22 mohor
// Revision 1.2  2001/09/11 14:17:00  mohor
89
// Few little NCSIM warnings fixed.
90
//
91 18 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
92
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
93
// Include files fixed to contain no path.
94
// File names and module names changed ta have a eth_ prologue in the name.
95
// File eth_timescale.v is used to define timescale
96
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
97
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
98
// and Mdo_OE. The bidirectional signal must be created on the top level. This
99
// is done due to the ASIC tools.
100
//
101 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
102
// Directory structure changed. Files checked and joind together.
103
//
104
//
105
//
106
//
107
//
108
 
109 22 mohor
`include "timescale.v"
110 15 mohor
 
111
 
112
module eth_macstatus(
113 42 mohor
                      MRxClk, Reset, ReceivedLengthOK, ReceiveEnd, ReceivedPacketGood, RxCrcError,
114 15 mohor
                      MRxErr, MRxDV, RxStateSFD, RxStateData, RxStatePreamble, RxStateIdle, Transmitting,
115 261 mohor
                      RxByteCnt, RxByteCntEq0, RxByteCntGreat2, RxByteCntMaxFrame,
116 42 mohor
                      InvalidSymbol, MRxD, LatchedCrcError, Collision, CollValid, RxLateCollision,
117
                      r_RecSmall, r_MinFL, r_MaxFL, ShortFrame, DribbleNibble, ReceivedPacketTooBig, r_HugEn,
118 43 mohor
                      LoadRxStatus, StartTxDone, StartTxAbort, RetryCnt, RetryCntLatched, MTxClk, MaxCollisionOccured,
119 325 igorm
                      RetryLimit, LateCollision, LateCollLatched, DeferIndication, DeferLatched, RstDeferLatched, TxStartFrm,
120 168 mohor
                      StatePreamble, StateData, CarrierSense, CarrierSenseLost, TxUsedData, LatchedMRxErr, Loopback,
121
                      r_FullD
122 15 mohor
                    );
123
 
124
 
125
 
126
parameter Tp = 1;
127
 
128
 
129
input         MRxClk;
130
input         Reset;
131
input         RxCrcError;
132
input         MRxErr;
133
input         MRxDV;
134
 
135
input         RxStateSFD;
136
input   [1:0] RxStateData;
137
input         RxStatePreamble;
138
input         RxStateIdle;
139
input         Transmitting;
140
input  [15:0] RxByteCnt;
141
input         RxByteCntEq0;
142
input         RxByteCntGreat2;
143
input         RxByteCntMaxFrame;
144 42 mohor
input   [3:0] MRxD;
145
input         Collision;
146
input   [5:0] CollValid;
147
input         r_RecSmall;
148
input  [15:0] r_MinFL;
149
input  [15:0] r_MaxFL;
150
input         r_HugEn;
151 43 mohor
input         StartTxDone;
152
input         StartTxAbort;
153
input   [3:0] RetryCnt;
154
input         MTxClk;
155
input         MaxCollisionOccured;
156
input         LateCollision;
157 276 tadejm
input         DeferIndication;
158 43 mohor
input         TxStartFrm;
159
input         StatePreamble;
160
input   [1:0] StateData;
161
input         CarrierSense;
162
input         TxUsedData;
163 146 mohor
input         Loopback;
164 168 mohor
input         r_FullD;
165 15 mohor
 
166 43 mohor
 
167 15 mohor
output        ReceivedLengthOK;
168
output        ReceiveEnd;
169
output        ReceivedPacketGood;
170 42 mohor
output        InvalidSymbol;
171
output        LatchedCrcError;
172
output        RxLateCollision;
173
output        ShortFrame;
174
output        DribbleNibble;
175
output        ReceivedPacketTooBig;
176
output        LoadRxStatus;
177 43 mohor
output  [3:0] RetryCntLatched;
178
output        RetryLimit;
179
output        LateCollLatched;
180
output        DeferLatched;
181 325 igorm
input         RstDeferLatched;
182 43 mohor
output        CarrierSenseLost;
183 126 mohor
output        LatchedMRxErr;
184 15 mohor
 
185 43 mohor
 
186 15 mohor
reg           ReceiveEnd;
187
 
188
reg           LatchedCrcError;
189
reg           LatchedMRxErr;
190 42 mohor
reg           LoadRxStatus;
191
reg           InvalidSymbol;
192 43 mohor
reg     [3:0] RetryCntLatched;
193
reg           RetryLimit;
194
reg           LateCollLatched;
195
reg           DeferLatched;
196
reg           CarrierSenseLost;
197 15 mohor
 
198
wire          TakeSample;
199 42 mohor
wire          SetInvalidSymbol; // Invalid symbol was received during reception in 100Mbps 
200 15 mohor
 
201
// Crc error
202
always @ (posedge MRxClk or posedge Reset)
203
begin
204
  if(Reset)
205
    LatchedCrcError <=#Tp 1'b0;
206
  else
207 42 mohor
  if(RxStateSFD)
208
    LatchedCrcError <=#Tp 1'b0;
209
  else
210
  if(RxStateData[0])
211
    LatchedCrcError <=#Tp RxCrcError & ~RxByteCntEq0;
212 15 mohor
end
213
 
214
 
215
// LatchedMRxErr
216
always @ (posedge MRxClk or posedge Reset)
217
begin
218
  if(Reset)
219
    LatchedMRxErr <=#Tp 1'b0;
220
  else
221 18 mohor
  if(MRxErr & MRxDV & (RxStatePreamble | RxStateSFD | (|RxStateData) | RxStateIdle & ~Transmitting))
222 15 mohor
    LatchedMRxErr <=#Tp 1'b1;
223 126 mohor
  else
224
    LatchedMRxErr <=#Tp 1'b0;
225 15 mohor
end
226
 
227
 
228
// ReceivedPacketGood
229 126 mohor
assign ReceivedPacketGood = ~LatchedCrcError;
230 15 mohor
 
231
 
232
// ReceivedLengthOK
233 101 mohor
assign ReceivedLengthOK = RxByteCnt[15:0] >= r_MinFL[15:0] & RxByteCnt[15:0] <= r_MaxFL[15:0];
234 15 mohor
 
235
 
236
 
237 42 mohor
 
238
 
239
// Time to take a sample
240 242 tadejm
//assign TakeSample = |RxStateData     & ~MRxDV & RxByteCntGreat2  |
241
assign TakeSample = (|RxStateData)   & (~MRxDV)                    |
242
                      RxStateData[0] &   MRxDV & RxByteCntMaxFrame;
243 42 mohor
 
244
 
245
// LoadRxStatus
246 15 mohor
always @ (posedge MRxClk or posedge Reset)
247
begin
248
  if(Reset)
249 42 mohor
    LoadRxStatus <=#Tp 1'b0;
250 15 mohor
  else
251 42 mohor
    LoadRxStatus <=#Tp TakeSample;
252 15 mohor
end
253
 
254
 
255
 
256 42 mohor
// ReceiveEnd
257
always @ (posedge MRxClk or posedge Reset)
258
begin
259
  if(Reset)
260
    ReceiveEnd  <=#Tp 1'b0;
261
  else
262
    ReceiveEnd  <=#Tp LoadRxStatus;
263
end
264 15 mohor
 
265
 
266 42 mohor
// Invalid Symbol received during 100Mbps mode
267 126 mohor
assign SetInvalidSymbol = MRxDV & MRxErr & MRxD[3:0] == 4'he;
268 42 mohor
 
269
 
270
// InvalidSymbol
271 15 mohor
always @ (posedge MRxClk or posedge Reset)
272
begin
273
  if(Reset)
274 42 mohor
    InvalidSymbol <=#Tp 1'b0;
275 15 mohor
  else
276 42 mohor
  if(LoadRxStatus & ~SetInvalidSymbol)
277
    InvalidSymbol <=#Tp 1'b0;
278
  else
279
  if(SetInvalidSymbol)
280
    InvalidSymbol <=#Tp 1'b1;
281 15 mohor
end
282
 
283
 
284 42 mohor
// Late Collision
285 15 mohor
 
286 42 mohor
reg RxLateCollision;
287
reg RxColWindow;
288
// Collision Window
289 15 mohor
always @ (posedge MRxClk or posedge Reset)
290
begin
291
  if(Reset)
292 42 mohor
    RxLateCollision <=#Tp 1'b0;
293 15 mohor
  else
294 42 mohor
  if(LoadRxStatus)
295
    RxLateCollision <=#Tp 1'b0;
296
  else
297 242 tadejm
  if(Collision & (~r_FullD) & (~RxColWindow | r_RecSmall))
298 42 mohor
    RxLateCollision <=#Tp 1'b1;
299 15 mohor
end
300
 
301 42 mohor
// Collision Window
302
always @ (posedge MRxClk or posedge Reset)
303
begin
304
  if(Reset)
305
    RxColWindow <=#Tp 1'b1;
306
  else
307
  if(~Collision & RxByteCnt[5:0] == CollValid[5:0] & RxStateData[1])
308
    RxColWindow <=#Tp 1'b0;
309
  else
310
  if(RxStateIdle)
311
    RxColWindow <=#Tp 1'b1;
312
end
313 15 mohor
 
314 42 mohor
 
315
// ShortFrame
316
reg ShortFrame;
317
always @ (posedge MRxClk or posedge Reset)
318
begin
319
  if(Reset)
320
    ShortFrame <=#Tp 1'b0;
321
  else
322
  if(LoadRxStatus)
323
    ShortFrame <=#Tp 1'b0;
324
  else
325
  if(TakeSample)
326 101 mohor
    ShortFrame <=#Tp RxByteCnt[15:0] < r_MinFL[15:0];
327 42 mohor
end
328
 
329
 
330
// DribbleNibble
331
reg DribbleNibble;
332
always @ (posedge MRxClk or posedge Reset)
333
begin
334
  if(Reset)
335
    DribbleNibble <=#Tp 1'b0;
336
  else
337
  if(RxStateSFD)
338
    DribbleNibble <=#Tp 1'b0;
339
  else
340
  if(~MRxDV & RxStateData[1])
341
    DribbleNibble <=#Tp 1'b1;
342
end
343
 
344
 
345
reg ReceivedPacketTooBig;
346
always @ (posedge MRxClk or posedge Reset)
347
begin
348
  if(Reset)
349
    ReceivedPacketTooBig <=#Tp 1'b0;
350
  else
351
  if(LoadRxStatus)
352
    ReceivedPacketTooBig <=#Tp 1'b0;
353
  else
354
  if(TakeSample)
355
    ReceivedPacketTooBig <=#Tp ~r_HugEn & RxByteCnt[15:0] > r_MaxFL[15:0];
356
end
357
 
358 43 mohor
 
359
 
360
// Latched Retry counter for tx status
361
always @ (posedge MTxClk or posedge Reset)
362
begin
363
  if(Reset)
364
    RetryCntLatched <=#Tp 4'h0;
365
  else
366
  if(StartTxDone | StartTxAbort)
367
    RetryCntLatched <=#Tp RetryCnt;
368
end
369
 
370
 
371
// Latched Retransmission limit
372
always @ (posedge MTxClk or posedge Reset)
373
begin
374
  if(Reset)
375
    RetryLimit <=#Tp 4'h0;
376
  else
377
  if(StartTxDone | StartTxAbort)
378
    RetryLimit <=#Tp MaxCollisionOccured;
379
end
380
 
381
 
382
// Latched Late Collision
383
always @ (posedge MTxClk or posedge Reset)
384
begin
385
  if(Reset)
386
    LateCollLatched <=#Tp 1'b0;
387
  else
388
  if(StartTxDone | StartTxAbort)
389
    LateCollLatched <=#Tp LateCollision;
390
end
391
 
392
 
393
 
394
// Latched Defer state
395
always @ (posedge MTxClk or posedge Reset)
396
begin
397
  if(Reset)
398
    DeferLatched <=#Tp 1'b0;
399
  else
400 325 igorm
  if(DeferIndication)
401 43 mohor
    DeferLatched <=#Tp 1'b1;
402
  else
403 325 igorm
  if(RstDeferLatched)
404 43 mohor
    DeferLatched <=#Tp 1'b0;
405
end
406
 
407
 
408
// CarrierSenseLost
409
always @ (posedge MTxClk or posedge Reset)
410
begin
411
  if(Reset)
412
    CarrierSenseLost <=#Tp 1'b0;
413
  else
414 168 mohor
  if((StatePreamble | (|StateData)) & ~CarrierSense & ~Loopback & ~Collision & ~r_FullD)
415 43 mohor
    CarrierSenseLost <=#Tp 1'b1;
416
  else
417
  if(TxStartFrm)
418
    CarrierSenseLost <=#Tp 1'b0;
419
end
420
 
421
 
422 15 mohor
endmodule

powered by: WebSVN 2.1.0

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