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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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