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

Subversion Repositories ethmac

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

powered by: WebSVN 2.1.0

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