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 37

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

powered by: WebSVN 2.1.0

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