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

Subversion Repositories ethmac

[/] [ethmac/] [branches/] [unneback/] [rtl/] [verilog/] [eth_top.v] - Blame information for rev 349

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

Line No. Rev Author Line
1 15 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_top.v                                                   ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6 346 olof
////  http://www.opencores.org/project,ethmac                     ////
7 15 mohor
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Igor Mohor (igorM@opencores.org)                      ////
10
////                                                              ////
11 202 mohor
////  All additional information is available in the Readme.txt   ////
12 15 mohor
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16 202 mohor
//// Copyright (C) 2001, 2002 Authors                             ////
17 15 mohor
////                                                              ////
18
//// This source file may be used and distributed without         ////
19
//// restriction provided that this copyright statement is not    ////
20
//// removed from the file and that any derivative work contains  ////
21
//// the original copyright notice and the associated disclaimer. ////
22
////                                                              ////
23
//// This source file is free software; you can redistribute it   ////
24
//// and/or modify it under the terms of the GNU Lesser General   ////
25
//// Public License as published by the Free Software Foundation; ////
26
//// either version 2.1 of the License, or (at your option) any   ////
27
//// later version.                                               ////
28
////                                                              ////
29
//// This source is distributed in the hope that it will be       ////
30
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
31
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
32
//// PURPOSE.  See the GNU Lesser General Public License for more ////
33
//// details.                                                     ////
34
////                                                              ////
35
//// You should have received a copy of the GNU Lesser General    ////
36
//// Public License along with this source; if not, download it   ////
37
//// from http://www.opencores.org/lgpl.shtml                     ////
38
////                                                              ////
39
//////////////////////////////////////////////////////////////////////
40
//
41
// CVS Revision History
42
//
43
// $Log: not supported by cvs2svn $
44 333 igorm
// Revision 1.51  2005/02/21 11:13:17  igorm
45
// Defer indication fixed.
46
//
47 327 igorm
// Revision 1.50  2004/04/26 15:26:23  igorm
48
// - Bug connected to the TX_BD_NUM_Wr signal fixed (bug came in with the
49
//   previous update of the core.
50
// - TxBDAddress is set to 0 after the TX is enabled in the MODER register.
51
// - RxBDAddress is set to r_TxBDNum<<1 after the RX is enabled in the MODER
52
//   register. (thanks to Mathias and Torbjorn)
53
// - Multicast reception was fixed. Thanks to Ulrich Gries
54
//
55 321 igorm
// Revision 1.49  2003/11/12 18:24:59  tadejm
56
// WISHBONE slave changed and tested from only 32-bit accesss to byte access.
57
//
58 304 tadejm
// Revision 1.48  2003/10/17 07:46:16  markom
59
// mbist signals updated according to newest convention
60
//
61 302 markom
// Revision 1.47  2003/10/06 15:43:45  knguyen
62
// Update RxEnSync only when mrxdv_pad_i is inactive (LOW).
63
//
64 301 knguyen
// Revision 1.46  2003/01/30 13:30:22  tadejm
65
// Defer indication changed.
66
//
67 276 tadejm
// Revision 1.45  2003/01/22 13:49:26  tadejm
68
// When control packets were received, they were ignored in some cases.
69
//
70 272 tadejm
// Revision 1.44  2003/01/21 12:09:40  mohor
71
// When receiving normal data frame and RxFlow control was switched on, RXB
72
// interrupt was not set.
73
//
74 270 mohor
// Revision 1.43  2002/11/22 01:57:06  mohor
75
// Rx Flow control fixed. CF flag added to the RX buffer descriptor. RxAbort
76
// synchronized.
77
//
78 261 mohor
// Revision 1.42  2002/11/21 00:09:19  mohor
79
// TPauseRq synchronized to tx_clk.
80
//
81 255 mohor
// Revision 1.41  2002/11/19 18:13:49  mohor
82
// r_MiiMRst is not used for resetting the MIIM module. wb_rst used instead.
83
//
84 253 mohor
// Revision 1.40  2002/11/19 17:34:25  mohor
85
// AddressMiss status is connecting to the Rx BD. AddressMiss is identifying
86
// that a frame was received because of the promiscous mode.
87
//
88 250 mohor
// Revision 1.39  2002/11/18 17:31:55  mohor
89
// wb_rst_i is used for MIIM reset.
90
//
91 248 mohor
// Revision 1.38  2002/11/14 18:37:20  mohor
92
// r_Rst signal does not reset any module any more and is removed from the design.
93
//
94 244 mohor
// Revision 1.37  2002/11/13 22:25:36  tadejm
95
// All modules are reset with wb_rst instead of the r_Rst. Exception is MII module.
96
//
97 240 tadejm
// Revision 1.36  2002/10/18 17:04:20  tadejm
98
// Changed BIST scan signals.
99
//
100 227 tadejm
// Revision 1.35  2002/10/11 13:36:58  mohor
101
// Typo error fixed. (When using Bist)
102
//
103 218 mohor
// Revision 1.34  2002/10/10 16:49:50  mohor
104
// Signals for WISHBONE B3 compliant interface added.
105
//
106 214 mohor
// Revision 1.33  2002/10/10 16:29:30  mohor
107
// BIST added.
108
//
109 210 mohor
// Revision 1.32  2002/09/20 17:12:58  mohor
110
// CsMiss added. When address between 0x800 and 0xfff is accessed within
111
// Ethernet Core, error acknowledge is generated.
112
//
113 202 mohor
// Revision 1.31  2002/09/12 14:50:17  mohor
114
// CarrierSenseLost bug fixed when operating in full duplex mode.
115
//
116 168 mohor
// Revision 1.30  2002/09/10 10:35:23  mohor
117
// Ethernet debug registers removed.
118
//
119 164 mohor
// Revision 1.29  2002/09/09 13:03:13  mohor
120
// Error acknowledge is generated when accessing BDs and RST bit in the
121
// MODER register (r_Rst) is set.
122
//
123 161 mohor
// Revision 1.28  2002/09/04 18:44:10  mohor
124
// Signals related to the control frames connected. Debug registers reg1, 2, 3, 4
125
// connected.
126
//
127 149 mohor
// Revision 1.27  2002/07/25 18:15:37  mohor
128
// RxAbort changed. Packets received with MRxErr (from PHY) are also
129
// aborted.
130
//
131 125 mohor
// Revision 1.26  2002/07/17 18:51:50  mohor
132
// EXTERNAL_DMA removed. External DMA not supported.
133
//
134 114 mohor
// Revision 1.25  2002/05/03 10:15:50  mohor
135
// Outputs registered. Reset changed for eth_wishbone module.
136
//
137 106 mohor
// Revision 1.24  2002/04/22 14:15:42  mohor
138
// Wishbone signals are registered when ETH_REGISTERED_OUTPUTS is
139
// selected in eth_defines.v
140
//
141 103 mohor
// Revision 1.23  2002/03/25 13:33:53  mohor
142
// md_padoen_o changed to md_padoe_o. Signal was always active high, just
143
// name was incorrect.
144
//
145 95 mohor
// Revision 1.22  2002/02/26 16:59:54  mohor
146
// Small fixes for external/internal DMA missmatches.
147
//
148 80 mohor
// Revision 1.21  2002/02/26 16:21:00  mohor
149
// Interrupts changed in the top file
150
//
151 76 mohor
// Revision 1.20  2002/02/18 10:40:17  mohor
152
// Small fixes.
153
//
154 70 mohor
// Revision 1.19  2002/02/16 14:03:44  mohor
155
// Registered trimmed. Unused registers removed.
156
//
157 68 mohor
// Revision 1.18  2002/02/16 13:06:33  mohor
158
// EXTERNAL_DMA used instead of WISHBONE_DMA.
159
//
160 67 mohor
// Revision 1.17  2002/02/16 07:15:27  mohor
161
// Testbench fixed, code simplified, unused signals removed.
162
//
163 65 mohor
// Revision 1.16  2002/02/15 13:49:39  mohor
164
// RxAbort is connected differently.
165
//
166 63 mohor
// Revision 1.15  2002/02/15 11:38:26  mohor
167
// Changes that were lost when updating from 1.11 to 1.14 fixed.
168
//
169 59 mohor
// Revision 1.14  2002/02/14 20:19:11  billditt
170
// Modified for Address Checking,
171
// addition of eth_addrcheck.v
172
//
173
// Revision 1.13  2002/02/12 17:03:03  mohor
174
// HASH0 and HASH1 registers added. Registers address width was
175
// changed to 8 bits.
176
//
177
// Revision 1.12  2002/02/11 09:18:22  mohor
178
// Tx status is written back to the BD.
179
//
180 43 mohor
// Revision 1.11  2002/02/08 16:21:54  mohor
181
// Rx status is written back to the BD.
182
//
183 42 mohor
// Revision 1.10  2002/02/06 14:10:21  mohor
184
// non-DMA host interface added. Select the right configutation in eth_defines.
185
//
186 41 mohor
// Revision 1.9  2002/01/23 10:28:16  mohor
187
// Link in the header changed.
188
//
189 37 mohor
// Revision 1.8  2001/12/05 15:00:16  mohor
190
// RX_BD_NUM changed to TX_BD_NUM (holds number of TX descriptors
191
// instead of the number of RX descriptors).
192
//
193 34 mohor
// Revision 1.7  2001/12/05 10:45:59  mohor
194
// ETH_RX_BD_ADR register deleted. ETH_RX_BD_NUM is used instead.
195
//
196 33 mohor
// Revision 1.6  2001/10/19 11:24:29  mohor
197
// Number of addresses (wb_adr_i) minimized.
198
//
199 23 mohor
// Revision 1.5  2001/10/19 08:43:51  mohor
200
// eth_timescale.v changed to timescale.v This is done because of the
201
// simulation of the few cores in a one joined project.
202
//
203 22 mohor
// Revision 1.4  2001/10/18 12:07:11  mohor
204
// Status signals changed, Adress decoding changed, interrupt controller
205
// added.
206
//
207 21 mohor
// Revision 1.3  2001/09/24 15:02:56  mohor
208
// Defines changed (All precede with ETH_). Small changes because some
209
// tools generate warnings when two operands are together. Synchronization
210
// between two clocks domains in eth_wishbonedma.v is changed (due to ASIC
211
// demands).
212
//
213 20 mohor
// Revision 1.2  2001/08/15 14:03:59  mohor
214
// Signal names changed on the top level for easier pad insertion (ASIC).
215
//
216 17 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
217
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
218
// Include files fixed to contain no path.
219
// File names and module names changed ta have a eth_ prologue in the name.
220
// File eth_timescale.v is used to define timescale
221
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
222
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
223
// and Mdo_OE. The bidirectional signal must be created on the top level. This
224
// is done due to the ASIC tools.
225
//
226 15 mohor
// Revision 1.2  2001/08/02 09:25:31  mohor
227
// Unconnected signals are now connected.
228
//
229
// Revision 1.1  2001/07/30 21:23:42  mohor
230
// Directory structure changed. Files checked and joind together.
231
//
232
//
233
//
234 20 mohor
// 
235 15 mohor
 
236
 
237
`include "eth_defines.v"
238 22 mohor
`include "timescale.v"
239 15 mohor
 
240
 
241
module eth_top
242
(
243
  // WISHBONE common
244 17 mohor
  wb_clk_i, wb_rst_i, wb_dat_i, wb_dat_o,
245 15 mohor
 
246
  // WISHBONE slave
247 17 mohor
  wb_adr_i, wb_sel_i, wb_we_i, wb_cyc_i, wb_stb_i, wb_ack_o, wb_err_o,
248 15 mohor
 
249 41 mohor
  // WISHBONE master
250
  m_wb_adr_o, m_wb_sel_o, m_wb_we_o,
251
  m_wb_dat_o, m_wb_dat_i, m_wb_cyc_o,
252
  m_wb_stb_o, m_wb_ack_i, m_wb_err_i,
253
 
254 214 mohor
`ifdef ETH_WISHBONE_B3
255
  m_wb_cti_o, m_wb_bte_o,
256
`endif
257
 
258 15 mohor
  //TX
259 20 mohor
  mtx_clk_pad_i, mtxd_pad_o, mtxen_pad_o, mtxerr_pad_o,
260 15 mohor
 
261
  //RX
262 20 mohor
  mrx_clk_pad_i, mrxd_pad_i, mrxdv_pad_i, mrxerr_pad_i, mcoll_pad_i, mcrs_pad_i,
263 15 mohor
 
264
  // MIIM
265 95 mohor
  mdc_pad_o, md_pad_i, md_pad_o, md_padoe_o,
266 17 mohor
 
267 21 mohor
  int_o
268 17 mohor
 
269 210 mohor
  // Bist
270
`ifdef ETH_BIST
271 227 tadejm
  ,
272
  // debug chain signals
273 302 markom
  mbist_si_i,       // bist scan serial in
274
  mbist_so_o,       // bist scan serial out
275
  mbist_ctrl_i        // bist chain shift control
276 210 mohor
`endif
277 21 mohor
 
278 15 mohor
);
279
 
280
 
281
parameter Tp = 1;
282 349 olof
parameter TX_FIFO_DATA_WIDTH = `ETH_TX_FIFO_DATA_WIDTH;
283
parameter TX_FIFO_DEPTH      = `ETH_TX_FIFO_DEPTH;
284
parameter TX_FIFO_CNT_WIDTH  = `ETH_TX_FIFO_CNT_WIDTH;
285
parameter RX_FIFO_DATA_WIDTH = `ETH_RX_FIFO_DATA_WIDTH;
286
parameter RX_FIFO_DEPTH      = `ETH_RX_FIFO_DEPTH;
287
parameter RX_FIFO_CNT_WIDTH  = `ETH_RX_FIFO_CNT_WIDTH;
288 15 mohor
 
289
 
290
// WISHBONE common
291 17 mohor
input           wb_clk_i;     // WISHBONE clock
292
input           wb_rst_i;     // WISHBONE reset
293
input   [31:0]  wb_dat_i;     // WISHBONE data input
294
output  [31:0]  wb_dat_o;     // WISHBONE data output
295
output          wb_err_o;     // WISHBONE error output
296 15 mohor
 
297
// WISHBONE slave
298 23 mohor
input   [11:2]  wb_adr_i;     // WISHBONE address input
299 17 mohor
input    [3:0]  wb_sel_i;     // WISHBONE byte select input
300
input           wb_we_i;      // WISHBONE write enable input
301
input           wb_cyc_i;     // WISHBONE cycle input
302
input           wb_stb_i;     // WISHBONE strobe input
303
output          wb_ack_o;     // WISHBONE acknowledge output
304 15 mohor
 
305 41 mohor
// WISHBONE master
306
output  [31:0]  m_wb_adr_o;
307
output   [3:0]  m_wb_sel_o;
308
output          m_wb_we_o;
309
input   [31:0]  m_wb_dat_i;
310
output  [31:0]  m_wb_dat_o;
311
output          m_wb_cyc_o;
312
output          m_wb_stb_o;
313
input           m_wb_ack_i;
314
input           m_wb_err_i;
315 15 mohor
 
316 327 igorm
wire    [29:0]  m_wb_adr_tmp;
317
 
318 214 mohor
`ifdef ETH_WISHBONE_B3
319
output   [2:0]  m_wb_cti_o;   // Cycle Type Identifier
320
output   [1:0]  m_wb_bte_o;   // Burst Type Extension
321
`endif
322 41 mohor
 
323 15 mohor
// Tx
324 20 mohor
input           mtx_clk_pad_i; // Transmit clock (from PHY)
325 21 mohor
output   [3:0]  mtxd_pad_o;    // Transmit nibble (to PHY)
326
output          mtxen_pad_o;   // Transmit enable (to PHY)
327
output          mtxerr_pad_o;  // Transmit error (to PHY)
328 15 mohor
 
329
// Rx
330 20 mohor
input           mrx_clk_pad_i; // Receive clock (from PHY)
331 21 mohor
input    [3:0]  mrxd_pad_i;    // Receive nibble (from PHY)
332
input           mrxdv_pad_i;   // Receive data valid (from PHY)
333
input           mrxerr_pad_i;  // Receive data error (from PHY)
334 15 mohor
 
335
// Common Tx and Rx
336 21 mohor
input           mcoll_pad_i;   // Collision (from PHY)
337
input           mcrs_pad_i;    // Carrier sense (from PHY)
338 15 mohor
 
339
// MII Management interface
340 21 mohor
input           md_pad_i;      // MII data input (from I/O cell)
341
output          mdc_pad_o;     // MII Management data clock (to PHY)
342
output          md_pad_o;      // MII data output (to I/O cell)
343 95 mohor
output          md_padoe_o;    // MII data output enable (to I/O cell)
344 15 mohor
 
345 21 mohor
output          int_o;         // Interrupt output
346 15 mohor
 
347 210 mohor
// Bist
348
`ifdef ETH_BIST
349 302 markom
input   mbist_si_i;       // bist scan serial in
350
output  mbist_so_o;       // bist scan serial out
351
input [`ETH_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;       // bist chain shift control
352 210 mohor
`endif
353
 
354 15 mohor
wire     [7:0]  r_ClkDiv;
355
wire            r_MiiNoPre;
356
wire    [15:0]  r_CtrlData;
357
wire     [4:0]  r_FIAD;
358
wire     [4:0]  r_RGAD;
359
wire            r_WCtrlData;
360
wire            r_RStat;
361
wire            r_ScanStat;
362
wire            NValid_stat;
363
wire            Busy_stat;
364
wire            LinkFail;
365
wire    [15:0]  Prsd;             // Read Status Data (data read from the PHY)
366
wire            WCtrlDataStart;
367
wire            RStatStart;
368
wire            UpdateMIIRX_DATAReg;
369
 
370
wire            TxStartFrm;
371
wire            TxEndFrm;
372
wire            TxUsedData;
373
wire     [7:0]  TxData;
374
wire            TxRetry;
375
wire            TxAbort;
376
wire            TxUnderRun;
377
wire            TxDone;
378
 
379
 
380 149 mohor
reg             WillSendControlFrame_sync1;
381
reg             WillSendControlFrame_sync2;
382
reg             WillSendControlFrame_sync3;
383
reg             RstTxPauseRq;
384 15 mohor
 
385 255 mohor
reg             TxPauseRq_sync1;
386
reg             TxPauseRq_sync2;
387
reg             TxPauseRq_sync3;
388
reg             TPauseRq;
389 15 mohor
 
390 255 mohor
 
391 15 mohor
// Connecting Miim module
392 349 olof
eth_miim #(.Tp(Tp))
393
miim1
394 15 mohor
(
395 248 mohor
  .Clk(wb_clk_i),                         .Reset(wb_rst_i),                   .Divider(r_ClkDiv),
396 15 mohor
  .NoPre(r_MiiNoPre),                     .CtrlData(r_CtrlData),              .Rgad(r_RGAD),
397
  .Fiad(r_FIAD),                          .WCtrlData(r_WCtrlData),            .RStat(r_RStat),
398 17 mohor
  .ScanStat(r_ScanStat),                  .Mdi(md_pad_i),                     .Mdo(md_pad_o),
399 95 mohor
  .MdoEn(md_padoe_o),                     .Mdc(mdc_pad_o),                    .Busy(Busy_stat),
400 15 mohor
  .Prsd(Prsd),                            .LinkFail(LinkFail),                .Nvalid(NValid_stat),
401
  .WCtrlDataStart(WCtrlDataStart),        .RStatStart(RStatStart),            .UpdateMIIRX_DATAReg(UpdateMIIRX_DATAReg)
402
);
403
 
404
 
405
 
406
 
407 304 tadejm
wire  [3:0] RegCs;          // Connected to registers
408 17 mohor
wire [31:0] RegDataOut;     // Multiplexed to wb_dat_o
409 42 mohor
wire        r_RecSmall;     // Receive small frames
410 15 mohor
wire        r_LoopBck;      // Loopback
411
wire        r_TxEn;         // Tx Enable
412
wire        r_RxEn;         // Rx Enable
413
 
414
wire        MRxDV_Lb;       // Muxed MII receive data valid
415
wire        MRxErr_Lb;      // Muxed MII Receive Error
416
wire  [3:0] MRxD_Lb;        // Muxed MII Receive Data
417
wire        Transmitting;   // Indication that TxEthMAC is transmitting
418
wire        r_HugEn;        // Huge packet enable
419
wire        r_DlyCrcEn;     // Delayed CRC enabled
420
wire [15:0] r_MaxFL;        // Maximum frame length
421
 
422
wire [15:0] r_MinFL;        // Minimum frame length
423 42 mohor
wire        ShortFrame;
424
wire        DribbleNibble;  // Extra nibble received
425
wire        ReceivedPacketTooBig; // Received packet is too big
426 15 mohor
wire [47:0] r_MAC;          // MAC address
427 42 mohor
wire        LoadRxStatus;   // Rx status was loaded
428 52 billditt
wire [31:0] r_HASH0;        // HASH table, lower 4 bytes
429
wire [31:0] r_HASH1;        // HASH table, upper 4 bytes
430 34 mohor
wire  [7:0] r_TxBDNum;      // Receive buffer descriptor number
431 15 mohor
wire  [6:0] r_IPGT;         // 
432
wire  [6:0] r_IPGR1;        // 
433
wire  [6:0] r_IPGR2;        // 
434
wire  [5:0] r_CollValid;    // 
435 149 mohor
wire [15:0] r_TxPauseTV;    // Transmit PAUSE value
436
wire        r_TxPauseRq;    // Transmit PAUSE request
437 15 mohor
 
438
wire  [3:0] r_MaxRet;       //
439
wire        r_NoBckof;      // 
440
wire        r_ExDfrEn;      // 
441
wire        r_TxFlow;       // Tx flow control enable
442
wire        r_IFG;          // Minimum interframe gap for incoming packets
443
 
444 21 mohor
wire        TxB_IRQ;        // Interrupt Tx Buffer
445
wire        TxE_IRQ;        // Interrupt Tx Error
446
wire        RxB_IRQ;        // Interrupt Rx Buffer
447 76 mohor
wire        RxE_IRQ;        // Interrupt Rx Error
448 21 mohor
wire        Busy_IRQ;       // Interrupt Busy (lack of buffers)
449 15 mohor
 
450 304 tadejm
//wire        DWord;
451
wire        ByteSelected;
452 15 mohor
wire        BDAck;
453 103 mohor
wire [31:0] BD_WB_DAT_O;    // wb_dat_o that comes from the Wishbone module (for buffer descriptors read/write)
454 304 tadejm
wire  [3:0] BDCs;           // Buffer descriptor CS
455 202 mohor
wire        CsMiss;         // When access to the address between 0x800 and 0xfff occurs, acknowledge is set
456
                            // but data is not valid.
457 327 igorm
wire        r_Pad;
458
wire        r_CrcEn;
459
wire        r_FullD;
460
wire        r_Pro;
461
wire        r_Bro;
462
wire        r_NoPre;
463
wire        r_RxFlow;
464
wire        r_PassAll;
465
wire        TxCtrlEndFrm;
466
wire        StartTxDone;
467
wire        SetPauseTimer;
468
wire        TxUsedDataIn;
469
wire        TxDoneIn;
470
wire        TxAbortIn;
471
wire        PerPacketPad;
472
wire        PadOut;
473
wire        PerPacketCrcEn;
474
wire        CrcEnOut;
475
wire        TxStartFrmOut;
476
wire        TxEndFrmOut;
477
wire        ReceivedPauseFrm;
478
wire        ControlFrmAddressOK;
479
wire        RxStatusWriteLatched_sync2;
480
wire        LateCollision;
481
wire        DeferIndication;
482
wire        LateCollLatched;
483
wire        DeferLatched;
484
wire        RstDeferLatched;
485
wire        CarrierSenseLost;
486 15 mohor
 
487 103 mohor
wire        temp_wb_ack_o;
488
wire [31:0] temp_wb_dat_o;
489
wire        temp_wb_err_o;
490 15 mohor
 
491 103 mohor
`ifdef ETH_REGISTERED_OUTPUTS
492
  reg         temp_wb_ack_o_reg;
493
  reg [31:0]  temp_wb_dat_o_reg;
494
  reg         temp_wb_err_o_reg;
495
`endif
496
 
497 304 tadejm
//assign DWord = &wb_sel_i;
498
assign ByteSelected = |wb_sel_i;
499
assign RegCs[3] = wb_stb_i & wb_cyc_i & ByteSelected & ~wb_adr_i[11] & ~wb_adr_i[10] & wb_sel_i[3];   // 0x0   - 0x3FF
500
assign RegCs[2] = wb_stb_i & wb_cyc_i & ByteSelected & ~wb_adr_i[11] & ~wb_adr_i[10] & wb_sel_i[2];   // 0x0   - 0x3FF
501
assign RegCs[1] = wb_stb_i & wb_cyc_i & ByteSelected & ~wb_adr_i[11] & ~wb_adr_i[10] & wb_sel_i[1];   // 0x0   - 0x3FF
502
assign RegCs[0] = wb_stb_i & wb_cyc_i & ByteSelected & ~wb_adr_i[11] & ~wb_adr_i[10] & wb_sel_i[0];   // 0x0   - 0x3FF
503
assign BDCs[3]  = wb_stb_i & wb_cyc_i & ByteSelected & ~wb_adr_i[11] &  wb_adr_i[10] & wb_sel_i[3];   // 0x400 - 0x7FF
504
assign BDCs[2]  = wb_stb_i & wb_cyc_i & ByteSelected & ~wb_adr_i[11] &  wb_adr_i[10] & wb_sel_i[2];   // 0x400 - 0x7FF
505
assign BDCs[1]  = wb_stb_i & wb_cyc_i & ByteSelected & ~wb_adr_i[11] &  wb_adr_i[10] & wb_sel_i[1];   // 0x400 - 0x7FF
506
assign BDCs[0]  = wb_stb_i & wb_cyc_i & ByteSelected & ~wb_adr_i[11] &  wb_adr_i[10] & wb_sel_i[0];   // 0x400 - 0x7FF
507
assign CsMiss = wb_stb_i & wb_cyc_i & ByteSelected & wb_adr_i[11];                   // 0x800 - 0xfFF
508
assign temp_wb_dat_o = ((|RegCs) & ~wb_we_i)? RegDataOut : BD_WB_DAT_O;
509
assign temp_wb_err_o = wb_stb_i & wb_cyc_i & (~ByteSelected | CsMiss);
510 15 mohor
 
511 103 mohor
`ifdef ETH_REGISTERED_OUTPUTS
512
  assign wb_ack_o = temp_wb_ack_o_reg;
513
  assign wb_dat_o[31:0] = temp_wb_dat_o_reg;
514
  assign wb_err_o = temp_wb_err_o_reg;
515
`else
516
  assign wb_ack_o = temp_wb_ack_o;
517
  assign wb_dat_o[31:0] = temp_wb_dat_o;
518
  assign wb_err_o = temp_wb_err_o;
519
`endif
520 15 mohor
 
521 327 igorm
`ifdef ETH_AVALON_BUS
522
  // As Avalon has no corresponding "error" signal, I (erroneously) will
523
  // send an ack to Avalon, even when accessing undefined memory. This
524
  // is a grey area in Avalon vs. Wishbone specs: My understanding
525
  // is that Avalon expects all memory addressable by the addr bus feeding
526
  // a slave to be, at the very minimum, readable.
527
  assign temp_wb_ack_o = (|RegCs) | BDAck | CsMiss;
528
`else // WISHBONE
529
  assign temp_wb_ack_o = (|RegCs) | BDAck;
530
`endif
531 15 mohor
 
532 103 mohor
`ifdef ETH_REGISTERED_OUTPUTS
533
  always @ (posedge wb_clk_i or posedge wb_rst_i)
534
  begin
535
    if(wb_rst_i)
536
      begin
537
        temp_wb_ack_o_reg <=#Tp 1'b0;
538
        temp_wb_dat_o_reg <=#Tp 32'h0;
539
        temp_wb_err_o_reg <=#Tp 1'b0;
540
      end
541
    else
542
      begin
543 106 mohor
        temp_wb_ack_o_reg <=#Tp temp_wb_ack_o & ~temp_wb_ack_o_reg;
544 103 mohor
        temp_wb_dat_o_reg <=#Tp temp_wb_dat_o;
545 106 mohor
        temp_wb_err_o_reg <=#Tp temp_wb_err_o & ~temp_wb_err_o_reg;
546 103 mohor
      end
547
  end
548
`endif
549
 
550
 
551 15 mohor
// Connecting Ethernet registers
552 349 olof
eth_registers #(.Tp(Tp))
553
ethreg1
554 15 mohor
(
555 47 mohor
  .DataIn(wb_dat_i),                      .Address(wb_adr_i[9:2]),                    .Rw(wb_we_i),
556 17 mohor
  .Cs(RegCs),                             .Clk(wb_clk_i),                             .Reset(wb_rst_i),
557 68 mohor
  .DataOut(RegDataOut),                   .r_RecSmall(r_RecSmall),
558 15 mohor
  .r_Pad(r_Pad),                          .r_HugEn(r_HugEn),                          .r_CrcEn(r_CrcEn),
559 244 mohor
  .r_DlyCrcEn(r_DlyCrcEn),                .r_FullD(r_FullD),
560 15 mohor
  .r_ExDfrEn(r_ExDfrEn),                  .r_NoBckof(r_NoBckof),                      .r_LoopBck(r_LoopBck),
561 52 billditt
  .r_IFG(r_IFG),                          .r_Pro(r_Pro),                              .r_Iam(),
562
  .r_Bro(r_Bro),                          .r_NoPre(r_NoPre),                          .r_TxEn(r_TxEn),
563 76 mohor
  .r_RxEn(r_RxEn),                        .Busy_IRQ(Busy_IRQ),                        .RxE_IRQ(RxE_IRQ),
564 21 mohor
  .RxB_IRQ(RxB_IRQ),                      .TxE_IRQ(TxE_IRQ),                          .TxB_IRQ(TxB_IRQ),
565 149 mohor
  .r_IPGT(r_IPGT),
566 15 mohor
  .r_IPGR1(r_IPGR1),                      .r_IPGR2(r_IPGR2),                          .r_MinFL(r_MinFL),
567
  .r_MaxFL(r_MaxFL),                      .r_MaxRet(r_MaxRet),                        .r_CollValid(r_CollValid),
568
  .r_TxFlow(r_TxFlow),                    .r_RxFlow(r_RxFlow),                        .r_PassAll(r_PassAll),
569 253 mohor
  .r_MiiNoPre(r_MiiNoPre),                .r_ClkDiv(r_ClkDiv),
570 15 mohor
  .r_WCtrlData(r_WCtrlData),              .r_RStat(r_RStat),                          .r_ScanStat(r_ScanStat),
571
  .r_RGAD(r_RGAD),                        .r_FIAD(r_FIAD),                            .r_CtrlData(r_CtrlData),
572
  .NValid_stat(NValid_stat),              .Busy_stat(Busy_stat),
573
  .LinkFail(LinkFail),                    .r_MAC(r_MAC),                              .WCtrlDataStart(WCtrlDataStart),
574
  .RStatStart(RStatStart),                .UpdateMIIRX_DATAReg(UpdateMIIRX_DATAReg),  .Prsd(Prsd),
575 321 igorm
  .r_TxBDNum(r_TxBDNum),                  .int_o(int_o),
576 149 mohor
  .r_HASH0(r_HASH0),                      .r_HASH1(r_HASH1),                          .r_TxPauseRq(r_TxPauseRq),
577
  .r_TxPauseTV(r_TxPauseTV),              .RstTxPauseRq(RstTxPauseRq),                .TxCtrlEndFrm(TxCtrlEndFrm),
578
  .StartTxDone(StartTxDone),              .TxClk(mtx_clk_pad_i),                      .RxClk(mrx_clk_pad_i),
579 261 mohor
  .SetPauseTimer(SetPauseTimer)
580 149 mohor
 
581 15 mohor
);
582
 
583
 
584
 
585
wire  [7:0] RxData;
586
wire        RxValid;
587
wire        RxStartFrm;
588
wire        RxEndFrm;
589 41 mohor
wire        RxAbort;
590 15 mohor
 
591
wire        WillTransmit;            // Will transmit (to RxEthMAC)
592
wire        ResetCollision;          // Reset Collision (for synchronizing collision)
593
wire  [7:0] TxDataOut;               // Transmit Packet Data (to TxEthMAC)
594
wire        WillSendControlFrame;
595
wire        ReceiveEnd;
596
wire        ReceivedPacketGood;
597
wire        ReceivedLengthOK;
598 42 mohor
wire        InvalidSymbol;
599
wire        LatchedCrcError;
600
wire        RxLateCollision;
601 59 mohor
wire  [3:0] RetryCntLatched;
602
wire  [3:0] RetryCnt;
603
wire        StartTxAbort;
604
wire        MaxCollisionOccured;
605
wire        RetryLimit;
606
wire        StatePreamble;
607
wire  [1:0] StateData;
608 15 mohor
 
609
// Connecting MACControl
610 349 olof
eth_maccontrol #(.Tp(Tp))
611
maccontrol1
612 15 mohor
(
613 255 mohor
  .MTxClk(mtx_clk_pad_i),                       .TPauseRq(TPauseRq),
614 149 mohor
  .TxPauseTV(r_TxPauseTV),                      .TxDataIn(TxData),
615 15 mohor
  .TxStartFrmIn(TxStartFrm),                    .TxEndFrmIn(TxEndFrm),
616
  .TxUsedDataIn(TxUsedDataIn),                  .TxDoneIn(TxDoneIn),
617 20 mohor
  .TxAbortIn(TxAbortIn),                        .MRxClk(mrx_clk_pad_i),
618 15 mohor
  .RxData(RxData),                              .RxValid(RxValid),
619
  .RxStartFrm(RxStartFrm),                      .RxEndFrm(RxEndFrm),
620
  .ReceiveEnd(ReceiveEnd),                      .ReceivedPacketGood(ReceivedPacketGood),
621 261 mohor
  .TxFlow(r_TxFlow),
622 15 mohor
  .RxFlow(r_RxFlow),                            .DlyCrcEn(r_DlyCrcEn),
623
  .MAC(r_MAC),                                  .PadIn(r_Pad | PerPacketPad),
624
  .PadOut(PadOut),                              .CrcEnIn(r_CrcEn | PerPacketCrcEn),
625 240 tadejm
  .CrcEnOut(CrcEnOut),                          .TxReset(wb_rst_i),
626
  .RxReset(wb_rst_i),                           .ReceivedLengthOK(ReceivedLengthOK),
627 15 mohor
  .TxDataOut(TxDataOut),                        .TxStartFrmOut(TxStartFrmOut),
628
  .TxEndFrmOut(TxEndFrmOut),                    .TxUsedDataOut(TxUsedData),
629
  .TxDoneOut(TxDone),                           .TxAbortOut(TxAbort),
630
  .WillSendControlFrame(WillSendControlFrame),  .TxCtrlEndFrm(TxCtrlEndFrm),
631 261 mohor
  .ReceivedPauseFrm(ReceivedPauseFrm),          .ControlFrmAddressOK(ControlFrmAddressOK),
632 272 tadejm
  .SetPauseTimer(SetPauseTimer),
633
  .RxStatusWriteLatched_sync2(RxStatusWriteLatched_sync2),                .r_PassAll(r_PassAll)
634 15 mohor
);
635
 
636
 
637
 
638
wire TxCarrierSense;          // Synchronized CarrierSense (to Tx clock)
639
wire Collision;               // Synchronized Collision
640
 
641
reg CarrierSense_Tx1;
642
reg CarrierSense_Tx2;
643
reg Collision_Tx1;
644
reg Collision_Tx2;
645
 
646
reg RxEnSync;                 // Synchronized Receive Enable
647
reg WillTransmit_q;
648
reg WillTransmit_q2;
649
 
650
 
651
 
652
// Muxed MII receive data valid
653 17 mohor
assign MRxDV_Lb = r_LoopBck? mtxen_pad_o : mrxdv_pad_i & RxEnSync;
654 15 mohor
 
655
// Muxed MII Receive Error
656 17 mohor
assign MRxErr_Lb = r_LoopBck? mtxerr_pad_o : mrxerr_pad_i & RxEnSync;
657 15 mohor
 
658
// Muxed MII Receive Data
659 17 mohor
assign MRxD_Lb[3:0] = r_LoopBck? mtxd_pad_o[3:0] : mrxd_pad_i[3:0];
660 15 mohor
 
661
 
662
 
663
// Connecting TxEthMAC
664 349 olof
eth_txethmac #(.Tp(Tp))
665
txethmac1
666 15 mohor
(
667 240 tadejm
  .MTxClk(mtx_clk_pad_i),             .Reset(wb_rst_i),                   .CarrierSense(TxCarrierSense),
668 15 mohor
  .Collision(Collision),              .TxData(TxDataOut),                 .TxStartFrm(TxStartFrmOut),
669
  .TxUnderRun(TxUnderRun),            .TxEndFrm(TxEndFrmOut),             .Pad(PadOut),
670
  .MinFL(r_MinFL),                    .CrcEn(CrcEnOut),                   .FullD(r_FullD),
671
  .HugEn(r_HugEn),                    .DlyCrcEn(r_DlyCrcEn),              .IPGT(r_IPGT),
672
  .IPGR1(r_IPGR1),                    .IPGR2(r_IPGR2),                    .CollValid(r_CollValid),
673
  .MaxRet(r_MaxRet),                  .NoBckof(r_NoBckof),                .ExDfrEn(r_ExDfrEn),
674 17 mohor
  .MaxFL(r_MaxFL),                    .MTxEn(mtxen_pad_o),                .MTxD(mtxd_pad_o),
675
  .MTxErr(mtxerr_pad_o),              .TxUsedData(TxUsedDataIn),          .TxDone(TxDoneIn),
676 15 mohor
  .TxRetry(TxRetry),                  .TxAbort(TxAbortIn),                .WillTransmit(WillTransmit),
677 59 mohor
  .ResetCollision(ResetCollision),    .RetryCnt(RetryCnt),                .StartTxDone(StartTxDone),
678
  .StartTxAbort(StartTxAbort),        .MaxCollisionOccured(MaxCollisionOccured), .LateCollision(LateCollision),
679 276 tadejm
  .DeferIndication(DeferIndication),  .StatePreamble(StatePreamble),      .StateData(StateData)
680 15 mohor
);
681
 
682
 
683
 
684
 
685
wire  [15:0]  RxByteCnt;
686
wire          RxByteCntEq0;
687
wire          RxByteCntGreat2;
688
wire          RxByteCntMaxFrame;
689
wire          RxCrcError;
690
wire          RxStateIdle;
691
wire          RxStatePreamble;
692
wire          RxStateSFD;
693
wire   [1:0]  RxStateData;
694 250 mohor
wire          AddressMiss;
695 15 mohor
 
696
 
697
 
698
// Connecting RxEthMAC
699 349 olof
eth_rxethmac #(.Tp(Tp))
700
rxethmac1
701 15 mohor
(
702 21 mohor
  .MRxClk(mrx_clk_pad_i),               .MRxDV(MRxDV_Lb),                     .MRxD(MRxD_Lb),
703 15 mohor
  .Transmitting(Transmitting),          .HugEn(r_HugEn),                      .DlyCrcEn(r_DlyCrcEn),
704 240 tadejm
  .MaxFL(r_MaxFL),                      .r_IFG(r_IFG),                        .Reset(wb_rst_i),
705 15 mohor
  .RxData(RxData),                      .RxValid(RxValid),                    .RxStartFrm(RxStartFrm),
706 65 mohor
  .RxEndFrm(RxEndFrm),                  .ByteCnt(RxByteCnt),
707 15 mohor
  .ByteCntEq0(RxByteCntEq0),            .ByteCntGreat2(RxByteCntGreat2),      .ByteCntMaxFrame(RxByteCntMaxFrame),
708
  .CrcError(RxCrcError),                .StateIdle(RxStateIdle),              .StatePreamble(RxStatePreamble),
709 52 billditt
  .StateSFD(RxStateSFD),                .StateData(RxStateData),
710 63 mohor
  .MAC(r_MAC),                          .r_Pro(r_Pro),                        .r_Bro(r_Bro),
711 250 mohor
  .r_HASH0(r_HASH0),                    .r_HASH1(r_HASH1),                    .RxAbort(RxAbort),
712 261 mohor
  .AddressMiss(AddressMiss),            .PassAll(r_PassAll),                  .ControlFrmAddressOK(ControlFrmAddressOK)
713 15 mohor
);
714
 
715
 
716
// MII Carrier Sense Synchronization
717 240 tadejm
always @ (posedge mtx_clk_pad_i or posedge wb_rst_i)
718 15 mohor
begin
719 240 tadejm
  if(wb_rst_i)
720 15 mohor
    begin
721
      CarrierSense_Tx1 <= #Tp 1'b0;
722
      CarrierSense_Tx2 <= #Tp 1'b0;
723
    end
724
  else
725
    begin
726 17 mohor
      CarrierSense_Tx1 <= #Tp mcrs_pad_i;
727 15 mohor
      CarrierSense_Tx2 <= #Tp CarrierSense_Tx1;
728
    end
729
end
730
 
731
assign TxCarrierSense = ~r_FullD & CarrierSense_Tx2;
732
 
733
 
734
// MII Collision Synchronization
735 240 tadejm
always @ (posedge mtx_clk_pad_i or posedge wb_rst_i)
736 15 mohor
begin
737 240 tadejm
  if(wb_rst_i)
738 15 mohor
    begin
739
      Collision_Tx1 <= #Tp 1'b0;
740
      Collision_Tx2 <= #Tp 1'b0;
741
    end
742
  else
743
    begin
744 17 mohor
      Collision_Tx1 <= #Tp mcoll_pad_i;
745 15 mohor
      if(ResetCollision)
746
        Collision_Tx2 <= #Tp 1'b0;
747
      else
748
      if(Collision_Tx1)
749
        Collision_Tx2 <= #Tp 1'b1;
750
    end
751
end
752
 
753
 
754
// Synchronized Collision
755
assign Collision = ~r_FullD & Collision_Tx2;
756
 
757
 
758
 
759
// Delayed WillTransmit
760 20 mohor
always @ (posedge mrx_clk_pad_i)
761 15 mohor
begin
762
  WillTransmit_q <= #Tp WillTransmit;
763
  WillTransmit_q2 <= #Tp WillTransmit_q;
764
end
765
 
766
 
767
assign Transmitting = ~r_FullD & WillTransmit_q2;
768
 
769
 
770
 
771
// Synchronized Receive Enable
772 240 tadejm
always @ (posedge mrx_clk_pad_i or posedge wb_rst_i)
773 15 mohor
begin
774 240 tadejm
  if(wb_rst_i)
775 15 mohor
    RxEnSync <= #Tp 1'b0;
776
  else
777 301 knguyen
  if(~mrxdv_pad_i)
778 15 mohor
    RxEnSync <= #Tp r_RxEn;
779
end
780
 
781
 
782
 
783 149 mohor
// Synchronizing WillSendControlFrame to WB_CLK;
784
always @ (posedge wb_clk_i or posedge wb_rst_i)
785
begin
786
  if(wb_rst_i)
787
    WillSendControlFrame_sync1 <= 1'b0;
788
  else
789
    WillSendControlFrame_sync1 <=#Tp WillSendControlFrame;
790
end
791 15 mohor
 
792 149 mohor
always @ (posedge wb_clk_i or posedge wb_rst_i)
793
begin
794
  if(wb_rst_i)
795
    WillSendControlFrame_sync2 <= 1'b0;
796
  else
797
    WillSendControlFrame_sync2 <=#Tp WillSendControlFrame_sync1;
798
end
799
 
800
always @ (posedge wb_clk_i or posedge wb_rst_i)
801
begin
802
  if(wb_rst_i)
803
    WillSendControlFrame_sync3 <= 1'b0;
804
  else
805
    WillSendControlFrame_sync3 <=#Tp WillSendControlFrame_sync2;
806
end
807
 
808
always @ (posedge wb_clk_i or posedge wb_rst_i)
809
begin
810
  if(wb_rst_i)
811
    RstTxPauseRq <= 1'b0;
812
  else
813
    RstTxPauseRq <=#Tp WillSendControlFrame_sync2 & ~WillSendControlFrame_sync3;
814
end
815
 
816
 
817 255 mohor
 
818
 
819
// TX Pause request Synchronization
820
always @ (posedge mtx_clk_pad_i or posedge wb_rst_i)
821
begin
822
  if(wb_rst_i)
823
    begin
824
      TxPauseRq_sync1 <= #Tp 1'b0;
825
      TxPauseRq_sync2 <= #Tp 1'b0;
826
      TxPauseRq_sync3 <= #Tp 1'b0;
827
    end
828
  else
829
    begin
830
      TxPauseRq_sync1 <= #Tp (r_TxPauseRq & r_TxFlow);
831
      TxPauseRq_sync2 <= #Tp TxPauseRq_sync1;
832
      TxPauseRq_sync3 <= #Tp TxPauseRq_sync2;
833
    end
834
end
835
 
836
 
837
always @ (posedge mtx_clk_pad_i or posedge wb_rst_i)
838
begin
839
  if(wb_rst_i)
840
    TPauseRq <= #Tp 1'b0;
841
  else
842
    TPauseRq <= #Tp TxPauseRq_sync2 & (~TxPauseRq_sync3);
843
end
844
 
845
 
846 261 mohor
wire LatchedMRxErr;
847
reg RxAbort_latch;
848
reg RxAbort_sync1;
849
reg RxAbort_wb;
850
reg RxAbortRst_sync1;
851
reg RxAbortRst;
852 255 mohor
 
853 261 mohor
// Synchronizing RxAbort to the WISHBONE clock
854
always @ (posedge mrx_clk_pad_i or posedge wb_rst_i)
855
begin
856
  if(wb_rst_i)
857
    RxAbort_latch <= #Tp 1'b0;
858
  else if(RxAbort | (ShortFrame & ~r_RecSmall) | LatchedMRxErr & ~InvalidSymbol | (ReceivedPauseFrm & (~r_PassAll)))
859
    RxAbort_latch <= #Tp 1'b1;
860
  else if(RxAbortRst)
861
    RxAbort_latch <= #Tp 1'b0;
862
end
863 255 mohor
 
864 261 mohor
always @ (posedge wb_clk_i or posedge wb_rst_i)
865
begin
866
  if(wb_rst_i)
867
    begin
868
      RxAbort_sync1 <= #Tp 1'b0;
869
      RxAbort_wb    <= #Tp 1'b0;
870
      RxAbort_wb    <= #Tp 1'b0;
871
    end
872
  else
873
    begin
874
      RxAbort_sync1 <= #Tp RxAbort_latch;
875
      RxAbort_wb    <= #Tp RxAbort_sync1;
876
    end
877
end
878
 
879
always @ (posedge mrx_clk_pad_i or posedge wb_rst_i)
880
begin
881
  if(wb_rst_i)
882
    begin
883
      RxAbortRst_sync1 <= #Tp 1'b0;
884
      RxAbortRst       <= #Tp 1'b0;
885
    end
886
  else
887
    begin
888
      RxAbortRst_sync1 <= #Tp RxAbort_wb;
889
      RxAbortRst       <= #Tp RxAbortRst_sync1;
890
    end
891
end
892
 
893
 
894
 
895 114 mohor
// Connecting Wishbone module
896 349 olof
eth_wishbone #(.Tp(Tp),
897
               .TX_FIFO_DATA_WIDTH(TX_FIFO_DATA_WIDTH),
898
               .TX_FIFO_DEPTH     (TX_FIFO_DEPTH),
899
               .TX_FIFO_CNT_WIDTH (TX_FIFO_CNT_WIDTH),
900
               .RX_FIFO_DATA_WIDTH(RX_FIFO_DATA_WIDTH),
901
               .RX_FIFO_DEPTH     (RX_FIFO_DEPTH),
902
               .RX_FIFO_CNT_WIDTH (RX_FIFO_CNT_WIDTH))
903
wishbone
904 15 mohor
(
905 41 mohor
  .WB_CLK_I(wb_clk_i),                .WB_DAT_I(wb_dat_i),
906 103 mohor
  .WB_DAT_O(BD_WB_DAT_O),
907 15 mohor
 
908
  // WISHBONE slave
909 76 mohor
  .WB_ADR_I(wb_adr_i[9:2]),           .WB_WE_I(wb_we_i),
910 21 mohor
  .BDCs(BDCs),                        .WB_ACK_O(BDAck),
911 15 mohor
 
912 240 tadejm
  .Reset(wb_rst_i),
913 41 mohor
 
914
  // WISHBONE master
915 327 igorm
  .m_wb_adr_o(m_wb_adr_tmp),          .m_wb_sel_o(m_wb_sel_o),                  .m_wb_we_o(m_wb_we_o),
916 41 mohor
  .m_wb_dat_i(m_wb_dat_i),            .m_wb_dat_o(m_wb_dat_o),                  .m_wb_cyc_o(m_wb_cyc_o),
917
  .m_wb_stb_o(m_wb_stb_o),            .m_wb_ack_i(m_wb_ack_i),                  .m_wb_err_i(m_wb_err_i),
918 214 mohor
 
919
`ifdef ETH_WISHBONE_B3
920
  .m_wb_cti_o(m_wb_cti_o),            .m_wb_bte_o(m_wb_bte_o),
921
`endif
922
 
923 41 mohor
 
924 15 mohor
    //TX
925 21 mohor
  .MTxClk(mtx_clk_pad_i),             .TxStartFrm(TxStartFrm),                  .TxEndFrm(TxEndFrm),
926 59 mohor
  .TxUsedData(TxUsedData),            .TxData(TxData),
927 15 mohor
  .TxRetry(TxRetry),                  .TxAbort(TxAbort),                        .TxUnderRun(TxUnderRun),
928 149 mohor
  .TxDone(TxDone),
929
  .PerPacketCrcEn(PerPacketCrcEn),    .PerPacketPad(PerPacketPad),
930 15 mohor
 
931
  // Register
932 34 mohor
  .r_TxEn(r_TxEn),                    .r_RxEn(r_RxEn),                          .r_TxBDNum(r_TxBDNum),
933 321 igorm
  .r_RxFlow(r_RxFlow),                      .r_PassAll(r_PassAll),
934 15 mohor
 
935
  //RX
936 21 mohor
  .MRxClk(mrx_clk_pad_i),             .RxData(RxData),                          .RxValid(RxValid),
937 41 mohor
  .RxStartFrm(RxStartFrm),            .RxEndFrm(RxEndFrm),
938 76 mohor
  .Busy_IRQ(Busy_IRQ),                .RxE_IRQ(RxE_IRQ),                        .RxB_IRQ(RxB_IRQ),
939 149 mohor
  .TxE_IRQ(TxE_IRQ),                  .TxB_IRQ(TxB_IRQ),
940 21 mohor
 
941 272 tadejm
  .RxAbort(RxAbort_wb),               .RxStatusWriteLatched_sync2(RxStatusWriteLatched_sync2),
942 41 mohor
 
943 42 mohor
  .InvalidSymbol(InvalidSymbol),      .LatchedCrcError(LatchedCrcError),        .RxLength(RxByteCnt),
944
  .RxLateCollision(RxLateCollision),  .ShortFrame(ShortFrame),                  .DribbleNibble(DribbleNibble),
945 59 mohor
  .ReceivedPacketTooBig(ReceivedPacketTooBig), .LoadRxStatus(LoadRxStatus),     .RetryCntLatched(RetryCntLatched),
946
  .RetryLimit(RetryLimit),            .LateCollLatched(LateCollLatched),        .DeferLatched(DeferLatched),
947 327 igorm
  .RstDeferLatched(RstDeferLatched),
948 261 mohor
  .CarrierSenseLost(CarrierSenseLost),.ReceivedPacketGood(ReceivedPacketGood),  .AddressMiss(AddressMiss),
949
  .ReceivedPauseFrm(ReceivedPauseFrm)
950 59 mohor
 
951 210 mohor
`ifdef ETH_BIST
952 218 mohor
  ,
953 302 markom
  .mbist_si_i       (mbist_si_i),
954
  .mbist_so_o       (mbist_so_o),
955
  .mbist_ctrl_i       (mbist_ctrl_i)
956 210 mohor
`endif
957 15 mohor
);
958
 
959 327 igorm
assign m_wb_adr_o = {m_wb_adr_tmp, 2'h0};
960 15 mohor
 
961
// Connecting MacStatus module
962 349 olof
eth_macstatus #(.Tp(Tp))
963
macstatus1
964 15 mohor
(
965 240 tadejm
  .MRxClk(mrx_clk_pad_i),             .Reset(wb_rst_i),
966 42 mohor
  .ReceiveEnd(ReceiveEnd),            .ReceivedPacketGood(ReceivedPacketGood),     .ReceivedLengthOK(ReceivedLengthOK),
967
  .RxCrcError(RxCrcError),            .MRxErr(MRxErr_Lb),                          .MRxDV(MRxDV_Lb),
968
  .RxStateSFD(RxStateSFD),            .RxStateData(RxStateData),                   .RxStatePreamble(RxStatePreamble),
969
  .RxStateIdle(RxStateIdle),          .Transmitting(Transmitting),                 .RxByteCnt(RxByteCnt),
970
  .RxByteCntEq0(RxByteCntEq0),        .RxByteCntGreat2(RxByteCntGreat2),           .RxByteCntMaxFrame(RxByteCntMaxFrame),
971 261 mohor
  .InvalidSymbol(InvalidSymbol),
972 42 mohor
  .MRxD(MRxD_Lb),                     .LatchedCrcError(LatchedCrcError),           .Collision(mcoll_pad_i),
973
  .CollValid(r_CollValid),            .RxLateCollision(RxLateCollision),           .r_RecSmall(r_RecSmall),
974
  .r_MinFL(r_MinFL),                  .r_MaxFL(r_MaxFL),                           .ShortFrame(ShortFrame),
975
  .DribbleNibble(DribbleNibble),      .ReceivedPacketTooBig(ReceivedPacketTooBig), .r_HugEn(r_HugEn),
976 59 mohor
  .LoadRxStatus(LoadRxStatus),        .RetryCnt(RetryCnt),                         .StartTxDone(StartTxDone),
977
  .StartTxAbort(StartTxAbort),        .RetryCntLatched(RetryCntLatched),           .MTxClk(mtx_clk_pad_i),
978
  .MaxCollisionOccured(MaxCollisionOccured), .RetryLimit(RetryLimit),              .LateCollision(LateCollision),
979 276 tadejm
  .LateCollLatched(LateCollLatched),  .DeferIndication(DeferIndication),           .DeferLatched(DeferLatched),
980 327 igorm
  .RstDeferLatched(RstDeferLatched),
981 59 mohor
  .TxStartFrm(TxStartFrmOut),         .StatePreamble(StatePreamble),               .StateData(StateData),
982 125 mohor
  .CarrierSense(CarrierSense_Tx2),    .CarrierSenseLost(CarrierSenseLost),         .TxUsedData(TxUsedDataIn),
983 168 mohor
  .LatchedMRxErr(LatchedMRxErr),      .Loopback(r_LoopBck),                        .r_FullD(r_FullD)
984 15 mohor
);
985
 
986
 
987
endmodule

powered by: WebSVN 2.1.0

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