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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_7/] [rtl/] [verilog/] [eth_top.v] - Blame information for rev 76

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

powered by: WebSVN 2.1.0

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