1 |
92 |
mohor |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// tb_eth_defines.v ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the Ethernet IP core project ////
|
6 |
|
|
//// http://www.opencores.org/projects/ethmac/ ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Author(s): ////
|
9 |
|
|
//// - Igor Mohor (igorM@opencores.org) ////
|
10 |
|
|
//// ////
|
11 |
170 |
mohor |
//// All additional information is available in the Readme.txt ////
|
12 |
92 |
mohor |
//// file. ////
|
13 |
|
|
//// ////
|
14 |
|
|
//////////////////////////////////////////////////////////////////////
|
15 |
|
|
//// ////
|
16 |
116 |
mohor |
//// Copyright (C) 2001, 2002 Authors ////
|
17 |
92 |
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 |
209 |
tadejm |
// Revision 1.8 2002/09/13 18:41:45 mohor
|
45 |
|
|
// Rearanged testcases
|
46 |
|
|
//
|
47 |
178 |
mohor |
// Revision 1.7 2002/09/13 12:29:14 mohor
|
48 |
|
|
// Headers changed.
|
49 |
|
|
//
|
50 |
170 |
mohor |
// Revision 1.6 2002/09/13 11:57:20 mohor
|
51 |
|
|
// New testbench. Thanks to Tadej M - "The Spammer".
|
52 |
|
|
//
|
53 |
124 |
mohor |
// Revision 1.3 2002/07/19 13:57:53 mohor
|
54 |
|
|
// Testing environment also includes traffic cop, memory interface and host
|
55 |
|
|
// interface.
|
56 |
|
|
//
|
57 |
116 |
mohor |
// Revision 1.2 2002/05/03 10:22:17 mohor
|
58 |
|
|
// TX_BUF_BASE changed.
|
59 |
|
|
//
|
60 |
107 |
mohor |
// Revision 1.1 2002/03/19 12:53:54 mohor
|
61 |
|
|
// Some defines that are used in testbench only were moved to tb_eth_defines.v
|
62 |
|
|
// file.
|
63 |
92 |
mohor |
//
|
64 |
|
|
//
|
65 |
|
|
//
|
66 |
107 |
mohor |
//
|
67 |
92 |
mohor |
|
68 |
|
|
|
69 |
169 |
mohor |
|
70 |
|
|
//`define VERBOSE // if log files of device modules are written
|
71 |
|
|
|
72 |
92 |
mohor |
`define MULTICAST_XFR 0
|
73 |
|
|
`define UNICAST_XFR 1
|
74 |
|
|
`define BROADCAST_XFR 2
|
75 |
107 |
mohor |
`define UNICAST_WRONG_XFR 3
|
76 |
92 |
mohor |
|
77 |
116 |
mohor |
`define ETH_BASE 32'hd0000000
|
78 |
|
|
`define ETH_WIDTH 32'h800
|
79 |
|
|
`define MEMORY_BASE 32'h2000
|
80 |
|
|
`define MEMORY_WIDTH 32'h10000
|
81 |
107 |
mohor |
`define TX_BUF_BASE `MEMORY_BASE
|
82 |
92 |
mohor |
`define RX_BUF_BASE `MEMORY_BASE + 32'h8000
|
83 |
116 |
mohor |
`define TX_BD_BASE `ETH_BASE + 32'h00000400
|
84 |
|
|
`define RX_BD_BASE `ETH_BASE + 32'h00000600
|
85 |
|
|
|
86 |
|
|
`define M1_ADDRESSED_S1 ( (m1_wb_adr_i >= `ETH_BASE) & (m1_wb_adr_i < (`ETH_BASE + `ETH_WIDTH )) )
|
87 |
|
|
`define M1_ADDRESSED_S2 ( (m1_wb_adr_i >= `MEMORY_BASE) & (m1_wb_adr_i < (`MEMORY_BASE + `MEMORY_WIDTH)) )
|
88 |
|
|
`define M2_ADDRESSED_S1 ( (m2_wb_adr_i >= `ETH_BASE) & (m2_wb_adr_i < (`ETH_BASE + `ETH_WIDTH )) )
|
89 |
|
|
`define M2_ADDRESSED_S2 ( (m2_wb_adr_i >= `MEMORY_BASE) & (m2_wb_adr_i < (`MEMORY_BASE + `MEMORY_WIDTH)) )
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
/* Tx BD */
|
94 |
|
|
`define ETH_TX_BD_READY 32'h8000 /* Tx BD Ready */
|
95 |
|
|
`define ETH_TX_BD_IRQ 32'h4000 /* Tx BD IRQ Enable */
|
96 |
|
|
`define ETH_TX_BD_WRAP 32'h2000 /* Tx BD Wrap (last BD) */
|
97 |
|
|
`define ETH_TX_BD_PAD 32'h1000 /* Tx BD Pad Enable */
|
98 |
|
|
`define ETH_TX_BD_CRC 32'h0800 /* Tx BD CRC Enable */
|
99 |
|
|
|
100 |
|
|
`define ETH_TX_BD_UNDERRUN 32'h0100 /* Tx BD Underrun Status */
|
101 |
|
|
`define ETH_TX_BD_RETRY 32'h00F0 /* Tx BD Retry Status */
|
102 |
|
|
`define ETH_TX_BD_RETLIM 32'h0008 /* Tx BD Retransmission Limit Status */
|
103 |
|
|
`define ETH_TX_BD_LATECOL 32'h0004 /* Tx BD Late Collision Status */
|
104 |
|
|
`define ETH_TX_BD_DEFER 32'h0002 /* Tx BD Defer Status */
|
105 |
|
|
`define ETH_TX_BD_CARRIER 32'h0001 /* Tx BD Carrier Sense Lost Status */
|
106 |
|
|
|
107 |
|
|
/* Rx BD */
|
108 |
|
|
`define ETH_RX_BD_EMPTY 32'h8000 /* Rx BD Empty */
|
109 |
|
|
`define ETH_RX_BD_IRQ 32'h4000 /* Rx BD IRQ Enable */
|
110 |
|
|
`define ETH_RX_BD_WRAP 32'h2000 /* Rx BD Wrap (last BD) */
|
111 |
|
|
|
112 |
|
|
`define ETH_RX_BD_MISS 32'h0080 /* Rx BD Miss Status */
|
113 |
|
|
`define ETH_RX_BD_OVERRUN 32'h0040 /* Rx BD Overrun Status */
|
114 |
|
|
`define ETH_RX_BD_INVSIMB 32'h0020 /* Rx BD Invalid Symbol Status */
|
115 |
|
|
`define ETH_RX_BD_DRIBBLE 32'h0010 /* Rx BD Dribble Nibble Status */
|
116 |
|
|
`define ETH_RX_BD_TOOLONG 32'h0008 /* Rx BD Too Long Status */
|
117 |
|
|
`define ETH_RX_BD_SHORT 32'h0004 /* Rx BD Too Short Frame Status */
|
118 |
|
|
`define ETH_RX_BD_CRCERR 32'h0002 /* Rx BD CRC Error Status */
|
119 |
|
|
`define ETH_RX_BD_LATECOL 32'h0001 /* Rx BD Late Collision Status */
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
/* Register space */
|
124 |
|
|
`define ETH_MODER `ETH_BASE + 32'h00 /* Mode Register */
|
125 |
|
|
`define ETH_INT `ETH_BASE + 32'h04 /* Interrupt Source Register */
|
126 |
|
|
`define ETH_INT_MASK `ETH_BASE + 32'h08 /* Interrupt Mask Register */
|
127 |
|
|
`define ETH_IPGT `ETH_BASE + 32'h0C /* Back to Bak Inter Packet Gap Register */
|
128 |
|
|
`define ETH_IPGR1 `ETH_BASE + 32'h10 /* Non Back to Back Inter Packet Gap Register 1 */
|
129 |
|
|
`define ETH_IPGR2 `ETH_BASE + 32'h14 /* Non Back to Back Inter Packet Gap Register 2 */
|
130 |
|
|
`define ETH_PACKETLEN `ETH_BASE + 32'h18 /* Packet Length Register (min. and max.) */
|
131 |
|
|
`define ETH_COLLCONF `ETH_BASE + 32'h1C /* Collision and Retry Configuration Register */
|
132 |
169 |
mohor |
`define ETH_TX_BD_NUM `ETH_BASE + 32'h20 /* Transmit Buffer Descriptor Number Register */
|
133 |
116 |
mohor |
`define ETH_CTRLMODER `ETH_BASE + 32'h24 /* Control Module Mode Register */
|
134 |
|
|
`define ETH_MIIMODER `ETH_BASE + 32'h28 /* MII Mode Register */
|
135 |
|
|
`define ETH_MIICOMMAND `ETH_BASE + 32'h2C /* MII Command Register */
|
136 |
|
|
`define ETH_MIIADDRESS `ETH_BASE + 32'h30 /* MII Address Register */
|
137 |
|
|
`define ETH_MIITX_DATA `ETH_BASE + 32'h34 /* MII Transmit Data Register */
|
138 |
|
|
`define ETH_MIIRX_DATA `ETH_BASE + 32'h38 /* MII Receive Data Register */
|
139 |
|
|
`define ETH_MIISTATUS `ETH_BASE + 32'h3C /* MII Status Register */
|
140 |
|
|
`define ETH_MAC_ADDR0 `ETH_BASE + 32'h40 /* MAC Individual Address Register 0 */
|
141 |
|
|
`define ETH_MAC_ADDR1 `ETH_BASE + 32'h44 /* MAC Individual Address Register 1 */
|
142 |
|
|
`define ETH_HASH_ADDR0 `ETH_BASE + 32'h48 /* Hash Register 0 */
|
143 |
|
|
`define ETH_HASH_ADDR1 `ETH_BASE + 32'h4C /* Hash Register 1 */
|
144 |
170 |
mohor |
`define ETH_TX_CTRL `ETH_BASE + 32'h50 /* Tx Control Register */
|
145 |
116 |
mohor |
|
146 |
170 |
mohor |
|
147 |
116 |
mohor |
/* MODER Register */
|
148 |
|
|
`define ETH_MODER_RXEN 32'h00000001 /* Receive Enable */
|
149 |
|
|
`define ETH_MODER_TXEN 32'h00000002 /* Transmit Enable */
|
150 |
|
|
`define ETH_MODER_NOPRE 32'h00000004 /* No Preamble */
|
151 |
|
|
`define ETH_MODER_BRO 32'h00000008 /* Reject Broadcast */
|
152 |
|
|
`define ETH_MODER_IAM 32'h00000010 /* Use Individual Hash */
|
153 |
|
|
`define ETH_MODER_PRO 32'h00000020 /* Promiscuous (receive all) */
|
154 |
|
|
`define ETH_MODER_IFG 32'h00000040 /* Min. IFG not required */
|
155 |
|
|
`define ETH_MODER_LOOPBCK 32'h00000080 /* Loop Back */
|
156 |
|
|
`define ETH_MODER_NOBCKOF 32'h00000100 /* No Backoff */
|
157 |
|
|
`define ETH_MODER_EXDFREN 32'h00000200 /* Excess Defer */
|
158 |
|
|
`define ETH_MODER_FULLD 32'h00000400 /* Full Duplex */
|
159 |
|
|
`define ETH_MODER_RST 32'h00000800 /* Reset MAC */
|
160 |
|
|
`define ETH_MODER_DLYCRCEN 32'h00001000 /* Delayed CRC Enable */
|
161 |
|
|
`define ETH_MODER_CRCEN 32'h00002000 /* CRC Enable */
|
162 |
|
|
`define ETH_MODER_HUGEN 32'h00004000 /* Huge Enable */
|
163 |
|
|
`define ETH_MODER_PAD 32'h00008000 /* Pad Enable */
|
164 |
|
|
`define ETH_MODER_RECSMALL 32'h00010000 /* Receive Small */
|
165 |
|
|
|
166 |
|
|
/* Interrupt Source Register */
|
167 |
|
|
`define ETH_INT_TXB 32'h00000001 /* Transmit Buffer IRQ */
|
168 |
|
|
`define ETH_INT_TXE 32'h00000002 /* Transmit Error IRQ */
|
169 |
209 |
tadejm |
`define ETH_INT_RXB 32'h00000004 /* Receive Buffer IRQ */
|
170 |
116 |
mohor |
`define ETH_INT_RXE 32'h00000008 /* Receive Error IRQ */
|
171 |
|
|
`define ETH_INT_BUSY 32'h00000010 /* Busy IRQ */
|
172 |
|
|
`define ETH_INT_TXC 32'h00000020 /* Transmit Control Frame IRQ */
|
173 |
|
|
`define ETH_INT_RXC 32'h00000040 /* Received Control Frame IRQ */
|
174 |
|
|
|
175 |
|
|
/* Interrupt Mask Register */
|
176 |
|
|
`define ETH_INT_MASK_TXB 32'h00000001 /* Transmit Buffer IRQ Mask */
|
177 |
|
|
`define ETH_INT_MASK_TXE 32'h00000002 /* Transmit Error IRQ Mask */
|
178 |
|
|
`define ETH_INT_MASK_RXF 32'h00000004 /* Receive Frame IRQ Mask */
|
179 |
|
|
`define ETH_INT_MASK_RXE 32'h00000008 /* Receive Error IRQ Mask */
|
180 |
|
|
`define ETH_INT_MASK_BUSY 32'h00000010 /* Busy IRQ Mask */
|
181 |
|
|
`define ETH_INT_MASK_TXC 32'h00000020 /* Transmit Control Frame IRQ Mask */
|
182 |
|
|
`define ETH_INT_MASK_RXC 32'h00000040 /* Received Control Frame IRQ Mask */
|
183 |
|
|
|
184 |
|
|
/* Control Module Mode Register */
|
185 |
|
|
`define ETH_CTRLMODER_PASSALL 32'h00000001 /* Pass Control Frames */
|
186 |
|
|
`define ETH_CTRLMODER_RXFLOW 32'h00000002 /* Receive Control Flow Enable */
|
187 |
|
|
`define ETH_CTRLMODER_TXFLOW 32'h00000004 /* Transmit Control Flow Enable */
|
188 |
|
|
|
189 |
|
|
/* MII Mode Register */
|
190 |
|
|
`define ETH_MIIMODER_CLKDIV 32'h000000FF /* Clock Divider */
|
191 |
|
|
`define ETH_MIIMODER_NOPRE 32'h00000100 /* No Preamble */
|
192 |
169 |
mohor |
`define ETH_MIIMODER_RST 32'h00000200 /* MIIM Reset */
|
193 |
116 |
mohor |
|
194 |
|
|
/* MII Command Register */
|
195 |
|
|
`define ETH_MIICOMMAND_SCANSTAT 32'h00000001 /* Scan Status */
|
196 |
|
|
`define ETH_MIICOMMAND_RSTAT 32'h00000002 /* Read Status */
|
197 |
|
|
`define ETH_MIICOMMAND_WCTRLDATA 32'h00000004 /* Write Control Data */
|
198 |
|
|
|
199 |
|
|
/* MII Address Register */
|
200 |
|
|
`define ETH_MIIADDRESS_FIAD 32'h0000001F /* PHY Address */
|
201 |
|
|
`define ETH_MIIADDRESS_RGAD 32'h00001F00 /* RGAD Address */
|
202 |
|
|
|
203 |
|
|
/* MII Status Register */
|
204 |
169 |
mohor |
`define ETH_MIISTATUS_LINKFAIL 0 /* Link Fail bit */
|
205 |
|
|
`define ETH_MIISTATUS_BUSY 1 /* MII Busy bit */
|
206 |
|
|
`define ETH_MIISTATUS_NVALID 2 /* Data in MII Status Register is invalid bit */
|
207 |
178 |
mohor |
|
208 |
|
|
|
209 |
|
|
`define TIME $display(" Time: %0t", $time)
|