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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [ethmac.v] - Blame information for rev 59

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