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 42

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 42 mohor
// Revision 1.4  2002/01/23 10:28:16  mohor
45
// Link in the header changed.
46
//
47 37 mohor
// Revision 1.3  2001/10/19 08:43:51  mohor
48
// eth_timescale.v changed to timescale.v This is done because of the
49
// simulation of the few cores in a one joined project.
50
//
51 22 mohor
// Revision 1.2  2001/09/11 14:17:00  mohor
52
// Few little NCSIM warnings fixed.
53
//
54 18 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
55
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
56
// Include files fixed to contain no path.
57
// File names and module names changed ta have a eth_ prologue in the name.
58
// File eth_timescale.v is used to define timescale
59
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
60
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
61
// and Mdo_OE. The bidirectional signal must be created on the top level. This
62
// is done due to the ASIC tools.
63
//
64 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
65
// Directory structure changed. Files checked and joind together.
66
//
67
//
68
//
69
//
70
//
71
 
72 22 mohor
`include "timescale.v"
73 15 mohor
 
74
 
75
module eth_macstatus(
76 42 mohor
                      MRxClk, Reset, ReceivedLengthOK, ReceiveEnd, ReceivedPacketGood, RxCrcError,
77 15 mohor
                      MRxErr, MRxDV, RxStateSFD, RxStateData, RxStatePreamble, RxStateIdle, Transmitting,
78 42 mohor
                      RxByteCnt, RxByteCntEq0, RxByteCntGreat2, RxByteCntMaxFrame, ReceivedPauseFrm,
79
                      InvalidSymbol, MRxD, LatchedCrcError, Collision, CollValid, RxLateCollision,
80
                      r_RecSmall, r_MinFL, r_MaxFL, ShortFrame, DribbleNibble, ReceivedPacketTooBig, r_HugEn,
81
                      LoadRxStatus
82 15 mohor
                    );
83
 
84
 
85
 
86
parameter Tp = 1;
87
 
88
 
89
input         MRxClk;
90
input         Reset;
91
input         RxCrcError;
92
input         MRxErr;
93
input         MRxDV;
94
 
95
input         RxStateSFD;
96
input   [1:0] RxStateData;
97
input         RxStatePreamble;
98
input         RxStateIdle;
99
input         Transmitting;
100
input  [15:0] RxByteCnt;
101
input         RxByteCntEq0;
102
input         RxByteCntGreat2;
103
input         RxByteCntMaxFrame;
104
input         ReceivedPauseFrm;
105 42 mohor
input   [3:0] MRxD;
106
input         Collision;
107
input   [5:0] CollValid;
108
input         r_RecSmall;
109
input  [15:0] r_MinFL;
110
input  [15:0] r_MaxFL;
111
input         r_HugEn;
112 15 mohor
 
113
output        ReceivedLengthOK;
114
output        ReceiveEnd;
115
output        ReceivedPacketGood;
116 42 mohor
output        InvalidSymbol;
117
output        LatchedCrcError;
118
output        RxLateCollision;
119
output        ShortFrame;
120
output        DribbleNibble;
121
output        ReceivedPacketTooBig;
122
output        LoadRxStatus;
123 15 mohor
 
124
reg           ReceiveEnd;
125
 
126
reg           LatchedCrcError;
127
reg           LatchedMRxErr;
128 42 mohor
reg           LoadRxStatus;
129
reg           InvalidSymbol;
130 15 mohor
 
131
wire          TakeSample;
132 42 mohor
wire          SetInvalidSymbol; // Invalid symbol was received during reception in 100Mbps 
133 15 mohor
 
134
// Crc error
135
always @ (posedge MRxClk or posedge Reset)
136
begin
137
  if(Reset)
138
    LatchedCrcError <=#Tp 1'b0;
139
  else
140 42 mohor
  if(RxStateSFD)
141
    LatchedCrcError <=#Tp 1'b0;
142
  else
143
  if(RxStateData[0])
144
    LatchedCrcError <=#Tp RxCrcError & ~RxByteCntEq0;
145 15 mohor
end
146
 
147
 
148
// LatchedMRxErr
149
always @ (posedge MRxClk or posedge Reset)
150
begin
151
  if(Reset)
152
    LatchedMRxErr <=#Tp 1'b0;
153
  else
154
  if(~MRxErr & MRxDV & RxStateIdle & ~Transmitting)
155
    LatchedMRxErr <=#Tp 1'b0;
156
  else
157 18 mohor
  if(MRxErr & MRxDV & (RxStatePreamble | RxStateSFD | (|RxStateData) | RxStateIdle & ~Transmitting))
158 15 mohor
    LatchedMRxErr <=#Tp 1'b1;
159
end
160
 
161
 
162
// ReceivedPacketGood
163
assign ReceivedPacketGood = ~LatchedCrcError & ~LatchedMRxErr;
164
 
165
 
166
// ReceivedLengthOK
167 42 mohor
assign ReceivedLengthOK = RxByteCnt[15:0] > 63 & RxByteCnt[15:0] < 1519;
168 15 mohor
 
169
 
170
 
171 42 mohor
 
172
 
173
// Time to take a sample
174
assign TakeSample = |RxStateData     & ~MRxDV & RxByteCntGreat2  |
175
                     RxStateData[0]  &  MRxDV & RxByteCntMaxFrame;
176
 
177
 
178
// LoadRxStatus
179 15 mohor
always @ (posedge MRxClk or posedge Reset)
180
begin
181
  if(Reset)
182 42 mohor
    LoadRxStatus <=#Tp 1'b0;
183 15 mohor
  else
184 42 mohor
    LoadRxStatus <=#Tp TakeSample;
185 15 mohor
end
186
 
187
 
188
 
189 42 mohor
// ReceiveEnd
190
always @ (posedge MRxClk or posedge Reset)
191
begin
192
  if(Reset)
193
    ReceiveEnd  <=#Tp 1'b0;
194
  else
195
    ReceiveEnd  <=#Tp LoadRxStatus;
196
end
197 15 mohor
 
198
 
199 42 mohor
// Invalid Symbol received during 100Mbps mode
200
assign SetInvalidSymbol = MRxDV & MRxErr & ~LatchedMRxErr & MRxD[3:0] == 4'he;
201
 
202
 
203
// InvalidSymbol
204 15 mohor
always @ (posedge MRxClk or posedge Reset)
205
begin
206
  if(Reset)
207 42 mohor
    InvalidSymbol <=#Tp 1'b0;
208 15 mohor
  else
209 42 mohor
  if(LoadRxStatus & ~SetInvalidSymbol)
210
    InvalidSymbol <=#Tp 1'b0;
211
  else
212
  if(SetInvalidSymbol)
213
    InvalidSymbol <=#Tp 1'b1;
214 15 mohor
end
215
 
216
 
217 42 mohor
// Late Collision
218 15 mohor
 
219 42 mohor
reg RxLateCollision;
220
reg RxColWindow;
221
// Collision Window
222 15 mohor
always @ (posedge MRxClk or posedge Reset)
223
begin
224
  if(Reset)
225 42 mohor
    RxLateCollision <=#Tp 1'b0;
226 15 mohor
  else
227 42 mohor
  if(LoadRxStatus)
228
    RxLateCollision <=#Tp 1'b0;
229
  else
230
  if(Collision & (~RxColWindow | r_RecSmall))
231
    RxLateCollision <=#Tp 1'b1;
232 15 mohor
end
233
 
234 42 mohor
// Collision Window
235
always @ (posedge MRxClk or posedge Reset)
236
begin
237
  if(Reset)
238
    RxColWindow <=#Tp 1'b1;
239
  else
240
  if(~Collision & RxByteCnt[5:0] == CollValid[5:0] & RxStateData[1])
241
    RxColWindow <=#Tp 1'b0;
242
  else
243
  if(RxStateIdle)
244
    RxColWindow <=#Tp 1'b1;
245
end
246 15 mohor
 
247 42 mohor
 
248
// ShortFrame
249
reg ShortFrame;
250
always @ (posedge MRxClk or posedge Reset)
251
begin
252
  if(Reset)
253
    ShortFrame <=#Tp 1'b0;
254
  else
255
  if(LoadRxStatus)
256
    ShortFrame <=#Tp 1'b0;
257
  else
258
  if(TakeSample)
259
    ShortFrame <=#Tp r_RecSmall & RxByteCnt[15:0] < r_MinFL[15:0];
260
end
261
 
262
 
263
// DribbleNibble
264
reg DribbleNibble;
265
always @ (posedge MRxClk or posedge Reset)
266
begin
267
  if(Reset)
268
    DribbleNibble <=#Tp 1'b0;
269
  else
270
  if(RxStateSFD)
271
    DribbleNibble <=#Tp 1'b0;
272
  else
273
  if(~MRxDV & RxStateData[1])
274
    DribbleNibble <=#Tp 1'b1;
275
end
276
 
277
 
278
reg ReceivedPacketTooBig;
279
assign ReceivedLengthOK = RxByteCnt[15:0] > 63 & RxByteCnt[15:0] < 1519;
280
always @ (posedge MRxClk or posedge Reset)
281
begin
282
  if(Reset)
283
    ReceivedPacketTooBig <=#Tp 1'b0;
284
  else
285
  if(LoadRxStatus)
286
    ReceivedPacketTooBig <=#Tp 1'b0;
287
  else
288
  if(TakeSample)
289
    ReceivedPacketTooBig <=#Tp ~r_HugEn & RxByteCnt[15:0] > r_MaxFL[15:0];
290
end
291
 
292 15 mohor
endmodule

powered by: WebSVN 2.1.0

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