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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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