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 80

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