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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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