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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_19/] [rtl/] [verilog/] [eth_macstatus.v] - Blame information for rev 338

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

powered by: WebSVN 2.1.0

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