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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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