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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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