1 |
15 |
mohor |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// eth_txethmac.v ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the Ethernet IP core project ////
|
6 |
|
|
//// http://www.opencores.org/cores/ethmac/ ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Author(s): ////
|
9 |
|
|
//// - Igor Mohor (igorM@opencores.org) ////
|
10 |
|
|
//// - Novan Hartadi (novan@vlsi.itb.ac.id) ////
|
11 |
|
|
//// - Mahmud Galela (mgalela@vlsi.itb.ac.id) ////
|
12 |
|
|
//// ////
|
13 |
|
|
//// All additional information is avaliable in the Readme.txt ////
|
14 |
|
|
//// file. ////
|
15 |
|
|
//// ////
|
16 |
|
|
//////////////////////////////////////////////////////////////////////
|
17 |
|
|
//// ////
|
18 |
|
|
//// Copyright (C) 2001 Authors ////
|
19 |
|
|
//// ////
|
20 |
|
|
//// This source file may be used and distributed without ////
|
21 |
|
|
//// restriction provided that this copyright statement is not ////
|
22 |
|
|
//// removed from the file and that any derivative work contains ////
|
23 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
24 |
|
|
//// ////
|
25 |
|
|
//// This source file is free software; you can redistribute it ////
|
26 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
27 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
28 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
29 |
|
|
//// later version. ////
|
30 |
|
|
//// ////
|
31 |
|
|
//// This source is distributed in the hope that it will be ////
|
32 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
33 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
34 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
35 |
|
|
//// details. ////
|
36 |
|
|
//// ////
|
37 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
38 |
|
|
//// Public License along with this source; if not, download it ////
|
39 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
40 |
|
|
//// ////
|
41 |
|
|
//////////////////////////////////////////////////////////////////////
|
42 |
|
|
//
|
43 |
|
|
// CVS Revision History
|
44 |
|
|
//
|
45 |
|
|
// $Log: not supported by cvs2svn $
|
46 |
|
|
// Revision 1.1 2001/07/30 21:23:42 mohor
|
47 |
|
|
// Directory structure changed. Files checked and joind together.
|
48 |
|
|
//
|
49 |
|
|
// Revision 1.3 2001/06/19 18:16:40 mohor
|
50 |
|
|
// TxClk changed to MTxClk (as discribed in the documentation).
|
51 |
|
|
// Crc changed so only one file can be used instead of two.
|
52 |
|
|
//
|
53 |
|
|
// Revision 1.2 2001/06/19 10:38:08 mohor
|
54 |
|
|
// Minor changes in header.
|
55 |
|
|
//
|
56 |
|
|
// Revision 1.1 2001/06/19 10:27:58 mohor
|
57 |
|
|
// TxEthMAC initial release.
|
58 |
|
|
//
|
59 |
|
|
//
|
60 |
|
|
//
|
61 |
|
|
|
62 |
|
|
`include "eth_timescale.v"
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
module eth_txethmac (MTxClk, Reset, TxStartFrm, TxEndFrm, TxUnderRun, TxData, CarrierSense,
|
66 |
|
|
Collision, Pad, CrcEn, FullD, HugEn, DlyCrcEn, MinFL, MaxFL, IPGT,
|
67 |
|
|
IPGR1, IPGR2, CollValid, MaxRet, NoBckof, ExDfrEn,
|
68 |
|
|
MTxD, MTxEn, MTxErr, TxDone, TxRetry, TxAbort, TxUsedData, WillTransmit,
|
69 |
|
|
ResetCollision
|
70 |
|
|
);
|
71 |
|
|
|
72 |
|
|
parameter Tp = 1;
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
input MTxClk; // Transmit clock (from PHY)
|
76 |
|
|
input Reset; // Reset
|
77 |
|
|
input TxStartFrm; // Transmit packet start frame
|
78 |
|
|
input TxEndFrm; // Transmit packet end frame
|
79 |
|
|
input TxUnderRun; // Transmit packet under-run
|
80 |
|
|
input [7:0] TxData; // Transmit packet data byte
|
81 |
|
|
input CarrierSense; // Carrier sense (synchronized)
|
82 |
|
|
input Collision; // Collision (synchronized)
|
83 |
|
|
input Pad; // Pad enable (from register)
|
84 |
|
|
input CrcEn; // Crc enable (from register)
|
85 |
|
|
input FullD; // Full duplex (from register)
|
86 |
|
|
input HugEn; // Huge packets enable (from register)
|
87 |
|
|
input DlyCrcEn; // Delayed Crc enabled (from register)
|
88 |
|
|
input [15:0] MinFL; // Minimum frame length (from register)
|
89 |
|
|
input [15:0] MaxFL; // Maximum frame length (from register)
|
90 |
|
|
input [6:0] IPGT; // Back to back transmit inter packet gap parameter (from register)
|
91 |
|
|
input [6:0] IPGR1; // Non back to back transmit inter packet gap parameter IPGR1 (from register)
|
92 |
|
|
input [6:0] IPGR2; // Non back to back transmit inter packet gap parameter IPGR2 (from register)
|
93 |
|
|
input [5:0] CollValid; // Valid collision window (from register)
|
94 |
|
|
input [3:0] MaxRet; // Maximum retry number (from register)
|
95 |
|
|
input NoBckof; // No backoff (from register)
|
96 |
|
|
input ExDfrEn; // Excessive defferal enable (from register)
|
97 |
|
|
|
98 |
|
|
output [3:0] MTxD; // Transmit nibble (to PHY)
|
99 |
|
|
output MTxEn; // Transmit enable (to PHY)
|
100 |
|
|
output MTxErr; // Transmit error (to PHY)
|
101 |
|
|
output TxDone; // Transmit packet done (to RISC)
|
102 |
|
|
output TxRetry; // Transmit packet retry (to RISC)
|
103 |
|
|
output TxAbort; // Transmit packet abort (to RISC)
|
104 |
|
|
output TxUsedData; // Transmit packet used data (to RISC)
|
105 |
|
|
output WillTransmit; // Will transmit (to RxEthMAC)
|
106 |
|
|
output ResetCollision; // Reset Collision (for synchronizing collision)
|
107 |
|
|
|
108 |
|
|
reg [3:0] MTxD;
|
109 |
|
|
reg MTxEn;
|
110 |
|
|
reg MTxErr;
|
111 |
|
|
reg TxDone;
|
112 |
|
|
reg TxRetry;
|
113 |
|
|
reg TxAbort;
|
114 |
|
|
reg TxUsedData;
|
115 |
|
|
reg WillTransmit;
|
116 |
|
|
reg ColWindow;
|
117 |
|
|
reg StopExcessiveDeferOccured;
|
118 |
|
|
reg [3:0] RetryCnt;
|
119 |
|
|
reg [3:0] MTxD_d;
|
120 |
|
|
reg StatusLatch;
|
121 |
|
|
reg PacketFinished_q;
|
122 |
|
|
reg PacketFinished;
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
wire ExcessiveDeferOccured;
|
126 |
|
|
wire StartDefer;
|
127 |
|
|
wire StartIPG;
|
128 |
|
|
wire StartPreamble;
|
129 |
|
|
wire [1:0] StartData;
|
130 |
|
|
wire StartFCS;
|
131 |
|
|
wire StartJam;
|
132 |
|
|
wire StartBackoff;
|
133 |
|
|
wire StateDefer;
|
134 |
|
|
wire StateIPG;
|
135 |
|
|
wire StateIdle;
|
136 |
|
|
wire StatePreamble;
|
137 |
|
|
wire [1:0] StateData;
|
138 |
|
|
wire StatePAD;
|
139 |
|
|
wire StateFCS;
|
140 |
|
|
wire StateJam;
|
141 |
|
|
wire StateBackOff;
|
142 |
|
|
wire StateSFD;
|
143 |
|
|
wire StartTxRetry;
|
144 |
|
|
wire StartTxDone;
|
145 |
|
|
wire LateCollision;
|
146 |
|
|
wire MaxCollisionOccured;
|
147 |
|
|
wire UnderRun;
|
148 |
|
|
wire TooBig;
|
149 |
|
|
wire StartTxAbort;
|
150 |
|
|
wire [31:0] Crc;
|
151 |
|
|
wire CrcError;
|
152 |
|
|
wire [2:0] DlyCrcCnt;
|
153 |
|
|
wire [15:0] NibCnt;
|
154 |
|
|
wire NibCntEq7;
|
155 |
|
|
wire NibCntEq15;
|
156 |
|
|
wire NibbleMinFl;
|
157 |
|
|
wire ExcessiveDefer;
|
158 |
|
|
wire [15:0] ByteCnt;
|
159 |
|
|
wire MaxFrame;
|
160 |
|
|
wire RetryMax;
|
161 |
|
|
wire RandomEq0;
|
162 |
|
|
wire RandomEqByteCnt;
|
163 |
|
|
wire PacketFinished_d;
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
assign ResetCollision = ~(StatePreamble | |StateData | StatePAD | StateFCS);
|
168 |
|
|
|
169 |
|
|
assign ExcessiveDeferOccured = TxStartFrm & StateDefer & ExcessiveDefer & ~StopExcessiveDeferOccured;
|
170 |
|
|
|
171 |
|
|
assign StartTxDone = ~Collision & (StateFCS & NibCntEq7 | StateData[1] & TxEndFrm & ~Pad & ~CrcEn);
|
172 |
|
|
|
173 |
|
|
assign UnderRun = StateData[0] & TxUnderRun & ~Collision;
|
174 |
|
|
|
175 |
|
|
assign TooBig = ~Collision & MaxFrame & (StateData[0] & ~TxUnderRun | StateFCS);
|
176 |
|
|
|
177 |
|
|
assign StartTxRetry = StartJam & (ColWindow & ~RetryMax);
|
178 |
|
|
|
179 |
|
|
assign LateCollision = StartJam & ~ColWindow & ~UnderRun;
|
180 |
|
|
|
181 |
|
|
assign MaxCollisionOccured = StartJam & ColWindow & RetryMax;
|
182 |
|
|
|
183 |
|
|
assign StateSFD = StatePreamble & NibCntEq15;
|
184 |
|
|
|
185 |
|
|
assign StartTxAbort = TooBig | UnderRun | ExcessiveDeferOccured | LateCollision | MaxCollisionOccured;
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
// StopExcessiveDeferOccured
|
189 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
190 |
|
|
begin
|
191 |
|
|
if(Reset)
|
192 |
|
|
StopExcessiveDeferOccured <= #Tp 1'b0;
|
193 |
|
|
else
|
194 |
|
|
begin
|
195 |
|
|
if(~TxStartFrm)
|
196 |
|
|
StopExcessiveDeferOccured <= #Tp 1'b0;
|
197 |
|
|
else
|
198 |
|
|
if(ExcessiveDeferOccured)
|
199 |
|
|
StopExcessiveDeferOccured <= #Tp 1'b1;
|
200 |
|
|
end
|
201 |
|
|
end
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
// Collision Window
|
205 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
206 |
|
|
begin
|
207 |
|
|
if(Reset)
|
208 |
|
|
ColWindow <= #Tp 1'b1;
|
209 |
|
|
else
|
210 |
|
|
begin
|
211 |
|
|
if(~Collision & ByteCnt[5:0] == CollValid[5:0] & (StateData[1] | StatePAD & NibCnt[0] | StateFCS & NibCnt[0]))
|
212 |
|
|
ColWindow <= #Tp 1'b0;
|
213 |
|
|
else
|
214 |
|
|
if(StateIdle | StateIPG)
|
215 |
|
|
ColWindow <= #Tp 1'b1;
|
216 |
|
|
end
|
217 |
|
|
end
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
// Start Window
|
221 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
222 |
|
|
begin
|
223 |
|
|
if(Reset)
|
224 |
|
|
StatusLatch <= #Tp 1'b0;
|
225 |
|
|
else
|
226 |
|
|
begin
|
227 |
|
|
if(~TxStartFrm)
|
228 |
|
|
StatusLatch <= #Tp 1'b0;
|
229 |
|
|
else
|
230 |
|
|
if(ExcessiveDeferOccured | StateIdle)
|
231 |
|
|
StatusLatch <= #Tp 1'b1;
|
232 |
|
|
end
|
233 |
|
|
end
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
// Transmit packet used data
|
237 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
238 |
|
|
begin
|
239 |
|
|
if(Reset)
|
240 |
|
|
TxUsedData <= #Tp 1'b0;
|
241 |
|
|
else
|
242 |
|
|
TxUsedData <= #Tp |StartData;
|
243 |
|
|
end
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
// Transmit packet done
|
247 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
248 |
|
|
begin
|
249 |
|
|
if(Reset)
|
250 |
|
|
TxDone <= #Tp 1'b0;
|
251 |
|
|
else
|
252 |
|
|
begin
|
253 |
|
|
if(TxStartFrm & ~StatusLatch)
|
254 |
|
|
TxDone <= #Tp 1'b0;
|
255 |
|
|
else
|
256 |
|
|
if(StartTxDone)
|
257 |
|
|
TxDone <= #Tp 1'b1;
|
258 |
|
|
end
|
259 |
|
|
end
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
// Transmit packet retry
|
263 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
264 |
|
|
begin
|
265 |
|
|
if(Reset)
|
266 |
|
|
TxRetry <= #Tp 1'b0;
|
267 |
|
|
else
|
268 |
|
|
begin
|
269 |
|
|
if(TxStartFrm & ~StatusLatch)
|
270 |
|
|
TxRetry <= #Tp 1'b0;
|
271 |
|
|
else
|
272 |
|
|
if(StartTxRetry)
|
273 |
|
|
TxRetry <= #Tp 1'b1;
|
274 |
|
|
end
|
275 |
|
|
end
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
// Transmit packet abort
|
279 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
280 |
|
|
begin
|
281 |
|
|
if(Reset)
|
282 |
|
|
TxAbort <= #Tp 1'b0;
|
283 |
|
|
else
|
284 |
|
|
begin
|
285 |
|
|
if(TxStartFrm & ~StatusLatch & ~ExcessiveDeferOccured)
|
286 |
|
|
TxAbort <= #Tp 1'b0;
|
287 |
|
|
else
|
288 |
|
|
if(StartTxAbort)
|
289 |
|
|
TxAbort <= #Tp 1'b1;
|
290 |
|
|
end
|
291 |
|
|
end
|
292 |
|
|
|
293 |
|
|
|
294 |
|
|
// Retry counter
|
295 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
296 |
|
|
begin
|
297 |
|
|
if(Reset)
|
298 |
|
|
RetryCnt[3:0] <= #Tp 4'h0;
|
299 |
|
|
else
|
300 |
|
|
begin
|
301 |
|
|
if(ExcessiveDeferOccured | UnderRun | TooBig | StartTxDone | TxUnderRun
|
302 |
|
|
| StateJam & NibCntEq7 & (~ColWindow | RetryMax))
|
303 |
|
|
RetryCnt[3:0] <= #Tp 4'h0;
|
304 |
|
|
else
|
305 |
|
|
if(StateJam & NibCntEq7 & ColWindow & (RandomEq0 | NoBckof) | StateBackOff & RandomEqByteCnt)
|
306 |
|
|
RetryCnt[3:0] <= #Tp RetryCnt[3:0] + 1'b1;
|
307 |
|
|
end
|
308 |
|
|
end
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
assign RetryMax = RetryCnt[3:0] == MaxRet[3:0];
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
// Transmit nibble
|
315 |
|
|
always @ (StatePreamble or StateData or StateData or StateFCS or StateJam or StateSFD or TxData or
|
316 |
|
|
Crc or NibCnt or NibCntEq15)
|
317 |
|
|
begin
|
318 |
|
|
if(StateData[0])
|
319 |
|
|
MTxD_d[3:0] = TxData[3:0]; // Lower nibble
|
320 |
|
|
else
|
321 |
|
|
if(StateData[1])
|
322 |
|
|
MTxD_d[3:0] = TxData[7:4]; // Higher nibble
|
323 |
|
|
else
|
324 |
|
|
if(StateFCS)
|
325 |
|
|
MTxD_d[3:0] = {~Crc[28], ~Crc[29], ~Crc[30], ~Crc[31]}; // Crc
|
326 |
|
|
else
|
327 |
|
|
if(StateJam)
|
328 |
|
|
MTxD_d[3:0] = 4'h9; // Jam pattern
|
329 |
|
|
else
|
330 |
|
|
if(StatePreamble)
|
331 |
|
|
if(NibCntEq15)
|
332 |
|
|
MTxD_d[3:0] = 4'hd; // SFD
|
333 |
|
|
else
|
334 |
|
|
MTxD_d[3:0] = 4'h5; // Preamble
|
335 |
|
|
else
|
336 |
|
|
MTxD_d[3:0] = 4'h0;
|
337 |
|
|
end
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
// Transmit Enable
|
341 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
342 |
|
|
begin
|
343 |
|
|
if(Reset)
|
344 |
|
|
MTxEn <= #Tp 1'b0;
|
345 |
|
|
else
|
346 |
|
|
MTxEn <= #Tp StatePreamble | |StateData | StatePAD | StateFCS | StateJam;
|
347 |
|
|
end
|
348 |
|
|
|
349 |
|
|
|
350 |
|
|
// Transmit nibble
|
351 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
352 |
|
|
begin
|
353 |
|
|
if(Reset)
|
354 |
|
|
MTxD[3:0] <= #Tp 4'h0;
|
355 |
|
|
else
|
356 |
|
|
MTxD[3:0] <= #Tp MTxD_d[3:0];
|
357 |
|
|
end
|
358 |
|
|
|
359 |
|
|
|
360 |
|
|
// Transmit error
|
361 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
362 |
|
|
begin
|
363 |
|
|
if(Reset)
|
364 |
|
|
MTxErr <= #Tp 1'b0;
|
365 |
|
|
else
|
366 |
|
|
MTxErr <= #Tp TooBig | UnderRun;
|
367 |
|
|
end
|
368 |
|
|
|
369 |
|
|
|
370 |
|
|
// WillTransmit
|
371 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
372 |
|
|
begin
|
373 |
|
|
if(Reset)
|
374 |
|
|
WillTransmit <= #Tp 1'b0;
|
375 |
|
|
else
|
376 |
|
|
WillTransmit <= #Tp StartPreamble | StatePreamble | |StateData | StatePAD | StateFCS | StateJam;
|
377 |
|
|
end
|
378 |
|
|
|
379 |
|
|
|
380 |
|
|
assign PacketFinished_d = StartTxDone | TooBig | UnderRun | LateCollision | MaxCollisionOccured | ExcessiveDeferOccured;
|
381 |
|
|
|
382 |
|
|
|
383 |
|
|
// Packet finished
|
384 |
|
|
always @ (posedge MTxClk or posedge Reset)
|
385 |
|
|
begin
|
386 |
|
|
if(Reset)
|
387 |
|
|
begin
|
388 |
|
|
PacketFinished <= #Tp 1'b0;
|
389 |
|
|
PacketFinished_q <= #Tp 1'b0;
|
390 |
|
|
end
|
391 |
|
|
else
|
392 |
|
|
begin
|
393 |
|
|
PacketFinished <= #Tp PacketFinished_d;
|
394 |
|
|
PacketFinished_q <= #Tp PacketFinished;
|
395 |
|
|
end
|
396 |
|
|
end
|
397 |
|
|
|
398 |
|
|
|
399 |
|
|
// Connecting module Counters
|
400 |
|
|
eth_txcounters txcounters1 (.StatePreamble(StatePreamble), .StateIPG(StateIPG), .StateData(StateData),
|
401 |
|
|
.StatePAD(StatePAD), .StateFCS(StateFCS), .StateJam(StateJam), .StateBackOff(StateBackOff),
|
402 |
|
|
.StateDefer(StateDefer), .StateIdle(StateIdle), .StartDefer(StartDefer), .StartIPG(StartIPG),
|
403 |
|
|
.StartFCS(StartFCS), .StartJam(StartJam), .TxStartFrm(TxStartFrm), .MTxClk(MTxClk),
|
404 |
|
|
.Reset(Reset), .MinFL(MinFL), .MaxFL(MaxFL), .HugEn(HugEn), .ExDfrEn(ExDfrEn),
|
405 |
|
|
.PacketFinished_q(PacketFinished_q), .DlyCrcEn(DlyCrcEn), .StartBackoff(StartBackoff),
|
406 |
|
|
.StateSFD(StateSFD), .ByteCnt(ByteCnt), .NibCnt(NibCnt), .ExcessiveDefer(ExcessiveDefer),
|
407 |
|
|
.NibCntEq7(NibCntEq7), .NibCntEq15(NibCntEq15), .MaxFrame(MaxFrame), .NibbleMinFl(NibbleMinFl),
|
408 |
|
|
.DlyCrcCnt(DlyCrcCnt)
|
409 |
|
|
);
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
// Connecting module StateM
|
413 |
|
|
eth_txstatem txstatem1 (.MTxClk(MTxClk), .Reset(Reset), .ExcessiveDefer(ExcessiveDefer), .CarrierSense(CarrierSense),
|
414 |
|
|
.NibCnt(NibCnt[6:0]), .IPGT(IPGT), .IPGR1(IPGR1), .IPGR2(IPGR2), .FullD(FullD),
|
415 |
|
|
.TxStartFrm(TxStartFrm), .TxEndFrm(TxEndFrm), .TxUnderRun(TxUnderRun), .Collision(Collision),
|
416 |
|
|
.UnderRun(UnderRun), .StartTxDone(StartTxDone), .TooBig(TooBig), .NibCntEq7(NibCntEq7),
|
417 |
|
|
.NibCntEq15(NibCntEq15), .MaxFrame(MaxFrame), .Pad(Pad), .CrcEn(CrcEn),
|
418 |
|
|
.NibbleMinFl(NibbleMinFl), .RandomEq0(RandomEq0), .ColWindow(ColWindow), .RetryMax(RetryMax),
|
419 |
|
|
.NoBckof(NoBckof), .RandomEqByteCnt(RandomEqByteCnt), .StateIdle(StateIdle),
|
420 |
|
|
.StateIPG(StateIPG), .StatePreamble(StatePreamble), .StateData(StateData), .StatePAD(StatePAD),
|
421 |
|
|
.StateFCS(StateFCS), .StateJam(StateJam), .StateJam_q(StateJam_q), .StateBackOff(StateBackOff),
|
422 |
|
|
.StateDefer(StateDefer), .StartFCS(StartFCS), .StartJam(StartJam), .StartBackoff(StartBackoff),
|
423 |
|
|
.StartDefer(StartDefer), .StartPreamble(StartPreamble), .StartData(StartData), .StartIPG(StartIPG)
|
424 |
|
|
);
|
425 |
|
|
|
426 |
|
|
|
427 |
|
|
wire Enable_Crc;
|
428 |
|
|
wire [3:0] Data_Crc;
|
429 |
|
|
wire Initialize_Crc;
|
430 |
|
|
|
431 |
|
|
assign Enable_Crc = ~StateFCS;
|
432 |
|
|
|
433 |
|
|
assign Data_Crc[0] = StateData[0]? TxData[3] : StateData[1]? TxData[7] : 1'b0;
|
434 |
|
|
assign Data_Crc[1] = StateData[0]? TxData[2] : StateData[1]? TxData[6] : 1'b0;
|
435 |
|
|
assign Data_Crc[2] = StateData[0]? TxData[1] : StateData[1]? TxData[5] : 1'b0;
|
436 |
|
|
assign Data_Crc[3] = StateData[0]? TxData[0] : StateData[1]? TxData[4] : 1'b0;
|
437 |
|
|
|
438 |
|
|
assign Initialize_Crc = StateIdle | StatePreamble | |DlyCrcCnt;
|
439 |
|
|
|
440 |
|
|
|
441 |
|
|
// Connecting module Crc
|
442 |
|
|
eth_crc txcrc (.Clk(MTxClk), .Reset(Reset), .Data(Data_Crc), .Enable(Enable_Crc), .Initialize(Initialize_Crc),
|
443 |
|
|
.Crc(Crc), .CrcError(CrcError)
|
444 |
|
|
);
|
445 |
|
|
|
446 |
|
|
|
447 |
|
|
// Connecting module Random
|
448 |
|
|
eth_random random1 (.MTxClk(MTxClk), .Reset(Reset), .StateJam(StateJam), .StateJam_q(StateJam_q), .RetryCnt(RetryCnt),
|
449 |
|
|
.NibCnt(NibCnt), .ByteCnt(ByteCnt[9:0]), .RandomEq0(RandomEq0), .RandomEqByteCnt(RandomEqByteCnt));
|
450 |
|
|
|
451 |
|
|
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
endmodule
|