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

Subversion Repositories ts7300_opencore

[/] [ts7300_opencore/] [trunk/] [ethernet/] [eth_macstatus.v] - Blame information for rev 6

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

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

powered by: WebSVN 2.1.0

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