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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_7/] [rtl/] [verilog/] [eth_wishbone.v] - Blame information for rev 97

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

Line No. Rev Author Line
1 38 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_wishbone.v                                              ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/projects/ethmac/                   ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Igor Mohor (igorM@opencores.org)                      ////
10
////                                                              ////
11
////  All additional information is avaliable in the Readme.txt   ////
12
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16
//// Copyright (C) 2001 Authors                                   ////
17
////                                                              ////
18
//// This source file may be used and distributed without         ////
19
//// restriction provided that this copyright statement is not    ////
20
//// removed from the file and that any derivative work contains  ////
21
//// the original copyright notice and the associated disclaimer. ////
22
////                                                              ////
23
//// This source file is free software; you can redistribute it   ////
24
//// and/or modify it under the terms of the GNU Lesser General   ////
25
//// Public License as published by the Free Software Foundation; ////
26
//// either version 2.1 of the License, or (at your option) any   ////
27
//// later version.                                               ////
28
////                                                              ////
29
//// This source is distributed in the hope that it will be       ////
30
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
31
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
32
//// PURPOSE.  See the GNU Lesser General Public License for more ////
33
//// details.                                                     ////
34
////                                                              ////
35
//// You should have received a copy of the GNU Lesser General    ////
36
//// Public License along with this source; if not, download it   ////
37
//// from http://www.opencores.org/lgpl.shtml                     ////
38
////                                                              ////
39
//////////////////////////////////////////////////////////////////////
40
//
41
// CVS Revision History
42
//
43
// $Log: not supported by cvs2svn $
44 97 lampret
// Revision 1.20  2002/03/25 16:19:12  mohor
45
// Any address can be used for Tx and Rx BD pointers. Address does not need
46
// to be aligned.
47
//
48 96 mohor
// Revision 1.19  2002/03/19 12:51:50  mohor
49
// Comments in Slovene language removed.
50
//
51 91 mohor
// Revision 1.18  2002/03/19 12:46:52  mohor
52
// casex changed with case, fifo reset changed.
53
//
54 90 mohor
// Revision 1.17  2002/03/09 16:08:45  mohor
55
// rx_fifo was not always cleared ok. Fixed.
56
//
57 88 mohor
// Revision 1.16  2002/03/09 13:51:20  mohor
58
// Status was not latched correctly sometimes. Fixed.
59
//
60 87 mohor
// Revision 1.15  2002/03/08 06:56:46  mohor
61
// Big Endian problem when sending frames fixed.
62
//
63 86 mohor
// Revision 1.14  2002/03/02 19:12:40  mohor
64
// Byte ordering changed (Big Endian used). casex changed with case because
65
// Xilinx Foundation had problems. Tested in HW. It WORKS.
66
//
67 82 mohor
// Revision 1.13  2002/02/26 16:59:55  mohor
68
// Small fixes for external/internal DMA missmatches.
69
//
70 80 mohor
// Revision 1.12  2002/02/26 16:22:07  mohor
71
// Interrupts changed
72
//
73 77 mohor
// Revision 1.11  2002/02/15 17:07:39  mohor
74
// Status was not written correctly when frames were discarted because of
75
// address mismatch.
76
//
77 64 mohor
// Revision 1.10  2002/02/15 12:17:39  mohor
78
// RxStartFrm cleared when abort or retry comes.
79
//
80 61 mohor
// Revision 1.9  2002/02/15 11:59:10  mohor
81
// Changes that were lost when updating from 1.5 to 1.8 fixed.
82
//
83 60 mohor
// Revision 1.8  2002/02/14 20:54:33  billditt
84
// Addition  of new module eth_addrcheck.v
85
//
86
// Revision 1.7  2002/02/12 17:03:47  mohor
87
// RxOverRun added to statuses.
88
//
89
// Revision 1.6  2002/02/11 09:18:22  mohor
90
// Tx status is written back to the BD.
91
//
92 43 mohor
// Revision 1.5  2002/02/08 16:21:54  mohor
93
// Rx status is written back to the BD.
94
//
95 42 mohor
// Revision 1.4  2002/02/06 14:10:21  mohor
96
// non-DMA host interface added. Select the right configutation in eth_defines.
97
//
98 41 mohor
// Revision 1.3  2002/02/05 16:44:39  mohor
99
// Both rx and tx part are finished. Tested with wb_clk_i between 10 and 200
100
// MHz. Statuses, overrun, control frame transmission and reception still  need
101
// to be fixed.
102
//
103 40 mohor
// Revision 1.2  2002/02/01 12:46:51  mohor
104
// Tx part finished. TxStatus needs to be fixed. Pause request needs to be
105
// added.
106
//
107 39 mohor
// Revision 1.1  2002/01/23 10:47:59  mohor
108
// Initial version. Equals to eth_wishbonedma.v at this moment.
109 38 mohor
//
110
//
111
//
112 39 mohor
//
113 38 mohor
 
114 77 mohor
// Build pause frame
115
// Check GotData and evaluate data (abort or something like that comes before StartFrm)
116
// m_wb_err_i should start status underrun or uverrun
117
// r_RecSmall not used
118 38 mohor
 
119
`include "eth_defines.v"
120
`include "timescale.v"
121
 
122
 
123
module eth_wishbone
124
   (
125
 
126
    // WISHBONE common
127 40 mohor
    WB_CLK_I, WB_DAT_I, WB_DAT_O,
128 38 mohor
 
129
    // WISHBONE slave
130 77 mohor
                WB_ADR_I, WB_WE_I, WB_ACK_O,
131 40 mohor
    BDCs,
132 38 mohor
 
133 40 mohor
    Reset,
134
 
135 39 mohor
    // WISHBONE master
136
    m_wb_adr_o, m_wb_sel_o, m_wb_we_o,
137
    m_wb_dat_o, m_wb_dat_i, m_wb_cyc_o,
138
    m_wb_stb_o, m_wb_ack_i, m_wb_err_i,
139
 
140 38 mohor
    //TX
141 60 mohor
    MTxClk, TxStartFrm, TxEndFrm, TxUsedData, TxData,
142 38 mohor
    TxRetry, TxAbort, TxUnderRun, TxDone, TPauseRq, TxPauseTV, PerPacketCrcEn,
143
    PerPacketPad,
144
 
145
    //RX
146 40 mohor
    MRxClk, RxData, RxValid, RxStartFrm, RxEndFrm, RxAbort,
147 38 mohor
 
148
    // Register
149 77 mohor
    r_TxEn, r_RxEn, r_TxBDNum, TX_BD_NUM_Wr, r_RecSmall,
150 38 mohor
 
151 91 mohor
    WillSendControlFrame, TxCtrlEndFrm, // WillSendControlFrame out ?
152 38 mohor
 
153
    // Interrupts
154 77 mohor
    TxB_IRQ, TxE_IRQ, RxB_IRQ, RxE_IRQ, Busy_IRQ, TxC_IRQ, RxC_IRQ,
155 42 mohor
 
156 60 mohor
    // Rx Status
157 42 mohor
    InvalidSymbol, LatchedCrcError, RxLateCollision, ShortFrame, DribbleNibble,
158 77 mohor
    ReceivedPacketTooBig, RxLength, LoadRxStatus, ReceivedPacketGood,
159 60 mohor
 
160
    // Tx Status
161
    RetryCntLatched, RetryLimit, LateCollLatched, DeferLatched, CarrierSenseLost
162 38 mohor
                );
163
 
164
 
165
parameter Tp = 1;
166
 
167
// WISHBONE common
168
input           WB_CLK_I;       // WISHBONE clock
169
input  [31:0]   WB_DAT_I;       // WISHBONE data input
170
output [31:0]   WB_DAT_O;       // WISHBONE data output
171
 
172
// WISHBONE slave
173
input   [9:2]   WB_ADR_I;       // WISHBONE address input
174
input           WB_WE_I;        // WISHBONE write enable input
175
input           BDCs;           // Buffer descriptors are selected
176
output          WB_ACK_O;       // WISHBONE acknowledge output
177
 
178 39 mohor
// WISHBONE master
179
output  [31:0]  m_wb_adr_o;     // 
180
output   [3:0]  m_wb_sel_o;     // 
181
output          m_wb_we_o;      // 
182
output  [31:0]  m_wb_dat_o;     // 
183
output          m_wb_cyc_o;     // 
184
output          m_wb_stb_o;     // 
185
input   [31:0]  m_wb_dat_i;     // 
186
input           m_wb_ack_i;     // 
187
input           m_wb_err_i;     // 
188
 
189 40 mohor
input           Reset;       // Reset signal
190 39 mohor
 
191 60 mohor
// Rx Status signals
192 42 mohor
input           InvalidSymbol;    // Invalid symbol was received during reception in 100 Mbps mode
193
input           LatchedCrcError;  // CRC error
194
input           RxLateCollision;  // Late collision occured while receiving frame
195
input           ShortFrame;       // Frame shorter then the minimum size (r_MinFL) was received while small packets are enabled (r_RecSmall)
196
input           DribbleNibble;    // Extra nibble received
197
input           ReceivedPacketTooBig;// Received packet is bigger than r_MaxFL
198
input    [15:0] RxLength;         // Length of the incoming frame
199
input           LoadRxStatus;     // Rx status was loaded
200 77 mohor
input           ReceivedPacketGood;// Received packet's length and CRC are good
201 39 mohor
 
202 60 mohor
// Tx Status signals
203
input     [3:0] RetryCntLatched;  // Latched Retry Counter
204
input           RetryLimit;       // Retry limit reached (Retry Max value + 1 attempts were made)
205
input           LateCollLatched;  // Late collision occured
206
input           DeferLatched;     // Defer indication (Frame was defered before sucessfully sent)
207
input           CarrierSenseLost; // Carrier Sense was lost during the frame transmission
208
 
209 38 mohor
// Tx
210
input           MTxClk;         // Transmit clock (from PHY)
211
input           TxUsedData;     // Transmit packet used data
212
input           TxRetry;        // Transmit packet retry
213
input           TxAbort;        // Transmit packet abort
214
input           TxDone;         // Transmission ended
215
output          TxStartFrm;     // Transmit packet start frame
216
output          TxEndFrm;       // Transmit packet end frame
217
output  [7:0]   TxData;         // Transmit packet data byte
218
output          TxUnderRun;     // Transmit packet under-run
219
output          PerPacketCrcEn; // Per packet crc enable
220
output          PerPacketPad;   // Per packet pading
221
output          TPauseRq;       // Tx PAUSE control frame
222
output [15:0]   TxPauseTV;      // PAUSE timer value
223
input           WillSendControlFrame;
224
input           TxCtrlEndFrm;
225
 
226
// Rx
227
input           MRxClk;         // Receive clock (from PHY)
228
input   [7:0]   RxData;         // Received data byte (from PHY)
229
input           RxValid;        // 
230
input           RxStartFrm;     // 
231
input           RxEndFrm;       // 
232 40 mohor
input           RxAbort;        // This signal is set when address doesn't match.
233 38 mohor
 
234
//Register
235
input           r_TxEn;         // Transmit enable
236
input           r_RxEn;         // Receive enable
237
input   [7:0]   r_TxBDNum;      // Receive buffer descriptor number
238
input           TX_BD_NUM_Wr;   // RxBDNumber written
239 42 mohor
input           r_RecSmall;     // Receive small frames igor !!! tega uporabi
240 38 mohor
 
241
// Interrupts
242
output TxB_IRQ;
243
output TxE_IRQ;
244
output RxB_IRQ;
245 77 mohor
output RxE_IRQ;
246 38 mohor
output Busy_IRQ;
247 77 mohor
output TxC_IRQ;
248
output RxC_IRQ;
249 38 mohor
 
250 77 mohor
 
251
reg TxB_IRQ;
252
reg TxE_IRQ;
253
reg RxB_IRQ;
254
reg RxE_IRQ;
255
 
256
 
257 38 mohor
reg             TxStartFrm;
258
reg             TxEndFrm;
259
reg     [7:0]   TxData;
260
 
261
reg             TxUnderRun;
262 60 mohor
reg             TxUnderRun_wb;
263 38 mohor
 
264
reg             TxBDRead;
265 39 mohor
wire            TxStatusWrite;
266 38 mohor
 
267
reg     [1:0]   TxValidBytesLatched;
268
 
269
reg    [15:0]   TxLength;
270 60 mohor
reg    [15:0]   LatchedTxLength;
271
reg   [14:11]   TxStatus;
272 38 mohor
 
273 60 mohor
reg   [14:13]   RxStatus;
274 38 mohor
 
275
reg             TxStartFrm_wb;
276
reg             TxRetry_wb;
277 39 mohor
reg             TxAbort_wb;
278 38 mohor
reg             TxDone_wb;
279
 
280
reg             TxDone_wb_q;
281
reg             TxAbort_wb_q;
282 39 mohor
reg             TxRetry_wb_q;
283 38 mohor
reg             RxBDReady;
284
reg             TxBDReady;
285
 
286
reg             RxBDRead;
287 40 mohor
wire            RxStatusWrite;
288 38 mohor
 
289
reg    [31:0]   TxDataLatched;
290
reg     [1:0]   TxByteCnt;
291
reg             LastWord;
292 39 mohor
reg             ReadTxDataFromFifo_tck;
293 38 mohor
 
294
reg             BlockingTxStatusWrite;
295
reg             BlockingTxBDRead;
296
 
297 40 mohor
reg             Flop;
298 38 mohor
 
299
reg     [7:0]   TxBDAddress;
300
reg     [7:0]   RxBDAddress;
301
 
302
reg             TxRetrySync1;
303
reg             TxAbortSync1;
304 39 mohor
reg             TxDoneSync1;
305 38 mohor
 
306
reg             TxAbort_q;
307
reg             TxRetry_q;
308
reg             TxUsedData_q;
309
 
310
reg    [31:0]   RxDataLatched2;
311 82 mohor
 
312
// reg    [23:0]   RxDataLatched1;
313
reg    [31:8]   RxDataLatched1;     // Big Endian Byte Ordering
314
 
315 38 mohor
reg     [1:0]   RxValidBytes;
316
reg     [1:0]   RxByteCnt;
317
reg             LastByteIn;
318
reg             ShiftWillEnd;
319
 
320 40 mohor
reg             WriteRxDataToFifo;
321 42 mohor
reg    [15:0]   LatchedRxLength;
322 64 mohor
reg             RxAbortLatched;
323 38 mohor
 
324 40 mohor
reg             ShiftEnded;
325 60 mohor
reg             RxOverrun;
326 38 mohor
 
327 40 mohor
reg             BDWrite;                    // BD Write Enable for access from WISHBONE side
328
reg             BDRead;                     // BD Read access from WISHBONE side
329 39 mohor
wire   [31:0]   RxBDDataIn;                 // Rx BD data in
330
wire   [31:0]   TxBDDataIn;                 // Tx BD data in
331 38 mohor
 
332 39 mohor
reg             TxEndFrm_wb;
333 38 mohor
 
334 39 mohor
wire            TxRetryPulse;
335 38 mohor
wire            TxDonePulse;
336
wire            TxAbortPulse;
337
 
338
wire            StartRxBDRead;
339
 
340
wire            StartTxBDRead;
341
 
342
wire            TxIRQEn;
343
wire            WrapTxStatusBit;
344
 
345 77 mohor
wire            RxIRQEn;
346 38 mohor
wire            WrapRxStatusBit;
347
 
348
wire    [1:0]   TxValidBytes;
349
 
350
wire    [7:0]   TempTxBDAddress;
351
wire    [7:0]   TempRxBDAddress;
352
 
353
wire            SetGotData;
354
wire            GotDataEvaluate;
355
 
356 39 mohor
reg             temp_ack;
357 38 mohor
 
358 60 mohor
wire    [6:0]   RxStatusIn;
359
reg     [6:0]   RxStatusInLatched;
360 42 mohor
 
361 39 mohor
`ifdef ETH_REGISTERED_OUTPUTS
362
reg             temp_ack2;
363
reg [31:0]      registered_ram_do;
364
`endif
365 38 mohor
 
366 39 mohor
reg WbEn, WbEn_q;
367
reg RxEn, RxEn_q;
368
reg TxEn, TxEn_q;
369 38 mohor
 
370 39 mohor
wire ram_ce;
371
wire ram_we;
372
wire ram_oe;
373
reg [7:0]   ram_addr;
374
reg [31:0]  ram_di;
375
wire [31:0] ram_do;
376 38 mohor
 
377 39 mohor
wire StartTxPointerRead;
378
reg  TxPointerRead;
379
reg TxEn_needed;
380 40 mohor
reg RxEn_needed;
381 38 mohor
 
382 40 mohor
wire StartRxPointerRead;
383
reg RxPointerRead;
384 38 mohor
 
385 39 mohor
 
386 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
387
begin
388
  if(Reset)
389
    begin
390
      temp_ack <=#Tp 1'b0;
391
      `ifdef ETH_REGISTERED_OUTPUTS
392
      temp_ack2 <=#Tp 1'b0;
393
      registered_ram_do <=#Tp 32'h0;
394
      `endif
395
    end
396
  else
397
    begin
398
      temp_ack <=#Tp BDWrite & WbEn & WbEn_q | BDRead & WbEn & ~WbEn_q;
399
      `ifdef ETH_REGISTERED_OUTPUTS
400
      temp_ack2 <=#Tp temp_ack;
401
      registered_ram_do <=#Tp ram_do;
402
      `endif
403
    end
404
end
405 39 mohor
 
406
`ifdef ETH_REGISTERED_OUTPUTS
407
  assign WB_ACK_O = temp_ack2;
408
  assign WB_DAT_O = registered_ram_do;
409
`else
410
  assign WB_ACK_O = temp_ack;
411
  assign WB_DAT_O = ram_do;
412
`endif
413
 
414
 
415 41 mohor
// Generic synchronous single-port RAM interface
416 39 mohor
generic_spram #(8, 32) ram (
417
        // Generic synchronous single-port RAM interface
418 40 mohor
        .clk(WB_CLK_I), .rst(Reset), .ce(ram_ce), .we(ram_we), .oe(ram_oe), .addr(ram_addr), .di(ram_di), .do(ram_do)
419 39 mohor
);
420 41 mohor
 
421 39 mohor
assign ram_ce = 1'b1;
422 40 mohor
assign ram_we = BDWrite & WbEn & WbEn_q | TxStatusWrite | RxStatusWrite;
423 61 mohor
assign ram_oe = BDRead & WbEn & WbEn_q | TxEn & TxEn_q & (TxBDRead | TxPointerRead) | RxEn & RxEn_q & (RxBDRead | RxPointerRead);
424 39 mohor
 
425
 
426 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
427 38 mohor
begin
428 40 mohor
  if(Reset)
429 39 mohor
    TxEn_needed <=#Tp 1'b0;
430 38 mohor
  else
431 40 mohor
  if(~TxBDReady & r_TxEn & WbEn & ~WbEn_q)
432 39 mohor
    TxEn_needed <=#Tp 1'b1;
433
  else
434
  if(TxPointerRead & TxEn & TxEn_q)
435
    TxEn_needed <=#Tp 1'b0;
436 38 mohor
end
437
 
438
 
439 39 mohor
// Enabling access to the RAM for three devices.
440 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
441 39 mohor
begin
442 40 mohor
  if(Reset)
443 39 mohor
    begin
444
      WbEn <=#Tp 1'b1;
445
      RxEn <=#Tp 1'b0;
446
      TxEn <=#Tp 1'b0;
447
      ram_addr <=#Tp 8'h0;
448
      ram_di <=#Tp 32'h0;
449 77 mohor
      BDRead <=#Tp 1'b0;
450
      BDWrite <=#Tp 1'b0;
451 39 mohor
    end
452
  else
453
    begin
454
      // Switching between three stages depends on enable signals
455 90 mohor
      case ({WbEn_q, RxEn_q, TxEn_q, RxEn_needed, TxEn_needed})  // synopsys parallel_case
456
        5'b100_10, 5'b100_11 :
457 39 mohor
          begin
458
            WbEn <=#Tp 1'b0;
459
            RxEn <=#Tp 1'b1;  // wb access stage and r_RxEn is enabled
460
            TxEn <=#Tp 1'b0;
461 40 mohor
            ram_addr <=#Tp RxBDAddress + RxPointerRead;
462 39 mohor
            ram_di <=#Tp RxBDDataIn;
463
          end
464
        5'b100_01 :
465
          begin
466
            WbEn <=#Tp 1'b0;
467
            RxEn <=#Tp 1'b0;
468
            TxEn <=#Tp 1'b1;  // wb access stage, r_RxEn is disabled but r_TxEn is enabled
469
            ram_addr <=#Tp TxBDAddress + TxPointerRead;
470
            ram_di <=#Tp TxBDDataIn;
471
          end
472 90 mohor
        5'b010_00, 5'b010_10 :
473 39 mohor
          begin
474
            WbEn <=#Tp 1'b1;  // RxEn access stage and r_TxEn is disabled
475
            RxEn <=#Tp 1'b0;
476
            TxEn <=#Tp 1'b0;
477
            ram_addr <=#Tp WB_ADR_I[9:2];
478
            ram_di <=#Tp WB_DAT_I;
479 40 mohor
            BDWrite <=#Tp BDCs & WB_WE_I;
480
            BDRead <=#Tp BDCs & ~WB_WE_I;
481 39 mohor
          end
482 90 mohor
        5'b010_01, 5'b010_11 :
483 39 mohor
          begin
484
            WbEn <=#Tp 1'b0;
485
            RxEn <=#Tp 1'b0;
486
            TxEn <=#Tp 1'b1;  // RxEn access stage and r_TxEn is enabled
487
            ram_addr <=#Tp TxBDAddress + TxPointerRead;
488
            ram_di <=#Tp TxBDDataIn;
489
          end
490 90 mohor
        5'b001_00, 5'b001_01, 5'b001_10, 5'b001_11 :
491 39 mohor
          begin
492
            WbEn <=#Tp 1'b1;  // TxEn access stage (we always go to wb access stage)
493
            RxEn <=#Tp 1'b0;
494
            TxEn <=#Tp 1'b0;
495
            ram_addr <=#Tp WB_ADR_I[9:2];
496
            ram_di <=#Tp WB_DAT_I;
497 40 mohor
            BDWrite <=#Tp BDCs & WB_WE_I;
498
            BDRead <=#Tp BDCs & ~WB_WE_I;
499 39 mohor
          end
500
        5'b100_00 :
501
          begin
502
            WbEn <=#Tp 1'b0;  // WbEn access stage and there is no need for other stages. WbEn needs to be switched off for a bit
503
          end
504
        5'b000_00 :
505
          begin
506
            WbEn <=#Tp 1'b1;  // Idle state. We go to WbEn access stage.
507
            RxEn <=#Tp 1'b0;
508
            TxEn <=#Tp 1'b0;
509
            ram_addr <=#Tp WB_ADR_I[9:2];
510
            ram_di <=#Tp WB_DAT_I;
511 40 mohor
            BDWrite <=#Tp BDCs & WB_WE_I;
512
            BDRead <=#Tp BDCs & ~WB_WE_I;
513 39 mohor
          end
514
        default :
515
          begin
516
            WbEn <=#Tp 1'b1;  // We go to wb access stage
517
            RxEn <=#Tp 1'b0;
518
            TxEn <=#Tp 1'b0;
519
            ram_addr <=#Tp WB_ADR_I[9:2];
520
            ram_di <=#Tp WB_DAT_I;
521 40 mohor
            BDWrite <=#Tp BDCs & WB_WE_I;
522
            BDRead <=#Tp BDCs & ~WB_WE_I;
523 39 mohor
          end
524
      endcase
525
    end
526
end
527
 
528
 
529
// Delayed stage signals
530 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
531 39 mohor
begin
532 40 mohor
  if(Reset)
533 39 mohor
    begin
534
      WbEn_q <=#Tp 1'b0;
535
      RxEn_q <=#Tp 1'b0;
536
      TxEn_q <=#Tp 1'b0;
537
    end
538
  else
539
    begin
540
      WbEn_q <=#Tp WbEn;
541
      RxEn_q <=#Tp RxEn;
542
      TxEn_q <=#Tp TxEn;
543
    end
544
end
545
 
546 38 mohor
// Changes for tx occur every second clock. Flop is used for this manner.
547 40 mohor
always @ (posedge MTxClk or posedge Reset)
548 38 mohor
begin
549 40 mohor
  if(Reset)
550 38 mohor
    Flop <=#Tp 1'b0;
551
  else
552
  if(TxDone | TxAbort | TxRetry_q)
553
    Flop <=#Tp 1'b0;
554
  else
555
  if(TxUsedData)
556
    Flop <=#Tp ~Flop;
557
end
558
 
559 39 mohor
wire ResetTxBDReady;
560
assign ResetTxBDReady = TxDonePulse | TxAbortPulse | TxRetryPulse;
561 38 mohor
 
562
// Latching READY status of the Tx buffer descriptor
563 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
564 38 mohor
begin
565 40 mohor
  if(Reset)
566 38 mohor
    TxBDReady <=#Tp 1'b0;
567
  else
568 40 mohor
  if(TxEn & TxEn_q & TxBDRead)
569
    TxBDReady <=#Tp ram_do[15] & (ram_do[31:16] > 4); // TxBDReady is sampled only once at the beginning.
570
  else                                                // Only packets larger then 4 bytes are transmitted.
571 39 mohor
  if(ResetTxBDReady)
572 38 mohor
    TxBDReady <=#Tp 1'b0;
573
end
574
 
575
 
576 39 mohor
// Reading the Tx buffer descriptor
577
assign StartTxBDRead = (TxRetry_wb | TxStatusWrite) & ~BlockingTxBDRead;
578
 
579 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
580 38 mohor
begin
581 40 mohor
  if(Reset)
582 39 mohor
    TxBDRead <=#Tp 1'b1;
583 38 mohor
  else
584 90 mohor
  if(StartTxBDRead & ~TxBDReady)
585 39 mohor
    TxBDRead <=#Tp 1'b1;
586 38 mohor
  else
587 39 mohor
  if(TxBDReady)
588
    TxBDRead <=#Tp 1'b0;
589 38 mohor
end
590
 
591
 
592 39 mohor
// Reading Tx BD pointer
593
assign StartTxPointerRead = TxBDRead & TxBDReady;
594 38 mohor
 
595 39 mohor
// Reading Tx BD Pointer
596 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
597 38 mohor
begin
598 40 mohor
  if(Reset)
599 39 mohor
    TxPointerRead <=#Tp 1'b0;
600 38 mohor
  else
601 39 mohor
  if(StartTxPointerRead)
602
    TxPointerRead <=#Tp 1'b1;
603 38 mohor
  else
604 39 mohor
  if(TxEn_q)
605
    TxPointerRead <=#Tp 1'b0;
606 38 mohor
end
607
 
608
 
609 39 mohor
// Writing status back to the Tx buffer descriptor
610
assign TxStatusWrite = (TxDone_wb | TxAbort_wb) & TxEn & TxEn_q & ~BlockingTxStatusWrite;
611 38 mohor
 
612
 
613
 
614 39 mohor
// Status writing must occur only once. Meanwhile it is blocked.
615 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
616 38 mohor
begin
617 40 mohor
  if(Reset)
618 39 mohor
    BlockingTxStatusWrite <=#Tp 1'b0;
619 38 mohor
  else
620 39 mohor
  if(TxStatusWrite)
621
    BlockingTxStatusWrite <=#Tp 1'b1;
622 38 mohor
  else
623 39 mohor
  if(~TxDone_wb & ~TxAbort_wb)
624
    BlockingTxStatusWrite <=#Tp 1'b0;
625 38 mohor
end
626
 
627
 
628 39 mohor
// TxBDRead state is activated only once. 
629 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
630 39 mohor
begin
631 40 mohor
  if(Reset)
632 39 mohor
    BlockingTxBDRead <=#Tp 1'b0;
633
  else
634 90 mohor
  if(StartTxBDRead & ~TxBDReady)
635 39 mohor
    BlockingTxBDRead <=#Tp 1'b1;
636
  else
637
  if(TxStartFrm_wb)
638
    BlockingTxBDRead <=#Tp 1'b0;
639
end
640 38 mohor
 
641
 
642 39 mohor
// Latching status from the tx buffer descriptor
643
// Data is avaliable one cycle after the access is started (at that time signal TxEn is not active)
644 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
645 38 mohor
begin
646 40 mohor
  if(Reset)
647 60 mohor
    TxStatus <=#Tp 4'h0;
648 38 mohor
  else
649 40 mohor
  if(TxEn & TxEn_q & TxBDRead)
650 60 mohor
    TxStatus <=#Tp ram_do[14:11];
651 38 mohor
end
652
 
653 40 mohor
reg ReadTxDataFromMemory;
654
wire WriteRxDataToMemory;
655 38 mohor
 
656 39 mohor
reg MasterWbTX;
657
reg MasterWbRX;
658
 
659
reg [31:0] m_wb_adr_o;
660
reg        m_wb_cyc_o;
661
reg        m_wb_stb_o;
662 96 mohor
reg  [3:0] m_wb_sel_o;
663 39 mohor
reg        m_wb_we_o;
664 40 mohor
 
665 39 mohor
wire TxLengthEq0;
666
wire TxLengthLt4;
667
 
668 96 mohor
wire WordAccFinished;
669
wire HalfAccFinished;
670 39 mohor
 
671
//Latching length from the buffer descriptor;
672 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
673 38 mohor
begin
674 40 mohor
  if(Reset)
675 39 mohor
    TxLength <=#Tp 16'h0;
676 38 mohor
  else
677 39 mohor
  if(TxEn & TxEn_q & TxBDRead)
678
    TxLength <=#Tp ram_do[31:16];
679 38 mohor
  else
680 39 mohor
  if(MasterWbTX & m_wb_ack_i)
681
    begin
682
      if(TxLengthLt4)
683
        TxLength <=#Tp 16'h0;
684 96 mohor
      else if(WordAccFinished)
685
        TxLength <=#Tp TxLength - 3'h4;    // Length is subtracted at the data request
686
      else if(HalfAccFinished)
687
        TxLength <=#Tp TxLength - 2'h2;    // Length is subtracted at the data request
688 39 mohor
      else
689 96 mohor
        TxLength <=#Tp TxLength - 1'h1;    // Length is subtracted at the data request
690 39 mohor
    end
691 38 mohor
end
692
 
693 96 mohor
assign WordAccFinished = &m_wb_sel_o[3:0];
694
assign HalfAccFinished = &m_wb_sel_o[1:0];
695
 
696
 
697
 
698 60 mohor
//Latching length from the buffer descriptor;
699
always @ (posedge WB_CLK_I or posedge Reset)
700
begin
701
  if(Reset)
702
    LatchedTxLength <=#Tp 16'h0;
703
  else
704
  if(TxEn & TxEn_q & TxBDRead)
705
    LatchedTxLength <=#Tp ram_do[31:16];
706
end
707
 
708 39 mohor
assign TxLengthEq0 = TxLength == 0;
709
assign TxLengthLt4 = TxLength < 4;
710 38 mohor
 
711 39 mohor
 
712
reg BlockingIncrementTxPointer;
713
 
714
reg [31:0] TxPointer;
715 96 mohor
reg [1:0]  TxPointerLatched;
716 39 mohor
reg [31:0] RxPointer;
717 96 mohor
reg [1:0]  RxPointerLatched;
718 39 mohor
 
719 96 mohor
wire TxBurstAcc;
720
wire TxWordAcc;
721
wire TxHalfAcc;
722
wire TxByteAcc;
723
 
724
wire RxBurstAcc;
725
wire RxWordAcc;
726
wire RxHalfAcc;
727
wire RxByteAcc;
728
 
729
 
730 39 mohor
//Latching Tx buffer pointer from buffer descriptor;
731 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
732 38 mohor
begin
733 40 mohor
  if(Reset)
734 39 mohor
    TxPointer <=#Tp 0;
735 38 mohor
  else
736 39 mohor
  if(TxEn & TxEn_q & TxPointerRead)
737
    TxPointer <=#Tp ram_do;
738 38 mohor
  else
739 39 mohor
  if(MasterWbTX & ~BlockingIncrementTxPointer)
740 96 mohor
    if(TxWordAcc)
741
      TxPointer <=#Tp TxPointer + 3'h4; // Word access
742
    else if(TxHalfAcc)
743
      TxPointer <=#Tp TxPointer + 2'h2; // Half access
744
    else
745
      TxPointer <=#Tp TxPointer + 1'h1; // Byte access
746 38 mohor
end
747
 
748 96 mohor
 
749
 
750
//Latching last addresses from buffer descriptor (used as byte-half-word indicator);
751
always @ (posedge WB_CLK_I or posedge Reset)
752
begin
753
  if(Reset)
754
    TxPointerLatched[1:0] <=#Tp 0;
755
  else
756
  if(TxEn & TxEn_q & TxPointerRead)
757
    TxPointerLatched[1:0] <=#Tp ram_do[1:0];
758
end
759
 
760
 
761
assign TxBurstAcc = ~TxPointer[3] & ~TxPointer[2] & ~TxPointer[1] & ~TxPointer[0]; // Add a counter that count burst to 4
762
assign TxWordAcc  = ~TxPointer[1] & ~TxPointer[0];
763
assign TxHalfAcc  =  TxPointer[1] & ~TxPointer[0];
764
assign TxByteAcc  =  TxPointer[0];
765
 
766
wire [3:0] m_wb_sel_tmp_tx;
767
reg  [3:0] m_wb_sel_tmp_rx;
768
 
769
 
770
assign m_wb_sel_tmp_tx[0] = TxWordAcc | TxHalfAcc | TxByteAcc &  TxPointer[1];
771
assign m_wb_sel_tmp_tx[1] = TxWordAcc | TxHalfAcc;
772
assign m_wb_sel_tmp_tx[2] = TxWordAcc |           | TxByteAcc & ~TxPointer[1];
773
assign m_wb_sel_tmp_tx[3] = TxWordAcc;
774
 
775
 
776 39 mohor
wire MasterAccessFinished;
777 38 mohor
 
778 39 mohor
 
779 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
780 38 mohor
begin
781 40 mohor
  if(Reset)
782 39 mohor
    BlockingIncrementTxPointer <=#Tp 0;
783 38 mohor
  else
784 39 mohor
  if(MasterAccessFinished)
785
    BlockingIncrementTxPointer <=#Tp 0;
786 38 mohor
  else
787 39 mohor
  if(MasterWbTX)
788
    BlockingIncrementTxPointer <=#Tp 1'b1;
789 38 mohor
end
790
 
791
 
792 39 mohor
wire TxBufferAlmostFull;
793
wire TxBufferFull;
794
wire TxBufferEmpty;
795
wire TxBufferAlmostEmpty;
796 40 mohor
wire ResetReadTxDataFromMemory;
797
wire SetReadTxDataFromMemory;
798 39 mohor
 
799 40 mohor
reg BlockReadTxDataFromMemory;
800 39 mohor
 
801 40 mohor
assign ResetReadTxDataFromMemory = (TxLengthEq0) | TxAbortPulse | TxRetryPulse;
802
assign SetReadTxDataFromMemory = TxEn & TxEn_q & TxPointerRead;
803 39 mohor
 
804 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
805 38 mohor
begin
806 40 mohor
  if(Reset)
807
    ReadTxDataFromMemory <=#Tp 1'b0;
808 38 mohor
  else
809 40 mohor
  if(ResetReadTxDataFromMemory)
810
    ReadTxDataFromMemory <=#Tp 1'b0;
811 39 mohor
  else
812 40 mohor
  if(SetReadTxDataFromMemory)
813
    ReadTxDataFromMemory <=#Tp 1'b1;
814 38 mohor
end
815
 
816 40 mohor
wire ReadTxDataFromMemory_2 = ReadTxDataFromMemory & ~BlockReadTxDataFromMemory;
817 39 mohor
wire [31:0] TxData_wb;
818
wire ReadTxDataFromFifo_wb;
819 38 mohor
 
820 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
821 38 mohor
begin
822 40 mohor
  if(Reset)
823
    BlockReadTxDataFromMemory <=#Tp 1'b0;
824 38 mohor
  else
825 90 mohor
  if(ReadTxDataFromFifo_wb | ResetReadTxDataFromMemory)
826 40 mohor
    BlockReadTxDataFromMemory <=#Tp 1'b0;
827 38 mohor
  else
828 39 mohor
  if((TxBufferAlmostFull | TxLength <= 4)& MasterWbTX)
829 40 mohor
    BlockReadTxDataFromMemory <=#Tp 1'b1;
830 39 mohor
end
831
 
832
 
833
 
834
assign MasterAccessFinished = m_wb_ack_i | m_wb_err_i;
835
 
836 96 mohor
//assign m_wb_sel_o = 4'hf;
837 39 mohor
 
838
// Enabling master wishbone access to the memory for two devices TX and RX.
839 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
840 39 mohor
begin
841 40 mohor
  if(Reset)
842 38 mohor
    begin
843 39 mohor
      MasterWbTX <=#Tp 1'b0;
844
      MasterWbRX <=#Tp 1'b0;
845
      m_wb_adr_o <=#Tp 32'h0;
846
      m_wb_cyc_o <=#Tp 1'b0;
847
      m_wb_stb_o <=#Tp 1'b0;
848
      m_wb_we_o  <=#Tp 1'b0;
849 96 mohor
      m_wb_sel_o <=#Tp 4'h0;
850 38 mohor
    end
851 39 mohor
  else
852
    begin
853
      // Switching between two stages depends on enable signals
854 82 mohor
      case ({MasterWbTX, MasterWbRX, ReadTxDataFromMemory_2, WriteRxDataToMemory, MasterAccessFinished})
855
        5'b00_01_0, 5'b00_11_0 :
856 39 mohor
          begin
857
            MasterWbTX <=#Tp 1'b0;  // idle and master write is needed (data write to rx buffer)
858
            MasterWbRX <=#Tp 1'b1;
859
            m_wb_adr_o <=#Tp RxPointer;
860
            m_wb_cyc_o <=#Tp 1'b1;
861
            m_wb_stb_o <=#Tp 1'b1;
862
            m_wb_we_o  <=#Tp 1'b1;
863 96 mohor
            m_wb_sel_o <=#Tp m_wb_sel_tmp_rx;
864 39 mohor
          end
865 82 mohor
        5'b00_10_0, 5'b00_10_1 :
866 39 mohor
          begin
867
            MasterWbTX <=#Tp 1'b1;  // idle and master read is needed (data read from tx buffer)
868
            MasterWbRX <=#Tp 1'b0;
869
            m_wb_adr_o <=#Tp TxPointer;
870
            m_wb_cyc_o <=#Tp 1'b1;
871
            m_wb_stb_o <=#Tp 1'b1;
872
            m_wb_we_o  <=#Tp 1'b0;
873 96 mohor
            m_wb_sel_o <=#Tp m_wb_sel_tmp_tx;
874 39 mohor
          end
875
        5'b10_10_1 :
876
          begin
877
            MasterWbTX <=#Tp 1'b1;  // master read and master read is needed (data read from tx buffer)
878
            MasterWbRX <=#Tp 1'b0;
879
            m_wb_adr_o <=#Tp TxPointer;
880
            m_wb_cyc_o <=#Tp 1'b1;
881
            m_wb_stb_o <=#Tp 1'b1;
882
            m_wb_we_o  <=#Tp 1'b0;
883 96 mohor
            m_wb_sel_o <=#Tp m_wb_sel_tmp_tx;
884 39 mohor
          end
885
        5'b01_01_1 :
886
          begin
887
            MasterWbTX <=#Tp 1'b0;  // master write and master write is needed (data write to rx buffer)
888
            MasterWbRX <=#Tp 1'b1;
889
            m_wb_adr_o <=#Tp RxPointer;
890
            m_wb_we_o  <=#Tp 1'b1;
891 96 mohor
            m_wb_sel_o <=#Tp m_wb_sel_tmp_rx;
892 39 mohor
          end
893 82 mohor
        5'b10_01_1, 5'b10_11_1 :
894 39 mohor
          begin
895
            MasterWbTX <=#Tp 1'b0;  // master read and master write is needed (data write to rx buffer)
896
            MasterWbRX <=#Tp 1'b1;
897
            m_wb_adr_o <=#Tp RxPointer;
898
            m_wb_we_o  <=#Tp 1'b1;
899 96 mohor
            m_wb_sel_o <=#Tp m_wb_sel_tmp_rx;
900 39 mohor
          end
901 82 mohor
        5'b01_10_1, 5'b01_11_1 :
902 39 mohor
          begin
903
            MasterWbTX <=#Tp 1'b1;  // master write and master read is needed (data read from tx buffer)
904
            MasterWbRX <=#Tp 1'b0;
905
            m_wb_adr_o <=#Tp TxPointer;
906
            m_wb_we_o  <=#Tp 1'b0;
907 96 mohor
            m_wb_sel_o <=#Tp m_wb_sel_tmp_tx;
908 39 mohor
          end
909 82 mohor
        5'b10_00_1, 5'b01_00_1 :
910 39 mohor
          begin
911
            MasterWbTX <=#Tp 1'b0;  // whatever and no master read or write is needed (ack or err comes finishing previous access)
912
            MasterWbRX <=#Tp 1'b0;
913
            m_wb_cyc_o <=#Tp 1'b0;
914
            m_wb_stb_o <=#Tp 1'b0;
915
          end
916 82 mohor
        default:                            // Don't touch
917
          begin
918
            MasterWbTX <=#Tp MasterWbTX;
919
            MasterWbRX <=#Tp MasterWbRX;
920
            m_wb_cyc_o <=#Tp m_wb_cyc_o;
921
            m_wb_stb_o <=#Tp m_wb_stb_o;
922 96 mohor
            m_wb_sel_o <=#Tp m_wb_sel_o;
923 82 mohor
          end
924 39 mohor
      endcase
925
    end
926 38 mohor
end
927
 
928 39 mohor
wire TxFifoClear;
929 96 mohor
wire [31:0] tx_fifo_dat_i;
930
 
931 39 mohor
assign TxFifoClear = (TxAbort_wb | TxRetry_wb) & ~TxBDReady;
932 38 mohor
 
933 96 mohor
reg  [23:16] LatchedData;
934
wire [23:16] TempData;
935
 
936
always @ (posedge WB_CLK_I or posedge Reset)
937
begin
938
  if(Reset)
939
    LatchedData[23:16] <=#Tp 0;
940
  else
941
  if(MasterWbTX & m_wb_ack_i & m_wb_sel_o[2])
942
    LatchedData[23:16] <=#Tp m_wb_dat_i[23:16];
943
end
944
 
945
assign TempData[23:16] = m_wb_sel_o[2]? m_wb_dat_i[23:16] : LatchedData[23:16];
946
 
947
assign tx_fifo_dat_i[31:0] = {m_wb_dat_i[31:24], TempData[23:16], m_wb_dat_i[15:8], m_wb_dat_i[7:0]};
948
 
949
 
950 40 mohor
eth_fifo #(`TX_FIFO_DATA_WIDTH, `TX_FIFO_DEPTH, `TX_FIFO_CNT_WIDTH)
951 96 mohor
tx_fifo ( .data_in(tx_fifo_dat_i),                          .data_out(TxData_wb),
952
          .clk(WB_CLK_I),                                   .reset(Reset),
953
          .write(MasterWbTX & m_wb_ack_i & m_wb_sel_o[0]),  .read(ReadTxDataFromFifo_wb),
954
          .clear(TxFifoClear),                              .full(TxBufferFull),
955
          .almost_full(TxBufferAlmostFull),                 .almost_empty(TxBufferAlmostEmpty),
956
          .empty(TxBufferEmpty)
957
        );
958 39 mohor
 
959
 
960
reg StartOccured;
961
reg TxStartFrm_sync1;
962
reg TxStartFrm_sync2;
963
reg TxStartFrm_syncb1;
964
reg TxStartFrm_syncb2;
965
 
966
 
967
 
968
// Start: Generation of the TxStartFrm_wb which is then synchronized to the MTxClk
969 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
970 38 mohor
begin
971 40 mohor
  if(Reset)
972 39 mohor
    TxStartFrm_wb <=#Tp 1'b0;
973 38 mohor
  else
974 39 mohor
  if(TxBDReady & ~StartOccured & (TxBufferFull | TxLengthEq0))
975
    TxStartFrm_wb <=#Tp 1'b1;
976 38 mohor
  else
977 39 mohor
  if(TxStartFrm_syncb2)
978
    TxStartFrm_wb <=#Tp 1'b0;
979 38 mohor
end
980
 
981 39 mohor
// StartOccured: TxStartFrm_wb occurs only ones at the beginning. Then it's blocked.
982 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
983 38 mohor
begin
984 40 mohor
  if(Reset)
985 39 mohor
    StartOccured <=#Tp 1'b0;
986 38 mohor
  else
987 39 mohor
  if(TxStartFrm_wb)
988
    StartOccured <=#Tp 1'b1;
989 38 mohor
  else
990 39 mohor
  if(ResetTxBDReady)
991
    StartOccured <=#Tp 1'b0;
992 38 mohor
end
993
 
994 39 mohor
// Synchronizing TxStartFrm_wb to MTxClk
995 40 mohor
always @ (posedge MTxClk or posedge Reset)
996 39 mohor
begin
997 40 mohor
  if(Reset)
998 39 mohor
    TxStartFrm_sync1 <=#Tp 1'b0;
999
  else
1000
    TxStartFrm_sync1 <=#Tp TxStartFrm_wb;
1001
end
1002 38 mohor
 
1003 40 mohor
always @ (posedge MTxClk or posedge Reset)
1004 39 mohor
begin
1005 40 mohor
  if(Reset)
1006 39 mohor
    TxStartFrm_sync2 <=#Tp 1'b0;
1007
  else
1008
    TxStartFrm_sync2 <=#Tp TxStartFrm_sync1;
1009
end
1010
 
1011 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1012 38 mohor
begin
1013 40 mohor
  if(Reset)
1014 39 mohor
    TxStartFrm_syncb1 <=#Tp 1'b0;
1015 38 mohor
  else
1016 39 mohor
    TxStartFrm_syncb1 <=#Tp TxStartFrm_sync2;
1017 38 mohor
end
1018
 
1019 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1020 38 mohor
begin
1021 40 mohor
  if(Reset)
1022 39 mohor
    TxStartFrm_syncb2 <=#Tp 1'b0;
1023 38 mohor
  else
1024 39 mohor
    TxStartFrm_syncb2 <=#Tp TxStartFrm_syncb1;
1025
end
1026
 
1027 40 mohor
always @ (posedge MTxClk or posedge Reset)
1028 39 mohor
begin
1029 40 mohor
  if(Reset)
1030 39 mohor
    TxStartFrm <=#Tp 1'b0;
1031 38 mohor
  else
1032 39 mohor
  if(TxStartFrm_sync2)
1033 61 mohor
    TxStartFrm <=#Tp 1'b1;
1034 39 mohor
  else
1035 61 mohor
  if(TxUsedData_q | ~TxStartFrm_sync2 & (TxRetry | TxAbort))
1036 39 mohor
    TxStartFrm <=#Tp 1'b0;
1037 38 mohor
end
1038 39 mohor
// End: Generation of the TxStartFrm_wb which is then synchronized to the MTxClk
1039 38 mohor
 
1040
 
1041 39 mohor
// TxEndFrm_wb: indicator of the end of frame
1042 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1043 38 mohor
begin
1044 40 mohor
  if(Reset)
1045 39 mohor
    TxEndFrm_wb <=#Tp 1'b0;
1046 38 mohor
  else
1047 39 mohor
  if(TxLengthLt4 & TxBufferAlmostEmpty & TxUsedData)
1048
    TxEndFrm_wb <=#Tp 1'b1;
1049 38 mohor
  else
1050 39 mohor
  if(TxRetryPulse | TxDonePulse | TxAbortPulse)
1051
    TxEndFrm_wb <=#Tp 1'b0;
1052 38 mohor
end
1053
 
1054
 
1055
// Marks which bytes are valid within the word.
1056 39 mohor
assign TxValidBytes = TxLengthLt4 ? TxLength[1:0] : 2'b0;
1057 38 mohor
 
1058 39 mohor
reg LatchValidBytes;
1059
reg LatchValidBytes_q;
1060 38 mohor
 
1061 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1062 38 mohor
begin
1063 40 mohor
  if(Reset)
1064 39 mohor
    LatchValidBytes <=#Tp 1'b0;
1065 38 mohor
  else
1066 39 mohor
  if(TxLengthLt4 & TxBDReady)
1067
    LatchValidBytes <=#Tp 1'b1;
1068 38 mohor
  else
1069 39 mohor
    LatchValidBytes <=#Tp 1'b0;
1070 38 mohor
end
1071
 
1072 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1073 38 mohor
begin
1074 40 mohor
  if(Reset)
1075 39 mohor
    LatchValidBytes_q <=#Tp 1'b0;
1076 38 mohor
  else
1077 39 mohor
    LatchValidBytes_q <=#Tp LatchValidBytes;
1078 38 mohor
end
1079
 
1080
 
1081 39 mohor
// Latching valid bytes
1082 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1083 38 mohor
begin
1084 40 mohor
  if(Reset)
1085 39 mohor
    TxValidBytesLatched <=#Tp 2'h0;
1086 38 mohor
  else
1087 39 mohor
  if(LatchValidBytes & ~LatchValidBytes_q)
1088
    TxValidBytesLatched <=#Tp TxValidBytes;
1089
  else
1090
  if(TxRetryPulse | TxDonePulse | TxAbortPulse)
1091
    TxValidBytesLatched <=#Tp 2'h0;
1092 38 mohor
end
1093
 
1094
 
1095
assign TxIRQEn          = TxStatus[14];
1096 60 mohor
assign WrapTxStatusBit  = TxStatus[13];
1097
assign PerPacketPad     = TxStatus[12];
1098
assign PerPacketCrcEn   = TxStatus[11];
1099 38 mohor
 
1100
 
1101 77 mohor
assign RxIRQEn         = RxStatus[14];
1102 60 mohor
assign WrapRxStatusBit = RxStatus[13];
1103 38 mohor
 
1104
 
1105
// Temporary Tx and Rx buffer descriptor address 
1106 39 mohor
assign TempTxBDAddress[7:0] = {8{ TxStatusWrite     & ~WrapTxStatusBit}} & (TxBDAddress + 2'h2) ; // Tx BD increment or wrap (last BD)
1107 38 mohor
assign TempRxBDAddress[7:0] = {8{ WrapRxStatusBit}} & (r_TxBDNum)       | // Using first Rx BD
1108 39 mohor
                              {8{~WrapRxStatusBit}} & (RxBDAddress + 2'h2) ; // Using next Rx BD (incremenrement address)
1109 38 mohor
 
1110
 
1111
// Latching Tx buffer descriptor address
1112 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1113 38 mohor
begin
1114 40 mohor
  if(Reset)
1115 38 mohor
    TxBDAddress <=#Tp 8'h0;
1116
  else
1117
  if(TxStatusWrite)
1118
    TxBDAddress <=#Tp TempTxBDAddress;
1119
end
1120
 
1121
 
1122
// Latching Rx buffer descriptor address
1123 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1124 38 mohor
begin
1125 40 mohor
  if(Reset)
1126 38 mohor
    RxBDAddress <=#Tp 8'h0;
1127
  else
1128 77 mohor
  if(TX_BD_NUM_Wr)                        // When r_TxBDNum is updated, RxBDAddress is also
1129 38 mohor
    RxBDAddress <=#Tp WB_DAT_I[7:0];
1130
  else
1131
  if(RxStatusWrite)
1132
    RxBDAddress <=#Tp TempRxBDAddress;
1133
end
1134
 
1135 60 mohor
wire [8:0] TxStatusInLatched = {TxUnderRun, RetryCntLatched[3:0], RetryLimit, LateCollLatched, DeferLatched, CarrierSenseLost};
1136 38 mohor
 
1137 60 mohor
assign RxBDDataIn = {LatchedRxLength, 1'b0, RxStatus, 6'h0, RxStatusInLatched};
1138
assign TxBDDataIn = {LatchedTxLength, 1'b0, TxStatus, 2'h0, TxStatusInLatched};
1139 38 mohor
 
1140 60 mohor
 
1141 38 mohor
// Signals used for various purposes
1142 39 mohor
assign TxRetryPulse   = TxRetry_wb   & ~TxRetry_wb_q;
1143 38 mohor
assign TxDonePulse    = TxDone_wb    & ~TxDone_wb_q;
1144
assign TxAbortPulse   = TxAbort_wb   & ~TxAbort_wb_q;
1145
 
1146
 
1147 91 mohor
assign TPauseRq = 0;
1148
assign TxPauseTV[15:0] = TxLength[15:0];
1149 38 mohor
 
1150
 
1151 39 mohor
// Generating delayed signals
1152 40 mohor
always @ (posedge MTxClk or posedge Reset)
1153 38 mohor
begin
1154 40 mohor
  if(Reset)
1155 39 mohor
    begin
1156
      TxAbort_q      <=#Tp 1'b0;
1157
      TxRetry_q      <=#Tp 1'b0;
1158
      TxUsedData_q   <=#Tp 1'b0;
1159
    end
1160 38 mohor
  else
1161 39 mohor
    begin
1162
      TxAbort_q      <=#Tp TxAbort;
1163
      TxRetry_q      <=#Tp TxRetry;
1164
      TxUsedData_q   <=#Tp TxUsedData;
1165
    end
1166 38 mohor
end
1167
 
1168
// Generating delayed signals
1169 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1170 38 mohor
begin
1171 40 mohor
  if(Reset)
1172 38 mohor
    begin
1173 39 mohor
      TxDone_wb_q   <=#Tp 1'b0;
1174
      TxAbort_wb_q  <=#Tp 1'b0;
1175 40 mohor
      TxRetry_wb_q  <=#Tp 1'b0;
1176 38 mohor
    end
1177
  else
1178
    begin
1179 39 mohor
      TxDone_wb_q   <=#Tp TxDone_wb;
1180
      TxAbort_wb_q  <=#Tp TxAbort_wb;
1181 40 mohor
      TxRetry_wb_q  <=#Tp TxRetry_wb;
1182 38 mohor
    end
1183
end
1184
 
1185
 
1186
// Sinchronizing and evaluating tx data
1187 39 mohor
//assign SetGotData = (TxStartFrm_wb | NewTxDataAvaliable_wb & ~TxAbort_wb & ~TxRetry_wb) & ~WB_CLK_I;
1188
assign SetGotData = (TxStartFrm_wb); // igor namesto zgornje
1189 38 mohor
 
1190
// Evaluating data. If abort or retry occured meanwhile than data is ignored.
1191 40 mohor
//assign GotDataEvaluate = GotDataSync3 & ~GotData & (~TxRetry & ~TxAbort | (TxRetry | TxAbort) & (TxStartFrm));
1192
assign GotDataEvaluate = (~TxRetry & ~TxAbort | (TxRetry | TxAbort) & (TxStartFrm));
1193 38 mohor
 
1194
 
1195
// Indication of the last word
1196 40 mohor
always @ (posedge MTxClk or posedge Reset)
1197 38 mohor
begin
1198 40 mohor
  if(Reset)
1199 38 mohor
    LastWord <=#Tp 1'b0;
1200
  else
1201
  if((TxEndFrm | TxAbort | TxRetry) & Flop)
1202
    LastWord <=#Tp 1'b0;
1203
  else
1204
  if(TxUsedData & Flop & TxByteCnt == 2'h3)
1205 39 mohor
    LastWord <=#Tp TxEndFrm_wb;
1206 38 mohor
end
1207
 
1208
 
1209
// Tx end frame generation
1210 40 mohor
always @ (posedge MTxClk or posedge Reset)
1211 38 mohor
begin
1212 40 mohor
  if(Reset)
1213 38 mohor
    TxEndFrm <=#Tp 1'b0;
1214
  else
1215 91 mohor
  if(Flop & TxEndFrm | TxAbort | TxRetry_q)
1216 38 mohor
    TxEndFrm <=#Tp 1'b0;
1217
  else
1218
  if(Flop & LastWord)
1219
    begin
1220
      case (TxValidBytesLatched)
1221
        1 : TxEndFrm <=#Tp TxByteCnt == 2'h0;
1222
        2 : TxEndFrm <=#Tp TxByteCnt == 2'h1;
1223
        3 : TxEndFrm <=#Tp TxByteCnt == 2'h2;
1224
 
1225
        default : TxEndFrm <=#Tp 1'b0;
1226
      endcase
1227
    end
1228
end
1229
 
1230
 
1231
// Tx data selection (latching)
1232 40 mohor
always @ (posedge MTxClk or posedge Reset)
1233 38 mohor
begin
1234 40 mohor
  if(Reset)
1235 96 mohor
    TxData <=#Tp 0;
1236 38 mohor
  else
1237 39 mohor
  if(TxStartFrm_sync2 & ~TxStartFrm)
1238 96 mohor
    case(TxPointerLatched)
1239
      2'h0 : TxData <=#Tp TxData_wb[31:24];                  // Big Endian Byte Ordering
1240
      2'h1 : TxData <=#Tp TxData_wb[23:16];                  // Big Endian Byte Ordering
1241
      2'h2 : TxData <=#Tp TxData_wb[15:08];                  // Big Endian Byte Ordering
1242
      2'h3 : TxData <=#Tp TxData_wb[07:00];                  // Big Endian Byte Ordering
1243
    endcase
1244 38 mohor
  else
1245 96 mohor
  if(TxStartFrm & TxUsedData & TxPointerLatched==2'h3)
1246
    TxData <=#Tp TxData_wb[31:24];                           // Big Endian Byte Ordering
1247
  else
1248 38 mohor
  if(TxUsedData & Flop)
1249
    begin
1250
      case(TxByteCnt)
1251 82 mohor
 
1252
        1 : TxData <=#Tp TxDataLatched[23:16];
1253
        2 : TxData <=#Tp TxDataLatched[15:8];
1254
        3 : TxData <=#Tp TxDataLatched[7:0];
1255 38 mohor
      endcase
1256
    end
1257
end
1258
 
1259
 
1260
// Latching tx data
1261 40 mohor
always @ (posedge MTxClk or posedge Reset)
1262 38 mohor
begin
1263 40 mohor
  if(Reset)
1264 38 mohor
    TxDataLatched[31:0] <=#Tp 32'h0;
1265
  else
1266 96 mohor
 if(TxStartFrm_sync2 & ~TxStartFrm | TxUsedData & Flop & TxByteCnt == 2'h3 | TxStartFrm & TxUsedData & Flop & TxByteCnt == 2'h0)
1267 39 mohor
    TxDataLatched[31:0] <=#Tp TxData_wb[31:0];
1268 38 mohor
end
1269
 
1270
 
1271
// Tx under run
1272 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1273 38 mohor
begin
1274 40 mohor
  if(Reset)
1275 60 mohor
    TxUnderRun_wb <=#Tp 1'b0;
1276 38 mohor
  else
1277 39 mohor
  if(TxAbortPulse)
1278 60 mohor
    TxUnderRun_wb <=#Tp 1'b0;
1279
  else
1280
  if(TxBufferEmpty & ReadTxDataFromFifo_wb)
1281
    TxUnderRun_wb <=#Tp 1'b1;
1282
end
1283
 
1284
 
1285
// Tx under run
1286
always @ (posedge MTxClk or posedge Reset)
1287
begin
1288
  if(Reset)
1289 54 billditt
    TxUnderRun <=#Tp 1'b0;
1290 43 mohor
  else
1291 60 mohor
  if(TxUnderRun_wb)
1292 38 mohor
    TxUnderRun <=#Tp 1'b1;
1293 60 mohor
  else
1294
  if(BlockingTxStatusWrite)
1295
    TxUnderRun <=#Tp 1'b0;
1296 38 mohor
end
1297
 
1298
 
1299
// Tx Byte counter
1300 40 mohor
always @ (posedge MTxClk or posedge Reset)
1301 38 mohor
begin
1302 40 mohor
  if(Reset)
1303 38 mohor
    TxByteCnt <=#Tp 2'h0;
1304
  else
1305
  if(TxAbort_q | TxRetry_q)
1306
    TxByteCnt <=#Tp 2'h0;
1307
  else
1308
  if(TxStartFrm & ~TxUsedData)
1309 96 mohor
    case(TxPointerLatched)
1310
      2'h0 : TxByteCnt <=#Tp 2'h1;
1311
      2'h1 : TxByteCnt <=#Tp 2'h2;
1312
      2'h2 : TxByteCnt <=#Tp 2'h3;
1313
      2'h3 : TxByteCnt <=#Tp 2'h0;
1314
    endcase
1315 38 mohor
  else
1316
  if(TxUsedData & Flop)
1317 96 mohor
    TxByteCnt <=#Tp TxByteCnt + 1'b1;
1318 38 mohor
end
1319
 
1320
 
1321 39 mohor
// Start: Generation of the ReadTxDataFromFifo_tck signal and synchronization to the WB_CLK_I
1322
reg ReadTxDataFromFifo_sync1;
1323
reg ReadTxDataFromFifo_sync2;
1324
reg ReadTxDataFromFifo_sync3;
1325
reg ReadTxDataFromFifo_syncb1;
1326
reg ReadTxDataFromFifo_syncb2;
1327
 
1328
 
1329 40 mohor
always @ (posedge MTxClk or posedge Reset)
1330 38 mohor
begin
1331 40 mohor
  if(Reset)
1332 39 mohor
    ReadTxDataFromFifo_tck <=#Tp 1'b0;
1333 38 mohor
  else
1334 39 mohor
  if(ReadTxDataFromFifo_syncb2)
1335
    ReadTxDataFromFifo_tck <=#Tp 1'b0;
1336 38 mohor
  else
1337 96 mohor
  if(TxStartFrm_sync2 & ~TxStartFrm | TxUsedData & Flop & TxByteCnt == 2'h3 & ~LastWord | TxStartFrm & TxUsedData & Flop & TxByteCnt == 2'h0)
1338 39 mohor
     ReadTxDataFromFifo_tck <=#Tp 1'b1;
1339 38 mohor
end
1340
 
1341 39 mohor
// Synchronizing TxStartFrm_wb to MTxClk
1342 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1343 38 mohor
begin
1344 40 mohor
  if(Reset)
1345 39 mohor
    ReadTxDataFromFifo_sync1 <=#Tp 1'b0;
1346 38 mohor
  else
1347 39 mohor
    ReadTxDataFromFifo_sync1 <=#Tp ReadTxDataFromFifo_tck;
1348
end
1349 38 mohor
 
1350 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1351 38 mohor
begin
1352 40 mohor
  if(Reset)
1353 39 mohor
    ReadTxDataFromFifo_sync2 <=#Tp 1'b0;
1354 38 mohor
  else
1355 39 mohor
    ReadTxDataFromFifo_sync2 <=#Tp ReadTxDataFromFifo_sync1;
1356 38 mohor
end
1357
 
1358 40 mohor
always @ (posedge MTxClk or posedge Reset)
1359 38 mohor
begin
1360 40 mohor
  if(Reset)
1361 39 mohor
    ReadTxDataFromFifo_syncb1 <=#Tp 1'b0;
1362 38 mohor
  else
1363 39 mohor
    ReadTxDataFromFifo_syncb1 <=#Tp ReadTxDataFromFifo_sync2;
1364 38 mohor
end
1365
 
1366 40 mohor
always @ (posedge MTxClk or posedge Reset)
1367 38 mohor
begin
1368 40 mohor
  if(Reset)
1369 39 mohor
    ReadTxDataFromFifo_syncb2 <=#Tp 1'b0;
1370 38 mohor
  else
1371 39 mohor
    ReadTxDataFromFifo_syncb2 <=#Tp ReadTxDataFromFifo_syncb1;
1372 38 mohor
end
1373
 
1374 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1375 38 mohor
begin
1376 40 mohor
  if(Reset)
1377 39 mohor
    ReadTxDataFromFifo_sync3 <=#Tp 1'b0;
1378 38 mohor
  else
1379 39 mohor
    ReadTxDataFromFifo_sync3 <=#Tp ReadTxDataFromFifo_sync2;
1380 38 mohor
end
1381
 
1382 39 mohor
assign ReadTxDataFromFifo_wb = ReadTxDataFromFifo_sync2 & ~ReadTxDataFromFifo_sync3;
1383
// End: Generation of the ReadTxDataFromFifo_tck signal and synchronization to the WB_CLK_I
1384 38 mohor
 
1385
 
1386 39 mohor
// Synchronizing TxRetry signal (synchronized to WISHBONE clock)
1387 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1388 38 mohor
begin
1389 40 mohor
  if(Reset)
1390 39 mohor
    TxRetrySync1 <=#Tp 1'b0;
1391 38 mohor
  else
1392 39 mohor
    TxRetrySync1 <=#Tp TxRetry;
1393 38 mohor
end
1394
 
1395 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1396 38 mohor
begin
1397 40 mohor
  if(Reset)
1398 39 mohor
    TxRetry_wb <=#Tp 1'b0;
1399 38 mohor
  else
1400 39 mohor
    TxRetry_wb <=#Tp TxRetrySync1;
1401 38 mohor
end
1402
 
1403
 
1404 39 mohor
// Synchronized TxDone_wb signal (synchronized to WISHBONE clock)
1405 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1406 38 mohor
begin
1407 40 mohor
  if(Reset)
1408 39 mohor
    TxDoneSync1 <=#Tp 1'b0;
1409 38 mohor
  else
1410 39 mohor
    TxDoneSync1 <=#Tp TxDone;
1411 38 mohor
end
1412
 
1413 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1414 38 mohor
begin
1415 40 mohor
  if(Reset)
1416 39 mohor
    TxDone_wb <=#Tp 1'b0;
1417 38 mohor
  else
1418 39 mohor
    TxDone_wb <=#Tp TxDoneSync1;
1419 38 mohor
end
1420
 
1421 39 mohor
// Synchronizing TxAbort signal (synchronized to WISHBONE clock)
1422 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1423 38 mohor
begin
1424 40 mohor
  if(Reset)
1425 39 mohor
    TxAbortSync1 <=#Tp 1'b0;
1426 38 mohor
  else
1427 39 mohor
    TxAbortSync1 <=#Tp TxAbort;
1428 38 mohor
end
1429
 
1430 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1431 38 mohor
begin
1432 40 mohor
  if(Reset)
1433 38 mohor
    TxAbort_wb <=#Tp 1'b0;
1434
  else
1435 39 mohor
    TxAbort_wb <=#Tp TxAbortSync1;
1436 38 mohor
end
1437
 
1438
 
1439 90 mohor
assign StartRxBDRead = RxStatusWrite | RxAbortLatched;
1440 39 mohor
 
1441 40 mohor
// Reading the Rx buffer descriptor
1442
always @ (posedge WB_CLK_I or posedge Reset)
1443
begin
1444
  if(Reset)
1445
    RxBDRead <=#Tp 1'b1;
1446
  else
1447 90 mohor
  if(StartRxBDRead & ~RxBDReady)
1448 40 mohor
    RxBDRead <=#Tp 1'b1;
1449
  else
1450
  if(RxBDReady)
1451
    RxBDRead <=#Tp 1'b0;
1452
end
1453 39 mohor
 
1454
 
1455 38 mohor
// Reading of the next receive buffer descriptor starts after reception status is
1456
// written to the previous one.
1457
 
1458
// Latching READY status of the Rx buffer descriptor
1459 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1460 38 mohor
begin
1461 40 mohor
  if(Reset)
1462 38 mohor
    RxBDReady <=#Tp 1'b0;
1463
  else
1464 40 mohor
  if(RxEn & RxEn_q & RxBDRead)
1465
    RxBDReady <=#Tp ram_do[15]; // RxBDReady is sampled only once at the beginning
1466 38 mohor
  else
1467 61 mohor
  if(ShiftEnded | RxAbort)
1468 38 mohor
    RxBDReady <=#Tp 1'b0;
1469
end
1470
 
1471 40 mohor
// Latching Rx buffer descriptor status
1472
// Data is avaliable one cycle after the access is started (at that time signal RxEn is not active)
1473
always @ (posedge WB_CLK_I or posedge Reset)
1474 38 mohor
begin
1475 40 mohor
  if(Reset)
1476 60 mohor
    RxStatus <=#Tp 2'h0;
1477 38 mohor
  else
1478 40 mohor
  if(RxEn & RxEn_q & RxBDRead)
1479 60 mohor
    RxStatus <=#Tp ram_do[14:13];
1480 38 mohor
end
1481
 
1482
 
1483
 
1484
 
1485 40 mohor
// Reading Rx BD pointer
1486
 
1487
 
1488
assign StartRxPointerRead = RxBDRead & RxBDReady;
1489
 
1490
// Reading Tx BD Pointer
1491
always @ (posedge WB_CLK_I or posedge Reset)
1492 38 mohor
begin
1493 40 mohor
  if(Reset)
1494
    RxPointerRead <=#Tp 1'b0;
1495 38 mohor
  else
1496 40 mohor
  if(StartRxPointerRead)
1497
    RxPointerRead <=#Tp 1'b1;
1498 38 mohor
  else
1499 40 mohor
  if(RxEn_q)
1500
    RxPointerRead <=#Tp 1'b0;
1501 38 mohor
end
1502
 
1503 40 mohor
reg BlockingIncrementRxPointer;
1504
//Latching Rx buffer pointer from buffer descriptor;
1505
always @ (posedge WB_CLK_I or posedge Reset)
1506
begin
1507
  if(Reset)
1508
    RxPointer <=#Tp 32'h0;
1509
  else
1510
  if(RxEn & RxEn_q & RxPointerRead)
1511 96 mohor
    RxPointer <=#Tp {ram_do[31:2], 2'h0};
1512 40 mohor
  else
1513
  if(MasterWbRX & ~BlockingIncrementRxPointer)
1514 96 mohor
      RxPointer <=#Tp RxPointer + 3'h4; // Word access  (always word access. m_wb_sel_o are used for selecting bytes)
1515 40 mohor
end
1516 38 mohor
 
1517
 
1518 96 mohor
//Latching last addresses from buffer descriptor (used as byte-half-word indicator);
1519 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1520
begin
1521
  if(Reset)
1522 96 mohor
    RxPointerLatched[1:0] <=#Tp 0;
1523
  else
1524
  if(MasterWbRX & m_wb_ack_i)                 // After first write all m_wb_sel_tmp_rx are active
1525
    RxPointerLatched[1:0] <=#Tp 0;
1526
  else
1527
  if(RxEn & RxEn_q & RxPointerRead)
1528
    RxPointerLatched[1:0] <=#Tp ram_do[1:0];
1529
end
1530
 
1531
 
1532
always @ (RxPointerLatched)
1533
begin
1534
  case(RxPointerLatched[1:0])
1535
    2'h0 : m_wb_sel_tmp_rx[3:0] = 4'hf;
1536
    2'h1 : m_wb_sel_tmp_rx[3:0] = 4'h7;
1537
    2'h2 : m_wb_sel_tmp_rx[3:0] = 4'h3;
1538
    2'h3 : m_wb_sel_tmp_rx[3:0] = 4'h1;
1539
  endcase
1540
end
1541
 
1542
 
1543
always @ (posedge WB_CLK_I or posedge Reset)
1544
begin
1545
  if(Reset)
1546 40 mohor
    BlockingIncrementRxPointer <=#Tp 0;
1547
  else
1548
  if(MasterAccessFinished)
1549
    BlockingIncrementRxPointer <=#Tp 0;
1550
  else
1551
  if(MasterWbRX)
1552
    BlockingIncrementRxPointer <=#Tp 1'b1;
1553
end
1554
 
1555 38 mohor
 
1556 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1557 38 mohor
begin
1558 40 mohor
  if(Reset)
1559
    RxEn_needed <=#Tp 1'b0;
1560 38 mohor
  else
1561 40 mohor
  if(~RxBDReady & r_RxEn & WbEn & ~WbEn_q)
1562
    RxEn_needed <=#Tp 1'b1;
1563 38 mohor
  else
1564 40 mohor
  if(RxPointerRead & RxEn & RxEn_q)
1565
    RxEn_needed <=#Tp 1'b0;
1566 38 mohor
end
1567
 
1568
 
1569 40 mohor
// Reception status is written back to the buffer descriptor after the end of frame is detected.
1570
assign RxStatusWrite = ShiftEnded & RxEn & RxEn_q;
1571 38 mohor
 
1572 42 mohor
reg RxStatusWriteLatched;
1573
reg RxStatusWrite_rck;
1574
 
1575
always @ (posedge WB_CLK_I or posedge Reset)
1576
begin
1577
  if(Reset)
1578
    RxStatusWriteLatched <=#Tp 1'b0;
1579
  else
1580 87 mohor
  if(RxStatusWrite & ~RxStatusWrite_rck)
1581 42 mohor
    RxStatusWriteLatched <=#Tp 1'b1;
1582
  else
1583
  if(RxStatusWrite_rck)
1584
    RxStatusWriteLatched <=#Tp 1'b0;
1585
end
1586
 
1587
 
1588
always @ (posedge MRxClk or posedge Reset)
1589
begin
1590
  if(Reset)
1591
    RxStatusWrite_rck <=#Tp 1'b0;
1592
  else
1593 87 mohor
  if(RxStatusWriteLatched)
1594
    RxStatusWrite_rck <=#Tp 1'b1;
1595
  else
1596
    RxStatusWrite_rck <=#Tp 1'b0;
1597 42 mohor
end
1598
 
1599
 
1600 40 mohor
reg RxEnableWindow;
1601 38 mohor
 
1602
// Indicating that last byte is being reveived
1603 40 mohor
always @ (posedge MRxClk or posedge Reset)
1604 38 mohor
begin
1605 40 mohor
  if(Reset)
1606 38 mohor
    LastByteIn <=#Tp 1'b0;
1607
  else
1608 40 mohor
  if(ShiftWillEnd & (&RxByteCnt) | RxAbort)
1609 38 mohor
    LastByteIn <=#Tp 1'b0;
1610
  else
1611 40 mohor
  if(RxValid & RxBDReady & RxEndFrm & ~(&RxByteCnt) & RxEnableWindow)
1612 38 mohor
    LastByteIn <=#Tp 1'b1;
1613
end
1614
 
1615 40 mohor
reg ShiftEnded_tck;
1616
reg ShiftEndedSync1;
1617
reg ShiftEndedSync2;
1618
wire StartShiftWillEnd;
1619 96 mohor
//assign StartShiftWillEnd = LastByteIn & (&RxByteCnt) | RxValid & RxEndFrm & (&RxByteCnt) & RxEnableWindow;
1620
assign StartShiftWillEnd = LastByteIn  | RxValid & RxEndFrm & (&RxByteCnt) & RxEnableWindow;
1621 38 mohor
 
1622
// Indicating that data reception will end
1623 40 mohor
always @ (posedge MRxClk or posedge Reset)
1624 38 mohor
begin
1625 40 mohor
  if(Reset)
1626 38 mohor
    ShiftWillEnd <=#Tp 1'b0;
1627
  else
1628 40 mohor
  if(ShiftEnded_tck | RxAbort)
1629 38 mohor
    ShiftWillEnd <=#Tp 1'b0;
1630
  else
1631 40 mohor
  if(StartShiftWillEnd)
1632 38 mohor
    ShiftWillEnd <=#Tp 1'b1;
1633
end
1634
 
1635
 
1636 40 mohor
 
1637 38 mohor
// Receive byte counter
1638 40 mohor
always @ (posedge MRxClk or posedge Reset)
1639 38 mohor
begin
1640 40 mohor
  if(Reset)
1641 38 mohor
    RxByteCnt <=#Tp 2'h0;
1642
  else
1643 40 mohor
  if(ShiftEnded_tck | RxAbort)
1644 38 mohor
    RxByteCnt <=#Tp 2'h0;
1645 97 lampret
  else
1646 96 mohor
  if(RxValid & RxStartFrm & RxBDReady)
1647
    case(RxPointerLatched)
1648
      2'h0 : RxByteCnt <=#Tp 2'h1;
1649
      2'h1 : RxByteCnt <=#Tp 2'h2;
1650
      2'h2 : RxByteCnt <=#Tp 2'h3;
1651
      2'h3 : RxByteCnt <=#Tp 2'h0;
1652
    endcase
1653 38 mohor
  else
1654 96 mohor
  if(RxValid & RxEnableWindow & RxBDReady | LastByteIn)
1655 40 mohor
    RxByteCnt <=#Tp RxByteCnt + 1'b1;
1656 38 mohor
end
1657
 
1658
 
1659
// Indicates how many bytes are valid within the last word
1660 40 mohor
always @ (posedge MRxClk or posedge Reset)
1661 38 mohor
begin
1662 40 mohor
  if(Reset)
1663 38 mohor
    RxValidBytes <=#Tp 2'h1;
1664
  else
1665 96 mohor
  if(RxValid & RxStartFrm)
1666
    case(RxPointerLatched)
1667
      2'h0 : RxValidBytes <=#Tp 2'h1;
1668
      2'h1 : RxValidBytes <=#Tp 2'h2;
1669
      2'h2 : RxValidBytes <=#Tp 2'h3;
1670
      2'h3 : RxValidBytes <=#Tp 2'h0;
1671
    endcase
1672 38 mohor
  else
1673 40 mohor
  if(RxValid & ~LastByteIn & ~RxStartFrm & RxEnableWindow)
1674 38 mohor
    RxValidBytes <=#Tp RxValidBytes + 1;
1675
end
1676
 
1677
 
1678 40 mohor
always @ (posedge MRxClk or posedge Reset)
1679 38 mohor
begin
1680 40 mohor
  if(Reset)
1681
    RxDataLatched1       <=#Tp 24'h0;
1682 38 mohor
  else
1683 96 mohor
  if(RxValid & RxBDReady & ~LastByteIn)
1684
    if(RxStartFrm)
1685 40 mohor
    begin
1686 96 mohor
      case(RxPointerLatched)     // synopsys parallel_case
1687
        2'h0:        RxDataLatched1[31:24] <=#Tp RxData;            // Big Endian Byte Ordering
1688
        2'h1:        RxDataLatched1[23:16] <=#Tp RxData;
1689
        2'h2:        RxDataLatched1[15:8]  <=#Tp RxData;
1690
        2'h3:        RxDataLatched1        <=#Tp RxDataLatched1;
1691
      endcase
1692
    end
1693
    else if (RxEnableWindow)
1694
    begin
1695 40 mohor
      case(RxByteCnt)     // synopsys parallel_case
1696 82 mohor
        2'h0:        RxDataLatched1[31:24] <=#Tp RxData;            // Big Endian Byte Ordering
1697
        2'h1:        RxDataLatched1[23:16] <=#Tp RxData;
1698
        2'h2:        RxDataLatched1[15:8]  <=#Tp RxData;
1699 40 mohor
        2'h3:        RxDataLatched1        <=#Tp RxDataLatched1;
1700
      endcase
1701
    end
1702 38 mohor
end
1703
 
1704 40 mohor
wire SetWriteRxDataToFifo;
1705 38 mohor
 
1706 40 mohor
// Assembling data that will be written to the rx_fifo
1707
always @ (posedge MRxClk or posedge Reset)
1708 38 mohor
begin
1709 40 mohor
  if(Reset)
1710
    RxDataLatched2 <=#Tp 32'h0;
1711 38 mohor
  else
1712 40 mohor
  if(SetWriteRxDataToFifo & ~ShiftWillEnd)
1713 82 mohor
    RxDataLatched2 <=#Tp {RxDataLatched1[31:8], RxData};              // Big Endian Byte Ordering
1714 38 mohor
  else
1715 40 mohor
  if(SetWriteRxDataToFifo & ShiftWillEnd)
1716
    case(RxValidBytes)
1717 96 mohor
//      0 : RxDataLatched2 <=#Tp {RxDataLatched1[31:8],  RxData};       // Big Endian Byte Ordering
1718
//      1 : RxDataLatched2 <=#Tp {RxDataLatched1[31:24], 24'h0};
1719
//      2 : RxDataLatched2 <=#Tp {RxDataLatched1[31:16], 16'h0};
1720
//      3 : RxDataLatched2 <=#Tp {RxDataLatched1[31:8],   8'h0};
1721 82 mohor
 
1722
      1 : RxDataLatched2 <=#Tp {RxDataLatched1[31:24], 24'h0};
1723
      2 : RxDataLatched2 <=#Tp {RxDataLatched1[31:16], 16'h0};
1724
      3 : RxDataLatched2 <=#Tp {RxDataLatched1[31:8],   8'h0};
1725 40 mohor
    endcase
1726 38 mohor
end
1727
 
1728
 
1729 40 mohor
reg WriteRxDataToFifoSync1;
1730
reg WriteRxDataToFifoSync2;
1731 38 mohor
 
1732
 
1733 40 mohor
// Indicating start of the reception process
1734 96 mohor
//assign SetWriteRxDataToFifo = (RxValid & RxBDReady & ~RxStartFrm & RxEnableWindow & (&RxByteCnt)) | (ShiftWillEnd & LastByteIn & (&RxByteCnt));
1735
assign SetWriteRxDataToFifo = (RxValid & RxBDReady & ~RxStartFrm & RxEnableWindow & (&RxByteCnt)) | (RxValid & RxBDReady & RxStartFrm & (&RxPointerLatched)) | (ShiftWillEnd & LastByteIn & (&RxByteCnt));
1736 38 mohor
 
1737 40 mohor
always @ (posedge MRxClk or posedge Reset)
1738 38 mohor
begin
1739 40 mohor
  if(Reset)
1740
    WriteRxDataToFifo <=#Tp 1'b0;
1741 38 mohor
  else
1742 40 mohor
  if(SetWriteRxDataToFifo & ~RxAbort)
1743
    WriteRxDataToFifo <=#Tp 1'b1;
1744 38 mohor
  else
1745 40 mohor
  if(WriteRxDataToFifoSync1 | RxAbort)
1746
    WriteRxDataToFifo <=#Tp 1'b0;
1747 38 mohor
end
1748
 
1749
 
1750
 
1751 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1752
begin
1753
  if(Reset)
1754
    WriteRxDataToFifoSync1 <=#Tp 1'b0;
1755
  else
1756
  if(WriteRxDataToFifo)
1757
    WriteRxDataToFifoSync1 <=#Tp 1'b1;
1758
  else
1759
    WriteRxDataToFifoSync1 <=#Tp 1'b0;
1760
end
1761 38 mohor
 
1762 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1763 38 mohor
begin
1764 40 mohor
  if(Reset)
1765
    WriteRxDataToFifoSync2 <=#Tp 1'b0;
1766 38 mohor
  else
1767 40 mohor
    WriteRxDataToFifoSync2 <=#Tp WriteRxDataToFifoSync1;
1768 38 mohor
end
1769
 
1770 40 mohor
wire WriteRxDataToFifo_wb;
1771
assign WriteRxDataToFifo_wb = WriteRxDataToFifoSync1 & ~WriteRxDataToFifoSync2;
1772 38 mohor
 
1773 40 mohor
reg RxAbortSync1;
1774
reg RxAbortSync2;
1775
reg RxAbortSyncb1;
1776
reg RxAbortSyncb2;
1777
 
1778 90 mohor
reg LatchedRxStartFrm;
1779
reg SyncRxStartFrm;
1780
reg SyncRxStartFrm_q;
1781
wire RxFifoReset;
1782 40 mohor
 
1783 90 mohor
always @ (posedge MRxClk or posedge Reset)
1784
begin
1785
  if(Reset)
1786
    LatchedRxStartFrm <=#Tp 0;
1787
  else
1788
  if(RxStartFrm & ~SyncRxStartFrm)
1789
    LatchedRxStartFrm <=#Tp 1;
1790
  else
1791
  if(SyncRxStartFrm)
1792
    LatchedRxStartFrm <=#Tp 0;
1793
end
1794
 
1795
 
1796
always @ (posedge WB_CLK_I or posedge Reset)
1797
begin
1798
  if(Reset)
1799
    SyncRxStartFrm <=#Tp 0;
1800
  else
1801
  if(LatchedRxStartFrm)
1802
    SyncRxStartFrm <=#Tp 1;
1803
  else
1804
    SyncRxStartFrm <=#Tp 0;
1805
end
1806
 
1807
 
1808
always @ (posedge WB_CLK_I or posedge Reset)
1809
begin
1810
  if(Reset)
1811
    SyncRxStartFrm_q <=#Tp 0;
1812
  else
1813
    SyncRxStartFrm_q <=#Tp SyncRxStartFrm;
1814
end
1815
 
1816
 
1817
assign RxFifoReset = SyncRxStartFrm & ~SyncRxStartFrm_q;
1818
 
1819
 
1820 40 mohor
eth_fifo #(`RX_FIFO_DATA_WIDTH, `RX_FIFO_DEPTH, `RX_FIFO_CNT_WIDTH)
1821 88 mohor
rx_fifo (.data_in(RxDataLatched2),                      .data_out(m_wb_dat_o),
1822
         .clk(WB_CLK_I),                                .reset(Reset),
1823
         .write(WriteRxDataToFifo_wb),                  .read(MasterWbRX & m_wb_ack_i),
1824 90 mohor
         .clear(RxFifoReset),                           .full(RxBufferFull),
1825 88 mohor
         .almost_full(RxBufferAlmostFull),              .almost_empty(RxBufferAlmostEmpty),
1826
         .empty(RxBufferEmpty)
1827
        );
1828 40 mohor
 
1829
assign WriteRxDataToMemory = ~RxBufferEmpty & (~MasterWbRX | ~RxBufferAlmostEmpty);
1830
 
1831
 
1832
 
1833
// Generation of the end-of-frame signal
1834
always @ (posedge MRxClk or posedge Reset)
1835 38 mohor
begin
1836 40 mohor
  if(Reset)
1837
    ShiftEnded_tck <=#Tp 1'b0;
1838 38 mohor
  else
1839 90 mohor
  if(SetWriteRxDataToFifo & StartShiftWillEnd & ~RxAbort & ~ShiftEnded_tck)
1840 40 mohor
    ShiftEnded_tck <=#Tp 1'b1;
1841 38 mohor
  else
1842 90 mohor
  if(ShiftEnded | RxAbort)
1843 40 mohor
    ShiftEnded_tck <=#Tp 1'b0;
1844 38 mohor
end
1845
 
1846 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1847
begin
1848
  if(Reset)
1849
    ShiftEndedSync1 <=#Tp 1'b0;
1850
  else
1851
    ShiftEndedSync1 <=#Tp ShiftEnded_tck;
1852
end
1853 38 mohor
 
1854 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1855 38 mohor
begin
1856 40 mohor
  if(Reset)
1857
    ShiftEndedSync2 <=#Tp 1'b0;
1858 38 mohor
  else
1859 90 mohor
    ShiftEndedSync2 <=#Tp ShiftEndedSync1;
1860 40 mohor
end
1861 38 mohor
 
1862
 
1863 40 mohor
// Generation of the end-of-frame signal
1864
always @ (posedge WB_CLK_I or posedge Reset)
1865 38 mohor
begin
1866 40 mohor
  if(Reset)
1867
    ShiftEnded <=#Tp 1'b0;
1868 38 mohor
  else
1869 90 mohor
  if(ShiftEndedSync2 & MasterWbRX & m_wb_ack_i & RxBufferAlmostEmpty & ~ShiftEnded)
1870 40 mohor
    ShiftEnded <=#Tp 1'b1;
1871 38 mohor
  else
1872 40 mohor
  if(RxStatusWrite)
1873
    ShiftEnded <=#Tp 1'b0;
1874 38 mohor
end
1875
 
1876
 
1877 40 mohor
// Generation of the end-of-frame signal
1878
always @ (posedge MRxClk or posedge Reset)
1879 38 mohor
begin
1880 40 mohor
  if(Reset)
1881
    RxEnableWindow <=#Tp 1'b0;
1882 38 mohor
  else
1883 40 mohor
  if(RxStartFrm)
1884
    RxEnableWindow <=#Tp 1'b1;
1885 38 mohor
  else
1886 40 mohor
  if(RxEndFrm | RxAbort)
1887
    RxEnableWindow <=#Tp 1'b0;
1888 38 mohor
end
1889
 
1890
 
1891 40 mohor
always @ (posedge WB_CLK_I or posedge Reset)
1892 38 mohor
begin
1893 40 mohor
  if(Reset)
1894
    RxAbortSync1 <=#Tp 1'b0;
1895 38 mohor
  else
1896 40 mohor
    RxAbortSync1 <=#Tp RxAbort;
1897
end
1898
 
1899
always @ (posedge WB_CLK_I or posedge Reset)
1900
begin
1901
  if(Reset)
1902
    RxAbortSync2 <=#Tp 1'b0;
1903 38 mohor
  else
1904 40 mohor
    RxAbortSync2 <=#Tp RxAbortSync1;
1905 38 mohor
end
1906
 
1907 40 mohor
always @ (posedge MRxClk or posedge Reset)
1908
begin
1909
  if(Reset)
1910
    RxAbortSyncb1 <=#Tp 1'b0;
1911
  else
1912
    RxAbortSyncb1 <=#Tp RxAbortSync2;
1913
end
1914 38 mohor
 
1915 40 mohor
always @ (posedge MRxClk or posedge Reset)
1916 38 mohor
begin
1917 40 mohor
  if(Reset)
1918
    RxAbortSyncb2 <=#Tp 1'b0;
1919 38 mohor
  else
1920 40 mohor
    RxAbortSyncb2 <=#Tp RxAbortSyncb1;
1921 38 mohor
end
1922
 
1923
 
1924 64 mohor
always @ (posedge MRxClk or posedge Reset)
1925
begin
1926
  if(Reset)
1927
    RxAbortLatched <=#Tp 1'b0;
1928
  else
1929
  if(RxAbort)
1930
    RxAbortLatched <=#Tp 1'b1;
1931
  else
1932
  if(RxStartFrm)
1933
    RxAbortLatched <=#Tp 1'b0;
1934
end
1935 40 mohor
 
1936
 
1937 42 mohor
reg LoadStatusBlocked;
1938 64 mohor
 
1939 42 mohor
always @ (posedge MRxClk or posedge Reset)
1940
begin
1941
  if(Reset)
1942
    LoadStatusBlocked <=#Tp 1'b0;
1943
  else
1944 64 mohor
  if(LoadRxStatus & ~RxAbortLatched)
1945 42 mohor
    LoadStatusBlocked <=#Tp 1'b1;
1946
  else
1947 87 mohor
  if(RxStatusWrite_rck | RxStartFrm)
1948 42 mohor
    LoadStatusBlocked <=#Tp 1'b0;
1949
end
1950
 
1951
// LatchedRxLength[15:0]
1952
always @ (posedge MRxClk or posedge Reset)
1953
begin
1954
  if(Reset)
1955
    LatchedRxLength[15:0] <=#Tp 16'h0;
1956
  else
1957 64 mohor
  if(LoadRxStatus & ~RxAbortLatched & ~LoadStatusBlocked)
1958 42 mohor
    LatchedRxLength[15:0] <=#Tp RxLength[15:0];
1959
end
1960
 
1961
 
1962 60 mohor
assign RxStatusIn = {RxOverrun, InvalidSymbol, DribbleNibble, ReceivedPacketTooBig, ShortFrame, LatchedCrcError, RxLateCollision};
1963 42 mohor
 
1964
always @ (posedge MRxClk or posedge Reset)
1965
begin
1966
  if(Reset)
1967
    RxStatusInLatched <=#Tp 'h0;
1968
  else
1969 64 mohor
  if(LoadRxStatus & ~RxAbortLatched & ~LoadStatusBlocked)
1970 42 mohor
    RxStatusInLatched <=#Tp RxStatusIn;
1971
end
1972
 
1973
 
1974 60 mohor
// Rx overrun
1975
always @ (posedge WB_CLK_I or posedge Reset)
1976
begin
1977
  if(Reset)
1978
    RxOverrun <=#Tp 1'b0;
1979
  else
1980
  if(RxStatusWrite)
1981
    RxOverrun <=#Tp 1'b0;
1982
  else
1983
  if(RxBufferFull & WriteRxDataToFifo_wb)
1984
    RxOverrun <=#Tp 1'b1;
1985
end
1986 48 mohor
 
1987 77 mohor
 
1988
 
1989
wire TxError;
1990
assign TxError = TxUnderRun | RetryLimit | LateCollLatched | CarrierSenseLost;
1991
 
1992
wire RxError;
1993
assign RxError = |RxStatusInLatched[6:0];
1994
 
1995
// Tx Done Interrupt
1996
always @ (posedge WB_CLK_I or posedge Reset)
1997
begin
1998
  if(Reset)
1999
    TxB_IRQ <=#Tp 1'b0;
2000
  else
2001
  if(TxStatusWrite & TxIRQEn)
2002
    TxB_IRQ <=#Tp ~TxError;
2003
  else
2004
    TxB_IRQ <=#Tp 1'b0;
2005
end
2006
 
2007
 
2008
// Tx Error Interrupt
2009
always @ (posedge WB_CLK_I or posedge Reset)
2010
begin
2011
  if(Reset)
2012
    TxE_IRQ <=#Tp 1'b0;
2013
  else
2014
  if(TxStatusWrite & TxIRQEn)
2015
    TxE_IRQ <=#Tp TxError;
2016
  else
2017
    TxE_IRQ <=#Tp 1'b0;
2018
end
2019
 
2020
 
2021
// Rx Done Interrupt
2022
always @ (posedge WB_CLK_I or posedge Reset)
2023
begin
2024
  if(Reset)
2025
    RxB_IRQ <=#Tp 1'b0;
2026
  else
2027
  if(RxStatusWrite & RxIRQEn)
2028
    RxB_IRQ <=#Tp ReceivedPacketGood;
2029
  else
2030
    RxB_IRQ <=#Tp 1'b0;
2031
end
2032
 
2033
 
2034
// Rx Error Interrupt
2035
always @ (posedge WB_CLK_I or posedge Reset)
2036
begin
2037
  if(Reset)
2038
    RxE_IRQ <=#Tp 1'b0;
2039
  else
2040
  if(RxStatusWrite & RxIRQEn)
2041
    RxE_IRQ <=#Tp RxError;
2042
  else
2043
    RxE_IRQ <=#Tp 1'b0;
2044
end
2045
 
2046
 
2047
assign RxC_IRQ = 1'b0;
2048
assign TxC_IRQ = 1'b0;
2049
assign Busy_IRQ = 1'b0;
2050
 
2051
 
2052
 
2053
 
2054 60 mohor
 
2055
// TX
2056 61 mohor
// bit 15 ready
2057
// bit 14 interrupt
2058
// bit 13 wrap
2059
// bit 12 pad
2060
// bit 11 crc
2061
// bit 10 last
2062
// bit 9  pause request (control frame)
2063
// bit 8  TxUnderRun          
2064
// bit 7-4 RetryCntLatched    
2065
// bit 3  retransmittion limit
2066
// bit 2  LateCollLatched        
2067
// bit 1  DeferLatched        
2068
// bit 0  CarrierSenseLost    
2069 60 mohor
 
2070
 
2071
// RX
2072
// bit 15 od rx je empty
2073 61 mohor
// bit 14 od rx je interrupt
2074 60 mohor
// bit 13 od rx je wrap
2075
// bit 12 od rx je reserved
2076
// bit 11 od rx je reserved
2077
// bit 10 od rx je reserved
2078
// bit 9  od rx je reserved
2079
// bit 8  od rx je reserved
2080 80 mohor
// bit 7  od rx je Miss               still needs to be done
2081 60 mohor
// bit 6  od rx je RxOverrun
2082
// bit 5  od rx je InvalidSymbol
2083
// bit 4  od rx je DribbleNibble
2084
// bit 3  od rx je ReceivedPacketTooBig
2085
// bit 2  od rx je ShortFrame
2086
// bit 1  od rx je LatchedCrcError
2087
// bit 0  od rx je RxLateCollision
2088
 
2089 38 mohor
endmodule
2090
 

powered by: WebSVN 2.1.0

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