1 |
15 |
dinesha |
|
2 |
|
|
/*-----------------------------------------------------------------\
|
3 |
|
|
| DESCRIPTION: |
|
4 |
|
|
| tb_objs.v: Definitions of global variables and data structures |
|
5 |
|
|
| |
|
6 |
|
|
| Instantiated modules: none |
|
7 |
|
|
| Included files: none |
|
8 |
|
|
\-----------------------------------------------------------------*/
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
/******************** Port parameters ***************************/
|
12 |
|
|
reg [2:0] port_mii_type; // 0 = reduced MII,
|
13 |
|
|
// 1 = full MII
|
14 |
|
|
// 2 = Gigabit MII
|
15 |
|
|
// 3 = Serial MII
|
16 |
|
|
reg port_duplex_status; // 0 = half-duplex, 1 = full
|
17 |
|
|
reg [2:0] port_speed; // 0 = 10 Mb/s, 1 = 100 Mb/s
|
18 |
|
|
// 2 = 1000 Mb/s
|
19 |
|
|
|
20 |
|
|
// Enable flags for ports, set only for active ports
|
21 |
|
|
reg MII_port_tx_enable,
|
22 |
|
|
MII_port_rx_enable,
|
23 |
|
|
RMII_port_tx_enable,
|
24 |
|
|
RMII_port_rx_enable,
|
25 |
|
|
GMII_port_tx_enable,
|
26 |
|
|
GMII_port_rx_enable,
|
27 |
|
|
SMII_port_tx_enable,
|
28 |
|
|
SMII_port_rx_enable,
|
29 |
|
|
SERDES_tx_enable,
|
30 |
|
|
SERDES_rx_enable,
|
31 |
|
|
custom_tx_enable,
|
32 |
|
|
custom_rx_enable;
|
33 |
|
|
|
34 |
|
|
integer port_min_ifg; // Minimum inter-frame gap in bits
|
35 |
|
|
integer current_ifg; // Current inter-frame gap for packet sequence
|
36 |
|
|
integer port_idle_count; // Number of idle bits transmitted
|
37 |
|
|
// before preamble, must be a multiple
|
38 |
|
|
// of the MII data width
|
39 |
|
|
// Default value = 0
|
40 |
|
|
|
41 |
|
|
integer preamble_length; // Length of preamble in bits
|
42 |
|
|
// Includes Start-of-Frame Delimiter (SFD)
|
43 |
|
|
// Range: 0 to 128, default = 64 bits
|
44 |
|
|
reg [127:0] preamble_reg; // Preamble pattern, upto 128 bits long
|
45 |
|
|
// Includes SFD
|
46 |
|
|
// Default = 55_55_55_55_55_55_55_57 hex
|
47 |
|
|
|
48 |
|
|
integer dribble_bit_count; // number of bits buffered in the PHY
|
49 |
|
|
// when carrier sense is deasserted.
|
50 |
|
|
// Must be a multiple of 4 for MII and RMII;
|
51 |
|
|
// and a multiple of 8 for GMII and SMII
|
52 |
|
|
// Default value = 0
|
53 |
|
|
reg carrier_override; // Turns on carrier sense when set.
|
54 |
|
|
// Useful for testing carrier-based flow control
|
55 |
|
|
// Flag overrides normal carrier-sense signal
|
56 |
|
|
|
57 |
|
|
integer frame_extend_bit_count;
|
58 |
|
|
// number of extra bits sent at the end of frame
|
59 |
|
|
// to generate an alignment error
|
60 |
|
|
// Must be a multiple of the particular MII width
|
61 |
|
|
reg [31:0] frame_extend_reg; // The pattern of bits appended
|
62 |
|
|
|
63 |
|
|
// The following variables define the MAC behavior when a PAUSE frame
|
64 |
|
|
// is received
|
65 |
|
|
reg ignore_rcv_pause; // When set, the MAC does not respond
|
66 |
|
|
// to received PAUSE frames
|
67 |
|
|
// Default = 0
|
68 |
|
|
integer pause_increment; // This value is added to the received
|
69 |
|
|
// pause parameter in the PAUSE FRAME
|
70 |
|
|
// Can be set to negative value to
|
71 |
|
|
// model aggressive MAC behavior
|
72 |
|
|
|
73 |
|
|
integer collision_detection_delay;
|
74 |
|
|
// Delay between the actual collision event
|
75 |
|
|
// and the testbench sending the jam pattern
|
76 |
|
|
//(in nanoseconds)
|
77 |
|
|
// This parameter models the PHY delay
|
78 |
|
|
// Default = 0
|
79 |
|
|
reg force_collision; // when set, testbench forces a collision
|
80 |
|
|
// with the next incoming frame
|
81 |
|
|
// and transmits the jamming pattern
|
82 |
|
|
integer collision_offset; // Delay in clock cycles from
|
83 |
|
|
// TX_EN active to the forced collision
|
84 |
|
|
integer forced_collision_count; // Number of collisions
|
85 |
|
|
// to be forced
|
86 |
|
|
reg [31:0] force_collision_delay;
|
87 |
|
|
// variable stores position at which
|
88 |
|
|
// collision is to be forced
|
89 |
|
|
|
90 |
|
|
integer jam_length; // Length of jamming pattern in bits
|
91 |
|
|
// Default = 32 bits of 0101..01 pattern
|
92 |
|
|
|
93 |
|
|
// Collision backoff parameters
|
94 |
|
|
reg [31:0] backoff_slots[`MAX_COLLISIONS: 1];
|
95 |
|
|
// Number of slots to back off
|
96 |
|
|
// on i-th collision
|
97 |
|
|
reg [`MAX_COLLISIONS: 1] backoff_type; // 0 = deterministic backoff
|
98 |
|
|
// 1 = random backoff
|
99 |
|
|
integer collision_limit; // Max collisions allowed
|
100 |
|
|
|
101 |
|
|
/*************************************************************/
|
102 |
|
|
|
103 |
|
|
/**** Flow-level parameters used for packet generation****/
|
104 |
|
|
reg [7:0] flow_type; // flow type
|
105 |
|
|
// Valid flow types are
|
106 |
|
|
// 0 = Layer-2 unicast, 1 = Layer-2 broadcast, 2 = Layer-2 multicast
|
107 |
|
|
// 3 = Layer-3 unicast, 4 = Layer-3 multicast
|
108 |
|
|
// 5 = Layer-4 unicast, 6 = Layer-4 multicast
|
109 |
|
|
|
110 |
|
|
integer L2_protocol_type; // L2 protocol type
|
111 |
|
|
// Valid Layer-2 protocols
|
112 |
|
|
// 0 = Ethernet without VLAN tagging
|
113 |
|
|
// 1 = Ethernet with IEEE 802.1Q tagging
|
114 |
|
|
// 2 = IEEE 802.3 frames without VLAN tagging
|
115 |
|
|
// 3 = IEEE 802.3 frames with 802.1Q tagging
|
116 |
|
|
// 4 = IEEE 802.1d Bridge Protocol Data Units
|
117 |
|
|
|
118 |
|
|
//Layer-2 Header Parameters
|
119 |
|
|
|
120 |
|
|
reg [47:0] L2_src_mac_min, //source MAC addr at transmission
|
121 |
|
|
L2_src_mac_max, //Max for incremental pattern
|
122 |
|
|
L2_src_mac_incr; //increment
|
123 |
|
|
|
124 |
|
|
reg [1:0] L2_src_mac_option; //Option for MAC addr generation
|
125 |
|
|
// 0 = constant MAC addr, 1 = incremental pattern, 2 = random between min and max
|
126 |
|
|
|
127 |
|
|
reg [47:0] L2_dstn_mac_min, // destination MAC addr
|
128 |
|
|
L2_dstn_mac_max, // at transmission
|
129 |
|
|
L2_dstn_mac_incr; // increment for pattern
|
130 |
|
|
|
131 |
|
|
reg [1:0] L2_dstn_mac_option;
|
132 |
|
|
//Option for MAC addr generation
|
133 |
|
|
// 0 = constant MAC addr, 1 = incremental pattern,
|
134 |
|
|
// 2 = random between min and max
|
135 |
|
|
|
136 |
|
|
reg [15:0] L2_type_field; // Type field for Ethernet
|
137 |
|
|
// This type field is used only when the flow type is L2.
|
138 |
|
|
// For L3 and L4 flows, the type field is automatically set
|
139 |
|
|
// based on the L3 protocol used.
|
140 |
|
|
|
141 |
|
|
reg [15:0] L2_VLAN_TCI_min, // VLAN Tag Control Information
|
142 |
|
|
L2_VLAN_TCI_max, // at transmission
|
143 |
|
|
L2_VLAN_TCI_incr; // increment
|
144 |
|
|
reg [1:0] L2_VLAN_TCI_option;
|
145 |
|
|
//Option for VLAN TCI generation
|
146 |
|
|
// 0 = constant, 1 = incremental pattern,
|
147 |
|
|
// 2 = random between min and max
|
148 |
|
|
|
149 |
|
|
reg [15:0] L2_VLAN_TPID; // VLAN TPID field for IEEE 802.1Q
|
150 |
|
|
// default = 8100 hex
|
151 |
|
|
|
152 |
|
|
reg [31:0] L2_frame_size_min, // Min packet size
|
153 |
|
|
L2_frame_size_max, // Max packet size
|
154 |
|
|
L2_frame_size_incr;// packet size increment
|
155 |
|
|
reg [1:0] L2_frame_size_option;
|
156 |
|
|
//Option for packet size
|
157 |
|
|
// 0 = constant, 1 = incremental size
|
158 |
|
|
// 2 = random between min and max
|
159 |
|
|
|
160 |
|
|
reg [`MAX_HEADER_SIZE*8-1:0] L2_LLC_header; // user-defined LLC header
|
161 |
|
|
integer L2_LLC_header_length; // length of LLC header
|
162 |
|
|
reg L2_LLC_header_enable; // enable custom LLC header
|
163 |
|
|
|
164 |
|
|
reg [`MAX_HEADER_SIZE*8-1:0] L2_custom_header;// user_defined L2 header
|
165 |
|
|
integer L2_custom_header_length;// length of
|
166 |
|
|
// user_defined L2 header
|
167 |
|
|
reg L2_custom_header_enable;// enable user-defined
|
168 |
|
|
// L2 header
|
169 |
|
|
|
170 |
|
|
reg [1:0] flowrec_crc_option; // options for CRC generation
|
171 |
|
|
// 0 = Generate and append good CRC
|
172 |
|
|
// 1 = Append bad CRC
|
173 |
|
|
// 2 = Do not append CRC
|
174 |
|
|
// 3 = Append user-defined CRC
|
175 |
|
|
reg [31:0] flowrec_user_crc; // user-defined CRC
|
176 |
|
|
|
177 |
|
|
reg [7:0] L3_protocol_type; // Layer-3 protocol
|
178 |
|
|
// Valid Layer-3 protocols
|
179 |
|
|
// 1 = IGMP Version 1
|
180 |
|
|
// 2 = IGMP Version 2
|
181 |
|
|
// 4 = IP Version 4
|
182 |
|
|
// 6 = IP Version 6 (not supported yet)
|
183 |
|
|
// 7 = ICMP on IP Version 4
|
184 |
|
|
// 8 = TCP/IP ARP
|
185 |
|
|
// 9 = IPX (not supported yet)
|
186 |
|
|
|
187 |
|
|
// Layer-3 Header Parameters
|
188 |
|
|
|
189 |
|
|
reg [31:0] L3_src_address, // IP source address
|
190 |
|
|
L3_dstn_address; // IP destination address
|
191 |
|
|
reg [7:0] L3_TTL; // time to live
|
192 |
|
|
reg [15:0] L3_sequence_number; // IP sequence number field
|
193 |
|
|
// other IP header fields
|
194 |
|
|
reg [7:0] IP_service_type;
|
195 |
|
|
reg [2:0] IP_flags;
|
196 |
|
|
reg [12:0] IP_fragment_offset;
|
197 |
|
|
reg [7:0] IP_protocol_field;
|
198 |
|
|
|
199 |
|
|
reg [`IP_EXTENSION_HEADER_SIZE*8-1:0] IP_ext_header;
|
200 |
|
|
// IP extension header
|
201 |
|
|
reg [31:0] IP_ext_header_length; // length of
|
202 |
|
|
// IP extension header
|
203 |
|
|
|
204 |
|
|
reg [`MAX_HEADER_SIZE*8-1:0] L3_custom_header; // user_defined L3 header
|
205 |
|
|
integer L3_custom_header_length; // length of
|
206 |
|
|
// user_defined L3 header
|
207 |
|
|
reg L3_custom_header_enable; // enable user-defined
|
208 |
|
|
// L3 header
|
209 |
|
|
reg [1:0] L3_checksum_option; // options for L3 checksum
|
210 |
|
|
// 0 = Generate good checksum
|
211 |
|
|
// 1 = Generate bad checksum
|
212 |
|
|
// 2 = Set checkum to zero
|
213 |
|
|
// 3 = Set checksum to user-defined value
|
214 |
|
|
reg [15:0] L3_user_checksum; // user-defined L3 checksum
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
reg [7:0] L4_protocol_type; // Layer-4 protocol
|
219 |
|
|
// Valid Layer-4 protocols
|
220 |
|
|
// 0 = TCP
|
221 |
|
|
// 1 = UDP
|
222 |
|
|
|
223 |
|
|
reg [15:0] L4_src_port, // TCP or UDP port numbers
|
224 |
|
|
L4_dstn_port;
|
225 |
|
|
|
226 |
|
|
reg [31:0] L4_sequence_number,
|
227 |
|
|
L4_ack_number; // TCP sequence and ack numbers
|
228 |
|
|
reg [5:0] TCP_flags; // flags in the TCP header (6 bits)
|
229 |
|
|
reg [15:0] TCP_urgent_pointer; // Urgent pointer in TCP header;
|
230 |
|
|
reg [15:0] TCP_window_size; // Window size in TCP header;
|
231 |
|
|
|
232 |
|
|
reg [`MAX_HEADER_SIZE*8-1:0] L4_custom_header; // user_defined L4 header
|
233 |
|
|
integer L4_custom_header_length; // length of
|
234 |
|
|
// user_defined L4 header
|
235 |
|
|
reg L4_custom_header_enable; // enable user-defined
|
236 |
|
|
// L4 header
|
237 |
|
|
|
238 |
|
|
reg [1:0] L4_checksum_option; // options for L4 checksum
|
239 |
|
|
// 0 = Generate good checksum
|
240 |
|
|
// 1 = Generate bad checksum
|
241 |
|
|
// 2 = Set checkum to zero
|
242 |
|
|
// 3 = Set checksum to user-defined value
|
243 |
|
|
reg [15:0 ] L4_user_checksum; // user-defined L4 checksum
|
244 |
|
|
|
245 |
|
|
// Payload variables
|
246 |
|
|
reg [1:0] payload_option; // Option for setting payload of
|
247 |
|
|
// transmitted packets
|
248 |
|
|
// 0 = send increasing sequence of bytes
|
249 |
|
|
// 1 = send decreasing sequence of bytes
|
250 |
|
|
// 2 = random payload
|
251 |
|
|
// 3 = user-defined payload
|
252 |
|
|
reg [7:0] payload_start; // starting value for payload sequence
|
253 |
|
|
reg [`MAX_PKT_SIZE*8-1:0] user_payload;// buffer to hold user-defined payload
|
254 |
|
|
integer payload_length; // max size of payload in bytes for L3 and L4 flows
|
255 |
|
|
|
256 |
|
|
integer L3_header_position, // offsets for various headers
|
257 |
|
|
L4_header_position, // in frame
|
258 |
|
|
payload_position;
|
259 |
|
|
|
260 |
|
|
/***************End of flow records *************************/
|
261 |
|
|
// global options
|
262 |
|
|
|
263 |
|
|
reg seqno_enable; // flag to enable insertion of
|
264 |
|
|
// seq numbers in transmitted frames
|
265 |
|
|
integer seq_number_offset; // position of seq number transmitted within frame
|
266 |
|
|
// set to negative value for insertion at end of frame
|
267 |
|
|
reg timestamp_enable; // flag to enable insertion of
|
268 |
|
|
// timestamps in transmitted frames
|
269 |
|
|
integer timestamp_offset; // position of timestamp transmitted within frame
|
270 |
|
|
// set to negative value for insertion at end of frame
|
271 |
|
|
|
272 |
|
|
reg [31:0] packet_seq_no; // Sequence number of packet
|
273 |
|
|
|
274 |
|
|
reg [31:0] packet_timestamp; // timestamp in packet
|
275 |
|
|
/********************************************************************************/
|
276 |
|
|
|
277 |
|
|
reg [31:0] event_file; // handle to event log file
|
278 |
|
|
reg [31:0] outfile; // handle to param log file
|
279 |
|
|
/*************************************************************/
|
280 |
|
|
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
|
284 |
|
|
|