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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_17/] [rtl/] [verilog/] [eth_top.v] - Blame information for rev 253

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 202 mohor
////  All additional information is available in the Readme.txt   ////
12 15 mohor
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16 202 mohor
//// Copyright (C) 2001, 2002 Authors                             ////
17 15 mohor
////                                                              ////
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 253 mohor
// Revision 1.40  2002/11/19 17:34:25  mohor
45
// AddressMiss status is connecting to the Rx BD. AddressMiss is identifying
46
// that a frame was received because of the promiscous mode.
47
//
48 250 mohor
// Revision 1.39  2002/11/18 17:31:55  mohor
49
// wb_rst_i is used for MIIM reset.
50
//
51 248 mohor
// Revision 1.38  2002/11/14 18:37:20  mohor
52
// r_Rst signal does not reset any module any more and is removed from the design.
53
//
54 244 mohor
// Revision 1.37  2002/11/13 22:25:36  tadejm
55
// All modules are reset with wb_rst instead of the r_Rst. Exception is MII module.
56
//
57 240 tadejm
// Revision 1.36  2002/10/18 17:04:20  tadejm
58
// Changed BIST scan signals.
59
//
60 227 tadejm
// Revision 1.35  2002/10/11 13:36:58  mohor
61
// Typo error fixed. (When using Bist)
62
//
63 218 mohor
// Revision 1.34  2002/10/10 16:49:50  mohor
64
// Signals for WISHBONE B3 compliant interface added.
65
//
66 214 mohor
// Revision 1.33  2002/10/10 16:29:30  mohor
67
// BIST added.
68
//
69 210 mohor
// Revision 1.32  2002/09/20 17:12:58  mohor
70
// CsMiss added. When address between 0x800 and 0xfff is accessed within
71
// Ethernet Core, error acknowledge is generated.
72
//
73 202 mohor
// Revision 1.31  2002/09/12 14:50:17  mohor
74
// CarrierSenseLost bug fixed when operating in full duplex mode.
75
//
76 168 mohor
// Revision 1.30  2002/09/10 10:35:23  mohor
77
// Ethernet debug registers removed.
78
//
79 164 mohor
// Revision 1.29  2002/09/09 13:03:13  mohor
80
// Error acknowledge is generated when accessing BDs and RST bit in the
81
// MODER register (r_Rst) is set.
82
//
83 161 mohor
// Revision 1.28  2002/09/04 18:44:10  mohor
84
// Signals related to the control frames connected. Debug registers reg1, 2, 3, 4
85
// connected.
86
//
87 149 mohor
// Revision 1.27  2002/07/25 18:15:37  mohor
88
// RxAbort changed. Packets received with MRxErr (from PHY) are also
89
// aborted.
90
//
91 125 mohor
// Revision 1.26  2002/07/17 18:51:50  mohor
92
// EXTERNAL_DMA removed. External DMA not supported.
93
//
94 114 mohor
// Revision 1.25  2002/05/03 10:15:50  mohor
95
// Outputs registered. Reset changed for eth_wishbone module.
96
//
97 106 mohor
// Revision 1.24  2002/04/22 14:15:42  mohor
98
// Wishbone signals are registered when ETH_REGISTERED_OUTPUTS is
99
// selected in eth_defines.v
100
//
101 103 mohor
// Revision 1.23  2002/03/25 13:33:53  mohor
102
// md_padoen_o changed to md_padoe_o. Signal was always active high, just
103
// name was incorrect.
104
//
105 95 mohor
// Revision 1.22  2002/02/26 16:59:54  mohor
106
// Small fixes for external/internal DMA missmatches.
107
//
108 80 mohor
// Revision 1.21  2002/02/26 16:21:00  mohor
109
// Interrupts changed in the top file
110
//
111 76 mohor
// Revision 1.20  2002/02/18 10:40:17  mohor
112
// Small fixes.
113
//
114 70 mohor
// Revision 1.19  2002/02/16 14:03:44  mohor
115
// Registered trimmed. Unused registers removed.
116
//
117 68 mohor
// Revision 1.18  2002/02/16 13:06:33  mohor
118
// EXTERNAL_DMA used instead of WISHBONE_DMA.
119
//
120 67 mohor
// Revision 1.17  2002/02/16 07:15:27  mohor
121
// Testbench fixed, code simplified, unused signals removed.
122
//
123 65 mohor
// Revision 1.16  2002/02/15 13:49:39  mohor
124
// RxAbort is connected differently.
125
//
126 63 mohor
// Revision 1.15  2002/02/15 11:38:26  mohor
127
// Changes that were lost when updating from 1.11 to 1.14 fixed.
128
//
129 59 mohor
// Revision 1.14  2002/02/14 20:19:11  billditt
130
// Modified for Address Checking,
131
// addition of eth_addrcheck.v
132
//
133
// Revision 1.13  2002/02/12 17:03:03  mohor
134
// HASH0 and HASH1 registers added. Registers address width was
135
// changed to 8 bits.
136
//
137
// Revision 1.12  2002/02/11 09:18:22  mohor
138
// Tx status is written back to the BD.
139
//
140 43 mohor
// Revision 1.11  2002/02/08 16:21:54  mohor
141
// Rx status is written back to the BD.
142
//
143 42 mohor
// Revision 1.10  2002/02/06 14:10:21  mohor
144
// non-DMA host interface added. Select the right configutation in eth_defines.
145
//
146 41 mohor
// Revision 1.9  2002/01/23 10:28:16  mohor
147
// Link in the header changed.
148
//
149 37 mohor
// Revision 1.8  2001/12/05 15:00:16  mohor
150
// RX_BD_NUM changed to TX_BD_NUM (holds number of TX descriptors
151
// instead of the number of RX descriptors).
152
//
153 34 mohor
// Revision 1.7  2001/12/05 10:45:59  mohor
154
// ETH_RX_BD_ADR register deleted. ETH_RX_BD_NUM is used instead.
155
//
156 33 mohor
// Revision 1.6  2001/10/19 11:24:29  mohor
157
// Number of addresses (wb_adr_i) minimized.
158
//
159 23 mohor
// Revision 1.5  2001/10/19 08:43:51  mohor
160
// eth_timescale.v changed to timescale.v This is done because of the
161
// simulation of the few cores in a one joined project.
162
//
163 22 mohor
// Revision 1.4  2001/10/18 12:07:11  mohor
164
// Status signals changed, Adress decoding changed, interrupt controller
165
// added.
166
//
167 21 mohor
// Revision 1.3  2001/09/24 15:02:56  mohor
168
// Defines changed (All precede with ETH_). Small changes because some
169
// tools generate warnings when two operands are together. Synchronization
170
// between two clocks domains in eth_wishbonedma.v is changed (due to ASIC
171
// demands).
172
//
173 20 mohor
// Revision 1.2  2001/08/15 14:03:59  mohor
174
// Signal names changed on the top level for easier pad insertion (ASIC).
175
//
176 17 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
177
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
178
// Include files fixed to contain no path.
179
// File names and module names changed ta have a eth_ prologue in the name.
180
// File eth_timescale.v is used to define timescale
181
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
182
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
183
// and Mdo_OE. The bidirectional signal must be created on the top level. This
184
// is done due to the ASIC tools.
185
//
186 15 mohor
// Revision 1.2  2001/08/02 09:25:31  mohor
187
// Unconnected signals are now connected.
188
//
189
// Revision 1.1  2001/07/30 21:23:42  mohor
190
// Directory structure changed. Files checked and joind together.
191
//
192
//
193
//
194 20 mohor
// 
195 15 mohor
 
196
 
197
`include "eth_defines.v"
198 22 mohor
`include "timescale.v"
199 15 mohor
 
200
 
201
module eth_top
202
(
203
  // WISHBONE common
204 17 mohor
  wb_clk_i, wb_rst_i, wb_dat_i, wb_dat_o,
205 15 mohor
 
206
  // WISHBONE slave
207 17 mohor
  wb_adr_i, wb_sel_i, wb_we_i, wb_cyc_i, wb_stb_i, wb_ack_o, wb_err_o,
208 15 mohor
 
209 41 mohor
  // WISHBONE master
210
  m_wb_adr_o, m_wb_sel_o, m_wb_we_o,
211
  m_wb_dat_o, m_wb_dat_i, m_wb_cyc_o,
212
  m_wb_stb_o, m_wb_ack_i, m_wb_err_i,
213
 
214 214 mohor
`ifdef ETH_WISHBONE_B3
215
  m_wb_cti_o, m_wb_bte_o,
216
`endif
217
 
218 15 mohor
  //TX
219 20 mohor
  mtx_clk_pad_i, mtxd_pad_o, mtxen_pad_o, mtxerr_pad_o,
220 15 mohor
 
221
  //RX
222 20 mohor
  mrx_clk_pad_i, mrxd_pad_i, mrxdv_pad_i, mrxerr_pad_i, mcoll_pad_i, mcrs_pad_i,
223 15 mohor
 
224
  // MIIM
225 95 mohor
  mdc_pad_o, md_pad_i, md_pad_o, md_padoe_o,
226 17 mohor
 
227 21 mohor
  int_o
228 17 mohor
 
229 210 mohor
  // Bist
230
`ifdef ETH_BIST
231 227 tadejm
  ,
232
  // debug chain signals
233
  scanb_rst,      // bist scan reset
234
  scanb_clk,      // bist scan clock
235
  scanb_si,       // bist scan serial in
236
  scanb_so,       // bist scan serial out
237
  scanb_en        // bist scan shift enable
238 210 mohor
`endif
239 21 mohor
 
240 15 mohor
);
241
 
242
 
243
parameter Tp = 1;
244
 
245
 
246
// WISHBONE common
247 17 mohor
input           wb_clk_i;     // WISHBONE clock
248
input           wb_rst_i;     // WISHBONE reset
249
input   [31:0]  wb_dat_i;     // WISHBONE data input
250
output  [31:0]  wb_dat_o;     // WISHBONE data output
251
output          wb_err_o;     // WISHBONE error output
252 15 mohor
 
253
// WISHBONE slave
254 23 mohor
input   [11:2]  wb_adr_i;     // WISHBONE address input
255 17 mohor
input    [3:0]  wb_sel_i;     // WISHBONE byte select input
256
input           wb_we_i;      // WISHBONE write enable input
257
input           wb_cyc_i;     // WISHBONE cycle input
258
input           wb_stb_i;     // WISHBONE strobe input
259
output          wb_ack_o;     // WISHBONE acknowledge output
260 15 mohor
 
261 41 mohor
// WISHBONE master
262
output  [31:0]  m_wb_adr_o;
263
output   [3:0]  m_wb_sel_o;
264
output          m_wb_we_o;
265
input   [31:0]  m_wb_dat_i;
266
output  [31:0]  m_wb_dat_o;
267
output          m_wb_cyc_o;
268
output          m_wb_stb_o;
269
input           m_wb_ack_i;
270
input           m_wb_err_i;
271 15 mohor
 
272 214 mohor
`ifdef ETH_WISHBONE_B3
273
output   [2:0]  m_wb_cti_o;   // Cycle Type Identifier
274
output   [1:0]  m_wb_bte_o;   // Burst Type Extension
275
`endif
276 41 mohor
 
277 15 mohor
// Tx
278 20 mohor
input           mtx_clk_pad_i; // Transmit clock (from PHY)
279 21 mohor
output   [3:0]  mtxd_pad_o;    // Transmit nibble (to PHY)
280
output          mtxen_pad_o;   // Transmit enable (to PHY)
281
output          mtxerr_pad_o;  // Transmit error (to PHY)
282 15 mohor
 
283
// Rx
284 20 mohor
input           mrx_clk_pad_i; // Receive clock (from PHY)
285 21 mohor
input    [3:0]  mrxd_pad_i;    // Receive nibble (from PHY)
286
input           mrxdv_pad_i;   // Receive data valid (from PHY)
287
input           mrxerr_pad_i;  // Receive data error (from PHY)
288 15 mohor
 
289
// Common Tx and Rx
290 21 mohor
input           mcoll_pad_i;   // Collision (from PHY)
291
input           mcrs_pad_i;    // Carrier sense (from PHY)
292 15 mohor
 
293
// MII Management interface
294 21 mohor
input           md_pad_i;      // MII data input (from I/O cell)
295
output          mdc_pad_o;     // MII Management data clock (to PHY)
296
output          md_pad_o;      // MII data output (to I/O cell)
297 95 mohor
output          md_padoe_o;    // MII data output enable (to I/O cell)
298 15 mohor
 
299 21 mohor
output          int_o;         // Interrupt output
300 15 mohor
 
301 210 mohor
// Bist
302
`ifdef ETH_BIST
303 227 tadejm
input   scanb_rst;      // bist scan reset
304
input   scanb_clk;      // bist scan clock
305
input   scanb_si;       // bist scan serial in
306
output  scanb_so;       // bist scan serial out
307
input   scanb_en;       // bist scan shift enable
308 210 mohor
`endif
309
 
310 15 mohor
wire     [7:0]  r_ClkDiv;
311
wire            r_MiiNoPre;
312
wire    [15:0]  r_CtrlData;
313
wire     [4:0]  r_FIAD;
314
wire     [4:0]  r_RGAD;
315
wire            r_WCtrlData;
316
wire            r_RStat;
317
wire            r_ScanStat;
318
wire            NValid_stat;
319
wire            Busy_stat;
320
wire            LinkFail;
321
wire    [15:0]  Prsd;             // Read Status Data (data read from the PHY)
322
wire            WCtrlDataStart;
323
wire            RStatStart;
324
wire            UpdateMIIRX_DATAReg;
325
 
326
wire            TxStartFrm;
327
wire            TxEndFrm;
328
wire            TxUsedData;
329
wire     [7:0]  TxData;
330
wire            TxRetry;
331
wire            TxAbort;
332
wire            TxUnderRun;
333
wire            TxDone;
334 42 mohor
wire     [5:0]  CollValid;
335 15 mohor
 
336
 
337 149 mohor
reg             WillSendControlFrame_sync1;
338
reg             WillSendControlFrame_sync2;
339
reg             WillSendControlFrame_sync3;
340
reg             RstTxPauseRq;
341 15 mohor
 
342
 
343
// Connecting Miim module
344
eth_miim miim1
345
(
346 248 mohor
  .Clk(wb_clk_i),                         .Reset(wb_rst_i),                   .Divider(r_ClkDiv),
347 15 mohor
  .NoPre(r_MiiNoPre),                     .CtrlData(r_CtrlData),              .Rgad(r_RGAD),
348
  .Fiad(r_FIAD),                          .WCtrlData(r_WCtrlData),            .RStat(r_RStat),
349 17 mohor
  .ScanStat(r_ScanStat),                  .Mdi(md_pad_i),                     .Mdo(md_pad_o),
350 95 mohor
  .MdoEn(md_padoe_o),                     .Mdc(mdc_pad_o),                    .Busy(Busy_stat),
351 15 mohor
  .Prsd(Prsd),                            .LinkFail(LinkFail),                .Nvalid(NValid_stat),
352
  .WCtrlDataStart(WCtrlDataStart),        .RStatStart(RStatStart),            .UpdateMIIRX_DATAReg(UpdateMIIRX_DATAReg)
353
);
354
 
355
 
356
 
357
 
358
wire        RegCs;          // Connected to registers
359 17 mohor
wire [31:0] RegDataOut;     // Multiplexed to wb_dat_o
360 42 mohor
wire        r_RecSmall;     // Receive small frames
361 15 mohor
wire        r_LoopBck;      // Loopback
362
wire        r_TxEn;         // Tx Enable
363
wire        r_RxEn;         // Rx Enable
364
 
365
wire        MRxDV_Lb;       // Muxed MII receive data valid
366
wire        MRxErr_Lb;      // Muxed MII Receive Error
367
wire  [3:0] MRxD_Lb;        // Muxed MII Receive Data
368
wire        Transmitting;   // Indication that TxEthMAC is transmitting
369
wire        r_HugEn;        // Huge packet enable
370
wire        r_DlyCrcEn;     // Delayed CRC enabled
371
wire [15:0] r_MaxFL;        // Maximum frame length
372
 
373
wire [15:0] r_MinFL;        // Minimum frame length
374 42 mohor
wire        ShortFrame;
375
wire        DribbleNibble;  // Extra nibble received
376
wire        ReceivedPacketTooBig; // Received packet is too big
377 15 mohor
wire [47:0] r_MAC;          // MAC address
378 42 mohor
wire        LoadRxStatus;   // Rx status was loaded
379 52 billditt
wire [31:0] r_HASH0;        // HASH table, lower 4 bytes
380
wire [31:0] r_HASH1;        // HASH table, upper 4 bytes
381 34 mohor
wire  [7:0] r_TxBDNum;      // Receive buffer descriptor number
382 15 mohor
wire  [6:0] r_IPGT;         // 
383
wire  [6:0] r_IPGR1;        // 
384
wire  [6:0] r_IPGR2;        // 
385
wire  [5:0] r_CollValid;    // 
386 149 mohor
wire [15:0] r_TxPauseTV;    // Transmit PAUSE value
387
wire        r_TxPauseRq;    // Transmit PAUSE request
388 15 mohor
 
389
wire  [3:0] r_MaxRet;       //
390
wire        r_NoBckof;      // 
391
wire        r_ExDfrEn;      // 
392 34 mohor
wire        TX_BD_NUM_Wr;   // Write enable that writes RX_BD_NUM to the registers.
393 15 mohor
wire        r_TxFlow;       // Tx flow control enable
394
wire        r_IFG;          // Minimum interframe gap for incoming packets
395
 
396 21 mohor
wire        TxB_IRQ;        // Interrupt Tx Buffer
397
wire        TxE_IRQ;        // Interrupt Tx Error
398
wire        RxB_IRQ;        // Interrupt Rx Buffer
399 76 mohor
wire        RxE_IRQ;        // Interrupt Rx Error
400 21 mohor
wire        Busy_IRQ;       // Interrupt Busy (lack of buffers)
401 15 mohor
 
402
wire        DWord;
403
wire        BDAck;
404 103 mohor
wire [31:0] BD_WB_DAT_O;    // wb_dat_o that comes from the Wishbone module (for buffer descriptors read/write)
405 21 mohor
wire        BDCs;           // Buffer descriptor CS
406 202 mohor
wire        CsMiss;         // When access to the address between 0x800 and 0xfff occurs, acknowledge is set
407
                            // but data is not valid.
408 15 mohor
 
409 103 mohor
wire        temp_wb_ack_o;
410
wire [31:0] temp_wb_dat_o;
411
wire        temp_wb_err_o;
412 15 mohor
 
413 103 mohor
`ifdef ETH_REGISTERED_OUTPUTS
414
  reg         temp_wb_ack_o_reg;
415
  reg [31:0]  temp_wb_dat_o_reg;
416
  reg         temp_wb_err_o_reg;
417
`endif
418
 
419 17 mohor
assign DWord = &wb_sel_i;
420 103 mohor
assign RegCs = wb_stb_i & wb_cyc_i & DWord & ~wb_adr_i[11] & ~wb_adr_i[10];   // 0x0   - 0x3FF
421 114 mohor
assign BDCs  = wb_stb_i & wb_cyc_i & DWord & ~wb_adr_i[11] &  wb_adr_i[10];   // 0x400 - 0x7FF
422 202 mohor
assign CsMiss = wb_stb_i & wb_cyc_i & DWord & wb_adr_i[11];                   // 0x800 - 0xfFF
423 103 mohor
assign temp_wb_ack_o = RegCs | BDAck;
424
assign temp_wb_dat_o = (RegCs & ~wb_we_i)? RegDataOut : BD_WB_DAT_O;
425 240 tadejm
assign temp_wb_err_o = wb_stb_i & wb_cyc_i & (~DWord | CsMiss);
426 15 mohor
 
427 103 mohor
`ifdef ETH_REGISTERED_OUTPUTS
428
  assign wb_ack_o = temp_wb_ack_o_reg;
429
  assign wb_dat_o[31:0] = temp_wb_dat_o_reg;
430
  assign wb_err_o = temp_wb_err_o_reg;
431
`else
432
  assign wb_ack_o = temp_wb_ack_o;
433
  assign wb_dat_o[31:0] = temp_wb_dat_o;
434
  assign wb_err_o = temp_wb_err_o;
435
`endif
436 15 mohor
 
437
 
438
 
439 103 mohor
`ifdef ETH_REGISTERED_OUTPUTS
440
  always @ (posedge wb_clk_i or posedge wb_rst_i)
441
  begin
442
    if(wb_rst_i)
443
      begin
444
        temp_wb_ack_o_reg <=#Tp 1'b0;
445
        temp_wb_dat_o_reg <=#Tp 32'h0;
446
        temp_wb_err_o_reg <=#Tp 1'b0;
447
      end
448
    else
449
      begin
450 106 mohor
        temp_wb_ack_o_reg <=#Tp temp_wb_ack_o & ~temp_wb_ack_o_reg;
451 103 mohor
        temp_wb_dat_o_reg <=#Tp temp_wb_dat_o;
452 106 mohor
        temp_wb_err_o_reg <=#Tp temp_wb_err_o & ~temp_wb_err_o_reg;
453 103 mohor
      end
454
  end
455
`endif
456
 
457
 
458 15 mohor
// Connecting Ethernet registers
459
eth_registers ethreg1
460
(
461 47 mohor
  .DataIn(wb_dat_i),                      .Address(wb_adr_i[9:2]),                    .Rw(wb_we_i),
462 17 mohor
  .Cs(RegCs),                             .Clk(wb_clk_i),                             .Reset(wb_rst_i),
463 68 mohor
  .DataOut(RegDataOut),                   .r_RecSmall(r_RecSmall),
464 15 mohor
  .r_Pad(r_Pad),                          .r_HugEn(r_HugEn),                          .r_CrcEn(r_CrcEn),
465 244 mohor
  .r_DlyCrcEn(r_DlyCrcEn),                .r_FullD(r_FullD),
466 15 mohor
  .r_ExDfrEn(r_ExDfrEn),                  .r_NoBckof(r_NoBckof),                      .r_LoopBck(r_LoopBck),
467 52 billditt
  .r_IFG(r_IFG),                          .r_Pro(r_Pro),                              .r_Iam(),
468
  .r_Bro(r_Bro),                          .r_NoPre(r_NoPre),                          .r_TxEn(r_TxEn),
469 76 mohor
  .r_RxEn(r_RxEn),                        .Busy_IRQ(Busy_IRQ),                        .RxE_IRQ(RxE_IRQ),
470 21 mohor
  .RxB_IRQ(RxB_IRQ),                      .TxE_IRQ(TxE_IRQ),                          .TxB_IRQ(TxB_IRQ),
471 149 mohor
  .r_IPGT(r_IPGT),
472 15 mohor
  .r_IPGR1(r_IPGR1),                      .r_IPGR2(r_IPGR2),                          .r_MinFL(r_MinFL),
473
  .r_MaxFL(r_MaxFL),                      .r_MaxRet(r_MaxRet),                        .r_CollValid(r_CollValid),
474
  .r_TxFlow(r_TxFlow),                    .r_RxFlow(r_RxFlow),                        .r_PassAll(r_PassAll),
475 253 mohor
  .r_MiiNoPre(r_MiiNoPre),                .r_ClkDiv(r_ClkDiv),
476 15 mohor
  .r_WCtrlData(r_WCtrlData),              .r_RStat(r_RStat),                          .r_ScanStat(r_ScanStat),
477
  .r_RGAD(r_RGAD),                        .r_FIAD(r_FIAD),                            .r_CtrlData(r_CtrlData),
478
  .NValid_stat(NValid_stat),              .Busy_stat(Busy_stat),
479
  .LinkFail(LinkFail),                    .r_MAC(r_MAC),                              .WCtrlDataStart(WCtrlDataStart),
480
  .RStatStart(RStatStart),                .UpdateMIIRX_DATAReg(UpdateMIIRX_DATAReg),  .Prsd(Prsd),
481 47 mohor
  .r_TxBDNum(r_TxBDNum),                  .TX_BD_NUM_Wr(TX_BD_NUM_Wr),                .int_o(int_o),
482 149 mohor
  .r_HASH0(r_HASH0),                      .r_HASH1(r_HASH1),                          .r_TxPauseRq(r_TxPauseRq),
483
  .r_TxPauseTV(r_TxPauseTV),              .RstTxPauseRq(RstTxPauseRq),                .TxCtrlEndFrm(TxCtrlEndFrm),
484
  .StartTxDone(StartTxDone),              .TxClk(mtx_clk_pad_i),                      .RxClk(mrx_clk_pad_i),
485 164 mohor
  .ReceivedPauseFrm(ReceivedPauseFrm)
486 149 mohor
 
487 15 mohor
);
488
 
489
 
490
 
491
wire  [7:0] RxData;
492
wire        RxValid;
493
wire        RxStartFrm;
494
wire        RxEndFrm;
495 41 mohor
wire        RxAbort;
496 15 mohor
 
497
wire        WillTransmit;            // Will transmit (to RxEthMAC)
498
wire        ResetCollision;          // Reset Collision (for synchronizing collision)
499
wire  [7:0] TxDataOut;               // Transmit Packet Data (to TxEthMAC)
500
wire        WillSendControlFrame;
501
wire        ReceiveEnd;
502
wire        ReceivedPacketGood;
503
wire        ReceivedLengthOK;
504 42 mohor
wire        InvalidSymbol;
505
wire        LatchedCrcError;
506
wire        RxLateCollision;
507 59 mohor
wire  [3:0] RetryCntLatched;
508
wire  [3:0] RetryCnt;
509
wire        StartTxAbort;
510
wire        MaxCollisionOccured;
511
wire        RetryLimit;
512
wire        StatePreamble;
513
wire  [1:0] StateData;
514 15 mohor
 
515
// Connecting MACControl
516
eth_maccontrol maccontrol1
517
(
518 149 mohor
  .MTxClk(mtx_clk_pad_i),                       .TPauseRq(r_TxPauseRq),
519
  .TxPauseTV(r_TxPauseTV),                      .TxDataIn(TxData),
520 15 mohor
  .TxStartFrmIn(TxStartFrm),                    .TxEndFrmIn(TxEndFrm),
521
  .TxUsedDataIn(TxUsedDataIn),                  .TxDoneIn(TxDoneIn),
522 20 mohor
  .TxAbortIn(TxAbortIn),                        .MRxClk(mrx_clk_pad_i),
523 15 mohor
  .RxData(RxData),                              .RxValid(RxValid),
524
  .RxStartFrm(RxStartFrm),                      .RxEndFrm(RxEndFrm),
525
  .ReceiveEnd(ReceiveEnd),                      .ReceivedPacketGood(ReceivedPacketGood),
526
  .PassAll(r_PassAll),                          .TxFlow(r_TxFlow),
527
  .RxFlow(r_RxFlow),                            .DlyCrcEn(r_DlyCrcEn),
528
  .MAC(r_MAC),                                  .PadIn(r_Pad | PerPacketPad),
529
  .PadOut(PadOut),                              .CrcEnIn(r_CrcEn | PerPacketCrcEn),
530 240 tadejm
  .CrcEnOut(CrcEnOut),                          .TxReset(wb_rst_i),
531
  .RxReset(wb_rst_i),                           .ReceivedLengthOK(ReceivedLengthOK),
532 15 mohor
  .TxDataOut(TxDataOut),                        .TxStartFrmOut(TxStartFrmOut),
533
  .TxEndFrmOut(TxEndFrmOut),                    .TxUsedDataOut(TxUsedData),
534
  .TxDoneOut(TxDone),                           .TxAbortOut(TxAbort),
535
  .WillSendControlFrame(WillSendControlFrame),  .TxCtrlEndFrm(TxCtrlEndFrm),
536
  .ReceivedPauseFrm(ReceivedPauseFrm)
537
);
538
 
539
 
540
 
541
wire TxCarrierSense;          // Synchronized CarrierSense (to Tx clock)
542
wire Collision;               // Synchronized Collision
543
 
544
reg CarrierSense_Tx1;
545
reg CarrierSense_Tx2;
546
reg Collision_Tx1;
547
reg Collision_Tx2;
548
 
549
reg RxEnSync;                 // Synchronized Receive Enable
550
reg CarrierSense_Rx1;
551
reg RxCarrierSense;           // Synchronized CarrierSense (to Rx clock)
552
reg WillTransmit_q;
553
reg WillTransmit_q2;
554
 
555
 
556
 
557
// Muxed MII receive data valid
558 17 mohor
assign MRxDV_Lb = r_LoopBck? mtxen_pad_o : mrxdv_pad_i & RxEnSync;
559 15 mohor
 
560
// Muxed MII Receive Error
561 17 mohor
assign MRxErr_Lb = r_LoopBck? mtxerr_pad_o : mrxerr_pad_i & RxEnSync;
562 15 mohor
 
563
// Muxed MII Receive Data
564 17 mohor
assign MRxD_Lb[3:0] = r_LoopBck? mtxd_pad_o[3:0] : mrxd_pad_i[3:0];
565 15 mohor
 
566
 
567
 
568
// Connecting TxEthMAC
569
eth_txethmac txethmac1
570
(
571 240 tadejm
  .MTxClk(mtx_clk_pad_i),             .Reset(wb_rst_i),                   .CarrierSense(TxCarrierSense),
572 15 mohor
  .Collision(Collision),              .TxData(TxDataOut),                 .TxStartFrm(TxStartFrmOut),
573
  .TxUnderRun(TxUnderRun),            .TxEndFrm(TxEndFrmOut),             .Pad(PadOut),
574
  .MinFL(r_MinFL),                    .CrcEn(CrcEnOut),                   .FullD(r_FullD),
575
  .HugEn(r_HugEn),                    .DlyCrcEn(r_DlyCrcEn),              .IPGT(r_IPGT),
576
  .IPGR1(r_IPGR1),                    .IPGR2(r_IPGR2),                    .CollValid(r_CollValid),
577
  .MaxRet(r_MaxRet),                  .NoBckof(r_NoBckof),                .ExDfrEn(r_ExDfrEn),
578 17 mohor
  .MaxFL(r_MaxFL),                    .MTxEn(mtxen_pad_o),                .MTxD(mtxd_pad_o),
579
  .MTxErr(mtxerr_pad_o),              .TxUsedData(TxUsedDataIn),          .TxDone(TxDoneIn),
580 15 mohor
  .TxRetry(TxRetry),                  .TxAbort(TxAbortIn),                .WillTransmit(WillTransmit),
581 59 mohor
  .ResetCollision(ResetCollision),    .RetryCnt(RetryCnt),                .StartTxDone(StartTxDone),
582
  .StartTxAbort(StartTxAbort),        .MaxCollisionOccured(MaxCollisionOccured), .LateCollision(LateCollision),
583
  .StartDefer(StartDefer),            .StatePreamble(StatePreamble),      .StateData(StateData)
584 15 mohor
);
585
 
586
 
587
 
588
 
589
wire  [15:0]  RxByteCnt;
590
wire          RxByteCntEq0;
591
wire          RxByteCntGreat2;
592
wire          RxByteCntMaxFrame;
593
wire          RxCrcError;
594
wire          RxStateIdle;
595
wire          RxStatePreamble;
596
wire          RxStateSFD;
597
wire   [1:0]  RxStateData;
598 250 mohor
wire          AddressMiss;
599 15 mohor
 
600
 
601
 
602
// Connecting RxEthMAC
603
eth_rxethmac rxethmac1
604
(
605 21 mohor
  .MRxClk(mrx_clk_pad_i),               .MRxDV(MRxDV_Lb),                     .MRxD(MRxD_Lb),
606 15 mohor
  .Transmitting(Transmitting),          .HugEn(r_HugEn),                      .DlyCrcEn(r_DlyCrcEn),
607 240 tadejm
  .MaxFL(r_MaxFL),                      .r_IFG(r_IFG),                        .Reset(wb_rst_i),
608 15 mohor
  .RxData(RxData),                      .RxValid(RxValid),                    .RxStartFrm(RxStartFrm),
609 65 mohor
  .RxEndFrm(RxEndFrm),                  .ByteCnt(RxByteCnt),
610 15 mohor
  .ByteCntEq0(RxByteCntEq0),            .ByteCntGreat2(RxByteCntGreat2),      .ByteCntMaxFrame(RxByteCntMaxFrame),
611
  .CrcError(RxCrcError),                .StateIdle(RxStateIdle),              .StatePreamble(RxStatePreamble),
612 52 billditt
  .StateSFD(RxStateSFD),                .StateData(RxStateData),
613 63 mohor
  .MAC(r_MAC),                          .r_Pro(r_Pro),                        .r_Bro(r_Bro),
614 250 mohor
  .r_HASH0(r_HASH0),                    .r_HASH1(r_HASH1),                    .RxAbort(RxAbort),
615
  .AddressMiss(AddressMiss)
616 15 mohor
);
617
 
618
 
619
// MII Carrier Sense Synchronization
620 240 tadejm
always @ (posedge mtx_clk_pad_i or posedge wb_rst_i)
621 15 mohor
begin
622 240 tadejm
  if(wb_rst_i)
623 15 mohor
    begin
624
      CarrierSense_Tx1 <= #Tp 1'b0;
625
      CarrierSense_Tx2 <= #Tp 1'b0;
626
    end
627
  else
628
    begin
629 17 mohor
      CarrierSense_Tx1 <= #Tp mcrs_pad_i;
630 15 mohor
      CarrierSense_Tx2 <= #Tp CarrierSense_Tx1;
631
    end
632
end
633
 
634
assign TxCarrierSense = ~r_FullD & CarrierSense_Tx2;
635
 
636
 
637
// MII Collision Synchronization
638 240 tadejm
always @ (posedge mtx_clk_pad_i or posedge wb_rst_i)
639 15 mohor
begin
640 240 tadejm
  if(wb_rst_i)
641 15 mohor
    begin
642
      Collision_Tx1 <= #Tp 1'b0;
643
      Collision_Tx2 <= #Tp 1'b0;
644
    end
645
  else
646
    begin
647 17 mohor
      Collision_Tx1 <= #Tp mcoll_pad_i;
648 15 mohor
      if(ResetCollision)
649
        Collision_Tx2 <= #Tp 1'b0;
650
      else
651
      if(Collision_Tx1)
652
        Collision_Tx2 <= #Tp 1'b1;
653
    end
654
end
655
 
656
 
657
// Synchronized Collision
658
assign Collision = ~r_FullD & Collision_Tx2;
659
 
660
 
661
 
662
// Carrier sense is synchronized to receive clock.
663 240 tadejm
always @ (posedge mrx_clk_pad_i or posedge wb_rst_i)
664 15 mohor
begin
665 240 tadejm
  if(wb_rst_i)
666 15 mohor
    begin
667
      CarrierSense_Rx1 <= #Tp 1'h0;
668
      RxCarrierSense <= #Tp 1'h0;
669
    end
670
  else
671
    begin
672 17 mohor
      CarrierSense_Rx1 <= #Tp mcrs_pad_i;
673 15 mohor
      RxCarrierSense <= #Tp CarrierSense_Rx1;
674
    end
675
end
676
 
677
 
678
// Delayed WillTransmit
679 20 mohor
always @ (posedge mrx_clk_pad_i)
680 15 mohor
begin
681
  WillTransmit_q <= #Tp WillTransmit;
682
  WillTransmit_q2 <= #Tp WillTransmit_q;
683
end
684
 
685
 
686
assign Transmitting = ~r_FullD & WillTransmit_q2;
687
 
688
 
689
 
690
// Synchronized Receive Enable
691 240 tadejm
always @ (posedge mrx_clk_pad_i or posedge wb_rst_i)
692 15 mohor
begin
693 240 tadejm
  if(wb_rst_i)
694 15 mohor
    RxEnSync <= #Tp 1'b0;
695
  else
696
  if(~RxCarrierSense | RxCarrierSense & Transmitting)
697
    RxEnSync <= #Tp r_RxEn;
698
end
699
 
700
 
701
 
702 149 mohor
// Synchronizing WillSendControlFrame to WB_CLK;
703
always @ (posedge wb_clk_i or posedge wb_rst_i)
704
begin
705
  if(wb_rst_i)
706
    WillSendControlFrame_sync1 <= 1'b0;
707
  else
708
    WillSendControlFrame_sync1 <=#Tp WillSendControlFrame;
709
end
710 15 mohor
 
711 149 mohor
always @ (posedge wb_clk_i or posedge wb_rst_i)
712
begin
713
  if(wb_rst_i)
714
    WillSendControlFrame_sync2 <= 1'b0;
715
  else
716
    WillSendControlFrame_sync2 <=#Tp WillSendControlFrame_sync1;
717
end
718
 
719
always @ (posedge wb_clk_i or posedge wb_rst_i)
720
begin
721
  if(wb_rst_i)
722
    WillSendControlFrame_sync3 <= 1'b0;
723
  else
724
    WillSendControlFrame_sync3 <=#Tp WillSendControlFrame_sync2;
725
end
726
 
727
always @ (posedge wb_clk_i or posedge wb_rst_i)
728
begin
729
  if(wb_rst_i)
730
    RstTxPauseRq <= 1'b0;
731
  else
732
    RstTxPauseRq <=#Tp WillSendControlFrame_sync2 & ~WillSendControlFrame_sync3;
733
end
734
 
735
 
736 114 mohor
// Connecting Wishbone module
737 41 mohor
eth_wishbone wishbone
738 15 mohor
(
739 41 mohor
  .WB_CLK_I(wb_clk_i),                .WB_DAT_I(wb_dat_i),
740 103 mohor
  .WB_DAT_O(BD_WB_DAT_O),
741 15 mohor
 
742
  // WISHBONE slave
743 76 mohor
  .WB_ADR_I(wb_adr_i[9:2]),           .WB_WE_I(wb_we_i),
744 21 mohor
  .BDCs(BDCs),                        .WB_ACK_O(BDAck),
745 15 mohor
 
746 240 tadejm
  .Reset(wb_rst_i),
747 41 mohor
 
748
  // WISHBONE master
749
  .m_wb_adr_o(m_wb_adr_o),            .m_wb_sel_o(m_wb_sel_o),                  .m_wb_we_o(m_wb_we_o),
750
  .m_wb_dat_i(m_wb_dat_i),            .m_wb_dat_o(m_wb_dat_o),                  .m_wb_cyc_o(m_wb_cyc_o),
751
  .m_wb_stb_o(m_wb_stb_o),            .m_wb_ack_i(m_wb_ack_i),                  .m_wb_err_i(m_wb_err_i),
752 214 mohor
 
753
`ifdef ETH_WISHBONE_B3
754
  .m_wb_cti_o(m_wb_cti_o),            .m_wb_bte_o(m_wb_bte_o),
755
`endif
756
 
757 41 mohor
 
758 15 mohor
    //TX
759 21 mohor
  .MTxClk(mtx_clk_pad_i),             .TxStartFrm(TxStartFrm),                  .TxEndFrm(TxEndFrm),
760 59 mohor
  .TxUsedData(TxUsedData),            .TxData(TxData),
761 15 mohor
  .TxRetry(TxRetry),                  .TxAbort(TxAbort),                        .TxUnderRun(TxUnderRun),
762 149 mohor
  .TxDone(TxDone),
763
  .PerPacketCrcEn(PerPacketCrcEn),    .PerPacketPad(PerPacketPad),
764 15 mohor
 
765
  // Register
766 34 mohor
  .r_TxEn(r_TxEn),                    .r_RxEn(r_RxEn),                          .r_TxBDNum(r_TxBDNum),
767 149 mohor
  .TX_BD_NUM_Wr(TX_BD_NUM_Wr),
768 15 mohor
 
769
  //RX
770 21 mohor
  .MRxClk(mrx_clk_pad_i),             .RxData(RxData),                          .RxValid(RxValid),
771 41 mohor
  .RxStartFrm(RxStartFrm),            .RxEndFrm(RxEndFrm),
772 76 mohor
  .Busy_IRQ(Busy_IRQ),                .RxE_IRQ(RxE_IRQ),                        .RxB_IRQ(RxB_IRQ),
773 149 mohor
  .TxE_IRQ(TxE_IRQ),                  .TxB_IRQ(TxB_IRQ),
774 21 mohor
 
775 149 mohor
  .RxAbort(RxAbort | (ShortFrame & ~r_RecSmall) | LatchedMRxErr & ~InvalidSymbol | ReceivedPauseFrm & ~r_PassAll),
776 41 mohor
 
777 42 mohor
  .InvalidSymbol(InvalidSymbol),      .LatchedCrcError(LatchedCrcError),        .RxLength(RxByteCnt),
778
  .RxLateCollision(RxLateCollision),  .ShortFrame(ShortFrame),                  .DribbleNibble(DribbleNibble),
779 59 mohor
  .ReceivedPacketTooBig(ReceivedPacketTooBig), .LoadRxStatus(LoadRxStatus),     .RetryCntLatched(RetryCntLatched),
780
  .RetryLimit(RetryLimit),            .LateCollLatched(LateCollLatched),        .DeferLatched(DeferLatched),
781 250 mohor
  .CarrierSenseLost(CarrierSenseLost),.ReceivedPacketGood(ReceivedPacketGood),  .AddressMiss(AddressMiss)
782 59 mohor
 
783 210 mohor
`ifdef ETH_BIST
784 218 mohor
  ,
785 227 tadejm
  .scanb_rst      (scanb_rst),
786
  .scanb_clk      (scanb_clk),
787
  .scanb_si       (scanb_si),
788
  .scanb_so       (scanb_so),
789
  .scanb_en       (scanb_en)
790 210 mohor
`endif
791 15 mohor
);
792
 
793
 
794
 
795
// Connecting MacStatus module
796
eth_macstatus macstatus1
797
(
798 240 tadejm
  .MRxClk(mrx_clk_pad_i),             .Reset(wb_rst_i),
799 42 mohor
  .ReceiveEnd(ReceiveEnd),            .ReceivedPacketGood(ReceivedPacketGood),     .ReceivedLengthOK(ReceivedLengthOK),
800
  .RxCrcError(RxCrcError),            .MRxErr(MRxErr_Lb),                          .MRxDV(MRxDV_Lb),
801
  .RxStateSFD(RxStateSFD),            .RxStateData(RxStateData),                   .RxStatePreamble(RxStatePreamble),
802
  .RxStateIdle(RxStateIdle),          .Transmitting(Transmitting),                 .RxByteCnt(RxByteCnt),
803
  .RxByteCntEq0(RxByteCntEq0),        .RxByteCntGreat2(RxByteCntGreat2),           .RxByteCntMaxFrame(RxByteCntMaxFrame),
804
  .ReceivedPauseFrm(ReceivedPauseFrm),.InvalidSymbol(InvalidSymbol),
805
  .MRxD(MRxD_Lb),                     .LatchedCrcError(LatchedCrcError),           .Collision(mcoll_pad_i),
806
  .CollValid(r_CollValid),            .RxLateCollision(RxLateCollision),           .r_RecSmall(r_RecSmall),
807
  .r_MinFL(r_MinFL),                  .r_MaxFL(r_MaxFL),                           .ShortFrame(ShortFrame),
808
  .DribbleNibble(DribbleNibble),      .ReceivedPacketTooBig(ReceivedPacketTooBig), .r_HugEn(r_HugEn),
809 59 mohor
  .LoadRxStatus(LoadRxStatus),        .RetryCnt(RetryCnt),                         .StartTxDone(StartTxDone),
810
  .StartTxAbort(StartTxAbort),        .RetryCntLatched(RetryCntLatched),           .MTxClk(mtx_clk_pad_i),
811
  .MaxCollisionOccured(MaxCollisionOccured), .RetryLimit(RetryLimit),              .LateCollision(LateCollision),
812
  .LateCollLatched(LateCollLatched),  .StartDefer(StartDefer),                     .DeferLatched(DeferLatched),
813
  .TxStartFrm(TxStartFrmOut),         .StatePreamble(StatePreamble),               .StateData(StateData),
814 125 mohor
  .CarrierSense(CarrierSense_Tx2),    .CarrierSenseLost(CarrierSenseLost),         .TxUsedData(TxUsedDataIn),
815 168 mohor
  .LatchedMRxErr(LatchedMRxErr),      .Loopback(r_LoopBck),                        .r_FullD(r_FullD)
816 15 mohor
);
817
 
818
 
819
endmodule

powered by: WebSVN 2.1.0

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