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 23

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

powered by: WebSVN 2.1.0

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