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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [orp/] [orp_soc/] [rtl/] [verilog/] [ethernet.old/] [eth_top.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 746 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_top.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
// Revision 1.22  2002/02/26 16:59:54  mohor
45
// Small fixes for external/internal DMA missmatches.
46
//
47
// Revision 1.21  2002/02/26 16:21:00  mohor
48
// Interrupts changed in the top file
49
//
50
// Revision 1.20  2002/02/18 10:40:17  mohor
51
// Small fixes.
52
//
53
// Revision 1.19  2002/02/16 14:03:44  mohor
54
// Registered trimmed. Unused registers removed.
55
//
56
// Revision 1.18  2002/02/16 13:06:33  mohor
57
// EXTERNAL_DMA used instead of WISHBONE_DMA.
58
//
59
// Revision 1.17  2002/02/16 07:15:27  mohor
60
// Testbench fixed, code simplified, unused signals removed.
61
//
62
// Revision 1.16  2002/02/15 13:49:39  mohor
63
// RxAbort is connected differently.
64
//
65
// Revision 1.15  2002/02/15 11:38:26  mohor
66
// Changes that were lost when updating from 1.11 to 1.14 fixed.
67
//
68
// Revision 1.14  2002/02/14 20:19:11  billditt
69
// Modified for Address Checking,
70
// addition of eth_addrcheck.v
71
//
72
// Revision 1.13  2002/02/12 17:03:03  mohor
73
// HASH0 and HASH1 registers added. Registers address width was
74
// changed to 8 bits.
75
//
76
// Revision 1.12  2002/02/11 09:18:22  mohor
77
// Tx status is written back to the BD.
78
//
79
// Revision 1.11  2002/02/08 16:21:54  mohor
80
// Rx status is written back to the BD.
81
//
82
// Revision 1.10  2002/02/06 14:10:21  mohor
83
// non-DMA host interface added. Select the right configutation in eth_defines.
84
//
85
// Revision 1.9  2002/01/23 10:28:16  mohor
86
// Link in the header changed.
87
//
88
// Revision 1.8  2001/12/05 15:00:16  mohor
89
// RX_BD_NUM changed to TX_BD_NUM (holds number of TX descriptors
90
// instead of the number of RX descriptors).
91
//
92
// Revision 1.7  2001/12/05 10:45:59  mohor
93
// ETH_RX_BD_ADR register deleted. ETH_RX_BD_NUM is used instead.
94
//
95
// Revision 1.6  2001/10/19 11:24:29  mohor
96
// Number of addresses (wb_adr_i) minimized.
97
//
98
// Revision 1.5  2001/10/19 08:43:51  mohor
99
// eth_timescale.v changed to timescale.v This is done because of the
100
// simulation of the few cores in a one joined project.
101
//
102
// Revision 1.4  2001/10/18 12:07:11  mohor
103
// Status signals changed, Adress decoding changed, interrupt controller
104
// added.
105
//
106
// Revision 1.3  2001/09/24 15:02:56  mohor
107
// Defines changed (All precede with ETH_). Small changes because some
108
// tools generate warnings when two operands are together. Synchronization
109
// between two clocks domains in eth_wishbonedma.v is changed (due to ASIC
110
// demands).
111
//
112
// Revision 1.2  2001/08/15 14:03:59  mohor
113
// Signal names changed on the top level for easier pad insertion (ASIC).
114
//
115
// Revision 1.1  2001/08/06 14:44:29  mohor
116
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
117
// Include files fixed to contain no path.
118
// File names and module names changed ta have a eth_ prologue in the name.
119
// File eth_timescale.v is used to define timescale
120
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
121
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
122
// and Mdo_OE. The bidirectional signal must be created on the top level. This
123
// is done due to the ASIC tools.
124
//
125
// Revision 1.2  2001/08/02 09:25:31  mohor
126
// Unconnected signals are now connected.
127
//
128
// Revision 1.1  2001/07/30 21:23:42  mohor
129
// Directory structure changed. Files checked and joind together.
130
//
131
//
132
//
133
// 
134
 
135
 
136
`include "eth_defines.v"
137
`include "timescale.v"
138
 
139
 
140
module eth_top
141
(
142
  // WISHBONE common
143
  wb_clk_i, wb_rst_i, wb_dat_i, wb_dat_o,
144
 
145
  // WISHBONE slave
146
  wb_adr_i, wb_sel_i, wb_we_i, wb_cyc_i, wb_stb_i, wb_ack_o, wb_err_o,
147
 
148
`ifdef EXTERNAL_DMA
149
  wb_ack_i, wb_req_o, wb_nd_o, wb_rd_o,
150
`else
151
  // WISHBONE master
152
  m_wb_adr_o, m_wb_sel_o, m_wb_we_o,
153
  m_wb_dat_o, m_wb_dat_i, m_wb_cyc_o,
154
  m_wb_stb_o, m_wb_ack_i, m_wb_err_i,
155
`endif
156
 
157
  //TX
158
  mtx_clk_pad_i, mtxd_pad_o, mtxen_pad_o, mtxerr_pad_o,
159
 
160
  //RX
161
  mrx_clk_pad_i, mrxd_pad_i, mrxdv_pad_i, mrxerr_pad_i, mcoll_pad_i, mcrs_pad_i,
162
 
163
  // MIIM
164
  mdc_pad_o, md_pad_i, md_pad_o, md_padoen_o,
165
 
166
  int_o
167
 
168
 
169
);
170
 
171
 
172
parameter Tp = 1;
173
 
174
 
175
// WISHBONE common
176
input           wb_clk_i;     // WISHBONE clock
177
input           wb_rst_i;     // WISHBONE reset
178
input   [31:0]  wb_dat_i;     // WISHBONE data input
179
output  [31:0]  wb_dat_o;     // WISHBONE data output
180
output          wb_err_o;     // WISHBONE error output
181
 
182
// WISHBONE slave
183
input   [11:2]  wb_adr_i;     // WISHBONE address input
184
input    [3:0]  wb_sel_i;     // WISHBONE byte select input
185
input           wb_we_i;      // WISHBONE write enable input
186
input           wb_cyc_i;     // WISHBONE cycle input
187
input           wb_stb_i;     // WISHBONE strobe input
188
output          wb_ack_o;     // WISHBONE acknowledge output
189
 
190
`ifdef EXTERNAL_DMA
191
// DMA
192
input    [1:0]  wb_ack_i;     // DMA acknowledge input
193
output   [1:0]  wb_req_o;     // DMA request output
194
output   [1:0]  wb_nd_o;      // DMA force new descriptor output
195
output          wb_rd_o;      // DMA restart descriptor output
196
`else
197
// WISHBONE master
198
output  [31:0]  m_wb_adr_o;
199
output   [3:0]  m_wb_sel_o;
200
output          m_wb_we_o;
201
input   [31:0]  m_wb_dat_i;
202
output  [31:0]  m_wb_dat_o;
203
output          m_wb_cyc_o;
204
output          m_wb_stb_o;
205
input           m_wb_ack_i;
206
input           m_wb_err_i;
207
`endif
208
 
209
 
210
// Tx
211
input           mtx_clk_pad_i; // Transmit clock (from PHY)
212
output   [3:0]  mtxd_pad_o;    // Transmit nibble (to PHY)
213
output          mtxen_pad_o;   // Transmit enable (to PHY)
214
output          mtxerr_pad_o;  // Transmit error (to PHY)
215
 
216
// Rx
217
input           mrx_clk_pad_i; // Receive clock (from PHY)
218
input    [3:0]  mrxd_pad_i;    // Receive nibble (from PHY)
219
input           mrxdv_pad_i;   // Receive data valid (from PHY)
220
input           mrxerr_pad_i;  // Receive data error (from PHY)
221
 
222
// Common Tx and Rx
223
input           mcoll_pad_i;   // Collision (from PHY)
224
input           mcrs_pad_i;    // Carrier sense (from PHY)
225
 
226
// MII Management interface
227
input           md_pad_i;      // MII data input (from I/O cell)
228
output          mdc_pad_o;     // MII Management data clock (to PHY)
229
output          md_pad_o;      // MII data output (to I/O cell)
230
output          md_padoen_o;   // MII data output enable (to I/O cell)
231
 
232
output          int_o;         // Interrupt output
233
 
234
wire     [7:0]  r_ClkDiv;
235
wire            r_MiiNoPre;
236
wire    [15:0]  r_CtrlData;
237
wire     [4:0]  r_FIAD;
238
wire     [4:0]  r_RGAD;
239
wire            r_WCtrlData;
240
wire            r_RStat;
241
wire            r_ScanStat;
242
wire            NValid_stat;
243
wire            Busy_stat;
244
wire            LinkFail;
245
wire            r_MiiMRst;
246
wire    [15:0]  Prsd;             // Read Status Data (data read from the PHY)
247
wire            WCtrlDataStart;
248
wire            RStatStart;
249
wire            UpdateMIIRX_DATAReg;
250
 
251
wire            TxStartFrm;
252
wire            TxEndFrm;
253
wire            TxUsedData;
254
wire     [7:0]  TxData;
255
wire            TxRetry;
256
wire            TxAbort;
257
wire            TxUnderRun;
258
wire            TxDone;
259
wire     [5:0]  CollValid;
260
 
261
 
262
 
263
 
264
// Connecting Miim module
265
eth_miim miim1
266
(
267
  .Clk(wb_clk_i),                         .Reset(r_MiiMRst),                  .Divider(r_ClkDiv),
268
  .NoPre(r_MiiNoPre),                     .CtrlData(r_CtrlData),              .Rgad(r_RGAD),
269
  .Fiad(r_FIAD),                          .WCtrlData(r_WCtrlData),            .RStat(r_RStat),
270
  .ScanStat(r_ScanStat),                  .Mdi(md_pad_i),                     .Mdo(md_pad_o),
271
  .MdoEn(md_padoen_o),                    .Mdc(mdc_pad_o),                    .Busy(Busy_stat),
272
  .Prsd(Prsd),                            .LinkFail(LinkFail),                .Nvalid(NValid_stat),
273
  .WCtrlDataStart(WCtrlDataStart),        .RStatStart(RStatStart),            .UpdateMIIRX_DATAReg(UpdateMIIRX_DATAReg)
274
);
275
 
276
 
277
 
278
 
279
wire        RegCs;          // Connected to registers
280
wire [31:0] RegDataOut;     // Multiplexed to wb_dat_o
281
wire        r_RecSmall;     // Receive small frames
282
wire        r_Rst;          // Reset
283
wire        r_LoopBck;      // Loopback
284
wire        r_TxEn;         // Tx Enable
285
wire        r_RxEn;         // Rx Enable
286
 
287
wire        MRxDV_Lb;       // Muxed MII receive data valid
288
wire        MRxErr_Lb;      // Muxed MII Receive Error
289
wire  [3:0] MRxD_Lb;        // Muxed MII Receive Data
290
wire        Transmitting;   // Indication that TxEthMAC is transmitting
291
wire        r_HugEn;        // Huge packet enable
292
wire        r_DlyCrcEn;     // Delayed CRC enabled
293
wire [15:0] r_MaxFL;        // Maximum frame length
294
 
295
wire [15:0] r_MinFL;        // Minimum frame length
296
wire        ShortFrame;
297
wire        DribbleNibble;  // Extra nibble received
298
wire        ReceivedPacketTooBig; // Received packet is too big
299
wire [47:0] r_MAC;          // MAC address
300
wire        LoadRxStatus;   // Rx status was loaded
301
wire [31:0] r_HASH0;        // HASH table, lower 4 bytes
302
wire [31:0] r_HASH1;        // HASH table, upper 4 bytes
303
wire  [7:0] r_TxBDNum;      // Receive buffer descriptor number
304
wire  [6:0] r_IPGT;         // 
305
wire  [6:0] r_IPGR1;        // 
306
wire  [6:0] r_IPGR2;        // 
307
wire  [5:0] r_CollValid;    // 
308
wire        r_TPauseRq;     // Transmit PAUSE request pulse
309
 
310
wire  [3:0] r_MaxRet;       //
311
wire        r_NoBckof;      // 
312
wire        r_ExDfrEn;      // 
313
wire        TX_BD_NUM_Wr;   // Write enable that writes RX_BD_NUM to the registers.
314
wire        TPauseRq;       // Sinhronized Tx PAUSE request
315
wire [15:0] TxPauseTV;      // Tx PAUSE timer value
316
wire        r_TxFlow;       // Tx flow control enable
317
wire        r_IFG;          // Minimum interframe gap for incoming packets
318
 
319
wire        TxB_IRQ;        // Interrupt Tx Buffer
320
wire        TxE_IRQ;        // Interrupt Tx Error
321
wire        RxB_IRQ;        // Interrupt Rx Buffer
322
wire        RxE_IRQ;        // Interrupt Rx Error
323
wire        Busy_IRQ;       // Interrupt Busy (lack of buffers)
324
wire        TxC_IRQ;        // Interrupt Tx Control Frame
325
wire        RxC_IRQ;        // Interrupt Rx Control Frame
326
 
327
wire        DWord;
328
wire        BDAck;
329
wire [31:0] DMA_WB_DAT_O;   // wb_dat_o that comes from the WishboneDMA module
330
wire        BDCs;           // Buffer descriptor CS
331
 
332
 
333
assign DWord = &wb_sel_i;
334
assign RegCs = wb_stb_i & wb_cyc_i & DWord & ~wb_adr_i[11] & ~wb_adr_i[10];
335
assign BDCs  = wb_stb_i & wb_cyc_i & DWord & ~wb_adr_i[11] &  wb_adr_i[10];
336
assign wb_ack_o = RegCs | BDAck;
337
assign wb_err_o = wb_stb_i & wb_cyc_i & ~DWord;
338
 
339
 
340
// Selecting the WISHBONE output data
341
assign wb_dat_o[31:0] = (RegCs & ~wb_we_i)? RegDataOut : DMA_WB_DAT_O;
342
 
343
 
344
// Connecting Ethernet registers
345
eth_registers ethreg1
346
(
347
  .DataIn(wb_dat_i),                      .Address(wb_adr_i[9:2]),                    .Rw(wb_we_i),
348
  .Cs(RegCs),                             .Clk(wb_clk_i),                             .Reset(wb_rst_i),
349
  .DataOut(RegDataOut),                   .r_RecSmall(r_RecSmall),
350
  .r_Pad(r_Pad),                          .r_HugEn(r_HugEn),                          .r_CrcEn(r_CrcEn),
351
  .r_DlyCrcEn(r_DlyCrcEn),                .r_Rst(r_Rst),                              .r_FullD(r_FullD),
352
  .r_ExDfrEn(r_ExDfrEn),                  .r_NoBckof(r_NoBckof),                      .r_LoopBck(r_LoopBck),
353
  .r_IFG(r_IFG),                          .r_Pro(r_Pro),                              .r_Iam(),
354
  .r_Bro(r_Bro),                          .r_NoPre(r_NoPre),                          .r_TxEn(r_TxEn),
355
  .r_RxEn(r_RxEn),                        .Busy_IRQ(Busy_IRQ),                        .RxE_IRQ(RxE_IRQ),
356
  .RxB_IRQ(RxB_IRQ),                      .TxE_IRQ(TxE_IRQ),                          .TxB_IRQ(TxB_IRQ),
357
  .TxC_IRQ(TxC_IRQ),                      .RxC_IRQ(RxC_IRQ),                          .r_IPGT(r_IPGT),
358
  .r_IPGR1(r_IPGR1),                      .r_IPGR2(r_IPGR2),                          .r_MinFL(r_MinFL),
359
  .r_MaxFL(r_MaxFL),                      .r_MaxRet(r_MaxRet),                        .r_CollValid(r_CollValid),
360
  .r_TxFlow(r_TxFlow),                    .r_RxFlow(r_RxFlow),                        .r_PassAll(r_PassAll),
361
  .r_MiiMRst(r_MiiMRst),                  .r_MiiNoPre(r_MiiNoPre),                    .r_ClkDiv(r_ClkDiv),
362
  .r_WCtrlData(r_WCtrlData),              .r_RStat(r_RStat),                          .r_ScanStat(r_ScanStat),
363
  .r_RGAD(r_RGAD),                        .r_FIAD(r_FIAD),                            .r_CtrlData(r_CtrlData),
364
  .NValid_stat(NValid_stat),              .Busy_stat(Busy_stat),
365
  .LinkFail(LinkFail),                    .r_MAC(r_MAC),                              .WCtrlDataStart(WCtrlDataStart),
366
  .RStatStart(RStatStart),                .UpdateMIIRX_DATAReg(UpdateMIIRX_DATAReg),  .Prsd(Prsd),
367
  .r_TxBDNum(r_TxBDNum),                  .TX_BD_NUM_Wr(TX_BD_NUM_Wr),                .int_o(int_o),
368
  .r_HASH0(r_HASH0),                      .r_HASH1(r_HASH1)
369
);
370
 
371
 
372
 
373
wire  [7:0] RxData;
374
wire        RxValid;
375
wire        RxStartFrm;
376
wire        RxEndFrm;
377
wire        RxAbort;
378
 
379
wire        WillTransmit;            // Will transmit (to RxEthMAC)
380
wire        ResetCollision;          // Reset Collision (for synchronizing collision)
381
wire  [7:0] TxDataOut;               // Transmit Packet Data (to TxEthMAC)
382
wire        WillSendControlFrame;
383
wire        TxCtrlEndFrm;
384
wire        ReceivedPauseFrm;
385
wire        ReceiveEnd;
386
wire        ReceivedPacketGood;
387
wire        ReceivedLengthOK;
388
wire        InvalidSymbol;
389
wire        LatchedCrcError;
390
wire        RxLateCollision;
391
wire  [3:0] RetryCntLatched;
392
wire  [3:0] RetryCnt;
393
wire        StartTxDone;
394
wire        StartTxAbort;
395
wire        MaxCollisionOccured;
396
wire        RetryLimit;
397
wire        StatePreamble;
398
wire  [1:0] StateData;
399
 
400
// Connecting MACControl
401
eth_maccontrol maccontrol1
402
(
403
  .MTxClk(mtx_clk_pad_i),                       .TPauseRq(TPauseRq),
404
  .TxPauseTV(TxPauseTV),                        .TxDataIn(TxData),
405
  .TxStartFrmIn(TxStartFrm),                    .TxEndFrmIn(TxEndFrm),
406
  .TxUsedDataIn(TxUsedDataIn),                  .TxDoneIn(TxDoneIn),
407
  .TxAbortIn(TxAbortIn),                        .MRxClk(mrx_clk_pad_i),
408
  .RxData(RxData),                              .RxValid(RxValid),
409
  .RxStartFrm(RxStartFrm),                      .RxEndFrm(RxEndFrm),
410
  .ReceiveEnd(ReceiveEnd),                      .ReceivedPacketGood(ReceivedPacketGood),
411
  .PassAll(r_PassAll),                          .TxFlow(r_TxFlow),
412
  .RxFlow(r_RxFlow),                            .DlyCrcEn(r_DlyCrcEn),
413
  .MAC(r_MAC),                                  .PadIn(r_Pad | PerPacketPad),
414
  .PadOut(PadOut),                              .CrcEnIn(r_CrcEn | PerPacketCrcEn),
415
  .CrcEnOut(CrcEnOut),                          .TxReset(r_Rst),
416
  .RxReset(r_Rst),                              .ReceivedLengthOK(ReceivedLengthOK),
417
  .TxDataOut(TxDataOut),                        .TxStartFrmOut(TxStartFrmOut),
418
  .TxEndFrmOut(TxEndFrmOut),                    .TxUsedDataOut(TxUsedData),
419
  .TxDoneOut(TxDone),                           .TxAbortOut(TxAbort),
420
  .WillSendControlFrame(WillSendControlFrame),  .TxCtrlEndFrm(TxCtrlEndFrm),
421
  .ReceivedPauseFrm(ReceivedPauseFrm)
422
);
423
 
424
 
425
 
426
wire TxCarrierSense;          // Synchronized CarrierSense (to Tx clock)
427
wire Collision;               // Synchronized Collision
428
 
429
reg CarrierSense_Tx1;
430
reg CarrierSense_Tx2;
431
reg Collision_Tx1;
432
reg Collision_Tx2;
433
 
434
reg RxEnSync;                 // Synchronized Receive Enable
435
reg CarrierSense_Rx1;
436
reg RxCarrierSense;           // Synchronized CarrierSense (to Rx clock)
437
reg WillTransmit_q;
438
reg WillTransmit_q2;
439
 
440
 
441
 
442
// Muxed MII receive data valid
443
assign MRxDV_Lb = r_LoopBck? mtxen_pad_o : mrxdv_pad_i & RxEnSync;
444
 
445
// Muxed MII Receive Error
446
assign MRxErr_Lb = r_LoopBck? mtxerr_pad_o : mrxerr_pad_i & RxEnSync;
447
 
448
// Muxed MII Receive Data
449
assign MRxD_Lb[3:0] = r_LoopBck? mtxd_pad_o[3:0] : mrxd_pad_i[3:0];
450
 
451
 
452
 
453
// Connecting TxEthMAC
454
eth_txethmac txethmac1
455
(
456
  .MTxClk(mtx_clk_pad_i),             .Reset(r_Rst),                      .CarrierSense(TxCarrierSense),
457
  .Collision(Collision),              .TxData(TxDataOut),                 .TxStartFrm(TxStartFrmOut),
458
  .TxUnderRun(TxUnderRun),            .TxEndFrm(TxEndFrmOut),             .Pad(PadOut),
459
  .MinFL(r_MinFL),                    .CrcEn(CrcEnOut),                   .FullD(r_FullD),
460
  .HugEn(r_HugEn),                    .DlyCrcEn(r_DlyCrcEn),              .IPGT(r_IPGT),
461
  .IPGR1(r_IPGR1),                    .IPGR2(r_IPGR2),                    .CollValid(r_CollValid),
462
  .MaxRet(r_MaxRet),                  .NoBckof(r_NoBckof),                .ExDfrEn(r_ExDfrEn),
463
  .MaxFL(r_MaxFL),                    .MTxEn(mtxen_pad_o),                .MTxD(mtxd_pad_o),
464
  .MTxErr(mtxerr_pad_o),              .TxUsedData(TxUsedDataIn),          .TxDone(TxDoneIn),
465
  .TxRetry(TxRetry),                  .TxAbort(TxAbortIn),                .WillTransmit(WillTransmit),
466
  .ResetCollision(ResetCollision),    .RetryCnt(RetryCnt),                .StartTxDone(StartTxDone),
467
  .StartTxAbort(StartTxAbort),        .MaxCollisionOccured(MaxCollisionOccured), .LateCollision(LateCollision),
468
  .StartDefer(StartDefer),            .StatePreamble(StatePreamble),      .StateData(StateData)
469
);
470
 
471
 
472
 
473
 
474
wire  [15:0]  RxByteCnt;
475
wire          RxByteCntEq0;
476
wire          RxByteCntGreat2;
477
wire          RxByteCntMaxFrame;
478
wire          RxCrcError;
479
wire          RxStateIdle;
480
wire          RxStatePreamble;
481
wire          RxStateSFD;
482
wire   [1:0]  RxStateData;
483
 
484
 
485
 
486
 
487
// Connecting RxEthMAC
488
eth_rxethmac rxethmac1
489
(
490
  .MRxClk(mrx_clk_pad_i),               .MRxDV(MRxDV_Lb),                     .MRxD(MRxD_Lb),
491
  .Transmitting(Transmitting),          .HugEn(r_HugEn),                      .DlyCrcEn(r_DlyCrcEn),
492
  .MaxFL(r_MaxFL),                      .r_IFG(r_IFG),                        .Reset(r_Rst),
493
  .RxData(RxData),                      .RxValid(RxValid),                    .RxStartFrm(RxStartFrm),
494
  .RxEndFrm(RxEndFrm),                  .ByteCnt(RxByteCnt),
495
  .ByteCntEq0(RxByteCntEq0),            .ByteCntGreat2(RxByteCntGreat2),      .ByteCntMaxFrame(RxByteCntMaxFrame),
496
  .CrcError(RxCrcError),                .StateIdle(RxStateIdle),              .StatePreamble(RxStatePreamble),
497
  .StateSFD(RxStateSFD),                .StateData(RxStateData),
498
  .MAC(r_MAC),                          .r_Pro(r_Pro),                        .r_Bro(r_Bro),
499
  .r_HASH0(r_HASH0),                    .r_HASH1(r_HASH1),                    .RxAbort(RxAbort)
500
);
501
 
502
 
503
// MII Carrier Sense Synchronization
504
always @ (posedge mtx_clk_pad_i or posedge r_Rst)
505
begin
506
  if(r_Rst)
507
    begin
508
      CarrierSense_Tx1 <= #Tp 1'b0;
509
      CarrierSense_Tx2 <= #Tp 1'b0;
510
    end
511
  else
512
    begin
513
      CarrierSense_Tx1 <= #Tp mcrs_pad_i;
514
      CarrierSense_Tx2 <= #Tp CarrierSense_Tx1;
515
    end
516
end
517
 
518
assign TxCarrierSense = ~r_FullD & CarrierSense_Tx2;
519
 
520
 
521
// MII Collision Synchronization
522
always @ (posedge mtx_clk_pad_i or posedge r_Rst)
523
begin
524
  if(r_Rst)
525
    begin
526
      Collision_Tx1 <= #Tp 1'b0;
527
      Collision_Tx2 <= #Tp 1'b0;
528
    end
529
  else
530
    begin
531
      Collision_Tx1 <= #Tp mcoll_pad_i;
532
      if(ResetCollision)
533
        Collision_Tx2 <= #Tp 1'b0;
534
      else
535
      if(Collision_Tx1)
536
        Collision_Tx2 <= #Tp 1'b1;
537
    end
538
end
539
 
540
 
541
// Synchronized Collision
542
assign Collision = ~r_FullD & Collision_Tx2;
543
 
544
 
545
 
546
// Carrier sense is synchronized to receive clock.
547
always @ (posedge mrx_clk_pad_i or posedge r_Rst)
548
begin
549
  if(r_Rst)
550
    begin
551
      CarrierSense_Rx1 <= #Tp 1'h0;
552
      RxCarrierSense <= #Tp 1'h0;
553
    end
554
  else
555
    begin
556
      CarrierSense_Rx1 <= #Tp mcrs_pad_i;
557
      RxCarrierSense <= #Tp CarrierSense_Rx1;
558
    end
559
end
560
 
561
 
562
// Delayed WillTransmit
563
always @ (posedge mrx_clk_pad_i)
564
begin
565
  WillTransmit_q <= #Tp WillTransmit;
566
  WillTransmit_q2 <= #Tp WillTransmit_q;
567
end
568
 
569
 
570
assign Transmitting = ~r_FullD & WillTransmit_q2;
571
 
572
 
573
 
574
// Synchronized Receive Enable
575
always @ (posedge mrx_clk_pad_i or posedge r_Rst)
576
begin
577
  if(r_Rst)
578
    RxEnSync <= #Tp 1'b0;
579
  else
580
  if(~RxCarrierSense | RxCarrierSense & Transmitting)
581
    RxEnSync <= #Tp r_RxEn;
582
end
583
 
584
 
585
 
586
 
587
// Connecting WishboneDMA module
588
`ifdef EXTERNAL_DMA
589
eth_wishbonedma wishbone
590
`else
591
eth_wishbone wishbone
592
`endif
593
(
594
  .WB_CLK_I(wb_clk_i),                .WB_DAT_I(wb_dat_i),
595
  .WB_DAT_O(DMA_WB_DAT_O),
596
 
597
  // WISHBONE slave
598
  .WB_ADR_I(wb_adr_i[9:2]),           .WB_WE_I(wb_we_i),
599
  .BDCs(BDCs),                        .WB_ACK_O(BDAck),
600
 
601
  .Reset(wb_rst_i),
602
 
603
`ifdef EXTERNAL_DMA
604
  .WB_REQ_O(wb_req_o),                .WB_ND_O(wb_nd_o),                        .WB_RD_O(wb_rd_o),
605
  .WB_ACK_I(wb_ack_i),                .r_DmaEn(1'b1),
606
`else
607
  // WISHBONE master
608
  .m_wb_adr_o(m_wb_adr_o),            .m_wb_sel_o(m_wb_sel_o),                  .m_wb_we_o(m_wb_we_o),
609
  .m_wb_dat_i(m_wb_dat_i),            .m_wb_dat_o(m_wb_dat_o),                  .m_wb_cyc_o(m_wb_cyc_o),
610
  .m_wb_stb_o(m_wb_stb_o),            .m_wb_ack_i(m_wb_ack_i),                  .m_wb_err_i(m_wb_err_i),
611
`endif
612
 
613
 
614
 
615
    //TX
616
  .MTxClk(mtx_clk_pad_i),             .TxStartFrm(TxStartFrm),                  .TxEndFrm(TxEndFrm),
617
  .TxUsedData(TxUsedData),            .TxData(TxData),
618
  .TxRetry(TxRetry),                  .TxAbort(TxAbort),                        .TxUnderRun(TxUnderRun),
619
  .TxDone(TxDone),                    .TPauseRq(TPauseRq),                      .TxPauseTV(TxPauseTV),
620
  .PerPacketCrcEn(PerPacketCrcEn),    .PerPacketPad(PerPacketPad),              .WillSendControlFrame(WillSendControlFrame),
621
  .TxCtrlEndFrm(TxCtrlEndFrm),
622
 
623
  // Register
624
  .r_TxEn(r_TxEn),                    .r_RxEn(r_RxEn),                          .r_TxBDNum(r_TxBDNum),
625
  .TX_BD_NUM_Wr(TX_BD_NUM_Wr),        .r_RecSmall(r_RecSmall),
626
 
627
  //RX
628
  .MRxClk(mrx_clk_pad_i),             .RxData(RxData),                          .RxValid(RxValid),
629
  .RxStartFrm(RxStartFrm),            .RxEndFrm(RxEndFrm),
630
  .Busy_IRQ(Busy_IRQ),                .RxE_IRQ(RxE_IRQ),                        .RxB_IRQ(RxB_IRQ),
631
  .TxE_IRQ(TxE_IRQ),                  .TxB_IRQ(TxB_IRQ),                        .TxC_IRQ(TxC_IRQ),
632
  .RxC_IRQ(RxC_IRQ),
633
 
634
  .RxAbort(RxAbort),
635
 
636
  .InvalidSymbol(InvalidSymbol),      .LatchedCrcError(LatchedCrcError),        .RxLength(RxByteCnt),
637
  .RxLateCollision(RxLateCollision),  .ShortFrame(ShortFrame),                  .DribbleNibble(DribbleNibble),
638
  .ReceivedPacketTooBig(ReceivedPacketTooBig), .LoadRxStatus(LoadRxStatus),     .RetryCntLatched(RetryCntLatched),
639
  .RetryLimit(RetryLimit),            .LateCollLatched(LateCollLatched),        .DeferLatched(DeferLatched),
640
  .CarrierSenseLost(CarrierSenseLost),.ReceivedPacketGood(ReceivedPacketGood)
641
 
642
 
643
 
644
);
645
 
646
 
647
 
648
// Connecting MacStatus module
649
eth_macstatus macstatus1
650
(
651
  .MRxClk(mrx_clk_pad_i),             .Reset(r_Rst),
652
  .ReceiveEnd(ReceiveEnd),            .ReceivedPacketGood(ReceivedPacketGood),     .ReceivedLengthOK(ReceivedLengthOK),
653
  .RxCrcError(RxCrcError),            .MRxErr(MRxErr_Lb),                          .MRxDV(MRxDV_Lb),
654
  .RxStateSFD(RxStateSFD),            .RxStateData(RxStateData),                   .RxStatePreamble(RxStatePreamble),
655
  .RxStateIdle(RxStateIdle),          .Transmitting(Transmitting),                 .RxByteCnt(RxByteCnt),
656
  .RxByteCntEq0(RxByteCntEq0),        .RxByteCntGreat2(RxByteCntGreat2),           .RxByteCntMaxFrame(RxByteCntMaxFrame),
657
  .ReceivedPauseFrm(ReceivedPauseFrm),.InvalidSymbol(InvalidSymbol),
658
  .MRxD(MRxD_Lb),                     .LatchedCrcError(LatchedCrcError),           .Collision(mcoll_pad_i),
659
  .CollValid(r_CollValid),            .RxLateCollision(RxLateCollision),           .r_RecSmall(r_RecSmall),
660
  .r_MinFL(r_MinFL),                  .r_MaxFL(r_MaxFL),                           .ShortFrame(ShortFrame),
661
  .DribbleNibble(DribbleNibble),      .ReceivedPacketTooBig(ReceivedPacketTooBig), .r_HugEn(r_HugEn),
662
  .LoadRxStatus(LoadRxStatus),        .RetryCnt(RetryCnt),                         .StartTxDone(StartTxDone),
663
  .StartTxAbort(StartTxAbort),        .RetryCntLatched(RetryCntLatched),           .MTxClk(mtx_clk_pad_i),
664
  .MaxCollisionOccured(MaxCollisionOccured), .RetryLimit(RetryLimit),              .LateCollision(LateCollision),
665
  .LateCollLatched(LateCollLatched),  .StartDefer(StartDefer),                     .DeferLatched(DeferLatched),
666
  .TxStartFrm(TxStartFrmOut),         .StatePreamble(StatePreamble),               .StateData(StateData),
667
  .CarrierSense(CarrierSense_Tx2),    .CarrierSenseLost(CarrierSenseLost),         .TxUsedData(TxUsedDataIn)
668
);
669
 
670
 
671
endmodule

powered by: WebSVN 2.1.0

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