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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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