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 52

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

powered by: WebSVN 2.1.0

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