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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_4/] [rtl/] [verilog/] [eth_top.v] - Blame information for rev 22

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

powered by: WebSVN 2.1.0

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