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 96

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

powered by: WebSVN 2.1.0

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