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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_wishbone.v] - Blame information for rev 278

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_wishbone.v                                              ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/projects/ethmac/                   ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Igor Mohor (igorM@opencores.org)                      ////
10
////                                                              ////
11 166 mohor
////  All additional information is available in the Readme.txt   ////
12 38 mohor
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16 118 mohor
//// Copyright (C) 2001, 2002 Authors                             ////
17 38 mohor
////                                                              ////
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 278 mohor
// Revision 1.50  2003/01/22 13:49:26  tadejm
45
// When control packets were received, they were ignored in some cases.
46
//
47 272 tadejm
// Revision 1.49  2003/01/21 12:09:40  mohor
48
// When receiving normal data frame and RxFlow control was switched on, RXB
49
// interrupt was not set.
50
//
51 270 mohor
// Revision 1.48  2003/01/20 12:05:26  mohor
52
// When in full duplex, transmit was sometimes blocked. Fixed.
53
//
54 269 mohor
// Revision 1.47  2002/11/22 13:26:21  mohor
55
// Registers RxStatusWrite_rck and RxStatusWriteLatched were not used
56
// anywhere. Removed.
57
//
58 264 mohor
// Revision 1.46  2002/11/22 01:57:06  mohor
59
// Rx Flow control fixed. CF flag added to the RX buffer descriptor. RxAbort
60
// synchronized.
61
//
62 261 mohor
// Revision 1.45  2002/11/19 17:33:34  mohor
63
// AddressMiss status is connecting to the Rx BD. AddressMiss is identifying
64
// that a frame was received because of the promiscous mode.
65
//
66 250 mohor
// Revision 1.44  2002/11/13 22:21:40  tadejm
67
// RxError is not generated when small frame reception is enabled and small
68
// frames are received.
69
//
70 239 tadejm
// Revision 1.43  2002/10/18 20:53:34  mohor
71
// case changed to casex.
72
//
73 229 mohor
// Revision 1.42  2002/10/18 17:04:20  tadejm
74
// Changed BIST scan signals.
75
//
76 227 tadejm
// Revision 1.41  2002/10/18 15:42:09  tadejm
77
// Igor added WB burst support and repaired BUG when handling TX under-run and retry.
78
//
79 226 tadejm
// Revision 1.40  2002/10/14 16:07:02  mohor
80
// TxStatus is written after last access to the TX fifo is finished (in case of abort
81
// or retry). TxDone is fixed.
82
//
83 221 mohor
// Revision 1.39  2002/10/11 15:35:20  mohor
84
// txfifo_cnt and rxfifo_cnt counters width is defined in the eth_define.v file,
85
// TxDone and TxRetry are generated after the current WISHBONE access is
86
// finished.
87
//
88 219 mohor
// Revision 1.38  2002/10/10 16:29:30  mohor
89
// BIST added.
90
//
91 210 mohor
// Revision 1.37  2002/09/11 14:18:46  mohor
92
// Sometimes both RxB_IRQ and RxE_IRQ were activated. Bug fixed.
93
//
94 167 mohor
// Revision 1.36  2002/09/10 13:48:46  mohor
95
// Reception is possible after RxPointer is read and not after BD is read. For
96
// that reason RxBDReady is changed to RxReady.
97
// Busy_IRQ interrupt connected. When there is no RxBD ready and frame
98
// comes, interrupt is generated.
99
//
100 166 mohor
// Revision 1.35  2002/09/10 10:35:23  mohor
101
// Ethernet debug registers removed.
102
//
103 164 mohor
// Revision 1.34  2002/09/08 16:31:49  mohor
104
// Async reset for WB_ACK_O removed (when core was in reset, it was
105
// impossible to access BDs).
106
// RxPointers and TxPointers names changed to be more descriptive.
107
// TxUnderRun synchronized.
108
//
109 159 mohor
// Revision 1.33  2002/09/04 18:47:57  mohor
110
// Debug registers reg1, 2, 3, 4 connected. Synchronization of many signals
111
// changed (bugs fixed). Access to un-alligned buffers fixed. RxAbort signal
112
// was not used OK.
113
//
114 150 mohor
// Revision 1.32  2002/08/14 19:31:48  mohor
115
// Register TX_BD_NUM is changed so it contains value of the Tx buffer descriptors. No
116
// need to multiply or devide any more.
117
//
118 134 mohor
// Revision 1.31  2002/07/25 18:29:01  mohor
119
// WriteRxDataToMemory signal changed so end of frame (when last word is
120
// written to fifo) is changed.
121
//
122 127 mohor
// Revision 1.30  2002/07/23 15:28:31  mohor
123
// Ram , used for BDs changed from generic_spram to eth_spram_256x32.
124
//
125 119 mohor
// Revision 1.29  2002/07/20 00:41:32  mohor
126
// ShiftEnded synchronization changed.
127
//
128 118 mohor
// Revision 1.28  2002/07/18 16:11:46  mohor
129
// RxBDAddress takes `ETH_TX_BD_NUM_DEF value after reset.
130
//
131 115 mohor
// Revision 1.27  2002/07/11 02:53:20  mohor
132
// RxPointer bug fixed.
133
//
134 113 mohor
// Revision 1.26  2002/07/10 13:12:38  mohor
135
// Previous bug wasn't succesfully removed. Now fixed.
136
//
137 112 mohor
// Revision 1.25  2002/07/09 23:53:24  mohor
138
// Master state machine had a bug when switching from master write to
139
// master read.
140
//
141 111 mohor
// Revision 1.24  2002/07/09 20:44:41  mohor
142
// m_wb_cyc_o signal released after every single transfer.
143
//
144 110 mohor
// Revision 1.23  2002/05/03 10:15:50  mohor
145
// Outputs registered. Reset changed for eth_wishbone module.
146
//
147 106 mohor
// Revision 1.22  2002/04/24 08:52:19  mohor
148
// Compiler directives added. Tx and Rx fifo size incremented. A "late collision"
149
// bug fixed.
150
//
151 105 mohor
// Revision 1.21  2002/03/29 16:18:11  lampret
152
// Small typo fixed.
153
//
154 97 lampret
// Revision 1.20  2002/03/25 16:19:12  mohor
155
// Any address can be used for Tx and Rx BD pointers. Address does not need
156
// to be aligned.
157
//
158 96 mohor
// Revision 1.19  2002/03/19 12:51:50  mohor
159
// Comments in Slovene language removed.
160
//
161 91 mohor
// Revision 1.18  2002/03/19 12:46:52  mohor
162
// casex changed with case, fifo reset changed.
163
//
164 90 mohor
// Revision 1.17  2002/03/09 16:08:45  mohor
165
// rx_fifo was not always cleared ok. Fixed.
166
//
167 88 mohor
// Revision 1.16  2002/03/09 13:51:20  mohor
168
// Status was not latched correctly sometimes. Fixed.
169
//
170 87 mohor
// Revision 1.15  2002/03/08 06:56:46  mohor
171
// Big Endian problem when sending frames fixed.
172
//
173 86 mohor
// Revision 1.14  2002/03/02 19:12:40  mohor
174
// Byte ordering changed (Big Endian used). casex changed with case because
175
// Xilinx Foundation had problems. Tested in HW. It WORKS.
176
//
177 82 mohor
// Revision 1.13  2002/02/26 16:59:55  mohor
178
// Small fixes for external/internal DMA missmatches.
179
//
180 80 mohor
// Revision 1.12  2002/02/26 16:22:07  mohor
181
// Interrupts changed
182
//
183 77 mohor
// Revision 1.11  2002/02/15 17:07:39  mohor
184
// Status was not written correctly when frames were discarted because of
185
// address mismatch.
186
//
187 64 mohor
// Revision 1.10  2002/02/15 12:17:39  mohor
188
// RxStartFrm cleared when abort or retry comes.
189
//
190 61 mohor
// Revision 1.9  2002/02/15 11:59:10  mohor
191
// Changes that were lost when updating from 1.5 to 1.8 fixed.
192
//
193 60 mohor
// Revision 1.8  2002/02/14 20:54:33  billditt
194
// Addition  of new module eth_addrcheck.v
195
//
196
// Revision 1.7  2002/02/12 17:03:47  mohor
197
// RxOverRun added to statuses.
198
//
199
// Revision 1.6  2002/02/11 09:18:22  mohor
200
// Tx status is written back to the BD.
201
//
202 43 mohor
// Revision 1.5  2002/02/08 16:21:54  mohor
203
// Rx status is written back to the BD.
204
//
205 42 mohor
// Revision 1.4  2002/02/06 14:10:21  mohor
206
// non-DMA host interface added. Select the right configutation in eth_defines.
207
//
208 41 mohor
// Revision 1.3  2002/02/05 16:44:39  mohor
209
// Both rx and tx part are finished. Tested with wb_clk_i between 10 and 200
210
// MHz. Statuses, overrun, control frame transmission and reception still  need
211
// to be fixed.
212
//
213 40 mohor
// Revision 1.2  2002/02/01 12:46:51  mohor
214
// Tx part finished. TxStatus needs to be fixed. Pause request needs to be
215
// added.
216
//
217 39 mohor
// Revision 1.1  2002/01/23 10:47:59  mohor
218
// Initial version. Equals to eth_wishbonedma.v at this moment.
219 38 mohor
//
220
//
221
//
222
 
223
`include "eth_defines.v"
224
`include "timescale.v"
225
 
226
 
227
module eth_wishbone
228
   (
229
 
230
    // WISHBONE common
231 40 mohor
    WB_CLK_I, WB_DAT_I, WB_DAT_O,
232 38 mohor
 
233
    // WISHBONE slave
234 77 mohor
                WB_ADR_I, WB_WE_I, WB_ACK_O,
235 40 mohor
    BDCs,
236 38 mohor
 
237 40 mohor
    Reset,
238
 
239 39 mohor
    // WISHBONE master
240
    m_wb_adr_o, m_wb_sel_o, m_wb_we_o,
241
    m_wb_dat_o, m_wb_dat_i, m_wb_cyc_o,
242
    m_wb_stb_o, m_wb_ack_i, m_wb_err_i,
243
 
244 219 mohor
`ifdef ETH_WISHBONE_B3
245
    m_wb_cti_o, m_wb_bte_o,
246
`endif
247
 
248 38 mohor
    //TX
249 60 mohor
    MTxClk, TxStartFrm, TxEndFrm, TxUsedData, TxData,
250 150 mohor
    TxRetry, TxAbort, TxUnderRun, TxDone, PerPacketCrcEn,
251 38 mohor
    PerPacketPad,
252
 
253
    //RX
254 272 tadejm
    MRxClk, RxData, RxValid, RxStartFrm, RxEndFrm, RxAbort, RxStatusWriteLatched_sync2,
255 38 mohor
 
256
    // Register
257 270 mohor
    r_TxEn, r_RxEn, r_TxBDNum, TX_BD_NUM_Wr, r_RxFlow, r_PassAll,
258 38 mohor
 
259
    // Interrupts
260 150 mohor
    TxB_IRQ, TxE_IRQ, RxB_IRQ, RxE_IRQ, Busy_IRQ,
261 42 mohor
 
262 60 mohor
    // Rx Status
263 42 mohor
    InvalidSymbol, LatchedCrcError, RxLateCollision, ShortFrame, DribbleNibble,
264 250 mohor
    ReceivedPacketTooBig, RxLength, LoadRxStatus, ReceivedPacketGood, AddressMiss,
265 261 mohor
    ReceivedPauseFrm,
266 60 mohor
 
267
    // Tx Status
268 164 mohor
    RetryCntLatched, RetryLimit, LateCollLatched, DeferLatched, CarrierSenseLost
269
 
270 210 mohor
    // Bist
271
`ifdef ETH_BIST
272 227 tadejm
    ,
273
    // debug chain signals
274
    scanb_rst,      // bist scan reset
275
    scanb_clk,      // bist scan clock
276
    scanb_si,       // bist scan serial in
277
    scanb_so,       // bist scan serial out
278
    scanb_en        // bist scan shift enable
279 210 mohor
`endif
280
 
281
 
282
 
283 38 mohor
                );
284
 
285
 
286
parameter Tp = 1;
287
 
288 150 mohor
 
289 38 mohor
// WISHBONE common
290
input           WB_CLK_I;       // WISHBONE clock
291
input  [31:0]   WB_DAT_I;       // WISHBONE data input
292
output [31:0]   WB_DAT_O;       // WISHBONE data output
293
 
294
// WISHBONE slave
295
input   [9:2]   WB_ADR_I;       // WISHBONE address input
296
input           WB_WE_I;        // WISHBONE write enable input
297
input           BDCs;           // Buffer descriptors are selected
298
output          WB_ACK_O;       // WISHBONE acknowledge output
299
 
300 39 mohor
// WISHBONE master
301
output  [31:0]  m_wb_adr_o;     // 
302
output   [3:0]  m_wb_sel_o;     // 
303
output          m_wb_we_o;      // 
304
output  [31:0]  m_wb_dat_o;     // 
305
output          m_wb_cyc_o;     // 
306
output          m_wb_stb_o;     // 
307
input   [31:0]  m_wb_dat_i;     // 
308
input           m_wb_ack_i;     // 
309
input           m_wb_err_i;     // 
310
 
311 219 mohor
`ifdef ETH_WISHBONE_B3
312
output   [2:0]  m_wb_cti_o;     // Cycle Type Identifier
313
output   [1:0]  m_wb_bte_o;     // Burst Type Extension
314
reg      [2:0]  m_wb_cti_o;     // Cycle Type Identifier
315
`endif
316
 
317 40 mohor
input           Reset;       // Reset signal
318 39 mohor
 
319 60 mohor
// Rx Status signals
320 42 mohor
input           InvalidSymbol;    // Invalid symbol was received during reception in 100 Mbps mode
321
input           LatchedCrcError;  // CRC error
322
input           RxLateCollision;  // Late collision occured while receiving frame
323
input           ShortFrame;       // Frame shorter then the minimum size (r_MinFL) was received while small packets are enabled (r_RecSmall)
324
input           DribbleNibble;    // Extra nibble received
325
input           ReceivedPacketTooBig;// Received packet is bigger than r_MaxFL
326
input    [15:0] RxLength;         // Length of the incoming frame
327
input           LoadRxStatus;     // Rx status was loaded
328 77 mohor
input           ReceivedPacketGood;// Received packet's length and CRC are good
329 250 mohor
input           AddressMiss;      // When a packet is received AddressMiss status is written to the Rx BD
330 261 mohor
input           r_RxFlow;
331 270 mohor
input           r_PassAll;
332 261 mohor
input           ReceivedPauseFrm;
333 39 mohor
 
334 60 mohor
// Tx Status signals
335
input     [3:0] RetryCntLatched;  // Latched Retry Counter
336
input           RetryLimit;       // Retry limit reached (Retry Max value + 1 attempts were made)
337
input           LateCollLatched;  // Late collision occured
338
input           DeferLatched;     // Defer indication (Frame was defered before sucessfully sent)
339
input           CarrierSenseLost; // Carrier Sense was lost during the frame transmission
340
 
341 38 mohor
// Tx
342
input           MTxClk;         // Transmit clock (from PHY)
343
input           TxUsedData;     // Transmit packet used data
344
input           TxRetry;        // Transmit packet retry
345
input           TxAbort;        // Transmit packet abort
346
input           TxDone;         // Transmission ended
347
output          TxStartFrm;     // Transmit packet start frame
348
output          TxEndFrm;       // Transmit packet end frame
349
output  [7:0]   TxData;         // Transmit packet data byte
350
output          TxUnderRun;     // Transmit packet under-run
351
output          PerPacketCrcEn; // Per packet crc enable
352
output          PerPacketPad;   // Per packet pading
353
 
354
// Rx
355
input           MRxClk;         // Receive clock (from PHY)
356
input   [7:0]   RxData;         // Received data byte (from PHY)
357
input           RxValid;        // 
358
input           RxStartFrm;     // 
359
input           RxEndFrm;       // 
360 40 mohor
input           RxAbort;        // This signal is set when address doesn't match.
361 272 tadejm
output          RxStatusWriteLatched_sync2;
362 38 mohor
 
363
//Register
364
input           r_TxEn;         // Transmit enable
365
input           r_RxEn;         // Receive enable
366
input   [7:0]   r_TxBDNum;      // Receive buffer descriptor number
367
input           TX_BD_NUM_Wr;   // RxBDNumber written
368
 
369
// Interrupts
370
output TxB_IRQ;
371
output TxE_IRQ;
372
output RxB_IRQ;
373 77 mohor
output RxE_IRQ;
374 38 mohor
output Busy_IRQ;
375
 
376 77 mohor
 
377 210 mohor
// Bist
378
`ifdef ETH_BIST
379 227 tadejm
input   scanb_rst;      // bist scan reset
380
input   scanb_clk;      // bist scan clock
381
input   scanb_si;       // bist scan serial in
382
output  scanb_so;       // bist scan serial out
383
input   scanb_en;       // bist scan shift enable
384 210 mohor
`endif
385
 
386 77 mohor
reg TxB_IRQ;
387
reg TxE_IRQ;
388
reg RxB_IRQ;
389
reg RxE_IRQ;
390
 
391 38 mohor
reg             TxStartFrm;
392
reg             TxEndFrm;
393
reg     [7:0]   TxData;
394
 
395
reg             TxUnderRun;
396 60 mohor
reg             TxUnderRun_wb;
397 38 mohor
 
398
reg             TxBDRead;
399 39 mohor
wire            TxStatusWrite;
400 38 mohor
 
401
reg     [1:0]   TxValidBytesLatched;
402
 
403
reg    [15:0]   TxLength;
404 60 mohor
reg    [15:0]   LatchedTxLength;
405
reg   [14:11]   TxStatus;
406 38 mohor
 
407 60 mohor
reg   [14:13]   RxStatus;
408 38 mohor
 
409
reg             TxStartFrm_wb;
410
reg             TxRetry_wb;
411 39 mohor
reg             TxAbort_wb;
412 38 mohor
reg             TxDone_wb;
413
 
414
reg             TxDone_wb_q;
415
reg             TxAbort_wb_q;
416 39 mohor
reg             TxRetry_wb_q;
417 219 mohor
reg             TxRetryPacket;
418 221 mohor
reg             TxRetryPacket_NotCleared;
419
reg             TxDonePacket;
420
reg             TxDonePacket_NotCleared;
421 219 mohor
reg             TxAbortPacket;
422 221 mohor
reg             TxAbortPacket_NotCleared;
423 38 mohor
reg             RxBDReady;
424 166 mohor
reg             RxReady;
425 38 mohor
reg             TxBDReady;
426
 
427
reg             RxBDRead;
428
 
429
reg    [31:0]   TxDataLatched;
430
reg     [1:0]   TxByteCnt;
431
reg             LastWord;
432 39 mohor
reg             ReadTxDataFromFifo_tck;
433 38 mohor
 
434
reg             BlockingTxStatusWrite;
435
reg             BlockingTxBDRead;
436
 
437 40 mohor
reg             Flop;
438 38 mohor
 
439
reg     [7:0]   TxBDAddress;
440
reg     [7:0]   RxBDAddress;
441
 
442
reg             TxRetrySync1;
443
reg             TxAbortSync1;
444 39 mohor
reg             TxDoneSync1;
445 38 mohor
 
446
reg             TxAbort_q;
447
reg             TxRetry_q;
448
reg             TxUsedData_q;
449
 
450
reg    [31:0]   RxDataLatched2;
451 82 mohor
 
452
reg    [31:8]   RxDataLatched1;     // Big Endian Byte Ordering
453
 
454 38 mohor
reg     [1:0]   RxValidBytes;
455
reg     [1:0]   RxByteCnt;
456
reg             LastByteIn;
457
reg             ShiftWillEnd;
458
 
459 40 mohor
reg             WriteRxDataToFifo;
460 42 mohor
reg    [15:0]   LatchedRxLength;
461 64 mohor
reg             RxAbortLatched;
462 38 mohor
 
463 40 mohor
reg             ShiftEnded;
464 60 mohor
reg             RxOverrun;
465 38 mohor
 
466 40 mohor
reg             BDWrite;                    // BD Write Enable for access from WISHBONE side
467
reg             BDRead;                     // BD Read access from WISHBONE side
468 39 mohor
wire   [31:0]   RxBDDataIn;                 // Rx BD data in
469
wire   [31:0]   TxBDDataIn;                 // Tx BD data in
470 38 mohor
 
471 39 mohor
reg             TxEndFrm_wb;
472 38 mohor
 
473 39 mohor
wire            TxRetryPulse;
474 38 mohor
wire            TxDonePulse;
475
wire            TxAbortPulse;
476
 
477
wire            StartRxBDRead;
478
 
479
wire            StartTxBDRead;
480
 
481
wire            TxIRQEn;
482
wire            WrapTxStatusBit;
483
 
484 77 mohor
wire            RxIRQEn;
485 38 mohor
wire            WrapRxStatusBit;
486
 
487
wire    [1:0]   TxValidBytes;
488
 
489
wire    [7:0]   TempTxBDAddress;
490
wire    [7:0]   TempRxBDAddress;
491
 
492 272 tadejm
wire            RxStatusWrite;
493
 
494 106 mohor
reg             WB_ACK_O;
495 38 mohor
 
496 261 mohor
wire    [8:0]   RxStatusIn;
497
reg     [8:0]   RxStatusInLatched;
498 42 mohor
 
499 39 mohor
reg WbEn, WbEn_q;
500
reg RxEn, RxEn_q;
501
reg TxEn, TxEn_q;
502 38 mohor
 
503 39 mohor
wire ram_ce;
504
wire ram_we;
505
wire ram_oe;
506
reg [7:0]   ram_addr;
507
reg [31:0]  ram_di;
508
wire [31:0] ram_do;
509 38 mohor
 
510 39 mohor
wire StartTxPointerRead;
511
reg  TxPointerRead;
512
reg TxEn_needed;
513 40 mohor
reg RxEn_needed;
514 38 mohor
 
515 40 mohor
wire StartRxPointerRead;
516
reg RxPointerRead;
517 38 mohor
 
518 219 mohor
`ifdef ETH_WISHBONE_B3
519
assign m_wb_bte_o = 2'b00;    // Linear burst
520
`endif
521 39 mohor
 
522 219 mohor
 
523 159 mohor
always @ (posedge WB_CLK_I)
524 40 mohor
begin
525 159 mohor
  WB_ACK_O <=#Tp BDWrite & WbEn & WbEn_q | BDRead & WbEn & ~WbEn_q;
526 40 mohor
end
527 39 mohor
 
528 106 mohor
assign WB_DAT_O = ram_do;
529 39 mohor
 
530 41 mohor
// Generic synchronous single-port RAM interface
531 119 mohor
eth_spram_256x32 bd_ram (
532 226 tadejm
        .clk(WB_CLK_I), .rst(Reset), .ce(ram_ce), .we(ram_we), .oe(ram_oe), .addr(ram_addr), .di(ram_di), .do(ram_do)
533 210 mohor
`ifdef ETH_BIST
534 227 tadejm
  ,
535
  .scanb_rst      (scanb_rst),
536
  .scanb_clk      (scanb_clk),
537
  .scanb_si       (scanb_si),
538
  .scanb_so       (scanb_so),
539
  .scanb_en       (scanb_en)
540 210 mohor
`endif
541 39 mohor
);
542 41 mohor
 
543 39 mohor
assign ram_ce = 1'b1;
544 40 mohor
assign ram_we = BDWrite & WbEn & WbEn_q | TxStatusWrite | RxStatusWrite;
545 61 mohor
assign ram_oe = BDRead & WbEn & WbEn_q | TxEn & TxEn_q & (TxBDRead | TxPointerRead) | RxEn & RxEn_q & (RxBDRead | RxPointerRead);
546 39 mohor
 
547
 
548 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
549 38 mohor
begin
550 40 mohor
  if(Reset)
551 39 mohor
    TxEn_needed <=#Tp 1'b0;
552 38 mohor
  else
553 40 mohor
  if(~TxBDReady & r_TxEn & WbEn & ~WbEn_q)
554 39 mohor
    TxEn_needed <=#Tp 1'b1;
555
  else
556
  if(TxPointerRead & TxEn & TxEn_q)
557
    TxEn_needed <=#Tp 1'b0;
558 38 mohor
end
559
 
560 39 mohor
// Enabling access to the RAM for three devices.
561 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
562 39 mohor
begin
563 40 mohor
  if(Reset)
564 39 mohor
    begin
565
      WbEn <=#Tp 1'b1;
566
      RxEn <=#Tp 1'b0;
567
      TxEn <=#Tp 1'b0;
568
      ram_addr <=#Tp 8'h0;
569
      ram_di <=#Tp 32'h0;
570 77 mohor
      BDRead <=#Tp 1'b0;
571
      BDWrite <=#Tp 1'b0;
572 39 mohor
    end
573
  else
574
    begin
575
      // Switching between three stages depends on enable signals
576 90 mohor
      case ({WbEn_q, RxEn_q, TxEn_q, RxEn_needed, TxEn_needed})  // synopsys parallel_case
577
        5'b100_10, 5'b100_11 :
578 39 mohor
          begin
579
            WbEn <=#Tp 1'b0;
580
            RxEn <=#Tp 1'b1;  // wb access stage and r_RxEn is enabled
581
            TxEn <=#Tp 1'b0;
582 40 mohor
            ram_addr <=#Tp RxBDAddress + RxPointerRead;
583 39 mohor
            ram_di <=#Tp RxBDDataIn;
584
          end
585
        5'b100_01 :
586
          begin
587
            WbEn <=#Tp 1'b0;
588
            RxEn <=#Tp 1'b0;
589
            TxEn <=#Tp 1'b1;  // wb access stage, r_RxEn is disabled but r_TxEn is enabled
590
            ram_addr <=#Tp TxBDAddress + TxPointerRead;
591
            ram_di <=#Tp TxBDDataIn;
592
          end
593 90 mohor
        5'b010_00, 5'b010_10 :
594 39 mohor
          begin
595
            WbEn <=#Tp 1'b1;  // RxEn access stage and r_TxEn is disabled
596
            RxEn <=#Tp 1'b0;
597
            TxEn <=#Tp 1'b0;
598
            ram_addr <=#Tp WB_ADR_I[9:2];
599
            ram_di <=#Tp WB_DAT_I;
600 40 mohor
            BDWrite <=#Tp BDCs & WB_WE_I;
601
            BDRead <=#Tp BDCs & ~WB_WE_I;
602 39 mohor
          end
603 90 mohor
        5'b010_01, 5'b010_11 :
604 39 mohor
          begin
605
            WbEn <=#Tp 1'b0;
606
            RxEn <=#Tp 1'b0;
607
            TxEn <=#Tp 1'b1;  // RxEn access stage and r_TxEn is enabled
608
            ram_addr <=#Tp TxBDAddress + TxPointerRead;
609
            ram_di <=#Tp TxBDDataIn;
610
          end
611 90 mohor
        5'b001_00, 5'b001_01, 5'b001_10, 5'b001_11 :
612 39 mohor
          begin
613
            WbEn <=#Tp 1'b1;  // TxEn access stage (we always go to wb access stage)
614
            RxEn <=#Tp 1'b0;
615
            TxEn <=#Tp 1'b0;
616
            ram_addr <=#Tp WB_ADR_I[9:2];
617
            ram_di <=#Tp WB_DAT_I;
618 40 mohor
            BDWrite <=#Tp BDCs & WB_WE_I;
619
            BDRead <=#Tp BDCs & ~WB_WE_I;
620 39 mohor
          end
621
        5'b100_00 :
622
          begin
623
            WbEn <=#Tp 1'b0;  // WbEn access stage and there is no need for other stages. WbEn needs to be switched off for a bit
624
          end
625
        5'b000_00 :
626
          begin
627
            WbEn <=#Tp 1'b1;  // Idle state. We go to WbEn access stage.
628
            RxEn <=#Tp 1'b0;
629
            TxEn <=#Tp 1'b0;
630
            ram_addr <=#Tp WB_ADR_I[9:2];
631
            ram_di <=#Tp WB_DAT_I;
632 40 mohor
            BDWrite <=#Tp BDCs & WB_WE_I;
633
            BDRead <=#Tp BDCs & ~WB_WE_I;
634 39 mohor
          end
635
      endcase
636
    end
637
end
638
 
639
 
640
// Delayed stage signals
641 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
642 39 mohor
begin
643 40 mohor
  if(Reset)
644 39 mohor
    begin
645
      WbEn_q <=#Tp 1'b0;
646
      RxEn_q <=#Tp 1'b0;
647
      TxEn_q <=#Tp 1'b0;
648
    end
649
  else
650
    begin
651
      WbEn_q <=#Tp WbEn;
652
      RxEn_q <=#Tp RxEn;
653
      TxEn_q <=#Tp TxEn;
654
    end
655
end
656
 
657 38 mohor
// Changes for tx occur every second clock. Flop is used for this manner.
658 40 mohor
always @ (posedge MTxClk or posedge Reset)
659 38 mohor
begin
660 40 mohor
  if(Reset)
661 38 mohor
    Flop <=#Tp 1'b0;
662
  else
663
  if(TxDone | TxAbort | TxRetry_q)
664
    Flop <=#Tp 1'b0;
665
  else
666
  if(TxUsedData)
667
    Flop <=#Tp ~Flop;
668
end
669
 
670 39 mohor
wire ResetTxBDReady;
671
assign ResetTxBDReady = TxDonePulse | TxAbortPulse | TxRetryPulse;
672 38 mohor
 
673
// Latching READY status of the Tx buffer descriptor
674 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
675 38 mohor
begin
676 40 mohor
  if(Reset)
677 38 mohor
    TxBDReady <=#Tp 1'b0;
678
  else
679 40 mohor
  if(TxEn & TxEn_q & TxBDRead)
680
    TxBDReady <=#Tp ram_do[15] & (ram_do[31:16] > 4); // TxBDReady is sampled only once at the beginning.
681
  else                                                // Only packets larger then 4 bytes are transmitted.
682 39 mohor
  if(ResetTxBDReady)
683 38 mohor
    TxBDReady <=#Tp 1'b0;
684
end
685
 
686
 
687 39 mohor
// Reading the Tx buffer descriptor
688 221 mohor
assign StartTxBDRead = (TxRetryPacket_NotCleared | TxStatusWrite) & ~BlockingTxBDRead & ~TxBDReady;
689 39 mohor
 
690 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
691 38 mohor
begin
692 40 mohor
  if(Reset)
693 39 mohor
    TxBDRead <=#Tp 1'b1;
694 38 mohor
  else
695 110 mohor
  if(StartTxBDRead)
696 39 mohor
    TxBDRead <=#Tp 1'b1;
697 38 mohor
  else
698 39 mohor
  if(TxBDReady)
699
    TxBDRead <=#Tp 1'b0;
700 38 mohor
end
701
 
702
 
703 39 mohor
// Reading Tx BD pointer
704
assign StartTxPointerRead = TxBDRead & TxBDReady;
705 38 mohor
 
706 39 mohor
// Reading Tx BD Pointer
707 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
708 38 mohor
begin
709 40 mohor
  if(Reset)
710 39 mohor
    TxPointerRead <=#Tp 1'b0;
711 38 mohor
  else
712 39 mohor
  if(StartTxPointerRead)
713
    TxPointerRead <=#Tp 1'b1;
714 38 mohor
  else
715 39 mohor
  if(TxEn_q)
716
    TxPointerRead <=#Tp 1'b0;
717 38 mohor
end
718
 
719
 
720 39 mohor
// Writing status back to the Tx buffer descriptor
721 221 mohor
assign TxStatusWrite = (TxDonePacket_NotCleared | TxAbortPacket_NotCleared) & TxEn & TxEn_q & ~BlockingTxStatusWrite;
722 38 mohor
 
723
 
724
 
725 39 mohor
// Status writing must occur only once. Meanwhile it is blocked.
726 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
727 38 mohor
begin
728 40 mohor
  if(Reset)
729 39 mohor
    BlockingTxStatusWrite <=#Tp 1'b0;
730 38 mohor
  else
731 272 tadejm
  if(~TxDone_wb & ~TxAbort_wb)
732
    BlockingTxStatusWrite <=#Tp 1'b0;
733
  else
734 39 mohor
  if(TxStatusWrite)
735
    BlockingTxStatusWrite <=#Tp 1'b1;
736 38 mohor
end
737
 
738
 
739 159 mohor
reg BlockingTxStatusWrite_sync1;
740
reg BlockingTxStatusWrite_sync2;
741
 
742
// Synchronizing BlockingTxStatusWrite to MTxClk
743
always @ (posedge MTxClk or posedge Reset)
744
begin
745
  if(Reset)
746
    BlockingTxStatusWrite_sync1 <=#Tp 1'b0;
747
  else
748
    BlockingTxStatusWrite_sync1 <=#Tp BlockingTxStatusWrite;
749
end
750
 
751
// Synchronizing BlockingTxStatusWrite to MTxClk
752
always @ (posedge MTxClk or posedge Reset)
753
begin
754
  if(Reset)
755
    BlockingTxStatusWrite_sync2 <=#Tp 1'b0;
756
  else
757
    BlockingTxStatusWrite_sync2 <=#Tp BlockingTxStatusWrite_sync1;
758
end
759
 
760
 
761 39 mohor
// TxBDRead state is activated only once. 
762 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
763 39 mohor
begin
764 40 mohor
  if(Reset)
765 39 mohor
    BlockingTxBDRead <=#Tp 1'b0;
766
  else
767 110 mohor
  if(StartTxBDRead)
768 39 mohor
    BlockingTxBDRead <=#Tp 1'b1;
769
  else
770 110 mohor
  if(~StartTxBDRead & ~TxBDReady)
771 39 mohor
    BlockingTxBDRead <=#Tp 1'b0;
772
end
773 38 mohor
 
774
 
775 39 mohor
// Latching status from the tx buffer descriptor
776
// Data is avaliable one cycle after the access is started (at that time signal TxEn is not active)
777 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
778 38 mohor
begin
779 40 mohor
  if(Reset)
780 60 mohor
    TxStatus <=#Tp 4'h0;
781 38 mohor
  else
782 40 mohor
  if(TxEn & TxEn_q & TxBDRead)
783 60 mohor
    TxStatus <=#Tp ram_do[14:11];
784 38 mohor
end
785
 
786 40 mohor
reg ReadTxDataFromMemory;
787
wire WriteRxDataToMemory;
788 38 mohor
 
789 39 mohor
reg MasterWbTX;
790
reg MasterWbRX;
791
 
792
reg [31:0] m_wb_adr_o;
793
reg        m_wb_cyc_o;
794
reg        m_wb_stb_o;
795 96 mohor
reg  [3:0] m_wb_sel_o;
796 39 mohor
reg        m_wb_we_o;
797 40 mohor
 
798 39 mohor
wire TxLengthEq0;
799
wire TxLengthLt4;
800
 
801 150 mohor
reg BlockingIncrementTxPointer;
802 159 mohor
reg [31:2] TxPointerMSB;
803
reg [1:0]  TxPointerLSB;
804
reg [1:0]  TxPointerLSB_rst;
805
reg [31:2] RxPointerMSB;
806
reg [1:0]  RxPointerLSB_rst;
807 39 mohor
 
808 150 mohor
wire RxBurstAcc;
809
wire RxWordAcc;
810
wire RxHalfAcc;
811
wire RxByteAcc;
812
 
813 39 mohor
//Latching length from the buffer descriptor;
814 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
815 38 mohor
begin
816 40 mohor
  if(Reset)
817 39 mohor
    TxLength <=#Tp 16'h0;
818 38 mohor
  else
819 39 mohor
  if(TxEn & TxEn_q & TxBDRead)
820
    TxLength <=#Tp ram_do[31:16];
821 38 mohor
  else
822 39 mohor
  if(MasterWbTX & m_wb_ack_i)
823
    begin
824
      if(TxLengthLt4)
825
        TxLength <=#Tp 16'h0;
826 150 mohor
      else
827 159 mohor
      if(TxPointerLSB_rst==2'h0)
828 96 mohor
        TxLength <=#Tp TxLength - 3'h4;    // Length is subtracted at the data request
829 39 mohor
      else
830 159 mohor
      if(TxPointerLSB_rst==2'h1)
831 150 mohor
        TxLength <=#Tp TxLength - 3'h3;    // Length is subtracted at the data request
832
      else
833 159 mohor
      if(TxPointerLSB_rst==2'h2)
834 150 mohor
        TxLength <=#Tp TxLength - 3'h2;    // Length is subtracted at the data request
835
      else
836 159 mohor
      if(TxPointerLSB_rst==2'h3)
837 150 mohor
        TxLength <=#Tp TxLength - 3'h1;    // Length is subtracted at the data request
838 39 mohor
    end
839 38 mohor
end
840
 
841 96 mohor
 
842
 
843 60 mohor
//Latching length from the buffer descriptor;
844
always @ (posedge WB_CLK_I or posedge Reset)
845
begin
846
  if(Reset)
847
    LatchedTxLength <=#Tp 16'h0;
848
  else
849
  if(TxEn & TxEn_q & TxBDRead)
850
    LatchedTxLength <=#Tp ram_do[31:16];
851
end
852
 
853 39 mohor
assign TxLengthEq0 = TxLength == 0;
854
assign TxLengthLt4 = TxLength < 4;
855 38 mohor
 
856 150 mohor
reg cyc_cleared;
857
reg IncrTxPointer;
858 39 mohor
 
859
 
860 159 mohor
// Latching Tx buffer pointer from buffer descriptor. Only 30 MSB bits are latched
861
// because TxPointerMSB is only used for word-aligned accesses.
862 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
863 38 mohor
begin
864 40 mohor
  if(Reset)
865 159 mohor
    TxPointerMSB <=#Tp 30'h0;
866 38 mohor
  else
867 39 mohor
  if(TxEn & TxEn_q & TxPointerRead)
868 159 mohor
    TxPointerMSB <=#Tp ram_do[31:2];
869 38 mohor
  else
870 150 mohor
  if(IncrTxPointer & ~BlockingIncrementTxPointer)
871 159 mohor
    TxPointerMSB <=#Tp TxPointerMSB + 1'b1;     // TxPointer is word-aligned
872 38 mohor
end
873
 
874 96 mohor
 
875 159 mohor
// Latching 2 MSB bits of the buffer descriptor. Since word accesses are performed,
876
// valid data does not necesserly start at byte 0 (could be byte 0, 1, 2 or 3). This
877
// signals are used for proper selection of the start byte (TxData and TxByteCnt) are
878
// set by this two bits.
879 96 mohor
always @ (posedge WB_CLK_I or posedge Reset)
880
begin
881
  if(Reset)
882 159 mohor
    TxPointerLSB[1:0] <=#Tp 0;
883 96 mohor
  else
884
  if(TxEn & TxEn_q & TxPointerRead)
885 159 mohor
    TxPointerLSB[1:0] <=#Tp ram_do[1:0];
886 96 mohor
end
887
 
888
 
889 159 mohor
// Latching 2 MSB bits of the buffer descriptor. 
890
// After the read access, TxLength needs to be decremented for the number of the valid
891
// bytes (1 to 4 bytes are valid in the first word). After the first read all bytes are 
892
// valid so this two bits are reset to zero. 
893 150 mohor
always @ (posedge WB_CLK_I or posedge Reset)
894
begin
895
  if(Reset)
896 159 mohor
    TxPointerLSB_rst[1:0] <=#Tp 0;
897 150 mohor
  else
898
  if(TxEn & TxEn_q & TxPointerRead)
899 159 mohor
    TxPointerLSB_rst[1:0] <=#Tp ram_do[1:0];
900 150 mohor
  else
901
  if(MasterWbTX & m_wb_ack_i)                 // After first access pointer is word alligned
902 159 mohor
    TxPointerLSB_rst[1:0] <=#Tp 0;
903 150 mohor
end
904 96 mohor
 
905 150 mohor
 
906 159 mohor
reg  [3:0] RxByteSel;
907 39 mohor
wire MasterAccessFinished;
908 38 mohor
 
909 39 mohor
 
910 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
911 38 mohor
begin
912 40 mohor
  if(Reset)
913 39 mohor
    BlockingIncrementTxPointer <=#Tp 0;
914 38 mohor
  else
915 39 mohor
  if(MasterAccessFinished)
916
    BlockingIncrementTxPointer <=#Tp 0;
917 38 mohor
  else
918 150 mohor
  if(IncrTxPointer)
919 39 mohor
    BlockingIncrementTxPointer <=#Tp 1'b1;
920 38 mohor
end
921
 
922
 
923 39 mohor
wire TxBufferAlmostFull;
924
wire TxBufferFull;
925
wire TxBufferEmpty;
926
wire TxBufferAlmostEmpty;
927 40 mohor
wire SetReadTxDataFromMemory;
928 39 mohor
 
929 40 mohor
reg BlockReadTxDataFromMemory;
930 39 mohor
 
931 40 mohor
assign SetReadTxDataFromMemory = TxEn & TxEn_q & TxPointerRead;
932 39 mohor
 
933 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
934 38 mohor
begin
935 40 mohor
  if(Reset)
936
    ReadTxDataFromMemory <=#Tp 1'b0;
937 38 mohor
  else
938 278 mohor
  if(TxLengthEq0 | TxAbortPulse | TxRetryPulse)
939 40 mohor
    ReadTxDataFromMemory <=#Tp 1'b0;
940 39 mohor
  else
941 40 mohor
  if(SetReadTxDataFromMemory)
942
    ReadTxDataFromMemory <=#Tp 1'b1;
943 38 mohor
end
944
 
945 226 tadejm
reg tx_burst_en;
946
reg rx_burst_en;
947 221 mohor
 
948 278 mohor
wire ReadTxDataFromMemory_2 = ReadTxDataFromMemory & ~BlockReadTxDataFromMemory;
949 226 tadejm
wire tx_burst = ReadTxDataFromMemory_2 & tx_burst_en;
950 221 mohor
 
951 39 mohor
wire [31:0] TxData_wb;
952
wire ReadTxDataFromFifo_wb;
953 38 mohor
 
954 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
955 38 mohor
begin
956 40 mohor
  if(Reset)
957
    BlockReadTxDataFromMemory <=#Tp 1'b0;
958 38 mohor
  else
959 278 mohor
  if((TxBufferAlmostFull | TxLength <= 4)& MasterWbTX & (~cyc_cleared) & (!(TxAbortPacket_NotCleared | TxRetryPacket_NotCleared)))
960 40 mohor
    BlockReadTxDataFromMemory <=#Tp 1'b1;
961 219 mohor
  else
962 221 mohor
  if(ReadTxDataFromFifo_wb | TxDonePacket | TxAbortPacket | TxRetryPacket)
963 219 mohor
    BlockReadTxDataFromMemory <=#Tp 1'b0;
964 39 mohor
end
965
 
966
 
967
assign MasterAccessFinished = m_wb_ack_i | m_wb_err_i;
968 219 mohor
wire [`ETH_TX_FIFO_CNT_WIDTH-1:0] txfifo_cnt;
969
wire [`ETH_RX_FIFO_CNT_WIDTH-1:0] rxfifo_cnt;
970 226 tadejm
reg  [`ETH_BURST_CNT_WIDTH-1:0] tx_burst_cnt;
971
reg  [`ETH_BURST_CNT_WIDTH-1:0] rx_burst_cnt;
972 159 mohor
 
973 226 tadejm
wire rx_burst;
974
wire enough_data_in_rxfifo_for_burst;
975
wire enough_data_in_rxfifo_for_burst_plus1;
976 229 mohor
 
977 39 mohor
// Enabling master wishbone access to the memory for two devices TX and RX.
978 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
979 39 mohor
begin
980 40 mohor
  if(Reset)
981 38 mohor
    begin
982 39 mohor
      MasterWbTX <=#Tp 1'b0;
983
      MasterWbRX <=#Tp 1'b0;
984
      m_wb_adr_o <=#Tp 32'h0;
985
      m_wb_cyc_o <=#Tp 1'b0;
986
      m_wb_stb_o <=#Tp 1'b0;
987
      m_wb_we_o  <=#Tp 1'b0;
988 96 mohor
      m_wb_sel_o <=#Tp 4'h0;
989 110 mohor
      cyc_cleared<=#Tp 1'b0;
990 226 tadejm
      tx_burst_cnt<=#Tp 0;
991
      rx_burst_cnt<=#Tp 0;
992 150 mohor
      IncrTxPointer<=#Tp 1'b0;
993 226 tadejm
      tx_burst_en<=#Tp 1'b1;
994
      rx_burst_en<=#Tp 1'b0;
995
      `ifdef ETH_WISHBONE_B3
996
        m_wb_cti_o <=#Tp 3'b0;
997
      `endif
998 38 mohor
    end
999 39 mohor
  else
1000
    begin
1001
      // Switching between two stages depends on enable signals
1002 229 mohor
      casex ({MasterWbTX, MasterWbRX, ReadTxDataFromMemory_2, WriteRxDataToMemory, MasterAccessFinished, cyc_cleared, tx_burst, rx_burst})  // synopsys parallel_case
1003 226 tadejm
        8'b00_10_00_10,             // Idle and MRB needed
1004 229 mohor
        8'b10_1x_10_1x,             // MRB continues
1005 226 tadejm
        8'b10_10_01_10,             // Clear (previously MR) and MRB needed
1006 229 mohor
        8'b01_1x_01_1x :            // Clear (previously MW) and MRB needed
1007 39 mohor
          begin
1008 226 tadejm
            MasterWbTX <=#Tp 1'b1;  // tx burst
1009
            MasterWbRX <=#Tp 1'b0;
1010
            m_wb_cyc_o <=#Tp 1'b1;
1011
            m_wb_stb_o <=#Tp 1'b1;
1012
            m_wb_we_o  <=#Tp 1'b0;
1013
            m_wb_sel_o <=#Tp 4'hf;
1014
            cyc_cleared<=#Tp 1'b0;
1015
            IncrTxPointer<=#Tp 1'b1;
1016
            tx_burst_cnt <=#Tp tx_burst_cnt+1;
1017
            if(tx_burst_cnt==0)
1018
              m_wb_adr_o <=#Tp {TxPointerMSB, 2'h0};
1019
            else
1020
              m_wb_adr_o <=#Tp m_wb_adr_o+3'h4;
1021
 
1022
            if(tx_burst_cnt==(`ETH_BURST_LENGTH-1))
1023
              begin
1024
                tx_burst_en<=#Tp 1'b0;
1025
              `ifdef ETH_WISHBONE_B3
1026
                m_wb_cti_o <=#Tp 3'b111;
1027
              `endif
1028
              end
1029
            else
1030
              begin
1031
              `ifdef ETH_WISHBONE_B3
1032
                m_wb_cti_o <=#Tp 3'b010;
1033
              `endif
1034
              end
1035
          end
1036 229 mohor
        8'b00_x1_00_x1,             // Idle and MWB needed
1037
        8'b01_x1_10_x1,             // MWB continues
1038 226 tadejm
        8'b01_01_01_01,             // Clear (previously MW) and MWB needed
1039 229 mohor
        8'b10_x1_01_x1 :            // Clear (previously MR) and MWB needed
1040 226 tadejm
          begin
1041
            MasterWbTX <=#Tp 1'b0;  // rx burst
1042 39 mohor
            MasterWbRX <=#Tp 1'b1;
1043 226 tadejm
            m_wb_cyc_o <=#Tp 1'b1;
1044
            m_wb_stb_o <=#Tp 1'b1;
1045
            m_wb_we_o  <=#Tp 1'b1;
1046
            m_wb_sel_o <=#Tp RxByteSel;
1047
            IncrTxPointer<=#Tp 1'b0;
1048
            cyc_cleared<=#Tp 1'b0;
1049
            rx_burst_cnt <=#Tp rx_burst_cnt+1;
1050
 
1051
            if(rx_burst_cnt==0)
1052
              m_wb_adr_o <=#Tp {RxPointerMSB, 2'h0};
1053
            else
1054
              m_wb_adr_o <=#Tp m_wb_adr_o+3'h4;
1055
 
1056
            if(rx_burst_cnt==(`ETH_BURST_LENGTH-1))
1057
              begin
1058
                rx_burst_en<=#Tp 1'b0;
1059
              `ifdef ETH_WISHBONE_B3
1060
                m_wb_cti_o <=#Tp 3'b111;
1061
              `endif
1062
              end
1063
            else
1064
              begin
1065
              `ifdef ETH_WISHBONE_B3
1066
                m_wb_cti_o <=#Tp 3'b010;
1067
              `endif
1068
              end
1069
          end
1070 229 mohor
        8'b00_x1_00_x0 :            // idle and MW is needed (data write to rx buffer)
1071 226 tadejm
          begin
1072
            MasterWbTX <=#Tp 1'b0;
1073
            MasterWbRX <=#Tp 1'b1;
1074 159 mohor
            m_wb_adr_o <=#Tp {RxPointerMSB, 2'h0};
1075 39 mohor
            m_wb_cyc_o <=#Tp 1'b1;
1076
            m_wb_stb_o <=#Tp 1'b1;
1077
            m_wb_we_o  <=#Tp 1'b1;
1078 159 mohor
            m_wb_sel_o <=#Tp RxByteSel;
1079 150 mohor
            IncrTxPointer<=#Tp 1'b0;
1080 39 mohor
          end
1081 226 tadejm
        8'b00_10_00_00 :            // idle and MR is needed (data read from tx buffer)
1082 39 mohor
          begin
1083 226 tadejm
            MasterWbTX <=#Tp 1'b1;
1084 39 mohor
            MasterWbRX <=#Tp 1'b0;
1085 159 mohor
            m_wb_adr_o <=#Tp {TxPointerMSB, 2'h0};
1086 39 mohor
            m_wb_cyc_o <=#Tp 1'b1;
1087
            m_wb_stb_o <=#Tp 1'b1;
1088
            m_wb_we_o  <=#Tp 1'b0;
1089 150 mohor
            m_wb_sel_o <=#Tp 4'hf;
1090
            IncrTxPointer<=#Tp 1'b1;
1091 39 mohor
          end
1092 226 tadejm
        8'b10_10_01_00,             // MR and MR is needed (data read from tx buffer)
1093 229 mohor
        8'b01_1x_01_0x  :           // MW and MR is needed (data read from tx buffer)
1094 39 mohor
          begin
1095 226 tadejm
            MasterWbTX <=#Tp 1'b1;
1096 39 mohor
            MasterWbRX <=#Tp 1'b0;
1097 159 mohor
            m_wb_adr_o <=#Tp {TxPointerMSB, 2'h0};
1098 39 mohor
            m_wb_cyc_o <=#Tp 1'b1;
1099
            m_wb_stb_o <=#Tp 1'b1;
1100
            m_wb_we_o  <=#Tp 1'b0;
1101 150 mohor
            m_wb_sel_o <=#Tp 4'hf;
1102 110 mohor
            cyc_cleared<=#Tp 1'b0;
1103 150 mohor
            IncrTxPointer<=#Tp 1'b1;
1104 39 mohor
          end
1105 226 tadejm
        8'b01_01_01_00,             // MW and MW needed (data write to rx buffer)
1106 229 mohor
        8'b10_x1_01_x0  :           // MR and MW is needed (data write to rx buffer)
1107 39 mohor
          begin
1108 226 tadejm
            MasterWbTX <=#Tp 1'b0;
1109 39 mohor
            MasterWbRX <=#Tp 1'b1;
1110 159 mohor
            m_wb_adr_o <=#Tp {RxPointerMSB, 2'h0};
1111 112 mohor
            m_wb_cyc_o <=#Tp 1'b1;
1112
            m_wb_stb_o <=#Tp 1'b1;
1113 39 mohor
            m_wb_we_o  <=#Tp 1'b1;
1114 159 mohor
            m_wb_sel_o <=#Tp RxByteSel;
1115 110 mohor
            cyc_cleared<=#Tp 1'b0;
1116 150 mohor
            IncrTxPointer<=#Tp 1'b0;
1117 39 mohor
          end
1118 226 tadejm
        8'b01_01_10_00,             // MW and MW needed (cycle is cleared between previous and next access)
1119 229 mohor
        8'b01_1x_10_x0,             // MW and MW or MR or MRB needed (cycle is cleared between previous and next access)
1120 226 tadejm
        8'b10_10_10_00,             // MR and MR needed (cycle is cleared between previous and next access)
1121 229 mohor
        8'b10_x1_10_0x :            // MR and MR or MW or MWB (cycle is cleared between previous and next access)
1122 39 mohor
          begin
1123 110 mohor
            m_wb_cyc_o <=#Tp 1'b0;  // whatever and master read or write is needed. We need to clear m_wb_cyc_o before next access is started
1124
            m_wb_stb_o <=#Tp 1'b0;
1125
            cyc_cleared<=#Tp 1'b1;
1126 150 mohor
            IncrTxPointer<=#Tp 1'b0;
1127 226 tadejm
            tx_burst_cnt<=#Tp 0;
1128
            tx_burst_en<=#Tp txfifo_cnt<(`ETH_TX_FIFO_DEPTH-`ETH_BURST_LENGTH) & (TxLength>(`ETH_BURST_LENGTH*4+4));
1129
            rx_burst_cnt<=#Tp 0;
1130
            rx_burst_en<=#Tp MasterWbRX ? enough_data_in_rxfifo_for_burst_plus1 : enough_data_in_rxfifo_for_burst;  // Counter is not decremented, yet, so plus1 is used.
1131
            `ifdef ETH_WISHBONE_B3
1132
              m_wb_cti_o <=#Tp 3'b0;
1133
            `endif
1134 110 mohor
          end
1135 229 mohor
        8'bxx_00_10_00,             // whatever and no master read or write is needed (ack or err comes finishing previous access)
1136
        8'bxx_00_01_00 :            // Between cyc_cleared request was cleared
1137 110 mohor
          begin
1138 226 tadejm
            MasterWbTX <=#Tp 1'b0;
1139 39 mohor
            MasterWbRX <=#Tp 1'b0;
1140
            m_wb_cyc_o <=#Tp 1'b0;
1141
            m_wb_stb_o <=#Tp 1'b0;
1142 226 tadejm
            cyc_cleared<=#Tp 1'b0;
1143 150 mohor
            IncrTxPointer<=#Tp 1'b0;
1144 226 tadejm
            rx_burst_cnt<=#Tp 0;
1145
            rx_burst_en<=#Tp MasterWbRX ? enough_data_in_rxfifo_for_burst_plus1 : enough_data_in_rxfifo_for_burst;  // Counter is not decremented, yet, so plus1 is used.
1146
            `ifdef ETH_WISHBONE_B3
1147
              m_wb_cti_o <=#Tp 3'b0;
1148
            `endif
1149 39 mohor
          end
1150 226 tadejm
        8'b00_00_00_00:             // whatever and no master read or write is needed (ack or err comes finishing previous access)
1151 127 mohor
          begin
1152 226 tadejm
            tx_burst_cnt<=#Tp 0;
1153
            tx_burst_en<=#Tp txfifo_cnt<(`ETH_TX_FIFO_DEPTH-`ETH_BURST_LENGTH) & (TxLength>(`ETH_BURST_LENGTH*4+4));
1154 127 mohor
          end
1155 226 tadejm
        default:                    // Don't touch
1156 82 mohor
          begin
1157
            MasterWbTX <=#Tp MasterWbTX;
1158
            MasterWbRX <=#Tp MasterWbRX;
1159
            m_wb_cyc_o <=#Tp m_wb_cyc_o;
1160
            m_wb_stb_o <=#Tp m_wb_stb_o;
1161 96 mohor
            m_wb_sel_o <=#Tp m_wb_sel_o;
1162 150 mohor
            IncrTxPointer<=#Tp IncrTxPointer;
1163 82 mohor
          end
1164 39 mohor
      endcase
1165
    end
1166 38 mohor
end
1167
 
1168 110 mohor
 
1169 39 mohor
wire TxFifoClear;
1170 96 mohor
 
1171 219 mohor
assign TxFifoClear = (TxAbortPacket | TxRetryPacket);
1172 38 mohor
 
1173 219 mohor
eth_fifo #(`ETH_TX_FIFO_DATA_WIDTH, `ETH_TX_FIFO_DEPTH, `ETH_TX_FIFO_CNT_WIDTH)
1174 150 mohor
tx_fifo ( .data_in(m_wb_dat_i),                             .data_out(TxData_wb),
1175 96 mohor
          .clk(WB_CLK_I),                                   .reset(Reset),
1176 226 tadejm
          .write(MasterWbTX & m_wb_ack_i),                  .read(ReadTxDataFromFifo_wb & ~TxBufferEmpty),
1177 96 mohor
          .clear(TxFifoClear),                              .full(TxBufferFull),
1178
          .almost_full(TxBufferAlmostFull),                 .almost_empty(TxBufferAlmostEmpty),
1179 150 mohor
          .empty(TxBufferEmpty),                            .cnt(txfifo_cnt)
1180 96 mohor
        );
1181 39 mohor
 
1182
 
1183
reg StartOccured;
1184
reg TxStartFrm_sync1;
1185
reg TxStartFrm_sync2;
1186
reg TxStartFrm_syncb1;
1187
reg TxStartFrm_syncb2;
1188
 
1189
 
1190
 
1191
// Start: Generation of the TxStartFrm_wb which is then synchronized to the MTxClk
1192 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1193 38 mohor
begin
1194 40 mohor
  if(Reset)
1195 39 mohor
    TxStartFrm_wb <=#Tp 1'b0;
1196 38 mohor
  else
1197 39 mohor
  if(TxBDReady & ~StartOccured & (TxBufferFull | TxLengthEq0))
1198
    TxStartFrm_wb <=#Tp 1'b1;
1199 38 mohor
  else
1200 39 mohor
  if(TxStartFrm_syncb2)
1201
    TxStartFrm_wb <=#Tp 1'b0;
1202 38 mohor
end
1203
 
1204 39 mohor
// StartOccured: TxStartFrm_wb occurs only ones at the beginning. Then it's blocked.
1205 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1206 38 mohor
begin
1207 40 mohor
  if(Reset)
1208 39 mohor
    StartOccured <=#Tp 1'b0;
1209 38 mohor
  else
1210 39 mohor
  if(TxStartFrm_wb)
1211
    StartOccured <=#Tp 1'b1;
1212 38 mohor
  else
1213 39 mohor
  if(ResetTxBDReady)
1214
    StartOccured <=#Tp 1'b0;
1215 38 mohor
end
1216
 
1217 39 mohor
// Synchronizing TxStartFrm_wb to MTxClk
1218 40 mohor
always @ (posedge MTxClk or posedge Reset)
1219 39 mohor
begin
1220 40 mohor
  if(Reset)
1221 39 mohor
    TxStartFrm_sync1 <=#Tp 1'b0;
1222
  else
1223
    TxStartFrm_sync1 <=#Tp TxStartFrm_wb;
1224
end
1225 38 mohor
 
1226 40 mohor
always @ (posedge MTxClk or posedge Reset)
1227 39 mohor
begin
1228 40 mohor
  if(Reset)
1229 39 mohor
    TxStartFrm_sync2 <=#Tp 1'b0;
1230
  else
1231
    TxStartFrm_sync2 <=#Tp TxStartFrm_sync1;
1232
end
1233
 
1234 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1235 38 mohor
begin
1236 40 mohor
  if(Reset)
1237 39 mohor
    TxStartFrm_syncb1 <=#Tp 1'b0;
1238 38 mohor
  else
1239 39 mohor
    TxStartFrm_syncb1 <=#Tp TxStartFrm_sync2;
1240 38 mohor
end
1241
 
1242 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1243 38 mohor
begin
1244 40 mohor
  if(Reset)
1245 39 mohor
    TxStartFrm_syncb2 <=#Tp 1'b0;
1246 38 mohor
  else
1247 39 mohor
    TxStartFrm_syncb2 <=#Tp TxStartFrm_syncb1;
1248
end
1249
 
1250 40 mohor
always @ (posedge MTxClk or posedge Reset)
1251 39 mohor
begin
1252 40 mohor
  if(Reset)
1253 39 mohor
    TxStartFrm <=#Tp 1'b0;
1254 38 mohor
  else
1255 39 mohor
  if(TxStartFrm_sync2)
1256 61 mohor
    TxStartFrm <=#Tp 1'b1;
1257 39 mohor
  else
1258 278 mohor
  if(TxUsedData_q | ~TxStartFrm_sync2 & (TxRetry & (~TxRetry_q) | TxAbort & (~TxAbort_q)))
1259 39 mohor
    TxStartFrm <=#Tp 1'b0;
1260 38 mohor
end
1261 39 mohor
// End: Generation of the TxStartFrm_wb which is then synchronized to the MTxClk
1262 38 mohor
 
1263
 
1264 39 mohor
// TxEndFrm_wb: indicator of the end of frame
1265 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1266 38 mohor
begin
1267 40 mohor
  if(Reset)
1268 39 mohor
    TxEndFrm_wb <=#Tp 1'b0;
1269 38 mohor
  else
1270 221 mohor
  if(TxLengthEq0 & TxBufferAlmostEmpty & TxUsedData)
1271 39 mohor
    TxEndFrm_wb <=#Tp 1'b1;
1272 38 mohor
  else
1273 39 mohor
  if(TxRetryPulse | TxDonePulse | TxAbortPulse)
1274
    TxEndFrm_wb <=#Tp 1'b0;
1275 38 mohor
end
1276
 
1277
 
1278
// Marks which bytes are valid within the word.
1279 39 mohor
assign TxValidBytes = TxLengthLt4 ? TxLength[1:0] : 2'b0;
1280 38 mohor
 
1281 39 mohor
reg LatchValidBytes;
1282
reg LatchValidBytes_q;
1283 38 mohor
 
1284 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1285 38 mohor
begin
1286 40 mohor
  if(Reset)
1287 39 mohor
    LatchValidBytes <=#Tp 1'b0;
1288 38 mohor
  else
1289 39 mohor
  if(TxLengthLt4 & TxBDReady)
1290
    LatchValidBytes <=#Tp 1'b1;
1291 38 mohor
  else
1292 39 mohor
    LatchValidBytes <=#Tp 1'b0;
1293 38 mohor
end
1294
 
1295 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1296 38 mohor
begin
1297 40 mohor
  if(Reset)
1298 39 mohor
    LatchValidBytes_q <=#Tp 1'b0;
1299 38 mohor
  else
1300 39 mohor
    LatchValidBytes_q <=#Tp LatchValidBytes;
1301 38 mohor
end
1302
 
1303
 
1304 39 mohor
// Latching valid bytes
1305 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1306 38 mohor
begin
1307 40 mohor
  if(Reset)
1308 39 mohor
    TxValidBytesLatched <=#Tp 2'h0;
1309 38 mohor
  else
1310 39 mohor
  if(LatchValidBytes & ~LatchValidBytes_q)
1311
    TxValidBytesLatched <=#Tp TxValidBytes;
1312
  else
1313
  if(TxRetryPulse | TxDonePulse | TxAbortPulse)
1314
    TxValidBytesLatched <=#Tp 2'h0;
1315 38 mohor
end
1316
 
1317
 
1318
assign TxIRQEn          = TxStatus[14];
1319 60 mohor
assign WrapTxStatusBit  = TxStatus[13];
1320
assign PerPacketPad     = TxStatus[12];
1321
assign PerPacketCrcEn   = TxStatus[11];
1322 38 mohor
 
1323
 
1324 77 mohor
assign RxIRQEn         = RxStatus[14];
1325 60 mohor
assign WrapRxStatusBit = RxStatus[13];
1326 38 mohor
 
1327
 
1328
// Temporary Tx and Rx buffer descriptor address 
1329 39 mohor
assign TempTxBDAddress[7:0] = {8{ TxStatusWrite     & ~WrapTxStatusBit}} & (TxBDAddress + 2'h2) ; // Tx BD increment or wrap (last BD)
1330 134 mohor
assign TempRxBDAddress[7:0] = {8{ WrapRxStatusBit}} & (r_TxBDNum<<1)     | // Using first Rx BD
1331 39 mohor
                              {8{~WrapRxStatusBit}} & (RxBDAddress + 2'h2) ; // Using next Rx BD (incremenrement address)
1332 38 mohor
 
1333
 
1334
// Latching Tx buffer descriptor address
1335 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1336 38 mohor
begin
1337 40 mohor
  if(Reset)
1338 38 mohor
    TxBDAddress <=#Tp 8'h0;
1339
  else
1340
  if(TxStatusWrite)
1341
    TxBDAddress <=#Tp TempTxBDAddress;
1342
end
1343
 
1344
 
1345
// Latching Rx buffer descriptor address
1346 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1347 38 mohor
begin
1348 40 mohor
  if(Reset)
1349 134 mohor
    RxBDAddress <=#Tp `ETH_TX_BD_NUM_DEF<<1;
1350 38 mohor
  else
1351 77 mohor
  if(TX_BD_NUM_Wr)                        // When r_TxBDNum is updated, RxBDAddress is also
1352 134 mohor
    RxBDAddress <=#Tp WB_DAT_I[7:0]<<1;
1353 38 mohor
  else
1354
  if(RxStatusWrite)
1355
    RxBDAddress <=#Tp TempRxBDAddress;
1356
end
1357
 
1358 60 mohor
wire [8:0] TxStatusInLatched = {TxUnderRun, RetryCntLatched[3:0], RetryLimit, LateCollLatched, DeferLatched, CarrierSenseLost};
1359 38 mohor
 
1360 261 mohor
assign RxBDDataIn = {LatchedRxLength, 1'b0, RxStatus, 4'h0, RxStatusInLatched};
1361 60 mohor
assign TxBDDataIn = {LatchedTxLength, 1'b0, TxStatus, 2'h0, TxStatusInLatched};
1362 38 mohor
 
1363 60 mohor
 
1364 38 mohor
// Signals used for various purposes
1365 39 mohor
assign TxRetryPulse   = TxRetry_wb   & ~TxRetry_wb_q;
1366 38 mohor
assign TxDonePulse    = TxDone_wb    & ~TxDone_wb_q;
1367
assign TxAbortPulse   = TxAbort_wb   & ~TxAbort_wb_q;
1368
 
1369
 
1370
 
1371 39 mohor
// Generating delayed signals
1372 40 mohor
always @ (posedge MTxClk or posedge Reset)
1373 38 mohor
begin
1374 40 mohor
  if(Reset)
1375 39 mohor
    begin
1376
      TxAbort_q      <=#Tp 1'b0;
1377
      TxRetry_q      <=#Tp 1'b0;
1378
      TxUsedData_q   <=#Tp 1'b0;
1379
    end
1380 38 mohor
  else
1381 39 mohor
    begin
1382
      TxAbort_q      <=#Tp TxAbort;
1383
      TxRetry_q      <=#Tp TxRetry;
1384
      TxUsedData_q   <=#Tp TxUsedData;
1385
    end
1386 38 mohor
end
1387
 
1388
// Generating delayed signals
1389 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1390 38 mohor
begin
1391 40 mohor
  if(Reset)
1392 38 mohor
    begin
1393 39 mohor
      TxDone_wb_q   <=#Tp 1'b0;
1394
      TxAbort_wb_q  <=#Tp 1'b0;
1395 40 mohor
      TxRetry_wb_q  <=#Tp 1'b0;
1396 38 mohor
    end
1397
  else
1398
    begin
1399 39 mohor
      TxDone_wb_q   <=#Tp TxDone_wb;
1400
      TxAbort_wb_q  <=#Tp TxAbort_wb;
1401 40 mohor
      TxRetry_wb_q  <=#Tp TxRetry_wb;
1402 38 mohor
    end
1403
end
1404
 
1405
 
1406 219 mohor
reg TxAbortPacketBlocked;
1407
always @ (posedge WB_CLK_I or posedge Reset)
1408
begin
1409
  if(Reset)
1410
    TxAbortPacket <=#Tp 1'b0;
1411
  else
1412 278 mohor
  if(TxAbort_wb & (~tx_burst_en) & MasterWbTX & MasterAccessFinished & (~TxAbortPacketBlocked) |
1413
     TxAbort_wb & (~MasterWbTX) & (~TxAbortPacketBlocked))
1414 219 mohor
    TxAbortPacket <=#Tp 1'b1;
1415
  else
1416
    TxAbortPacket <=#Tp 1'b0;
1417
end
1418
 
1419
 
1420
always @ (posedge WB_CLK_I or posedge Reset)
1421
begin
1422
  if(Reset)
1423 221 mohor
    TxAbortPacket_NotCleared <=#Tp 1'b0;
1424
  else
1425 272 tadejm
  if(TxEn & TxEn_q & TxAbortPacket_NotCleared)
1426
    TxAbortPacket_NotCleared <=#Tp 1'b0;
1427
  else
1428 278 mohor
  if(TxAbort_wb & (~tx_burst_en) & MasterWbTX & MasterAccessFinished & (~TxAbortPacketBlocked) |
1429
     TxAbort_wb & (~MasterWbTX) & (~TxAbortPacketBlocked))
1430 221 mohor
    TxAbortPacket_NotCleared <=#Tp 1'b1;
1431
end
1432
 
1433
 
1434
always @ (posedge WB_CLK_I or posedge Reset)
1435
begin
1436
  if(Reset)
1437 219 mohor
    TxAbortPacketBlocked <=#Tp 1'b0;
1438
  else
1439
  if(TxAbortPacket)
1440
    TxAbortPacketBlocked <=#Tp 1'b1;
1441
  else
1442
  if(!TxAbort_wb & TxAbort_wb_q)
1443
    TxAbortPacketBlocked <=#Tp 1'b0;
1444
end
1445
 
1446
 
1447
reg TxRetryPacketBlocked;
1448
always @ (posedge WB_CLK_I or posedge Reset)
1449
begin
1450
  if(Reset)
1451
    TxRetryPacket <=#Tp 1'b0;
1452
  else
1453 226 tadejm
  if(TxRetry_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished & !TxRetryPacketBlocked |
1454
     TxRetry_wb & !MasterWbTX & !TxRetryPacketBlocked)
1455 219 mohor
    TxRetryPacket <=#Tp 1'b1;
1456
  else
1457
    TxRetryPacket <=#Tp 1'b0;
1458
end
1459
 
1460
 
1461
always @ (posedge WB_CLK_I or posedge Reset)
1462
begin
1463
  if(Reset)
1464 221 mohor
    TxRetryPacket_NotCleared <=#Tp 1'b0;
1465
  else
1466 272 tadejm
  if(StartTxBDRead)
1467
    TxRetryPacket_NotCleared <=#Tp 1'b0;
1468
  else
1469 278 mohor
  if(TxRetry_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished & !TxRetryPacketBlocked |
1470
     TxRetry_wb & !MasterWbTX & !TxRetryPacketBlocked)
1471 221 mohor
    TxRetryPacket_NotCleared <=#Tp 1'b1;
1472
end
1473
 
1474
 
1475
always @ (posedge WB_CLK_I or posedge Reset)
1476
begin
1477
  if(Reset)
1478 219 mohor
    TxRetryPacketBlocked <=#Tp 1'b0;
1479
  else
1480
  if(TxRetryPacket)
1481
    TxRetryPacketBlocked <=#Tp 1'b1;
1482
  else
1483
  if(!TxRetry_wb & TxRetry_wb_q)
1484
    TxRetryPacketBlocked <=#Tp 1'b0;
1485
end
1486
 
1487
 
1488 221 mohor
reg TxDonePacketBlocked;
1489
always @ (posedge WB_CLK_I or posedge Reset)
1490
begin
1491
  if(Reset)
1492
    TxDonePacket <=#Tp 1'b0;
1493
  else
1494 226 tadejm
  if(TxDone_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished & !TxDonePacketBlocked |
1495
     TxDone_wb & !MasterWbTX & !TxDonePacketBlocked)
1496 221 mohor
    TxDonePacket <=#Tp 1'b1;
1497
  else
1498
    TxDonePacket <=#Tp 1'b0;
1499
end
1500
 
1501
 
1502
always @ (posedge WB_CLK_I or posedge Reset)
1503
begin
1504
  if(Reset)
1505
    TxDonePacket_NotCleared <=#Tp 1'b0;
1506
  else
1507 272 tadejm
  if(TxEn & TxEn_q & TxDonePacket_NotCleared)
1508
    TxDonePacket_NotCleared <=#Tp 1'b0;
1509
  else
1510 278 mohor
  if(TxDone_wb & !tx_burst_en & MasterWbTX & MasterAccessFinished & (~TxDonePacketBlocked) |
1511
     TxDone_wb & !MasterWbTX & (~TxDonePacketBlocked))
1512 221 mohor
    TxDonePacket_NotCleared <=#Tp 1'b1;
1513
end
1514
 
1515
 
1516
always @ (posedge WB_CLK_I or posedge Reset)
1517
begin
1518
  if(Reset)
1519
    TxDonePacketBlocked <=#Tp 1'b0;
1520
  else
1521
  if(TxDonePacket)
1522
    TxDonePacketBlocked <=#Tp 1'b1;
1523
  else
1524
  if(!TxDone_wb & TxDone_wb_q)
1525
    TxDonePacketBlocked <=#Tp 1'b0;
1526
end
1527
 
1528
 
1529 38 mohor
// Indication of the last word
1530 40 mohor
always @ (posedge MTxClk or posedge Reset)
1531 38 mohor
begin
1532 40 mohor
  if(Reset)
1533 38 mohor
    LastWord <=#Tp 1'b0;
1534
  else
1535
  if((TxEndFrm | TxAbort | TxRetry) & Flop)
1536
    LastWord <=#Tp 1'b0;
1537
  else
1538
  if(TxUsedData & Flop & TxByteCnt == 2'h3)
1539 39 mohor
    LastWord <=#Tp TxEndFrm_wb;
1540 38 mohor
end
1541
 
1542
 
1543
// Tx end frame generation
1544 40 mohor
always @ (posedge MTxClk or posedge Reset)
1545 38 mohor
begin
1546 40 mohor
  if(Reset)
1547 38 mohor
    TxEndFrm <=#Tp 1'b0;
1548
  else
1549 91 mohor
  if(Flop & TxEndFrm | TxAbort | TxRetry_q)
1550 38 mohor
    TxEndFrm <=#Tp 1'b0;
1551
  else
1552
  if(Flop & LastWord)
1553
    begin
1554 105 mohor
      case (TxValidBytesLatched)  // synopsys parallel_case
1555 38 mohor
        1 : TxEndFrm <=#Tp TxByteCnt == 2'h0;
1556
        2 : TxEndFrm <=#Tp TxByteCnt == 2'h1;
1557
        3 : TxEndFrm <=#Tp TxByteCnt == 2'h2;
1558
 
1559
        default : TxEndFrm <=#Tp 1'b0;
1560
      endcase
1561
    end
1562
end
1563
 
1564
 
1565
// Tx data selection (latching)
1566 40 mohor
always @ (posedge MTxClk or posedge Reset)
1567 38 mohor
begin
1568 40 mohor
  if(Reset)
1569 96 mohor
    TxData <=#Tp 0;
1570 38 mohor
  else
1571 39 mohor
  if(TxStartFrm_sync2 & ~TxStartFrm)
1572 159 mohor
    case(TxPointerLSB)  // synopsys parallel_case
1573 96 mohor
      2'h0 : TxData <=#Tp TxData_wb[31:24];                  // Big Endian Byte Ordering
1574
      2'h1 : TxData <=#Tp TxData_wb[23:16];                  // Big Endian Byte Ordering
1575
      2'h2 : TxData <=#Tp TxData_wb[15:08];                  // Big Endian Byte Ordering
1576
      2'h3 : TxData <=#Tp TxData_wb[07:00];                  // Big Endian Byte Ordering
1577
    endcase
1578 38 mohor
  else
1579 159 mohor
  if(TxStartFrm & TxUsedData & TxPointerLSB==2'h3)
1580 96 mohor
    TxData <=#Tp TxData_wb[31:24];                           // Big Endian Byte Ordering
1581
  else
1582 38 mohor
  if(TxUsedData & Flop)
1583
    begin
1584 105 mohor
      case(TxByteCnt)  // synopsys parallel_case
1585 226 tadejm
 
1586 82 mohor
        1 : TxData <=#Tp TxDataLatched[23:16];
1587
        2 : TxData <=#Tp TxDataLatched[15:8];
1588
        3 : TxData <=#Tp TxDataLatched[7:0];
1589 38 mohor
      endcase
1590
    end
1591
end
1592
 
1593
 
1594
// Latching tx data
1595 40 mohor
always @ (posedge MTxClk or posedge Reset)
1596 38 mohor
begin
1597 40 mohor
  if(Reset)
1598 38 mohor
    TxDataLatched[31:0] <=#Tp 32'h0;
1599
  else
1600 96 mohor
 if(TxStartFrm_sync2 & ~TxStartFrm | TxUsedData & Flop & TxByteCnt == 2'h3 | TxStartFrm & TxUsedData & Flop & TxByteCnt == 2'h0)
1601 39 mohor
    TxDataLatched[31:0] <=#Tp TxData_wb[31:0];
1602 38 mohor
end
1603
 
1604
 
1605
// Tx under run
1606 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1607 38 mohor
begin
1608 40 mohor
  if(Reset)
1609 60 mohor
    TxUnderRun_wb <=#Tp 1'b0;
1610 38 mohor
  else
1611 39 mohor
  if(TxAbortPulse)
1612 60 mohor
    TxUnderRun_wb <=#Tp 1'b0;
1613
  else
1614
  if(TxBufferEmpty & ReadTxDataFromFifo_wb)
1615
    TxUnderRun_wb <=#Tp 1'b1;
1616
end
1617
 
1618
 
1619 159 mohor
reg TxUnderRun_sync1;
1620
 
1621 60 mohor
// Tx under run
1622
always @ (posedge MTxClk or posedge Reset)
1623
begin
1624
  if(Reset)
1625 159 mohor
    TxUnderRun_sync1 <=#Tp 1'b0;
1626 43 mohor
  else
1627 60 mohor
  if(TxUnderRun_wb)
1628 159 mohor
    TxUnderRun_sync1 <=#Tp 1'b1;
1629 60 mohor
  else
1630 159 mohor
  if(BlockingTxStatusWrite_sync2)
1631
    TxUnderRun_sync1 <=#Tp 1'b0;
1632
end
1633
 
1634
// Tx under run
1635
always @ (posedge MTxClk or posedge Reset)
1636
begin
1637
  if(Reset)
1638 60 mohor
    TxUnderRun <=#Tp 1'b0;
1639 159 mohor
  else
1640
  if(BlockingTxStatusWrite_sync2)
1641
    TxUnderRun <=#Tp 1'b0;
1642
  else
1643
  if(TxUnderRun_sync1)
1644
    TxUnderRun <=#Tp 1'b1;
1645 38 mohor
end
1646
 
1647
 
1648
// Tx Byte counter
1649 40 mohor
always @ (posedge MTxClk or posedge Reset)
1650 38 mohor
begin
1651 40 mohor
  if(Reset)
1652 38 mohor
    TxByteCnt <=#Tp 2'h0;
1653
  else
1654
  if(TxAbort_q | TxRetry_q)
1655
    TxByteCnt <=#Tp 2'h0;
1656
  else
1657
  if(TxStartFrm & ~TxUsedData)
1658 159 mohor
    case(TxPointerLSB)  // synopsys parallel_case
1659 96 mohor
      2'h0 : TxByteCnt <=#Tp 2'h1;
1660
      2'h1 : TxByteCnt <=#Tp 2'h2;
1661
      2'h2 : TxByteCnt <=#Tp 2'h3;
1662
      2'h3 : TxByteCnt <=#Tp 2'h0;
1663
    endcase
1664 38 mohor
  else
1665
  if(TxUsedData & Flop)
1666 96 mohor
    TxByteCnt <=#Tp TxByteCnt + 1'b1;
1667 38 mohor
end
1668
 
1669 39 mohor
 
1670 150 mohor
// Start: Generation of the ReadTxDataFromFifo_tck signal and synchronization to the WB_CLK_I
1671
reg ReadTxDataFromFifo_sync1;
1672
reg ReadTxDataFromFifo_sync2;
1673
reg ReadTxDataFromFifo_sync3;
1674
reg ReadTxDataFromFifo_syncb1;
1675
reg ReadTxDataFromFifo_syncb2;
1676
reg ReadTxDataFromFifo_syncb3;
1677
 
1678
 
1679
always @ (posedge MTxClk or posedge Reset)
1680
begin
1681
  if(Reset)
1682
    ReadTxDataFromFifo_tck <=#Tp 1'b0;
1683
  else
1684 96 mohor
  if(TxStartFrm_sync2 & ~TxStartFrm | TxUsedData & Flop & TxByteCnt == 2'h3 & ~LastWord | TxStartFrm & TxUsedData & Flop & TxByteCnt == 2'h0)
1685 39 mohor
     ReadTxDataFromFifo_tck <=#Tp 1'b1;
1686 150 mohor
  else
1687
  if(ReadTxDataFromFifo_syncb2 & ~ReadTxDataFromFifo_syncb3)
1688
    ReadTxDataFromFifo_tck <=#Tp 1'b0;
1689 38 mohor
end
1690
 
1691 39 mohor
// Synchronizing TxStartFrm_wb to MTxClk
1692 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1693 38 mohor
begin
1694 40 mohor
  if(Reset)
1695 39 mohor
    ReadTxDataFromFifo_sync1 <=#Tp 1'b0;
1696 38 mohor
  else
1697 39 mohor
    ReadTxDataFromFifo_sync1 <=#Tp ReadTxDataFromFifo_tck;
1698
end
1699 38 mohor
 
1700 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1701 38 mohor
begin
1702 40 mohor
  if(Reset)
1703 39 mohor
    ReadTxDataFromFifo_sync2 <=#Tp 1'b0;
1704 38 mohor
  else
1705 39 mohor
    ReadTxDataFromFifo_sync2 <=#Tp ReadTxDataFromFifo_sync1;
1706 38 mohor
end
1707
 
1708 40 mohor
always @ (posedge MTxClk or posedge Reset)
1709 38 mohor
begin
1710 40 mohor
  if(Reset)
1711 39 mohor
    ReadTxDataFromFifo_syncb1 <=#Tp 1'b0;
1712 38 mohor
  else
1713 39 mohor
    ReadTxDataFromFifo_syncb1 <=#Tp ReadTxDataFromFifo_sync2;
1714 38 mohor
end
1715
 
1716 40 mohor
always @ (posedge MTxClk or posedge Reset)
1717 38 mohor
begin
1718 40 mohor
  if(Reset)
1719 39 mohor
    ReadTxDataFromFifo_syncb2 <=#Tp 1'b0;
1720 38 mohor
  else
1721 39 mohor
    ReadTxDataFromFifo_syncb2 <=#Tp ReadTxDataFromFifo_syncb1;
1722 38 mohor
end
1723
 
1724 150 mohor
always @ (posedge MTxClk or posedge Reset)
1725
begin
1726
  if(Reset)
1727
    ReadTxDataFromFifo_syncb3 <=#Tp 1'b0;
1728
  else
1729
    ReadTxDataFromFifo_syncb3 <=#Tp ReadTxDataFromFifo_syncb2;
1730
end
1731
 
1732 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1733 38 mohor
begin
1734 40 mohor
  if(Reset)
1735 39 mohor
    ReadTxDataFromFifo_sync3 <=#Tp 1'b0;
1736 38 mohor
  else
1737 39 mohor
    ReadTxDataFromFifo_sync3 <=#Tp ReadTxDataFromFifo_sync2;
1738 38 mohor
end
1739
 
1740 39 mohor
assign ReadTxDataFromFifo_wb = ReadTxDataFromFifo_sync2 & ~ReadTxDataFromFifo_sync3;
1741
// End: Generation of the ReadTxDataFromFifo_tck signal and synchronization to the WB_CLK_I
1742 38 mohor
 
1743
 
1744 39 mohor
// Synchronizing TxRetry signal (synchronized to WISHBONE clock)
1745 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1746 38 mohor
begin
1747 40 mohor
  if(Reset)
1748 39 mohor
    TxRetrySync1 <=#Tp 1'b0;
1749 38 mohor
  else
1750 39 mohor
    TxRetrySync1 <=#Tp TxRetry;
1751 38 mohor
end
1752
 
1753 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1754 38 mohor
begin
1755 40 mohor
  if(Reset)
1756 39 mohor
    TxRetry_wb <=#Tp 1'b0;
1757 38 mohor
  else
1758 39 mohor
    TxRetry_wb <=#Tp TxRetrySync1;
1759 38 mohor
end
1760
 
1761
 
1762 39 mohor
// Synchronized TxDone_wb signal (synchronized to WISHBONE clock)
1763 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1764 38 mohor
begin
1765 40 mohor
  if(Reset)
1766 39 mohor
    TxDoneSync1 <=#Tp 1'b0;
1767 38 mohor
  else
1768 39 mohor
    TxDoneSync1 <=#Tp TxDone;
1769 38 mohor
end
1770
 
1771 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1772 38 mohor
begin
1773 40 mohor
  if(Reset)
1774 39 mohor
    TxDone_wb <=#Tp 1'b0;
1775 38 mohor
  else
1776 39 mohor
    TxDone_wb <=#Tp TxDoneSync1;
1777 38 mohor
end
1778
 
1779 39 mohor
// Synchronizing TxAbort signal (synchronized to WISHBONE clock)
1780 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1781 38 mohor
begin
1782 40 mohor
  if(Reset)
1783 39 mohor
    TxAbortSync1 <=#Tp 1'b0;
1784 38 mohor
  else
1785 39 mohor
    TxAbortSync1 <=#Tp TxAbort;
1786 38 mohor
end
1787
 
1788 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1789 38 mohor
begin
1790 40 mohor
  if(Reset)
1791 38 mohor
    TxAbort_wb <=#Tp 1'b0;
1792
  else
1793 39 mohor
    TxAbort_wb <=#Tp TxAbortSync1;
1794 38 mohor
end
1795
 
1796
 
1797 150 mohor
reg RxAbortSync1;
1798
reg RxAbortSync2;
1799
reg RxAbortSync3;
1800
reg RxAbortSync4;
1801
reg RxAbortSyncb1;
1802
reg RxAbortSyncb2;
1803 39 mohor
 
1804 150 mohor
assign StartRxBDRead = RxStatusWrite | RxAbortSync3 & ~RxAbortSync4;
1805
 
1806 40 mohor
// Reading the Rx buffer descriptor
1807
always @ (posedge WB_CLK_I or posedge Reset)
1808
begin
1809
  if(Reset)
1810
    RxBDRead <=#Tp 1'b1;
1811
  else
1812 166 mohor
  if(StartRxBDRead & ~RxReady)
1813 40 mohor
    RxBDRead <=#Tp 1'b1;
1814
  else
1815
  if(RxBDReady)
1816
    RxBDRead <=#Tp 1'b0;
1817
end
1818 39 mohor
 
1819
 
1820 38 mohor
// Reading of the next receive buffer descriptor starts after reception status is
1821
// written to the previous one.
1822
 
1823
// Latching READY status of the Rx buffer descriptor
1824 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1825 38 mohor
begin
1826 40 mohor
  if(Reset)
1827 38 mohor
    RxBDReady <=#Tp 1'b0;
1828
  else
1829 166 mohor
  if(RxPointerRead)
1830 150 mohor
    RxBDReady <=#Tp 1'b0;
1831
  else
1832 40 mohor
  if(RxEn & RxEn_q & RxBDRead)
1833
    RxBDReady <=#Tp ram_do[15]; // RxBDReady is sampled only once at the beginning
1834 38 mohor
end
1835
 
1836 40 mohor
// Latching Rx buffer descriptor status
1837
// Data is avaliable one cycle after the access is started (at that time signal RxEn is not active)
1838
always @ (posedge WB_CLK_I or posedge Reset)
1839 38 mohor
begin
1840 40 mohor
  if(Reset)
1841 60 mohor
    RxStatus <=#Tp 2'h0;
1842 38 mohor
  else
1843 40 mohor
  if(RxEn & RxEn_q & RxBDRead)
1844 60 mohor
    RxStatus <=#Tp ram_do[14:13];
1845 38 mohor
end
1846
 
1847
 
1848 166 mohor
// RxReady generation
1849
always @ (posedge WB_CLK_I or posedge Reset)
1850
begin
1851
  if(Reset)
1852
    RxReady <=#Tp 1'b0;
1853
  else
1854
  if(ShiftEnded | RxAbortSync2 & ~RxAbortSync3)
1855
    RxReady <=#Tp 1'b0;
1856
  else
1857
  if(RxEn & RxEn_q & RxPointerRead)
1858
    RxReady <=#Tp 1'b1;
1859
end
1860 38 mohor
 
1861
 
1862 40 mohor
// Reading Rx BD pointer
1863
 
1864
 
1865
assign StartRxPointerRead = RxBDRead & RxBDReady;
1866
 
1867
// Reading Tx BD Pointer
1868
always @ (posedge WB_CLK_I or posedge Reset)
1869 38 mohor
begin
1870 40 mohor
  if(Reset)
1871
    RxPointerRead <=#Tp 1'b0;
1872 38 mohor
  else
1873 40 mohor
  if(StartRxPointerRead)
1874
    RxPointerRead <=#Tp 1'b1;
1875 38 mohor
  else
1876 166 mohor
  if(RxEn & RxEn_q)
1877 40 mohor
    RxPointerRead <=#Tp 1'b0;
1878 38 mohor
end
1879
 
1880 113 mohor
 
1881 40 mohor
//Latching Rx buffer pointer from buffer descriptor;
1882
always @ (posedge WB_CLK_I or posedge Reset)
1883
begin
1884
  if(Reset)
1885 159 mohor
    RxPointerMSB <=#Tp 30'h0;
1886 40 mohor
  else
1887
  if(RxEn & RxEn_q & RxPointerRead)
1888 159 mohor
    RxPointerMSB <=#Tp ram_do[31:2];
1889 40 mohor
  else
1890 113 mohor
  if(MasterWbRX & m_wb_ack_i)
1891 159 mohor
      RxPointerMSB <=#Tp RxPointerMSB + 1; // Word access  (always word access. m_wb_sel_o are used for selecting bytes)
1892 40 mohor
end
1893 38 mohor
 
1894
 
1895 96 mohor
//Latching last addresses from buffer descriptor (used as byte-half-word indicator);
1896 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1897
begin
1898
  if(Reset)
1899 159 mohor
    RxPointerLSB_rst[1:0] <=#Tp 0;
1900 96 mohor
  else
1901 159 mohor
  if(MasterWbRX & m_wb_ack_i)                 // After first write all RxByteSel are active
1902
    RxPointerLSB_rst[1:0] <=#Tp 0;
1903 96 mohor
  else
1904
  if(RxEn & RxEn_q & RxPointerRead)
1905 159 mohor
    RxPointerLSB_rst[1:0] <=#Tp ram_do[1:0];
1906 96 mohor
end
1907
 
1908
 
1909 159 mohor
always @ (RxPointerLSB_rst)
1910 96 mohor
begin
1911 159 mohor
  case(RxPointerLSB_rst[1:0])  // synopsys parallel_case
1912
    2'h0 : RxByteSel[3:0] = 4'hf;
1913
    2'h1 : RxByteSel[3:0] = 4'h7;
1914
    2'h2 : RxByteSel[3:0] = 4'h3;
1915
    2'h3 : RxByteSel[3:0] = 4'h1;
1916 96 mohor
  endcase
1917
end
1918
 
1919
 
1920
always @ (posedge WB_CLK_I or posedge Reset)
1921
begin
1922
  if(Reset)
1923 40 mohor
    RxEn_needed <=#Tp 1'b0;
1924 38 mohor
  else
1925 166 mohor
  if(~RxReady & r_RxEn & WbEn & ~WbEn_q)
1926 40 mohor
    RxEn_needed <=#Tp 1'b1;
1927 38 mohor
  else
1928 40 mohor
  if(RxPointerRead & RxEn & RxEn_q)
1929
    RxEn_needed <=#Tp 1'b0;
1930 38 mohor
end
1931
 
1932
 
1933 40 mohor
// Reception status is written back to the buffer descriptor after the end of frame is detected.
1934
assign RxStatusWrite = ShiftEnded & RxEn & RxEn_q;
1935 38 mohor
 
1936 40 mohor
reg RxEnableWindow;
1937 38 mohor
 
1938
// Indicating that last byte is being reveived
1939 40 mohor
always @ (posedge MRxClk or posedge Reset)
1940 38 mohor
begin
1941 40 mohor
  if(Reset)
1942 38 mohor
    LastByteIn <=#Tp 1'b0;
1943
  else
1944 40 mohor
  if(ShiftWillEnd & (&RxByteCnt) | RxAbort)
1945 38 mohor
    LastByteIn <=#Tp 1'b0;
1946
  else
1947 166 mohor
  if(RxValid & RxReady & RxEndFrm & ~(&RxByteCnt) & RxEnableWindow)
1948 38 mohor
    LastByteIn <=#Tp 1'b1;
1949
end
1950
 
1951 159 mohor
reg ShiftEnded_rck;
1952 40 mohor
reg ShiftEndedSync1;
1953
reg ShiftEndedSync2;
1954 118 mohor
reg ShiftEndedSync3;
1955
reg ShiftEndedSync_c1;
1956
reg ShiftEndedSync_c2;
1957
 
1958 40 mohor
wire StartShiftWillEnd;
1959 96 mohor
assign StartShiftWillEnd = LastByteIn  | RxValid & RxEndFrm & (&RxByteCnt) & RxEnableWindow;
1960 38 mohor
 
1961
// Indicating that data reception will end
1962 40 mohor
always @ (posedge MRxClk or posedge Reset)
1963 38 mohor
begin
1964 40 mohor
  if(Reset)
1965 38 mohor
    ShiftWillEnd <=#Tp 1'b0;
1966
  else
1967 159 mohor
  if(ShiftEnded_rck | RxAbort)
1968 38 mohor
    ShiftWillEnd <=#Tp 1'b0;
1969
  else
1970 40 mohor
  if(StartShiftWillEnd)
1971 38 mohor
    ShiftWillEnd <=#Tp 1'b1;
1972
end
1973
 
1974
 
1975 40 mohor
 
1976 38 mohor
// Receive byte counter
1977 40 mohor
always @ (posedge MRxClk or posedge Reset)
1978 38 mohor
begin
1979 40 mohor
  if(Reset)
1980 38 mohor
    RxByteCnt <=#Tp 2'h0;
1981
  else
1982 159 mohor
  if(ShiftEnded_rck | RxAbort)
1983 38 mohor
    RxByteCnt <=#Tp 2'h0;
1984 97 lampret
  else
1985 166 mohor
  if(RxValid & RxStartFrm & RxReady)
1986 159 mohor
    case(RxPointerLSB_rst)  // synopsys parallel_case
1987 96 mohor
      2'h0 : RxByteCnt <=#Tp 2'h1;
1988
      2'h1 : RxByteCnt <=#Tp 2'h2;
1989
      2'h2 : RxByteCnt <=#Tp 2'h3;
1990
      2'h3 : RxByteCnt <=#Tp 2'h0;
1991
    endcase
1992 38 mohor
  else
1993 166 mohor
  if(RxValid & RxEnableWindow & RxReady | LastByteIn)
1994 40 mohor
    RxByteCnt <=#Tp RxByteCnt + 1'b1;
1995 38 mohor
end
1996
 
1997
 
1998
// Indicates how many bytes are valid within the last word
1999 40 mohor
always @ (posedge MRxClk or posedge Reset)
2000 38 mohor
begin
2001 40 mohor
  if(Reset)
2002 38 mohor
    RxValidBytes <=#Tp 2'h1;
2003
  else
2004 96 mohor
  if(RxValid & RxStartFrm)
2005 159 mohor
    case(RxPointerLSB_rst)  // synopsys parallel_case
2006 96 mohor
      2'h0 : RxValidBytes <=#Tp 2'h1;
2007
      2'h1 : RxValidBytes <=#Tp 2'h2;
2008
      2'h2 : RxValidBytes <=#Tp 2'h3;
2009
      2'h3 : RxValidBytes <=#Tp 2'h0;
2010
    endcase
2011 38 mohor
  else
2012 40 mohor
  if(RxValid & ~LastByteIn & ~RxStartFrm & RxEnableWindow)
2013 38 mohor
    RxValidBytes <=#Tp RxValidBytes + 1;
2014
end
2015
 
2016
 
2017 40 mohor
always @ (posedge MRxClk or posedge Reset)
2018 38 mohor
begin
2019 40 mohor
  if(Reset)
2020
    RxDataLatched1       <=#Tp 24'h0;
2021 38 mohor
  else
2022 166 mohor
  if(RxValid & RxReady & ~LastByteIn)
2023 96 mohor
    if(RxStartFrm)
2024 40 mohor
    begin
2025 159 mohor
      case(RxPointerLSB_rst)     // synopsys parallel_case
2026 96 mohor
        2'h0:        RxDataLatched1[31:24] <=#Tp RxData;            // Big Endian Byte Ordering
2027
        2'h1:        RxDataLatched1[23:16] <=#Tp RxData;
2028
        2'h2:        RxDataLatched1[15:8]  <=#Tp RxData;
2029
        2'h3:        RxDataLatched1        <=#Tp RxDataLatched1;
2030
      endcase
2031
    end
2032
    else if (RxEnableWindow)
2033
    begin
2034 40 mohor
      case(RxByteCnt)     // synopsys parallel_case
2035 82 mohor
        2'h0:        RxDataLatched1[31:24] <=#Tp RxData;            // Big Endian Byte Ordering
2036
        2'h1:        RxDataLatched1[23:16] <=#Tp RxData;
2037
        2'h2:        RxDataLatched1[15:8]  <=#Tp RxData;
2038 40 mohor
        2'h3:        RxDataLatched1        <=#Tp RxDataLatched1;
2039
      endcase
2040
    end
2041 38 mohor
end
2042
 
2043 40 mohor
wire SetWriteRxDataToFifo;
2044 38 mohor
 
2045 40 mohor
// Assembling data that will be written to the rx_fifo
2046
always @ (posedge MRxClk or posedge Reset)
2047 38 mohor
begin
2048 40 mohor
  if(Reset)
2049
    RxDataLatched2 <=#Tp 32'h0;
2050 38 mohor
  else
2051 40 mohor
  if(SetWriteRxDataToFifo & ~ShiftWillEnd)
2052 82 mohor
    RxDataLatched2 <=#Tp {RxDataLatched1[31:8], RxData};              // Big Endian Byte Ordering
2053 38 mohor
  else
2054 40 mohor
  if(SetWriteRxDataToFifo & ShiftWillEnd)
2055 105 mohor
    case(RxValidBytes)  // synopsys parallel_case
2056 82 mohor
 
2057
      1 : RxDataLatched2 <=#Tp {RxDataLatched1[31:24], 24'h0};
2058
      2 : RxDataLatched2 <=#Tp {RxDataLatched1[31:16], 16'h0};
2059
      3 : RxDataLatched2 <=#Tp {RxDataLatched1[31:8],   8'h0};
2060 40 mohor
    endcase
2061 38 mohor
end
2062
 
2063
 
2064 40 mohor
reg WriteRxDataToFifoSync1;
2065
reg WriteRxDataToFifoSync2;
2066 150 mohor
reg WriteRxDataToFifoSync3;
2067 38 mohor
 
2068
 
2069 40 mohor
// Indicating start of the reception process
2070 166 mohor
assign SetWriteRxDataToFifo = (RxValid & RxReady & ~RxStartFrm & RxEnableWindow & (&RxByteCnt)) |
2071
                              (RxValid & RxReady &  RxStartFrm & (&RxPointerLSB_rst))           |
2072
                              (ShiftWillEnd & LastByteIn & (&RxByteCnt));
2073 38 mohor
 
2074 150 mohor
always @ (posedge MRxClk or posedge Reset)
2075
begin
2076
  if(Reset)
2077
    WriteRxDataToFifo <=#Tp 1'b0;
2078
  else
2079
  if(SetWriteRxDataToFifo & ~RxAbort)
2080
    WriteRxDataToFifo <=#Tp 1'b1;
2081
  else
2082
  if(WriteRxDataToFifoSync2 | RxAbort)
2083
    WriteRxDataToFifo <=#Tp 1'b0;
2084
end
2085 40 mohor
 
2086 150 mohor
 
2087
 
2088
always @ (posedge WB_CLK_I or posedge Reset)
2089
begin
2090
  if(Reset)
2091
    WriteRxDataToFifoSync1 <=#Tp 1'b0;
2092
  else
2093
  if(WriteRxDataToFifo)
2094
    WriteRxDataToFifoSync1 <=#Tp 1'b1;
2095
  else
2096
    WriteRxDataToFifoSync1 <=#Tp 1'b0;
2097
end
2098
 
2099
always @ (posedge WB_CLK_I or posedge Reset)
2100
begin
2101
  if(Reset)
2102
    WriteRxDataToFifoSync2 <=#Tp 1'b0;
2103
  else
2104
    WriteRxDataToFifoSync2 <=#Tp WriteRxDataToFifoSync1;
2105
end
2106
 
2107
always @ (posedge WB_CLK_I or posedge Reset)
2108
begin
2109
  if(Reset)
2110
    WriteRxDataToFifoSync3 <=#Tp 1'b0;
2111
  else
2112
    WriteRxDataToFifoSync3 <=#Tp WriteRxDataToFifoSync2;
2113
end
2114
 
2115
wire WriteRxDataToFifo_wb;
2116
assign WriteRxDataToFifo_wb = WriteRxDataToFifoSync2 & ~WriteRxDataToFifoSync3;
2117
 
2118
 
2119 90 mohor
reg LatchedRxStartFrm;
2120
reg SyncRxStartFrm;
2121
reg SyncRxStartFrm_q;
2122 150 mohor
reg SyncRxStartFrm_q2;
2123 90 mohor
wire RxFifoReset;
2124 40 mohor
 
2125 90 mohor
always @ (posedge MRxClk or posedge Reset)
2126
begin
2127
  if(Reset)
2128
    LatchedRxStartFrm <=#Tp 0;
2129
  else
2130 150 mohor
  if(RxStartFrm & ~SyncRxStartFrm_q)
2131 90 mohor
    LatchedRxStartFrm <=#Tp 1;
2132
  else
2133 150 mohor
  if(SyncRxStartFrm_q)
2134 90 mohor
    LatchedRxStartFrm <=#Tp 0;
2135
end
2136
 
2137
 
2138
always @ (posedge WB_CLK_I or posedge Reset)
2139
begin
2140
  if(Reset)
2141
    SyncRxStartFrm <=#Tp 0;
2142
  else
2143
  if(LatchedRxStartFrm)
2144
    SyncRxStartFrm <=#Tp 1;
2145
  else
2146
    SyncRxStartFrm <=#Tp 0;
2147
end
2148
 
2149
 
2150
always @ (posedge WB_CLK_I or posedge Reset)
2151
begin
2152
  if(Reset)
2153
    SyncRxStartFrm_q <=#Tp 0;
2154
  else
2155
    SyncRxStartFrm_q <=#Tp SyncRxStartFrm;
2156
end
2157
 
2158 150 mohor
always @ (posedge WB_CLK_I or posedge Reset)
2159
begin
2160
  if(Reset)
2161
    SyncRxStartFrm_q2 <=#Tp 0;
2162
  else
2163
    SyncRxStartFrm_q2 <=#Tp SyncRxStartFrm_q;
2164
end
2165 90 mohor
 
2166
 
2167 150 mohor
assign RxFifoReset = SyncRxStartFrm_q & ~SyncRxStartFrm_q2;
2168 90 mohor
 
2169 150 mohor
 
2170 219 mohor
eth_fifo #(`ETH_RX_FIFO_DATA_WIDTH, `ETH_RX_FIFO_DEPTH, `ETH_RX_FIFO_CNT_WIDTH)
2171 88 mohor
rx_fifo (.data_in(RxDataLatched2),                      .data_out(m_wb_dat_o),
2172
         .clk(WB_CLK_I),                                .reset(Reset),
2173 219 mohor
         .write(WriteRxDataToFifo_wb & ~RxBufferFull),  .read(MasterWbRX & m_wb_ack_i),
2174 90 mohor
         .clear(RxFifoReset),                           .full(RxBufferFull),
2175 118 mohor
         .almost_full(),                                .almost_empty(RxBufferAlmostEmpty),
2176 150 mohor
         .empty(RxBufferEmpty),                         .cnt(rxfifo_cnt)
2177 88 mohor
        );
2178 40 mohor
 
2179 226 tadejm
assign enough_data_in_rxfifo_for_burst = rxfifo_cnt>=`ETH_BURST_LENGTH;
2180
assign enough_data_in_rxfifo_for_burst_plus1 = rxfifo_cnt>`ETH_BURST_LENGTH;
2181 219 mohor
assign WriteRxDataToMemory = ~RxBufferEmpty;
2182 226 tadejm
assign rx_burst = rx_burst_en & WriteRxDataToMemory;
2183 40 mohor
 
2184
 
2185
// Generation of the end-of-frame signal
2186
always @ (posedge MRxClk or posedge Reset)
2187 38 mohor
begin
2188 40 mohor
  if(Reset)
2189 159 mohor
    ShiftEnded_rck <=#Tp 1'b0;
2190 38 mohor
  else
2191 118 mohor
  if(~RxAbort & SetWriteRxDataToFifo & StartShiftWillEnd)
2192 159 mohor
    ShiftEnded_rck <=#Tp 1'b1;
2193 38 mohor
  else
2194 118 mohor
  if(RxAbort | ShiftEndedSync_c1 & ShiftEndedSync_c2)
2195 159 mohor
    ShiftEnded_rck <=#Tp 1'b0;
2196 38 mohor
end
2197
 
2198 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
2199
begin
2200
  if(Reset)
2201
    ShiftEndedSync1 <=#Tp 1'b0;
2202
  else
2203 159 mohor
    ShiftEndedSync1 <=#Tp ShiftEnded_rck;
2204 40 mohor
end
2205 38 mohor
 
2206 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
2207 38 mohor
begin
2208 40 mohor
  if(Reset)
2209
    ShiftEndedSync2 <=#Tp 1'b0;
2210 38 mohor
  else
2211 90 mohor
    ShiftEndedSync2 <=#Tp ShiftEndedSync1;
2212 40 mohor
end
2213 38 mohor
 
2214 118 mohor
always @ (posedge WB_CLK_I or posedge Reset)
2215
begin
2216
  if(Reset)
2217
    ShiftEndedSync3 <=#Tp 1'b0;
2218
  else
2219
  if(ShiftEndedSync1 & ~ShiftEndedSync2)
2220
    ShiftEndedSync3 <=#Tp 1'b1;
2221
  else
2222
  if(ShiftEnded)
2223
    ShiftEndedSync3 <=#Tp 1'b0;
2224
end
2225 38 mohor
 
2226 40 mohor
// Generation of the end-of-frame signal
2227
always @ (posedge WB_CLK_I or posedge Reset)
2228 38 mohor
begin
2229 40 mohor
  if(Reset)
2230
    ShiftEnded <=#Tp 1'b0;
2231 38 mohor
  else
2232 118 mohor
  if(ShiftEndedSync3 & MasterWbRX & m_wb_ack_i & RxBufferAlmostEmpty & ~ShiftEnded)
2233 40 mohor
    ShiftEnded <=#Tp 1'b1;
2234 38 mohor
  else
2235 40 mohor
  if(RxStatusWrite)
2236
    ShiftEnded <=#Tp 1'b0;
2237 38 mohor
end
2238
 
2239 118 mohor
always @ (posedge MRxClk or posedge Reset)
2240
begin
2241
  if(Reset)
2242
    ShiftEndedSync_c1 <=#Tp 1'b0;
2243
  else
2244
    ShiftEndedSync_c1 <=#Tp ShiftEndedSync2;
2245
end
2246 38 mohor
 
2247 118 mohor
always @ (posedge MRxClk or posedge Reset)
2248
begin
2249
  if(Reset)
2250
    ShiftEndedSync_c2 <=#Tp 1'b0;
2251
  else
2252
    ShiftEndedSync_c2 <=#Tp ShiftEndedSync_c1;
2253
end
2254
 
2255 40 mohor
// Generation of the end-of-frame signal
2256
always @ (posedge MRxClk or posedge Reset)
2257 38 mohor
begin
2258 40 mohor
  if(Reset)
2259
    RxEnableWindow <=#Tp 1'b0;
2260 38 mohor
  else
2261 40 mohor
  if(RxStartFrm)
2262
    RxEnableWindow <=#Tp 1'b1;
2263 38 mohor
  else
2264 40 mohor
  if(RxEndFrm | RxAbort)
2265
    RxEnableWindow <=#Tp 1'b0;
2266 38 mohor
end
2267
 
2268
 
2269 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
2270 38 mohor
begin
2271 40 mohor
  if(Reset)
2272
    RxAbortSync1 <=#Tp 1'b0;
2273 38 mohor
  else
2274 150 mohor
    RxAbortSync1 <=#Tp RxAbortLatched;
2275 40 mohor
end
2276
 
2277
always @ (posedge WB_CLK_I or posedge Reset)
2278
begin
2279
  if(Reset)
2280
    RxAbortSync2 <=#Tp 1'b0;
2281 38 mohor
  else
2282 40 mohor
    RxAbortSync2 <=#Tp RxAbortSync1;
2283 38 mohor
end
2284
 
2285 150 mohor
always @ (posedge WB_CLK_I or posedge Reset)
2286
begin
2287
  if(Reset)
2288
    RxAbortSync3 <=#Tp 1'b0;
2289
  else
2290
    RxAbortSync3 <=#Tp RxAbortSync2;
2291
end
2292
 
2293
always @ (posedge WB_CLK_I or posedge Reset)
2294
begin
2295
  if(Reset)
2296
    RxAbortSync4 <=#Tp 1'b0;
2297
  else
2298
    RxAbortSync4 <=#Tp RxAbortSync3;
2299
end
2300
 
2301 40 mohor
always @ (posedge MRxClk or posedge Reset)
2302
begin
2303
  if(Reset)
2304
    RxAbortSyncb1 <=#Tp 1'b0;
2305
  else
2306
    RxAbortSyncb1 <=#Tp RxAbortSync2;
2307
end
2308 38 mohor
 
2309 40 mohor
always @ (posedge MRxClk or posedge Reset)
2310 38 mohor
begin
2311 40 mohor
  if(Reset)
2312
    RxAbortSyncb2 <=#Tp 1'b0;
2313 38 mohor
  else
2314 40 mohor
    RxAbortSyncb2 <=#Tp RxAbortSyncb1;
2315 38 mohor
end
2316
 
2317
 
2318 64 mohor
always @ (posedge MRxClk or posedge Reset)
2319
begin
2320
  if(Reset)
2321
    RxAbortLatched <=#Tp 1'b0;
2322
  else
2323 150 mohor
  if(RxAbortSyncb2)
2324
    RxAbortLatched <=#Tp 1'b0;
2325
  else
2326 64 mohor
  if(RxAbort)
2327
    RxAbortLatched <=#Tp 1'b1;
2328
end
2329 40 mohor
 
2330 64 mohor
 
2331 42 mohor
always @ (posedge MRxClk or posedge Reset)
2332
begin
2333
  if(Reset)
2334
    LatchedRxLength[15:0] <=#Tp 16'h0;
2335
  else
2336 150 mohor
  if(LoadRxStatus)
2337 42 mohor
    LatchedRxLength[15:0] <=#Tp RxLength[15:0];
2338
end
2339
 
2340
 
2341 261 mohor
assign RxStatusIn = {ReceivedPauseFrm, AddressMiss, RxOverrun, InvalidSymbol, DribbleNibble, ReceivedPacketTooBig, ShortFrame, LatchedCrcError, RxLateCollision};
2342 42 mohor
 
2343
always @ (posedge MRxClk or posedge Reset)
2344
begin
2345
  if(Reset)
2346
    RxStatusInLatched <=#Tp 'h0;
2347
  else
2348 150 mohor
  if(LoadRxStatus)
2349 42 mohor
    RxStatusInLatched <=#Tp RxStatusIn;
2350
end
2351
 
2352
 
2353 60 mohor
// Rx overrun
2354
always @ (posedge WB_CLK_I or posedge Reset)
2355
begin
2356
  if(Reset)
2357
    RxOverrun <=#Tp 1'b0;
2358
  else
2359
  if(RxStatusWrite)
2360
    RxOverrun <=#Tp 1'b0;
2361
  else
2362
  if(RxBufferFull & WriteRxDataToFifo_wb)
2363
    RxOverrun <=#Tp 1'b1;
2364
end
2365 48 mohor
 
2366 77 mohor
 
2367
 
2368
wire TxError;
2369
assign TxError = TxUnderRun | RetryLimit | LateCollLatched | CarrierSenseLost;
2370
 
2371
wire RxError;
2372
 
2373 239 tadejm
// ShortFrame (RxStatusInLatched[2]) can not set an error because short frames
2374 250 mohor
// are aborted when signal r_RecSmall is set to 0 in MODER register. 
2375
// AddressMiss is identifying that a frame was received because of the promiscous
2376
// mode and is not an error
2377 239 tadejm
assign RxError = (|RxStatusInLatched[6:3]) | (|RxStatusInLatched[1:0]);
2378
 
2379 272 tadejm
 
2380
 
2381
reg RxStatusWriteLatched;
2382
reg RxStatusWriteLatched_sync1;
2383
reg RxStatusWriteLatched_sync2;
2384
reg RxStatusWriteLatched_syncb1;
2385
reg RxStatusWriteLatched_syncb2;
2386
 
2387
 
2388
// Latching and synchronizing RxStatusWrite signal. This signal is used for clearing the ReceivedPauseFrm signal
2389
always @ (posedge WB_CLK_I or posedge Reset)
2390
begin
2391
  if(Reset)
2392
    RxStatusWriteLatched <=#Tp 1'b0;
2393
  else
2394
  if(RxStatusWriteLatched_syncb2)
2395
    RxStatusWriteLatched <=#Tp 1'b0;
2396
  else
2397
  if(RxStatusWrite)
2398
    RxStatusWriteLatched <=#Tp 1'b1;
2399
end
2400
 
2401
 
2402
always @ (posedge MRxClk or posedge Reset)
2403
begin
2404
  if(Reset)
2405
    begin
2406
      RxStatusWriteLatched_sync1 <=#Tp 1'b0;
2407
      RxStatusWriteLatched_sync2 <=#Tp 1'b0;
2408
    end
2409
  else
2410
    begin
2411
      RxStatusWriteLatched_sync1 <=#Tp RxStatusWriteLatched;
2412
      RxStatusWriteLatched_sync2 <=#Tp RxStatusWriteLatched_sync1;
2413
    end
2414
end
2415
 
2416
 
2417
always @ (posedge WB_CLK_I or posedge Reset)
2418
begin
2419
  if(Reset)
2420
    begin
2421
      RxStatusWriteLatched_syncb1 <=#Tp 1'b0;
2422
      RxStatusWriteLatched_syncb2 <=#Tp 1'b0;
2423
    end
2424
  else
2425
    begin
2426
      RxStatusWriteLatched_syncb1 <=#Tp RxStatusWriteLatched_sync2;
2427
      RxStatusWriteLatched_syncb2 <=#Tp RxStatusWriteLatched_syncb1;
2428
    end
2429
end
2430
 
2431
 
2432
 
2433 77 mohor
// Tx Done Interrupt
2434
always @ (posedge WB_CLK_I or posedge Reset)
2435
begin
2436
  if(Reset)
2437
    TxB_IRQ <=#Tp 1'b0;
2438
  else
2439
  if(TxStatusWrite & TxIRQEn)
2440
    TxB_IRQ <=#Tp ~TxError;
2441
  else
2442
    TxB_IRQ <=#Tp 1'b0;
2443
end
2444
 
2445
 
2446
// Tx Error Interrupt
2447
always @ (posedge WB_CLK_I or posedge Reset)
2448
begin
2449
  if(Reset)
2450
    TxE_IRQ <=#Tp 1'b0;
2451
  else
2452
  if(TxStatusWrite & TxIRQEn)
2453
    TxE_IRQ <=#Tp TxError;
2454
  else
2455
    TxE_IRQ <=#Tp 1'b0;
2456
end
2457
 
2458
 
2459
// Rx Done Interrupt
2460
always @ (posedge WB_CLK_I or posedge Reset)
2461
begin
2462
  if(Reset)
2463
    RxB_IRQ <=#Tp 1'b0;
2464
  else
2465 270 mohor
  if(RxStatusWrite & RxIRQEn & ReceivedPacketGood & (~ReceivedPauseFrm | ReceivedPauseFrm & r_PassAll & (~r_RxFlow)))
2466
    RxB_IRQ <=#Tp (~RxError);
2467 77 mohor
  else
2468
    RxB_IRQ <=#Tp 1'b0;
2469
end
2470
 
2471
 
2472
// Rx Error Interrupt
2473
always @ (posedge WB_CLK_I or posedge Reset)
2474
begin
2475
  if(Reset)
2476
    RxE_IRQ <=#Tp 1'b0;
2477
  else
2478 270 mohor
  if(RxStatusWrite & RxIRQEn & (~ReceivedPauseFrm | ReceivedPauseFrm & r_PassAll & (~r_RxFlow)))
2479 77 mohor
    RxE_IRQ <=#Tp RxError;
2480
  else
2481
    RxE_IRQ <=#Tp 1'b0;
2482
end
2483
 
2484
 
2485 166 mohor
// Busy Interrupt
2486 77 mohor
 
2487 166 mohor
reg Busy_IRQ_rck;
2488
reg Busy_IRQ_sync1;
2489
reg Busy_IRQ_sync2;
2490
reg Busy_IRQ_sync3;
2491
reg Busy_IRQ_syncb1;
2492
reg Busy_IRQ_syncb2;
2493 77 mohor
 
2494
 
2495 166 mohor
always @ (posedge MRxClk or posedge Reset)
2496
begin
2497
  if(Reset)
2498
    Busy_IRQ_rck <=#Tp 1'b0;
2499
  else
2500
  if(RxValid & RxStartFrm & ~RxReady)
2501
    Busy_IRQ_rck <=#Tp 1'b1;
2502
  else
2503
  if(Busy_IRQ_syncb2)
2504
    Busy_IRQ_rck <=#Tp 1'b0;
2505
end
2506 77 mohor
 
2507 166 mohor
always @ (posedge WB_CLK_I)
2508
begin
2509
    Busy_IRQ_sync1 <=#Tp Busy_IRQ_rck;
2510
    Busy_IRQ_sync2 <=#Tp Busy_IRQ_sync1;
2511
    Busy_IRQ_sync3 <=#Tp Busy_IRQ_sync2;
2512
end
2513
 
2514
always @ (posedge MRxClk)
2515
begin
2516
    Busy_IRQ_syncb1 <=#Tp Busy_IRQ_sync2;
2517
    Busy_IRQ_syncb2 <=#Tp Busy_IRQ_syncb1;
2518
end
2519
 
2520
assign Busy_IRQ = Busy_IRQ_sync2 & ~Busy_IRQ_sync3;
2521
 
2522
 
2523 60 mohor
 
2524
 
2525
 
2526 38 mohor
endmodule

powered by: WebSVN 2.1.0

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