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 41

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

powered by: WebSVN 2.1.0

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