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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_17/] [rtl/] [verilog/] [eth_top.v] - Blame information for rev 65

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

powered by: WebSVN 2.1.0

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