1 |
13 |
barabba |
|
2 |
|
|
//-----------------------------------------------------------------------------
|
3 |
|
|
//
|
4 |
|
|
// (c) Copyright 2009-2011 Xilinx, Inc. All rights reserved.
|
5 |
|
|
//
|
6 |
|
|
// This file contains confidential and proprietary information
|
7 |
|
|
// of Xilinx, Inc. and is protected under U.S. and
|
8 |
|
|
// international copyright and other intellectual property
|
9 |
|
|
// laws.
|
10 |
|
|
//
|
11 |
|
|
// DISCLAIMER
|
12 |
|
|
// This disclaimer is not a license and does not grant any
|
13 |
|
|
// rights to the materials distributed herewith. Except as
|
14 |
|
|
// otherwise provided in a valid license issued to you by
|
15 |
|
|
// Xilinx, and to the maximum extent permitted by applicable
|
16 |
|
|
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
|
17 |
|
|
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
|
18 |
|
|
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
|
19 |
|
|
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
|
20 |
|
|
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
|
21 |
|
|
// (2) Xilinx shall not be liable (whether in contract or tort,
|
22 |
|
|
// including negligence, or under any other theory of
|
23 |
|
|
// liability) for any loss or damage of any kind or nature
|
24 |
|
|
// related to, arising under or in connection with these
|
25 |
|
|
// materials, including for any direct, or any indirect,
|
26 |
|
|
// special, incidental, or consequential loss or damage
|
27 |
|
|
// (including loss of data, profits, goodwill, or any type of
|
28 |
|
|
// loss or damage suffered as a result of any action brought
|
29 |
|
|
// by a third party) even if such damage or loss was
|
30 |
|
|
// reasonably foreseeable or Xilinx had been advised of the
|
31 |
|
|
// possibility of the same.
|
32 |
|
|
//
|
33 |
|
|
// CRITICAL APPLICATIONS
|
34 |
|
|
// Xilinx products are not designed or intended to be fail-
|
35 |
|
|
// safe, or for use in any application requiring fail-safe
|
36 |
|
|
// performance, such as life-support or safety devices or
|
37 |
|
|
// systems, Class III medical devices, nuclear facilities,
|
38 |
|
|
// applications related to the deployment of airbags, or any
|
39 |
|
|
// other applications that could lead to death, personal
|
40 |
|
|
// injury, or severe property or environmental damage
|
41 |
|
|
// (individually and collectively, "Critical
|
42 |
|
|
// Applications"). Customer assumes the sole risk and
|
43 |
|
|
// liability of any use of Xilinx products in Critical
|
44 |
|
|
// Applications, subject only to applicable laws and
|
45 |
|
|
// regulations governing limitations on product liability.
|
46 |
|
|
//
|
47 |
|
|
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
|
48 |
|
|
// PART OF THIS FILE AT ALL TIMES.
|
49 |
|
|
//
|
50 |
|
|
//-----------------------------------------------------------------------------
|
51 |
|
|
// Project : Virtex-6 Integrated Block for PCI Express
|
52 |
|
|
// File : pci_exp_expect_tasks.v
|
53 |
|
|
// Version : 1.7
|
54 |
|
|
//--------------------------------------------------------------------------------
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
`define EXPECT_CPLD_PAYLOAD board.RP.tx_usrapp.expect_cpld_payload
|
58 |
|
|
`define EXPECT_MEMWR_PAYLOAD board.RP.tx_usrapp.expect_memwr_payload
|
59 |
|
|
`define EXPECT_MEMWR64_PAYLOAD board.RP.tx_usrapp.expect_memwr64_payload
|
60 |
|
|
|
61 |
|
|
reg [31:0] error_file_ptr;
|
62 |
|
|
|
63 |
|
|
initial
|
64 |
|
|
begin
|
65 |
|
|
error_file_ptr = $fopen("error.dat");
|
66 |
|
|
if (!error_file_ptr) begin
|
67 |
|
|
$write("ERROR: Could not open error.dat.\n");
|
68 |
|
|
$finish;
|
69 |
|
|
end
|
70 |
|
|
end
|
71 |
|
|
|
72 |
|
|
/************************************************************
|
73 |
|
|
Task : TSK_EXPECT_CPLD
|
74 |
|
|
Inputs : traffic_class, td, ep, attr, length, payload
|
75 |
|
|
Outputs : status 0-Failed 1-Successful
|
76 |
|
|
Description : Expecting a TLP from Rx side with matching
|
77 |
|
|
traffic_class, td, ep, attr, length and payload
|
78 |
|
|
*************************************************************/
|
79 |
|
|
task TSK_EXPECT_CPLD;
|
80 |
|
|
|
81 |
|
|
input [2:0] traffic_class;
|
82 |
|
|
input td;
|
83 |
|
|
input ep;
|
84 |
|
|
input [1:0] attr;
|
85 |
|
|
input [9:0] length;
|
86 |
|
|
input [15:0] completer_id;
|
87 |
|
|
input [2:0] completion_status;
|
88 |
|
|
input bcm;
|
89 |
|
|
input [11:0] byte_count;
|
90 |
|
|
input [15:0] requester_id;
|
91 |
|
|
input [7:0] tag;
|
92 |
|
|
input [6:0] address_low;
|
93 |
|
|
|
94 |
|
|
output expect_status;
|
95 |
|
|
|
96 |
|
|
reg [2:0] traffic_class_;
|
97 |
|
|
reg td_;
|
98 |
|
|
reg ep_;
|
99 |
|
|
reg [1:0] attr_;
|
100 |
|
|
reg [9:0] length_;
|
101 |
|
|
reg [15:0] completer_id_;
|
102 |
|
|
reg [2:0] completion_status_;
|
103 |
|
|
reg bcm_;
|
104 |
|
|
reg [11:0] byte_count_;
|
105 |
|
|
reg [15:0] requester_id_;
|
106 |
|
|
reg [7:0] tag_;
|
107 |
|
|
reg [6:0] address_low_;
|
108 |
|
|
|
109 |
|
|
integer payload_len;
|
110 |
|
|
integer i_;
|
111 |
|
|
reg wait_for_next;
|
112 |
|
|
|
113 |
|
|
begin
|
114 |
|
|
wait_for_next = 1'b1; //haven't found any matching tag yet
|
115 |
|
|
while(wait_for_next)
|
116 |
|
|
begin
|
117 |
|
|
@ rcvd_cpld; //wait for a rcvd_cpld event
|
118 |
|
|
traffic_class_ = frame_store_rx[1] >> 4;
|
119 |
|
|
td_ = frame_store_rx[2] >> 7;
|
120 |
|
|
ep_ = frame_store_rx[2] >> 6;
|
121 |
|
|
attr_ = frame_store_rx[2] >> 4;
|
122 |
|
|
length_ = frame_store_rx[2];
|
123 |
|
|
length_ = (length_ << 8) | (frame_store_rx[3]);
|
124 |
|
|
bcm_ = frame_store_rx[6] >> 4;
|
125 |
|
|
completion_status_= frame_store_rx[6] >> 5;
|
126 |
|
|
byte_count_ = (frame_store_rx[6]);
|
127 |
|
|
byte_count_ = (byte_count_ << 8) | frame_store_rx[7];
|
128 |
|
|
completer_id_ = {frame_store_rx[4], frame_store_rx[5]};
|
129 |
|
|
requester_id_= {frame_store_rx[8], frame_store_rx[9]};
|
130 |
|
|
tag_= frame_store_rx[10];
|
131 |
|
|
address_low_ = frame_store_rx[11];
|
132 |
|
|
|
133 |
|
|
payload_len = (bcm_) ? byte_count_ : (length << 2);
|
134 |
|
|
if (payload_len==0) payload_len = 4096;
|
135 |
|
|
|
136 |
|
|
$display("[%t] : Received CPLD --- Tag 0x%h", $realtime, tag_);
|
137 |
|
|
if(tag == tag_) //find matching tag
|
138 |
|
|
begin
|
139 |
|
|
wait_for_next = 1'b0;
|
140 |
|
|
if((traffic_class == traffic_class_) &&
|
141 |
|
|
(td === td_) && (ep == ep_) && (attr == attr_) &&
|
142 |
|
|
(length == length_) && (bcm == bcm_) &&
|
143 |
|
|
(completion_status == completion_status_) &&
|
144 |
|
|
(byte_count == byte_count_) &&
|
145 |
|
|
(completer_id == completer_id_) &&
|
146 |
|
|
(requester_id == requester_id_) &&
|
147 |
|
|
(address_low == address_low_))
|
148 |
|
|
begin
|
149 |
|
|
// find matching header then compare payload
|
150 |
|
|
for (i_ = 0; i_ < payload_len; i_ = i_ + 1)
|
151 |
|
|
if(`EXPECT_CPLD_PAYLOAD[i_] != frame_store_rx[12 + i_]) //find mismatch
|
152 |
|
|
begin
|
153 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found payload mismatch in received CPLD - Tag 0x%h: \n", $time, tag_);
|
154 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
155 |
|
|
for (i_ = 0; i_ < payload_len; i_ = i_ + 1)
|
156 |
|
|
$fdisplay(error_file_ptr,"\t %0x", `EXPECT_CPLD_PAYLOAD[i_]);
|
157 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
158 |
|
|
for (i_ = 0; i_ < payload_len; i_ = i_ + 1)
|
159 |
|
|
$fdisplay(error_file_ptr,"\t %0x", frame_store_rx[12+i_]);
|
160 |
|
|
|
161 |
|
|
$fdisplay(error_file_ptr, "");
|
162 |
|
|
expect_status = 1'b0;
|
163 |
|
|
i_ = 5000;
|
164 |
|
|
end
|
165 |
|
|
//find matching frame
|
166 |
|
|
if(i_ == payload_len)
|
167 |
|
|
expect_status = 1'b1;
|
168 |
|
|
end
|
169 |
|
|
else // header mismatches, error out
|
170 |
|
|
begin
|
171 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found header mismatch in received CPLD - Tag 0x%h: \n", $time, tag_);
|
172 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
173 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
174 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td);
|
175 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep);
|
176 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr);
|
177 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length);
|
178 |
|
|
$fdisplay(error_file_ptr, "\t BCM: 0x%h", bcm);
|
179 |
|
|
$fdisplay(error_file_ptr, "\t Completion Status: 0x%h", completion_status);
|
180 |
|
|
$fdisplay(error_file_ptr, "\t Byte Count: 0x%h", byte_count);
|
181 |
|
|
$fdisplay(error_file_ptr, "\t Completer ID: 0x%h", completer_id);
|
182 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id);
|
183 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag);
|
184 |
|
|
$fdisplay(error_file_ptr, "\t Lower Address: 0x%h", address_low);
|
185 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
186 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_);
|
187 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td_);
|
188 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep_);
|
189 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_);
|
190 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length_);
|
191 |
|
|
$fdisplay(error_file_ptr, "\t BCM: 0x%h", bcm_);
|
192 |
|
|
$fdisplay(error_file_ptr, "\t Completion Status: 0x%h", completion_status_);
|
193 |
|
|
$fdisplay(error_file_ptr, "\t Byte Count: 0x%h", byte_count_);
|
194 |
|
|
$fdisplay(error_file_ptr, "\t Completer ID: 0x%h", completer_id_);
|
195 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_);
|
196 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_);
|
197 |
|
|
$fdisplay(error_file_ptr, "\t Lower Address: 0x%h", address_low_);
|
198 |
|
|
$fdisplay(error_file_ptr, "");
|
199 |
|
|
expect_status = 1'b0;
|
200 |
|
|
end
|
201 |
|
|
end
|
202 |
|
|
end
|
203 |
|
|
end
|
204 |
|
|
endtask
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
/************************************************************
|
208 |
|
|
Task : TSK_EXPECT_CPL
|
209 |
|
|
Inputs : traffic_class, td, ep, attr, length, payload
|
210 |
|
|
Outputs : status 0-Failed 1-Successful
|
211 |
|
|
Description : Expecting a TLP from Rx side with matching
|
212 |
|
|
traffic_class, td, ep, attr and length
|
213 |
|
|
*************************************************************/
|
214 |
|
|
task TSK_EXPECT_CPL;
|
215 |
|
|
|
216 |
|
|
input [2:0] traffic_class;
|
217 |
|
|
input td;
|
218 |
|
|
input ep;
|
219 |
|
|
input [1:0] attr;
|
220 |
|
|
input [15:0] completer_id;
|
221 |
|
|
input [2:0] completion_status;
|
222 |
|
|
input bcm;
|
223 |
|
|
input [11:0] byte_count;
|
224 |
|
|
input [15:0] requester_id;
|
225 |
|
|
input [7:0] tag;
|
226 |
|
|
input [6:0] address_low;
|
227 |
|
|
|
228 |
|
|
output expect_status;
|
229 |
|
|
|
230 |
|
|
reg [2:0] traffic_class_;
|
231 |
|
|
reg td_;
|
232 |
|
|
reg ep_;
|
233 |
|
|
reg [1:0] attr_;
|
234 |
|
|
reg [15:0] completer_id_;
|
235 |
|
|
reg [2:0] completion_status_;
|
236 |
|
|
reg bcm_;
|
237 |
|
|
reg [11:0] byte_count_;
|
238 |
|
|
reg [15:0] requester_id_;
|
239 |
|
|
reg [7:0] tag_;
|
240 |
|
|
reg [6:0] address_low_;
|
241 |
|
|
|
242 |
|
|
integer i_;
|
243 |
|
|
reg wait_for_next;
|
244 |
|
|
|
245 |
|
|
begin
|
246 |
|
|
wait_for_next = 1'b1; //haven't found any matching tag yet
|
247 |
|
|
while(wait_for_next)
|
248 |
|
|
begin
|
249 |
|
|
@ rcvd_cpl; //wait for a rcvd_cpl event
|
250 |
|
|
traffic_class_ = frame_store_rx[1] >> 4;
|
251 |
|
|
td_ = frame_store_rx[2] >> 7;
|
252 |
|
|
ep_ = frame_store_rx[2] >> 6;
|
253 |
|
|
attr_ = frame_store_rx[2] >> 4;
|
254 |
|
|
bcm_ = frame_store_rx[6] >> 4;
|
255 |
|
|
completion_status_= frame_store_rx[6] >> 5;
|
256 |
|
|
byte_count_ = (frame_store_rx[6]);
|
257 |
|
|
byte_count_ = (byte_count_ << 8) | frame_store_rx[7];
|
258 |
|
|
completer_id_ = {frame_store_rx[4], frame_store_rx[5]};
|
259 |
|
|
requester_id_= {frame_store_rx[8], frame_store_rx[9]};
|
260 |
|
|
tag_= frame_store_rx[10];
|
261 |
|
|
address_low_ = frame_store_rx[11];
|
262 |
|
|
|
263 |
|
|
$display("[%t] : Received CPL --- Tag 0x%h", $realtime, tag_);
|
264 |
|
|
if(tag == tag_) //find matching tag
|
265 |
|
|
begin
|
266 |
|
|
wait_for_next = 1'b0;
|
267 |
|
|
if((traffic_class == traffic_class_) &&
|
268 |
|
|
(td === td_) && (ep == ep_) && (attr == attr_) &&
|
269 |
|
|
(bcm == bcm_) && (completion_status == completion_status_) &&
|
270 |
|
|
(byte_count == byte_count_) &&
|
271 |
|
|
(completer_id == completer_id_) &&
|
272 |
|
|
(requester_id == requester_id_) &&
|
273 |
|
|
(address_low == address_low_))
|
274 |
|
|
begin
|
275 |
|
|
// header matches
|
276 |
|
|
expect_status = 1'b1;
|
277 |
|
|
end
|
278 |
|
|
else // header mismatches, error out
|
279 |
|
|
begin
|
280 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found header mismatch in received CPL - Tag 0x%h: \n", $time, tag_);
|
281 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
282 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
283 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td);
|
284 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep);
|
285 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr);
|
286 |
|
|
$fdisplay(error_file_ptr, "\t BCM: 0x%h", bcm);
|
287 |
|
|
$fdisplay(error_file_ptr, "\t Completion Status: 0x%h", completion_status);
|
288 |
|
|
$fdisplay(error_file_ptr, "\t Byte Count: 0x%h", byte_count);
|
289 |
|
|
$fdisplay(error_file_ptr, "\t Completer ID: 0x%h", completer_id);
|
290 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id);
|
291 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag);
|
292 |
|
|
$fdisplay(error_file_ptr, "\t Lower Address: 0x%h", address_low);
|
293 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
294 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_);
|
295 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td_);
|
296 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep_);
|
297 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_);
|
298 |
|
|
$fdisplay(error_file_ptr, "\t BCM: 0x%h", bcm_);
|
299 |
|
|
$fdisplay(error_file_ptr, "\t Completion Status: 0x%h", completion_status_);
|
300 |
|
|
$fdisplay(error_file_ptr, "\t Byte Count: 0x%h", byte_count_);
|
301 |
|
|
$fdisplay(error_file_ptr, "\t Completer ID: 0x%h", completer_id_);
|
302 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_);
|
303 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_);
|
304 |
|
|
$fdisplay(error_file_ptr, "\t Lower Address: 0x%h", address_low_);
|
305 |
|
|
$fdisplay(error_file_ptr, "");
|
306 |
|
|
expect_status = 1'b0;
|
307 |
|
|
end
|
308 |
|
|
end
|
309 |
|
|
end
|
310 |
|
|
end
|
311 |
|
|
endtask
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
/************************************************************
|
315 |
|
|
Task : TSK_EXPECT_MEMRD
|
316 |
|
|
Inputs : traffic_class, td, ep, attr, length, last_dw_be,
|
317 |
|
|
first_dw_be, address
|
318 |
|
|
Outputs : status 0-Failed 1-Successful
|
319 |
|
|
Description : Expecting a memory read (32-bit address) TLP
|
320 |
|
|
from Rx side with matching header fields
|
321 |
|
|
*************************************************************/
|
322 |
|
|
task TSK_EXPECT_MEMRD;
|
323 |
|
|
|
324 |
|
|
input [2:0] traffic_class;
|
325 |
|
|
input td;
|
326 |
|
|
input ep;
|
327 |
|
|
input [1:0] attr;
|
328 |
|
|
input [9:0] length;
|
329 |
|
|
input [15:0] requester_id;
|
330 |
|
|
input [7:0] tag;
|
331 |
|
|
input [3:0] last_dw_be;
|
332 |
|
|
input [3:0] first_dw_be;
|
333 |
|
|
input [29:0] address;
|
334 |
|
|
|
335 |
|
|
output expect_status;
|
336 |
|
|
|
337 |
|
|
reg [2:0] traffic_class_;
|
338 |
|
|
reg td_;
|
339 |
|
|
reg ep_;
|
340 |
|
|
reg [1:0] attr_;
|
341 |
|
|
reg [9:0] length_;
|
342 |
|
|
reg [15:0] requester_id_;
|
343 |
|
|
reg [7:0] tag_;
|
344 |
|
|
reg [3:0] last_dw_be_;
|
345 |
|
|
reg [3:0] first_dw_be_;
|
346 |
|
|
reg [29:0] address_;
|
347 |
|
|
|
348 |
|
|
integer i_;
|
349 |
|
|
reg wait_for_next;
|
350 |
|
|
|
351 |
|
|
begin
|
352 |
|
|
wait_for_next = 1'b1; //haven't found any matching tag yet
|
353 |
|
|
while(wait_for_next)
|
354 |
|
|
begin
|
355 |
|
|
@ rcvd_memrd; //wait for a rcvd_memrd event
|
356 |
|
|
traffic_class_ = frame_store_rx[1] >> 4;
|
357 |
|
|
td_ = frame_store_rx[2] >> 7;
|
358 |
|
|
ep_ = frame_store_rx[2] >> 6;
|
359 |
|
|
attr_ = frame_store_rx[2] >> 4;
|
360 |
|
|
length_ = frame_store_rx[2];
|
361 |
|
|
length_ = (length_ << 8) | (frame_store_rx[3]);
|
362 |
|
|
requester_id_= {frame_store_rx[4], frame_store_rx[5]};
|
363 |
|
|
tag_= frame_store_rx[6];
|
364 |
|
|
last_dw_be_= frame_store_rx[7] >> 4;
|
365 |
|
|
first_dw_be_= frame_store_rx[7];
|
366 |
|
|
address_[29:6] = {frame_store_rx[8], frame_store_rx[9], frame_store_rx[10]};
|
367 |
|
|
address_[5:0] = frame_store_rx[11] >> 2;
|
368 |
|
|
|
369 |
|
|
$display("[%t] : Received MEMRD --- Tag 0x%h", $realtime, tag_);
|
370 |
|
|
if(tag == tag_) //find matching tag
|
371 |
|
|
begin
|
372 |
|
|
wait_for_next = 1'b0;
|
373 |
|
|
if((traffic_class == traffic_class_) &&
|
374 |
|
|
(td === td_) && (ep == ep_) && (attr == attr_) &&
|
375 |
|
|
(length == length_) && (requester_id == requester_id_) &&
|
376 |
|
|
(last_dw_be == last_dw_be_) && (first_dw_be == first_dw_be_) &&
|
377 |
|
|
(address == address_))
|
378 |
|
|
begin
|
379 |
|
|
// header matches
|
380 |
|
|
expect_status = 1'b1;
|
381 |
|
|
end
|
382 |
|
|
else // header mismatches, error out
|
383 |
|
|
begin
|
384 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found header mismatch in received MEMRD - Tag 0x%h: \n", $time, tag_);
|
385 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
386 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
387 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td);
|
388 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep);
|
389 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr);
|
390 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length);
|
391 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id);
|
392 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag);
|
393 |
|
|
$fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be);
|
394 |
|
|
$fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be);
|
395 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address);
|
396 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
397 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_);
|
398 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td_);
|
399 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep_);
|
400 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_);
|
401 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length_);
|
402 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_);
|
403 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_);
|
404 |
|
|
$fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be_);
|
405 |
|
|
$fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be_);
|
406 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address_);
|
407 |
|
|
$fdisplay(error_file_ptr, "");
|
408 |
|
|
expect_status = 1'b0;
|
409 |
|
|
end
|
410 |
|
|
end
|
411 |
|
|
end
|
412 |
|
|
end
|
413 |
|
|
endtask
|
414 |
|
|
|
415 |
|
|
|
416 |
|
|
/************************************************************
|
417 |
|
|
Task : TSK_EXPECT_MEMRD64
|
418 |
|
|
Inputs : traffic_class, td, ep, attr, length, last_dw_be,
|
419 |
|
|
first_dw_be, address
|
420 |
|
|
Outputs : status 0-Failed 1-Successful
|
421 |
|
|
Description : Expecting a memory read (64-bit address) TLP
|
422 |
|
|
from Rx side with matching header fields
|
423 |
|
|
*************************************************************/
|
424 |
|
|
task TSK_EXPECT_MEMRD64;
|
425 |
|
|
|
426 |
|
|
input [2:0] traffic_class;
|
427 |
|
|
input td;
|
428 |
|
|
input ep;
|
429 |
|
|
input [1:0] attr;
|
430 |
|
|
input [9:0] length;
|
431 |
|
|
input [15:0] requester_id;
|
432 |
|
|
input [7:0] tag;
|
433 |
|
|
input [3:0] last_dw_be;
|
434 |
|
|
input [3:0] first_dw_be;
|
435 |
|
|
input [61:0] address;
|
436 |
|
|
|
437 |
|
|
output expect_status;
|
438 |
|
|
|
439 |
|
|
reg [2:0] traffic_class_;
|
440 |
|
|
reg td_;
|
441 |
|
|
reg ep_;
|
442 |
|
|
reg [1:0] attr_;
|
443 |
|
|
reg [9:0] length_;
|
444 |
|
|
reg [15:0] requester_id_;
|
445 |
|
|
reg [7:0] tag_;
|
446 |
|
|
reg [3:0] last_dw_be_;
|
447 |
|
|
reg [3:0] first_dw_be_;
|
448 |
|
|
reg [61:0] address_;
|
449 |
|
|
|
450 |
|
|
integer i_;
|
451 |
|
|
reg wait_for_next;
|
452 |
|
|
|
453 |
|
|
begin
|
454 |
|
|
wait_for_next = 1'b1; //haven't found any matching tag yet
|
455 |
|
|
while(wait_for_next)
|
456 |
|
|
begin
|
457 |
|
|
@ rcvd_memrd64; //wait for a rcvd_memrd64 event
|
458 |
|
|
traffic_class_ = frame_store_rx[1] >> 4;
|
459 |
|
|
td_ = frame_store_rx[2] >> 7;
|
460 |
|
|
ep_ = frame_store_rx[2] >> 6;
|
461 |
|
|
attr_ = frame_store_rx[2] >> 4;
|
462 |
|
|
length_ = frame_store_rx[2];
|
463 |
|
|
length_ = (length_ << 8) | (frame_store_rx[3]);
|
464 |
|
|
requester_id_= {frame_store_rx[4], frame_store_rx[5]};
|
465 |
|
|
tag_= frame_store_rx[6];
|
466 |
|
|
last_dw_be_= frame_store_rx[7] >> 4;
|
467 |
|
|
first_dw_be_= frame_store_rx[7];
|
468 |
|
|
address_[61:6] = {frame_store_rx[8], frame_store_rx[9],
|
469 |
|
|
frame_store_rx[10], frame_store_rx[11],
|
470 |
|
|
frame_store_rx[12], frame_store_rx[13],
|
471 |
|
|
frame_store_rx[14]};
|
472 |
|
|
address_[5:0] = frame_store_rx[15] >> 2;
|
473 |
|
|
|
474 |
|
|
$display("[%t] : Received MEMRD64 --- Tag 0x%h", $realtime, tag_);
|
475 |
|
|
if(tag == tag_) //find matching tag
|
476 |
|
|
begin
|
477 |
|
|
wait_for_next = 1'b0;
|
478 |
|
|
if((traffic_class == traffic_class_) &&
|
479 |
|
|
(td === td_) && (ep == ep_) && (attr == attr_) &&
|
480 |
|
|
(length == length_) && (requester_id == requester_id_) &&
|
481 |
|
|
(last_dw_be == last_dw_be_) && (first_dw_be == first_dw_be_) &&
|
482 |
|
|
(address == address_))
|
483 |
|
|
begin
|
484 |
|
|
// header matches
|
485 |
|
|
expect_status = 1'b1;
|
486 |
|
|
end
|
487 |
|
|
else // header mismatches, error out
|
488 |
|
|
begin
|
489 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found header mismatch in received MEMRD64 - Tag 0x%h: \n", $time, tag_);
|
490 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
491 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
492 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td);
|
493 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep);
|
494 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr);
|
495 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length);
|
496 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id);
|
497 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag);
|
498 |
|
|
$fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be);
|
499 |
|
|
$fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be);
|
500 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address);
|
501 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
502 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_);
|
503 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td_);
|
504 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep_);
|
505 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_);
|
506 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length_);
|
507 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_);
|
508 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_);
|
509 |
|
|
$fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be_);
|
510 |
|
|
$fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be_);
|
511 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address_);
|
512 |
|
|
$fdisplay(error_file_ptr, "");
|
513 |
|
|
expect_status = 1'b0;
|
514 |
|
|
end
|
515 |
|
|
end
|
516 |
|
|
end
|
517 |
|
|
end
|
518 |
|
|
endtask
|
519 |
|
|
|
520 |
|
|
|
521 |
|
|
/************************************************************
|
522 |
|
|
Task : TSK_EXPECT_MEMWR
|
523 |
|
|
Inputs : traffic_class, td, ep, attr, length, last_dw_be,
|
524 |
|
|
first_dw_be, address
|
525 |
|
|
Outputs : status 0-Failed 1-Successful
|
526 |
|
|
Description : Expecting a memory write (32-bit address) TLP
|
527 |
|
|
from Rx side with matching header fields and
|
528 |
|
|
payload
|
529 |
|
|
*************************************************************/
|
530 |
|
|
task TSK_EXPECT_MEMWR;
|
531 |
|
|
|
532 |
|
|
input [2:0] traffic_class;
|
533 |
|
|
input td;
|
534 |
|
|
input ep;
|
535 |
|
|
input [1:0] attr;
|
536 |
|
|
input [9:0] length;
|
537 |
|
|
input [15:0] requester_id;
|
538 |
|
|
input [7:0] tag;
|
539 |
|
|
input [3:0] last_dw_be;
|
540 |
|
|
input [3:0] first_dw_be;
|
541 |
|
|
input [29:0] address;
|
542 |
|
|
|
543 |
|
|
output expect_status;
|
544 |
|
|
|
545 |
|
|
reg [2:0] traffic_class_;
|
546 |
|
|
reg td_;
|
547 |
|
|
reg ep_;
|
548 |
|
|
reg [1:0] attr_;
|
549 |
|
|
reg [9:0] length_;
|
550 |
|
|
reg [15:0] requester_id_;
|
551 |
|
|
reg [7:0] tag_;
|
552 |
|
|
reg [3:0] last_dw_be_;
|
553 |
|
|
reg [3:0] first_dw_be_;
|
554 |
|
|
reg [29:0] address_;
|
555 |
|
|
|
556 |
|
|
integer payload_len;
|
557 |
|
|
integer i_;
|
558 |
|
|
reg wait_for_next;
|
559 |
|
|
reg check_byte;
|
560 |
|
|
|
561 |
|
|
begin
|
562 |
|
|
wait_for_next = 1'b1; //haven't found any matching tag yet
|
563 |
|
|
while(wait_for_next)
|
564 |
|
|
begin
|
565 |
|
|
@ rcvd_memwr; //wait for a rcvd_memwr event
|
566 |
|
|
traffic_class_ = frame_store_rx[1] >> 4;
|
567 |
|
|
td_ = frame_store_rx[2] >> 7;
|
568 |
|
|
ep_ = frame_store_rx[2] >> 6;
|
569 |
|
|
attr_ = frame_store_rx[2] >> 4;
|
570 |
|
|
length_ = frame_store_rx[2];
|
571 |
|
|
length_ = (length_ << 8) | (frame_store_rx[3]);
|
572 |
|
|
requester_id_= {frame_store_rx[4], frame_store_rx[5]};
|
573 |
|
|
tag_= frame_store_rx[6];
|
574 |
|
|
last_dw_be_= frame_store_rx[7] >> 4;
|
575 |
|
|
first_dw_be_= frame_store_rx[7];
|
576 |
|
|
address_[29:6] = {frame_store_rx[8], frame_store_rx[9], frame_store_rx[10]};
|
577 |
|
|
address_[5:0] = frame_store_rx[11] >> 2;
|
578 |
|
|
|
579 |
|
|
payload_len = (length << 2);
|
580 |
|
|
if (payload_len==0) payload_len = 4096;
|
581 |
|
|
|
582 |
|
|
$display("[%t] : Received MEMWR --- Tag 0x%h", $realtime, tag_);
|
583 |
|
|
if(tag == tag_) //find matching tag
|
584 |
|
|
begin
|
585 |
|
|
wait_for_next = 1'b0;
|
586 |
|
|
if((traffic_class == traffic_class_) &&
|
587 |
|
|
(td === td_) && (ep == ep_) && (attr == attr_) &&
|
588 |
|
|
(length == length_) && (requester_id == requester_id_) &&
|
589 |
|
|
(last_dw_be == last_dw_be_) && (first_dw_be == first_dw_be_) &&
|
590 |
|
|
(address == address_))
|
591 |
|
|
begin
|
592 |
|
|
// find matching header then compare payload
|
593 |
|
|
for (i_ = 0; i_ < payload_len; i_ = i_ + 1)
|
594 |
|
|
begin
|
595 |
|
|
check_byte = 1;
|
596 |
|
|
if (i_ < 4) // apply first_dw_be
|
597 |
|
|
begin
|
598 |
|
|
if (first_dw_be[i_])
|
599 |
|
|
check_byte = 1;
|
600 |
|
|
else
|
601 |
|
|
check_byte = 0;
|
602 |
|
|
end else if (i_ > (payload_len - 5)) // apply last_dw_be
|
603 |
|
|
begin
|
604 |
|
|
if (last_dw_be[4 - (payload_len - i_)])
|
605 |
|
|
check_byte = 1;
|
606 |
|
|
else
|
607 |
|
|
check_byte = 0;
|
608 |
|
|
end
|
609 |
|
|
if(check_byte && `EXPECT_MEMWR_PAYLOAD[i_] != frame_store_rx[12 + i_]) //find mismatch
|
610 |
|
|
begin
|
611 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found payload mismatch in received MEMWR - Tag 0x%h: \n", $time, tag_);
|
612 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
613 |
|
|
for (i_ = 0; i_ < payload_len; i_ = i_ + 1)
|
614 |
|
|
$fdisplay(error_file_ptr,"\t %0x", `EXPECT_MEMWR_PAYLOAD[i_]);
|
615 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
616 |
|
|
for (i_ = 0; i_ < payload_len; i_ = i_ + 1)
|
617 |
|
|
$fdisplay(error_file_ptr,"\t %0x", frame_store_rx[12+i_]);
|
618 |
|
|
|
619 |
|
|
$fdisplay(error_file_ptr, "");
|
620 |
|
|
expect_status = 1'b0;
|
621 |
|
|
i_ = 5000;
|
622 |
|
|
end
|
623 |
|
|
end
|
624 |
|
|
//find matching frame
|
625 |
|
|
if(i_ == payload_len)
|
626 |
|
|
expect_status = 1'b1;
|
627 |
|
|
end
|
628 |
|
|
else // header mismatches, error out
|
629 |
|
|
begin
|
630 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found header mismatch in received MEMWR - Tag 0x%h: \n", $time, tag_);
|
631 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
632 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
633 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td);
|
634 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep);
|
635 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr);
|
636 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length);
|
637 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id);
|
638 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag);
|
639 |
|
|
$fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be);
|
640 |
|
|
$fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be);
|
641 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address);
|
642 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
643 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_);
|
644 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td_);
|
645 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep_);
|
646 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_);
|
647 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length_);
|
648 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_);
|
649 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_);
|
650 |
|
|
$fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be_);
|
651 |
|
|
$fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be_);
|
652 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address_);
|
653 |
|
|
$fdisplay(error_file_ptr, "");
|
654 |
|
|
expect_status = 1'b0;
|
655 |
|
|
end
|
656 |
|
|
end
|
657 |
|
|
end
|
658 |
|
|
end
|
659 |
|
|
endtask
|
660 |
|
|
|
661 |
|
|
|
662 |
|
|
/************************************************************
|
663 |
|
|
Task : TSK_EXPECT_MEMWR64
|
664 |
|
|
Inputs : traffic_class, td, ep, attr, length, last_dw_be,
|
665 |
|
|
first_dw_be, address
|
666 |
|
|
Outputs : status 0-Failed 1-Successful
|
667 |
|
|
Description : Expecting a memory write (64-bit address) TLP
|
668 |
|
|
from Rx side with matching header fields and
|
669 |
|
|
payload
|
670 |
|
|
*************************************************************/
|
671 |
|
|
task TSK_EXPECT_MEMWR64;
|
672 |
|
|
|
673 |
|
|
input [2:0] traffic_class;
|
674 |
|
|
input td;
|
675 |
|
|
input ep;
|
676 |
|
|
input [1:0] attr;
|
677 |
|
|
input [9:0] length;
|
678 |
|
|
input [15:0] requester_id;
|
679 |
|
|
input [7:0] tag;
|
680 |
|
|
input [3:0] last_dw_be;
|
681 |
|
|
input [3:0] first_dw_be;
|
682 |
|
|
input [61:0] address;
|
683 |
|
|
|
684 |
|
|
output expect_status;
|
685 |
|
|
|
686 |
|
|
reg [2:0] traffic_class_;
|
687 |
|
|
reg td_;
|
688 |
|
|
reg ep_;
|
689 |
|
|
reg [1:0] attr_;
|
690 |
|
|
reg [9:0] length_;
|
691 |
|
|
reg [15:0] requester_id_;
|
692 |
|
|
reg [7:0] tag_;
|
693 |
|
|
reg [3:0] last_dw_be_;
|
694 |
|
|
reg [3:0] first_dw_be_;
|
695 |
|
|
reg [61:0] address_;
|
696 |
|
|
|
697 |
|
|
integer payload_len;
|
698 |
|
|
integer i_;
|
699 |
|
|
reg wait_for_next;
|
700 |
|
|
reg check_byte;
|
701 |
|
|
|
702 |
|
|
begin
|
703 |
|
|
wait_for_next = 1'b1; //haven't found any matching tag yet
|
704 |
|
|
while(wait_for_next)
|
705 |
|
|
begin
|
706 |
|
|
@ rcvd_memwr64; //wait for a rcvd_memwr64 event
|
707 |
|
|
traffic_class_ = frame_store_rx[1] >> 4;
|
708 |
|
|
td_ = frame_store_rx[2] >> 7;
|
709 |
|
|
ep_ = frame_store_rx[2] >> 6;
|
710 |
|
|
attr_ = frame_store_rx[2] >> 4;
|
711 |
|
|
length_ = frame_store_rx[2];
|
712 |
|
|
length_ = (length_ << 8) | (frame_store_rx[3]);
|
713 |
|
|
requester_id_= {frame_store_rx[4], frame_store_rx[5]};
|
714 |
|
|
tag_= frame_store_rx[6];
|
715 |
|
|
last_dw_be_= frame_store_rx[7] >> 4;
|
716 |
|
|
first_dw_be_= frame_store_rx[7];
|
717 |
|
|
address_[61:6] = {frame_store_rx[8], frame_store_rx[9],
|
718 |
|
|
frame_store_rx[10], frame_store_rx[11],
|
719 |
|
|
frame_store_rx[12], frame_store_rx[13],
|
720 |
|
|
frame_store_rx[14]};
|
721 |
|
|
address_[5:0] = frame_store_rx[15] >> 2;
|
722 |
|
|
|
723 |
|
|
payload_len = (length << 2);
|
724 |
|
|
if (payload_len==0) payload_len = 4096;
|
725 |
|
|
|
726 |
|
|
$display("[%t] : Received MEMWR64 --- Tag 0x%h", $realtime, tag_);
|
727 |
|
|
if(tag == tag_) //find matching tag
|
728 |
|
|
begin
|
729 |
|
|
wait_for_next = 1'b0;
|
730 |
|
|
if((traffic_class == traffic_class_) &&
|
731 |
|
|
(td === td_) && (ep == ep_) && (attr == attr_) &&
|
732 |
|
|
(length == length_) && (requester_id == requester_id_) &&
|
733 |
|
|
(last_dw_be == last_dw_be_) && (first_dw_be == first_dw_be_) &&
|
734 |
|
|
(address == address_))
|
735 |
|
|
begin
|
736 |
|
|
// find matching header then compare payload
|
737 |
|
|
for (i_ = 0; i_ < payload_len; i_ = i_ + 1)
|
738 |
|
|
begin
|
739 |
|
|
check_byte = 1;
|
740 |
|
|
if (i_ < 4) // apply first_dw_be
|
741 |
|
|
begin
|
742 |
|
|
if (first_dw_be[i_])
|
743 |
|
|
check_byte = 1;
|
744 |
|
|
else
|
745 |
|
|
check_byte = 0;
|
746 |
|
|
end else if (i_ > (payload_len - 5)) // apply last_dw_be
|
747 |
|
|
begin
|
748 |
|
|
if (last_dw_be[4 - (payload_len - i_)])
|
749 |
|
|
check_byte = 1;
|
750 |
|
|
else
|
751 |
|
|
check_byte = 0;
|
752 |
|
|
end
|
753 |
|
|
if(check_byte && `EXPECT_MEMWR64_PAYLOAD[i_] != frame_store_rx[16 + i_]) //find mismatch
|
754 |
|
|
begin
|
755 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found payload mismatch in received MEMWR64 - Tag 0x%h: \n", $time, tag_);
|
756 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
757 |
|
|
for (i_ = 0; i_ < payload_len; i_ = i_ + 1)
|
758 |
|
|
$fdisplay(error_file_ptr,"\t %0x", `EXPECT_MEMWR64_PAYLOAD[i_]);
|
759 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
760 |
|
|
for (i_ = 0; i_ < payload_len; i_ = i_ + 1)
|
761 |
|
|
$fdisplay(error_file_ptr,"\t %0x", frame_store_rx[16+i_]);
|
762 |
|
|
|
763 |
|
|
$fdisplay(error_file_ptr, "");
|
764 |
|
|
expect_status = 1'b0;
|
765 |
|
|
i_ = 5000;
|
766 |
|
|
end
|
767 |
|
|
end
|
768 |
|
|
//find matching frame
|
769 |
|
|
if(i_ == payload_len)
|
770 |
|
|
expect_status = 1'b1;
|
771 |
|
|
end
|
772 |
|
|
else // header mismatches, error out
|
773 |
|
|
begin
|
774 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found header mismatch in received MEMWR64 - Tag 0x%h: \n", $time, tag_);
|
775 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
776 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
777 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td);
|
778 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep);
|
779 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr);
|
780 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length);
|
781 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id);
|
782 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag);
|
783 |
|
|
$fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be);
|
784 |
|
|
$fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be);
|
785 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address);
|
786 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
787 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_);
|
788 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td_);
|
789 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep_);
|
790 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_);
|
791 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length_);
|
792 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_);
|
793 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_);
|
794 |
|
|
$fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be_);
|
795 |
|
|
$fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be_);
|
796 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address_);
|
797 |
|
|
$fdisplay(error_file_ptr, "");
|
798 |
|
|
expect_status = 1'b0;
|
799 |
|
|
end
|
800 |
|
|
end
|
801 |
|
|
end
|
802 |
|
|
end
|
803 |
|
|
endtask
|
804 |
|
|
|
805 |
|
|
|
806 |
|
|
|
807 |
|
|
// Please note that the following io tasks can be only used if the customer has a mechanism for allowing
|
808 |
|
|
// the customer design to generate io write or io read tlps received by the dsport rx port.
|
809 |
|
|
|
810 |
|
|
|
811 |
|
|
/************************************************************
|
812 |
|
|
Task : TSK_EXPECT_IOWRITE
|
813 |
|
|
Inputs : td, ep, requested_id, tag, firstDwBe, address, data
|
814 |
|
|
Outputs : status 0-Failed 1-Successful
|
815 |
|
|
Description : Expecting a TLP from Rx side with matching
|
816 |
|
|
td, ep, requested_id, tag, firstDwBe, address, and 32 bit data
|
817 |
|
|
*************************************************************/
|
818 |
|
|
task TSK_EXPECT_IOWRITE;
|
819 |
|
|
|
820 |
|
|
|
821 |
|
|
input td;
|
822 |
|
|
input ep;
|
823 |
|
|
input [15:0] requester_id;
|
824 |
|
|
input [7:0] tag;
|
825 |
|
|
input [3:0] firstDwBe;
|
826 |
|
|
input [31:0] address; // note that low bits [1:0] are not used
|
827 |
|
|
input [31:0] data;
|
828 |
|
|
|
829 |
|
|
output expect_status;
|
830 |
|
|
|
831 |
|
|
reg [2:0] traffic_class;
|
832 |
|
|
reg [1:0] attr;
|
833 |
|
|
reg [9:0] length;
|
834 |
|
|
reg [3:0] lastDwBe;
|
835 |
|
|
|
836 |
|
|
reg [2:0] traffic_class_;
|
837 |
|
|
reg td_;
|
838 |
|
|
reg ep_;
|
839 |
|
|
reg [1:0] attr_;
|
840 |
|
|
reg [9:0] length_;
|
841 |
|
|
reg [15:0] requester_id_;
|
842 |
|
|
reg [7:0] tag_;
|
843 |
|
|
reg [3:0] lastDwBe_;
|
844 |
|
|
reg [3:0] firstDwBe_;
|
845 |
|
|
reg [31:0] address_; // note that the bottom two bits are not used in comparison
|
846 |
|
|
|
847 |
|
|
reg [7:0] write_payload[0:3];
|
848 |
|
|
|
849 |
|
|
|
850 |
|
|
reg [3:0] byte_enabled;
|
851 |
|
|
integer i_;
|
852 |
|
|
reg wait_for_next;
|
853 |
|
|
integer j_;
|
854 |
|
|
|
855 |
|
|
begin
|
856 |
|
|
// following assignments are required for io header
|
857 |
|
|
traffic_class = 3'b000;
|
858 |
|
|
attr = 2'b00;
|
859 |
|
|
length = 10'b00_0000_0001;
|
860 |
|
|
lastDwBe = 4'b0000;
|
861 |
|
|
write_payload[0] = data[31:24];
|
862 |
|
|
write_payload[1] = data[23:16];
|
863 |
|
|
write_payload[2] = data[15:8];
|
864 |
|
|
write_payload[3] = data[7:0];
|
865 |
|
|
|
866 |
|
|
j_ = 1000;
|
867 |
|
|
wait_for_next = 1'b1; //haven't found any matching tag yet
|
868 |
|
|
fork
|
869 |
|
|
while(wait_for_next)
|
870 |
|
|
begin
|
871 |
|
|
@ rcvd_iowr; //wait for a rcvd_iowr event
|
872 |
|
|
byte_enabled = 4'h0;
|
873 |
|
|
traffic_class_ = frame_store_rx[1] >> 4;
|
874 |
|
|
td_ = frame_store_rx[2] >> 7;
|
875 |
|
|
ep_ = frame_store_rx[2] >> 6;
|
876 |
|
|
attr_ = frame_store_rx[2] >> 4;
|
877 |
|
|
length_ = frame_store_rx[2];
|
878 |
|
|
length_ = (length_ << 8) | (frame_store_rx[3]);
|
879 |
|
|
requester_id_= {frame_store_rx[4], frame_store_rx[5]};
|
880 |
|
|
tag_= frame_store_rx[6];
|
881 |
|
|
lastDwBe_ = frame_store_rx[7] >>4;
|
882 |
|
|
firstDwBe_ = frame_store_rx[7];
|
883 |
|
|
|
884 |
|
|
address_ = (frame_store_rx[8]);
|
885 |
|
|
address_ = (address_ << 8) | frame_store_rx[9];
|
886 |
|
|
address_ = (address_ << 8) | frame_store_rx[10];
|
887 |
|
|
address_ = (address_ << 8) | frame_store_rx[11];
|
888 |
|
|
|
889 |
|
|
$display("[%t] : Received IO WRITE TLP --- Tag 0x%h", $realtime, tag_);
|
890 |
|
|
if(tag == tag_) //find matching tag
|
891 |
|
|
begin
|
892 |
|
|
wait_for_next = 1'b0;
|
893 |
|
|
if((traffic_class == traffic_class_) &&
|
894 |
|
|
(td === td_) && (ep == ep_) && (attr == attr_) &&
|
895 |
|
|
(length == length_) &&
|
896 |
|
|
(requester_id == requester_id_) &&
|
897 |
|
|
(lastDwBe == lastDwBe_) &&
|
898 |
|
|
(firstDwBe == firstDwBe_) &&
|
899 |
|
|
(address[31:2] == address_[31:2]))
|
900 |
|
|
begin
|
901 |
|
|
// find matching header then compare payload
|
902 |
|
|
expect_status = 1'b1; //assume that we will succeed
|
903 |
|
|
byte_enabled = firstDwBe;
|
904 |
|
|
for (i_ = 0; i_ < 4; i_ = i_ + 1)
|
905 |
|
|
begin
|
906 |
|
|
if (byte_enabled[3] && expect_status)
|
907 |
|
|
if (write_payload[i_] != frame_store_rx[12 + i_]) //find mismatch
|
908 |
|
|
begin
|
909 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found payload mismatch in IO WRITE DATA - Tag 0x%h: \n", $time, tag_);
|
910 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
911 |
|
|
for (i_ = 0; i_ < 4; i_ = i_ + 1)
|
912 |
|
|
$fdisplay(error_file_ptr,"\t %0x", write_payload[i_]);
|
913 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
914 |
|
|
for (i_ = 0; i_ < 4; i_ = i_ + 1)
|
915 |
|
|
$fdisplay(error_file_ptr,"\t %0x", frame_store_rx[12+i_]);
|
916 |
|
|
|
917 |
|
|
$fdisplay(error_file_ptr, "");
|
918 |
|
|
expect_status = 1'b0;
|
919 |
|
|
end
|
920 |
|
|
byte_enabled = byte_enabled << 1;
|
921 |
|
|
end
|
922 |
|
|
end
|
923 |
|
|
else // header mismatches, error out
|
924 |
|
|
begin
|
925 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found header mismatch in received CPLD - Tag 0x%h: \n", $time, tag_);
|
926 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
927 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
928 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td);
|
929 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep);
|
930 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr);
|
931 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length);
|
932 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id);
|
933 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag);
|
934 |
|
|
$fdisplay(error_file_ptr, "\t Last DW Byte Enable: 0x%h", lastDwBe);
|
935 |
|
|
$fdisplay(error_file_ptr, "\t 1st DW Byte Enable: 0x%h", firstDwBe);
|
936 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address);
|
937 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
938 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_);
|
939 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td_);
|
940 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep_);
|
941 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_);
|
942 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length_);
|
943 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_);
|
944 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_);
|
945 |
|
|
$fdisplay(error_file_ptr, "\t Last DW Byte Enable: 0x%h", lastDwBe_);
|
946 |
|
|
$fdisplay(error_file_ptr, "\t 1st DW Byte Enable: 0x%h", firstDwBe_);
|
947 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address_);
|
948 |
|
|
$fdisplay(error_file_ptr, "");
|
949 |
|
|
expect_status = 1'b0;
|
950 |
|
|
end
|
951 |
|
|
end
|
952 |
|
|
end // while
|
953 |
|
|
begin
|
954 |
|
|
// time out task function and return 0 if tlp never received and/or tag never matches
|
955 |
|
|
while (j_ && wait_for_next)
|
956 |
|
|
begin
|
957 |
|
|
`TX_TASKS.TSK_TX_CLK_EAT(1);
|
958 |
|
|
j_ = j_ - 1;
|
959 |
|
|
end
|
960 |
|
|
if (wait_for_next)
|
961 |
|
|
begin
|
962 |
|
|
$display("Failure: TSK_EXPECT_IOWRITE timeout. IO WRITE TLP never received or tag mismatch");
|
963 |
|
|
$finish;
|
964 |
|
|
end
|
965 |
|
|
end
|
966 |
|
|
join
|
967 |
|
|
end // 1st
|
968 |
|
|
endtask
|
969 |
|
|
|
970 |
|
|
|
971 |
|
|
|
972 |
|
|
/************************************************************
|
973 |
|
|
Task : TSK_EXPECT_IOREAD
|
974 |
|
|
Inputs : td, ep, requested_id, tag, firstDwBe, address
|
975 |
|
|
Outputs : status 0-Failed 1-Successful
|
976 |
|
|
Description : Expecting a TLP from Rx side with matching
|
977 |
|
|
td, ep, requested_id, tag, firstDwBe, and address
|
978 |
|
|
*************************************************************/
|
979 |
|
|
task TSK_EXPECT_IOREAD;
|
980 |
|
|
|
981 |
|
|
|
982 |
|
|
|
983 |
|
|
input td;
|
984 |
|
|
input ep;
|
985 |
|
|
input [15:0] requester_id;
|
986 |
|
|
input [7:0] tag;
|
987 |
|
|
input [3:0] firstDwBe;
|
988 |
|
|
input [31:0] address; // note that low bits [1:0] are not used
|
989 |
|
|
|
990 |
|
|
output expect_status;
|
991 |
|
|
|
992 |
|
|
reg [2:0] traffic_class;
|
993 |
|
|
reg [1:0] attr;
|
994 |
|
|
reg [9:0] length;
|
995 |
|
|
reg [3:0] lastDwBe;
|
996 |
|
|
|
997 |
|
|
reg [2:0] traffic_class_;
|
998 |
|
|
reg td_;
|
999 |
|
|
reg ep_;
|
1000 |
|
|
reg [1:0] attr_;
|
1001 |
|
|
reg [9:0] length_;
|
1002 |
|
|
reg [15:0] requester_id_;
|
1003 |
|
|
reg [7:0] tag_;
|
1004 |
|
|
reg [3:0] lastDwBe_;
|
1005 |
|
|
reg [3:0] firstDwBe_;
|
1006 |
|
|
reg [31:0] address_; // note that the bottom two bits are not used in comparison
|
1007 |
|
|
|
1008 |
|
|
integer i_;
|
1009 |
|
|
reg wait_for_next;
|
1010 |
|
|
integer j_;
|
1011 |
|
|
|
1012 |
|
|
begin
|
1013 |
|
|
// following assignments are required for io header
|
1014 |
|
|
traffic_class = 3'b000;
|
1015 |
|
|
attr = 2'b00;
|
1016 |
|
|
length = 10'b00_0000_0001;
|
1017 |
|
|
lastDwBe = 4'b0000;
|
1018 |
|
|
|
1019 |
|
|
j_ = 1000;
|
1020 |
|
|
wait_for_next = 1'b1; //haven't found any matching tag yet
|
1021 |
|
|
fork
|
1022 |
|
|
while(wait_for_next)
|
1023 |
|
|
begin
|
1024 |
|
|
@ rcvd_iord; //wait for a rcvd_iord event
|
1025 |
|
|
traffic_class_ = frame_store_rx[1] >> 4;
|
1026 |
|
|
td_ = frame_store_rx[2] >> 7;
|
1027 |
|
|
ep_ = frame_store_rx[2] >> 6;
|
1028 |
|
|
attr_ = frame_store_rx[2] >> 4;
|
1029 |
|
|
length_ = frame_store_rx[2];
|
1030 |
|
|
length_ = (length_ << 8) | (frame_store_rx[3]);
|
1031 |
|
|
requester_id_= {frame_store_rx[4], frame_store_rx[5]};
|
1032 |
|
|
tag_= frame_store_rx[6];
|
1033 |
|
|
lastDwBe_ = frame_store_rx[7] >>4;
|
1034 |
|
|
firstDwBe_ = frame_store_rx[7];
|
1035 |
|
|
|
1036 |
|
|
address_ = (frame_store_rx[8]);
|
1037 |
|
|
address_ = (address_ << 8) | frame_store_rx[9];
|
1038 |
|
|
address_ = (address_ << 8) | frame_store_rx[10];
|
1039 |
|
|
address_ = (address_ << 8) | frame_store_rx[11];
|
1040 |
|
|
|
1041 |
|
|
$display("[%t] : Received IO READ TLP --- Tag 0x%h", $realtime, tag_);
|
1042 |
|
|
if(tag == tag_) //find matching tag
|
1043 |
|
|
begin
|
1044 |
|
|
wait_for_next = 1'b0;
|
1045 |
|
|
if((traffic_class == traffic_class_) &&
|
1046 |
|
|
(td === td_) && (ep == ep_) && (attr == attr_) &&
|
1047 |
|
|
(length == length_) &&
|
1048 |
|
|
(requester_id == requester_id_) &&
|
1049 |
|
|
(lastDwBe == lastDwBe_) &&
|
1050 |
|
|
(firstDwBe == firstDwBe_) &&
|
1051 |
|
|
(address[31:2] == address_[31:2]))
|
1052 |
|
|
begin
|
1053 |
|
|
expect_status = 1'b1;
|
1054 |
|
|
end
|
1055 |
|
|
else // header mismatches, error out
|
1056 |
|
|
begin
|
1057 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found header mismatch in received CPLD - Tag 0x%h: \n", $time, tag_);
|
1058 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
1059 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
1060 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td);
|
1061 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep);
|
1062 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr);
|
1063 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length);
|
1064 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id);
|
1065 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag);
|
1066 |
|
|
$fdisplay(error_file_ptr, "\t Last DW Byte Enable: 0x%h", lastDwBe);
|
1067 |
|
|
$fdisplay(error_file_ptr, "\t 1st DW Byte Enable: 0x%h", firstDwBe);
|
1068 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address);
|
1069 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
1070 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_);
|
1071 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td_);
|
1072 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep_);
|
1073 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_);
|
1074 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length_);
|
1075 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_);
|
1076 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_);
|
1077 |
|
|
$fdisplay(error_file_ptr, "\t Last DW Byte Enable: 0x%h", lastDwBe_);
|
1078 |
|
|
$fdisplay(error_file_ptr, "\t 1st DW Byte Enable: 0x%h", firstDwBe_);
|
1079 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address_);
|
1080 |
|
|
$fdisplay(error_file_ptr, "");
|
1081 |
|
|
expect_status = 1'b0;
|
1082 |
|
|
end
|
1083 |
|
|
end
|
1084 |
|
|
end // while
|
1085 |
|
|
begin
|
1086 |
|
|
// time out task function and return 0 if tlp never received and/or tag never matches
|
1087 |
|
|
while (j_ && wait_for_next)
|
1088 |
|
|
begin
|
1089 |
|
|
`TX_TASKS.TSK_TX_CLK_EAT(1);
|
1090 |
|
|
j_ = j_ - 1;
|
1091 |
|
|
end
|
1092 |
|
|
if (wait_for_next)
|
1093 |
|
|
begin
|
1094 |
|
|
$display("Failure: TSK_EXPECT_IOREAD timeout. IO READ TLP never received or tag mismatch");
|
1095 |
|
|
$finish;
|
1096 |
|
|
end
|
1097 |
|
|
end
|
1098 |
|
|
join
|
1099 |
|
|
end //1st
|
1100 |
|
|
endtask
|
1101 |
|
|
|
1102 |
|
|
|
1103 |
|
|
|
1104 |
|
|
// Please note that the following task, TSK_EXPECT_TYPE0_CONFIGURATION_WRITE, should not be exported
|
1105 |
|
|
// to the customer because all the current express cores currently consume all Type 0 configuration
|
1106 |
|
|
// accesses. This means that this task will always time out since a type 0 config tlp will never
|
1107 |
|
|
// be received at the rx trn interface. This function is being included for completeness and in case
|
1108 |
|
|
// a future release of an express core passes type 0 configuration writes through the express core
|
1109 |
|
|
// and on to the customer rx application.
|
1110 |
|
|
|
1111 |
|
|
// Also note that this function has not been tested completely due to the restrictions indicated above.
|
1112 |
|
|
|
1113 |
|
|
|
1114 |
|
|
/************************************************************
|
1115 |
|
|
Task : TSK_EXPECT_TYPE0_CONFIGURATION_WRITE
|
1116 |
|
|
Inputs : td, ep, requested_id, tag, firstDwBe, , data
|
1117 |
|
|
Outputs : status 0-Failed 1-Successful
|
1118 |
|
|
Description : Expecting a TLP from Rx side with matching
|
1119 |
|
|
td, ep, requested_id, tag, firstDwBe, , and 32 bit data
|
1120 |
|
|
*************************************************************/
|
1121 |
|
|
task TSK_EXPECT_TYPE0_CONFIGURATION_WRITE;
|
1122 |
|
|
|
1123 |
|
|
|
1124 |
|
|
input td;
|
1125 |
|
|
input ep;
|
1126 |
|
|
input [15:0] requester_id;
|
1127 |
|
|
input [7:0] tag;
|
1128 |
|
|
input [3:0] firstDwBe;
|
1129 |
|
|
input [7:0] busNumber;
|
1130 |
|
|
input [4:0] deviceNumber;
|
1131 |
|
|
input [2:0] functionNumber;
|
1132 |
|
|
input [3:0] extRegNumber;
|
1133 |
|
|
input [5:0] registerNumber;
|
1134 |
|
|
input [31:0] data;
|
1135 |
|
|
|
1136 |
|
|
output expect_status;
|
1137 |
|
|
|
1138 |
|
|
reg [2:0] traffic_class;
|
1139 |
|
|
reg [1:0] attr;
|
1140 |
|
|
reg [9:0] length;
|
1141 |
|
|
reg [3:0] lastDwBe;
|
1142 |
|
|
|
1143 |
|
|
reg [2:0] traffic_class_;
|
1144 |
|
|
reg td_;
|
1145 |
|
|
reg ep_;
|
1146 |
|
|
reg [1:0] attr_;
|
1147 |
|
|
reg [9:0] length_;
|
1148 |
|
|
reg [15:0] requester_id_;
|
1149 |
|
|
reg [7:0] tag_;
|
1150 |
|
|
reg [3:0] lastDwBe_;
|
1151 |
|
|
reg [3:0] firstDwBe_;
|
1152 |
|
|
reg [7:0] busNumber_;
|
1153 |
|
|
reg [4:0] deviceNumber_;
|
1154 |
|
|
reg [2:0] functionNumber_;
|
1155 |
|
|
reg [3:0] extRegNumber_;
|
1156 |
|
|
reg [5:0] registerNumber_;
|
1157 |
|
|
|
1158 |
|
|
reg [7:0] write_payload[0:3];
|
1159 |
|
|
|
1160 |
|
|
|
1161 |
|
|
reg [3:0] byte_enabled;
|
1162 |
|
|
integer i_;
|
1163 |
|
|
reg wait_for_next;
|
1164 |
|
|
integer j_;
|
1165 |
|
|
|
1166 |
|
|
begin
|
1167 |
|
|
// following assignments are required for io header
|
1168 |
|
|
traffic_class = 3'b000;
|
1169 |
|
|
attr = 2'b00;
|
1170 |
|
|
length = 10'b00_0000_0001;
|
1171 |
|
|
lastDwBe = 4'b0000;
|
1172 |
|
|
write_payload[0] = data[31:24];
|
1173 |
|
|
write_payload[1] = data[23:16];
|
1174 |
|
|
write_payload[2] = data[15:8];
|
1175 |
|
|
write_payload[3] = data[7:0];
|
1176 |
|
|
|
1177 |
|
|
j_ = 1000;
|
1178 |
|
|
wait_for_next = 1'b1; //haven't found any matching tag yet
|
1179 |
|
|
fork
|
1180 |
|
|
while(wait_for_next)
|
1181 |
|
|
begin
|
1182 |
|
|
@ rcvd_cfgwr0; //wait for a rcvd_cfgwr0 event *** currently this event will never occur
|
1183 |
|
|
byte_enabled = 4'h0;
|
1184 |
|
|
traffic_class_ = frame_store_rx[1] >> 4;
|
1185 |
|
|
td_ = frame_store_rx[2] >> 7;
|
1186 |
|
|
ep_ = frame_store_rx[2] >> 6;
|
1187 |
|
|
attr_ = frame_store_rx[2] >> 4;
|
1188 |
|
|
length_ = frame_store_rx[2];
|
1189 |
|
|
length_ = (length_ << 8) | (frame_store_rx[3]);
|
1190 |
|
|
requester_id_= {frame_store_rx[4], frame_store_rx[5]};
|
1191 |
|
|
tag_= frame_store_rx[6];
|
1192 |
|
|
lastDwBe_ = frame_store_rx[7] >>4;
|
1193 |
|
|
firstDwBe_ = frame_store_rx[7];
|
1194 |
|
|
|
1195 |
|
|
busNumber_ = frame_store_rx[8];
|
1196 |
|
|
deviceNumber_ = frame_store_rx[9] >> 3;
|
1197 |
|
|
functionNumber_ = frame_store_rx[9];
|
1198 |
|
|
extRegNumber_ = frame_store_rx[10];
|
1199 |
|
|
registerNumber_ = frame_store_rx[11] >> 2;
|
1200 |
|
|
|
1201 |
|
|
$display("[%t] : Received TYPE 0 CFG WRITE TLP --- Tag 0x%h", $realtime, tag_);
|
1202 |
|
|
if(tag == tag_) //find matching tag
|
1203 |
|
|
begin
|
1204 |
|
|
wait_for_next = 1'b0;
|
1205 |
|
|
if((traffic_class == traffic_class_) &&
|
1206 |
|
|
(td === td_) && (ep == ep_) && (attr == attr_) &&
|
1207 |
|
|
(length == length_) &&
|
1208 |
|
|
(requester_id == requester_id_) &&
|
1209 |
|
|
(lastDwBe == lastDwBe_) &&
|
1210 |
|
|
(firstDwBe == firstDwBe_) &&
|
1211 |
|
|
(busNumber == busNumber_) &&
|
1212 |
|
|
(deviceNumber == deviceNumber_) &&
|
1213 |
|
|
(functionNumber == functionNumber_) &&
|
1214 |
|
|
(extRegNumber == extRegNumber_) &&
|
1215 |
|
|
(registerNumber == registerNumber_))
|
1216 |
|
|
begin
|
1217 |
|
|
// find matching header then compare payload
|
1218 |
|
|
expect_status = 1'b1; //assume that we will succeed
|
1219 |
|
|
byte_enabled = firstDwBe;
|
1220 |
|
|
for (i_ = 0; i_ < 4; i_ = i_ + 1)
|
1221 |
|
|
begin
|
1222 |
|
|
if (byte_enabled[3] && expect_status)
|
1223 |
|
|
if (write_payload[i_] != frame_store_rx[12 + i_]) //find mismatch
|
1224 |
|
|
begin
|
1225 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found payload mismatch in TYPE 0 WRITE DATA - Tag 0x%h: \n", $time, tag_);
|
1226 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
1227 |
|
|
for (i_ = 0; i_ < 4; i_ = i_ + 1)
|
1228 |
|
|
$fdisplay(error_file_ptr,"\t %0x", write_payload[i_]);
|
1229 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
1230 |
|
|
for (i_ = 0; i_ < 4; i_ = i_ + 1)
|
1231 |
|
|
$fdisplay(error_file_ptr,"\t %0x", frame_store_rx[12+i_]);
|
1232 |
|
|
|
1233 |
|
|
$fdisplay(error_file_ptr, "");
|
1234 |
|
|
expect_status = 1'b0;
|
1235 |
|
|
end
|
1236 |
|
|
byte_enabled = byte_enabled << 1;
|
1237 |
|
|
end
|
1238 |
|
|
end
|
1239 |
|
|
else // header mismatches, error out
|
1240 |
|
|
begin
|
1241 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found header mismatch in received CPLD - Tag 0x%h: \n", $time, tag_);
|
1242 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
1243 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
1244 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td);
|
1245 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep);
|
1246 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr);
|
1247 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length);
|
1248 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id);
|
1249 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag);
|
1250 |
|
|
$fdisplay(error_file_ptr, "\t Last DW Byte Enable: 0x%h", lastDwBe);
|
1251 |
|
|
$fdisplay(error_file_ptr, "\t 1st DW Byte Enable: 0x%h", firstDwBe);
|
1252 |
|
|
$fdisplay(error_file_ptr, "\t Bus Number: 0x%h", busNumber);
|
1253 |
|
|
$fdisplay(error_file_ptr, "\t Device Number: 0x%h", deviceNumber);
|
1254 |
|
|
$fdisplay(error_file_ptr, "\t Function Number: 0x%h", functionNumber);
|
1255 |
|
|
$fdisplay(error_file_ptr, "\t Ext Reg Number: 0x%h", extRegNumber);
|
1256 |
|
|
$fdisplay(error_file_ptr, "\t Register Number: 0x%h", registerNumber);
|
1257 |
|
|
|
1258 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
1259 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_);
|
1260 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td_);
|
1261 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep_);
|
1262 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_);
|
1263 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length_);
|
1264 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_);
|
1265 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_);
|
1266 |
|
|
$fdisplay(error_file_ptr, "\t Last DW Byte Enable: 0x%h", lastDwBe_);
|
1267 |
|
|
$fdisplay(error_file_ptr, "\t 1st DW Byte Enable: 0x%h", firstDwBe_);
|
1268 |
|
|
$fdisplay(error_file_ptr, "\t Bus Number: 0x%h", busNumber_);
|
1269 |
|
|
$fdisplay(error_file_ptr, "\t Device Number: 0x%h", deviceNumber_);
|
1270 |
|
|
$fdisplay(error_file_ptr, "\t Function Number: 0x%h", functionNumber_);
|
1271 |
|
|
$fdisplay(error_file_ptr, "\t Ext Reg Number: 0x%h", extRegNumber_);
|
1272 |
|
|
$fdisplay(error_file_ptr, "\t Register Number: 0x%h", registerNumber_);
|
1273 |
|
|
|
1274 |
|
|
$fdisplay(error_file_ptr, "");
|
1275 |
|
|
expect_status = 1'b0;
|
1276 |
|
|
end
|
1277 |
|
|
end
|
1278 |
|
|
end // while
|
1279 |
|
|
begin
|
1280 |
|
|
// time out task function and return 0 if tlp never received and/or tag never matches
|
1281 |
|
|
while (j_ && wait_for_next)
|
1282 |
|
|
begin
|
1283 |
|
|
`TX_TASKS.TSK_TX_CLK_EAT(1);
|
1284 |
|
|
j_ = j_ - 1;
|
1285 |
|
|
end
|
1286 |
|
|
if (wait_for_next)
|
1287 |
|
|
begin
|
1288 |
|
|
$display("Failure: TSK_EXPECT_TYPE0_CONFIGURATION_WRITE timeout. CFG TYPE 0 WRITE TLP never received");
|
1289 |
|
|
$finish;
|
1290 |
|
|
end
|
1291 |
|
|
end
|
1292 |
|
|
join
|
1293 |
|
|
end // 1st
|
1294 |
|
|
endtask
|
1295 |
|
|
|
1296 |
|
|
|
1297 |
|
|
/************************************************************
|
1298 |
|
|
Task : TSK_EXPECT_MSG
|
1299 |
|
|
Inputs : traffic_class, td, ep, attr, length, msg type, msg code
|
1300 |
|
|
address
|
1301 |
|
|
Outputs : status 0-Failed 1-Successful
|
1302 |
|
|
Description : Expecting a message no data TLP
|
1303 |
|
|
from Rx side with matching header fields
|
1304 |
|
|
*************************************************************/
|
1305 |
|
|
task TSK_EXPECT_MSG;
|
1306 |
|
|
|
1307 |
|
|
input [2:0] traffic_class;
|
1308 |
|
|
input td;
|
1309 |
|
|
input ep;
|
1310 |
|
|
input [1:0] attr;
|
1311 |
|
|
input [9:0] length;
|
1312 |
|
|
input [15:0] requester_id;
|
1313 |
|
|
input [7:0] tag;
|
1314 |
|
|
input [7:0] msg_code;
|
1315 |
|
|
input [29:0] address;
|
1316 |
|
|
|
1317 |
|
|
output expect_status;
|
1318 |
|
|
|
1319 |
|
|
reg [2:0] traffic_class_;
|
1320 |
|
|
reg td_;
|
1321 |
|
|
reg ep_;
|
1322 |
|
|
reg [1:0] attr_;
|
1323 |
|
|
reg [9:0] length_;
|
1324 |
|
|
reg [15:0] requester_id_;
|
1325 |
|
|
reg [7:0] tag_;
|
1326 |
|
|
reg [7:0] msg_code_;
|
1327 |
|
|
reg [29:0] address_;
|
1328 |
|
|
|
1329 |
|
|
integer i_;
|
1330 |
|
|
reg wait_for_next;
|
1331 |
|
|
|
1332 |
|
|
begin
|
1333 |
|
|
wait_for_next = 1'b1; //haven't found any matching tag yet
|
1334 |
|
|
while(wait_for_next)
|
1335 |
|
|
begin
|
1336 |
|
|
@ rcvd_msg; //wait for a rcvd_memrd event
|
1337 |
|
|
traffic_class_ = frame_store_rx[1] >> 4;
|
1338 |
|
|
td_ = frame_store_rx[2] >> 7;
|
1339 |
|
|
ep_ = frame_store_rx[2] >> 6;
|
1340 |
|
|
attr_ = frame_store_rx[2] >> 4;
|
1341 |
|
|
length_ = frame_store_rx[2];
|
1342 |
|
|
length_ = (length_ << 8) | (frame_store_rx[3]);
|
1343 |
|
|
requester_id_= {frame_store_rx[4], frame_store_rx[5]};
|
1344 |
|
|
tag_= frame_store_rx[6];
|
1345 |
|
|
msg_code_ = frame_store_rx[7];
|
1346 |
|
|
|
1347 |
|
|
address_[29:6] = {frame_store_rx[8], frame_store_rx[9], frame_store_rx[10]};
|
1348 |
|
|
address_[5:0] = frame_store_rx[11] >> 2;
|
1349 |
|
|
|
1350 |
|
|
$display("[%t] : Received MSG w/o Data --- Tag 0x%h", $realtime, tag_);
|
1351 |
|
|
if(tag == tag_) //find matching tag
|
1352 |
|
|
begin
|
1353 |
|
|
wait_for_next = 1'b0;
|
1354 |
|
|
if((traffic_class == traffic_class_) &&
|
1355 |
|
|
(td === td_) && (ep == ep_) && (attr == attr_) &&
|
1356 |
|
|
(length == length_) && (requester_id == requester_id_) &&
|
1357 |
|
|
(msg_code == msg_code_) && (address == address_))
|
1358 |
|
|
begin
|
1359 |
|
|
// header matches
|
1360 |
|
|
expect_status = 1'b1;
|
1361 |
|
|
end
|
1362 |
|
|
else // header mismatches, error out
|
1363 |
|
|
begin
|
1364 |
|
|
$fdisplay(error_file_ptr, "[%t] : Found header mismatch in received MSG w/o Data - Tag 0x%h: \n", $time, tag_);
|
1365 |
|
|
$fdisplay(error_file_ptr, "Expected:");
|
1366 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
1367 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td);
|
1368 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep);
|
1369 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr);
|
1370 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length);
|
1371 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id);
|
1372 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag);
|
1373 |
|
|
$fdisplay(error_file_ptr, "\t Msg Code: 0x%h", msg_code);
|
1374 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address);
|
1375 |
|
|
$fdisplay(error_file_ptr, "Received:");
|
1376 |
|
|
$fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_);
|
1377 |
|
|
$fdisplay(error_file_ptr, "\t TD: %h", td_);
|
1378 |
|
|
$fdisplay(error_file_ptr, "\t EP: %h", ep_);
|
1379 |
|
|
$fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_);
|
1380 |
|
|
$fdisplay(error_file_ptr, "\t Length: 0x%h", length_);
|
1381 |
|
|
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_);
|
1382 |
|
|
$fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_);
|
1383 |
|
|
$fdisplay(error_file_ptr, "\t Msg Code: 0x%h", msg_code_);
|
1384 |
|
|
$fdisplay(error_file_ptr, "\t Address: 0x%h", address_);
|
1385 |
|
|
$fdisplay(error_file_ptr, "");
|
1386 |
|
|
expect_status = 1'b0;
|
1387 |
|
|
end
|
1388 |
|
|
end
|
1389 |
|
|
end
|
1390 |
|
|
end
|
1391 |
|
|
endtask
|
1392 |
|
|
|
1393 |
|
|
|
1394 |
|
|
|
1395 |
|
|
|
1396 |
|
|
|