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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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