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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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