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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [ethmac/] [eth_wishbone.v] - Blame information for rev 478

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

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

powered by: WebSVN 2.1.0

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