1 |
13 |
barabba |
|
2 |
|
|
|
3 |
|
|
//-----------------------------------------------------------------------------
|
4 |
|
|
//
|
5 |
|
|
// (c) Copyright 2009-2011 Xilinx, Inc. All rights reserved.
|
6 |
|
|
//
|
7 |
|
|
// This file contains confidential and proprietary information
|
8 |
|
|
// of Xilinx, Inc. and is protected under U.S. and
|
9 |
|
|
// international copyright and other intellectual property
|
10 |
|
|
// laws.
|
11 |
|
|
//
|
12 |
|
|
// DISCLAIMER
|
13 |
|
|
// This disclaimer is not a license and does not grant any
|
14 |
|
|
// rights to the materials distributed herewith. Except as
|
15 |
|
|
// otherwise provided in a valid license issued to you by
|
16 |
|
|
// Xilinx, and to the maximum extent permitted by applicable
|
17 |
|
|
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
|
18 |
|
|
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
|
19 |
|
|
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
|
20 |
|
|
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
|
21 |
|
|
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
|
22 |
|
|
// (2) Xilinx shall not be liable (whether in contract or tort,
|
23 |
|
|
// including negligence, or under any other theory of
|
24 |
|
|
// liability) for any loss or damage of any kind or nature
|
25 |
|
|
// related to, arising under or in connection with these
|
26 |
|
|
// materials, including for any direct, or any indirect,
|
27 |
|
|
// special, incidental, or consequential loss or damage
|
28 |
|
|
// (including loss of data, profits, goodwill, or any type of
|
29 |
|
|
// loss or damage suffered as a result of any action brought
|
30 |
|
|
// by a third party) even if such damage or loss was
|
31 |
|
|
// reasonably foreseeable or Xilinx had been advised of the
|
32 |
|
|
// possibility of the same.
|
33 |
|
|
//
|
34 |
|
|
// CRITICAL APPLICATIONS
|
35 |
|
|
// Xilinx products are not designed or intended to be fail-
|
36 |
|
|
// safe, or for use in any application requiring fail-safe
|
37 |
|
|
// performance, such as life-support or safety devices or
|
38 |
|
|
// systems, Class III medical devices, nuclear facilities,
|
39 |
|
|
// applications related to the deployment of airbags, or any
|
40 |
|
|
// other applications that could lead to death, personal
|
41 |
|
|
// injury, or severe property or environmental damage
|
42 |
|
|
// (individually and collectively, "Critical
|
43 |
|
|
// Applications"). Customer assumes the sole risk and
|
44 |
|
|
// liability of any use of Xilinx products in Critical
|
45 |
|
|
// Applications, subject only to applicable laws and
|
46 |
|
|
// regulations governing limitations on product liability.
|
47 |
|
|
//
|
48 |
|
|
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
|
49 |
|
|
// PART OF THIS FILE AT ALL TIMES.
|
50 |
|
|
//
|
51 |
|
|
//-----------------------------------------------------------------------------
|
52 |
|
|
// Project : Virtex-6 Integrated Block for PCI Express
|
53 |
|
|
// File : pci_exp_usrapp_com.v
|
54 |
|
|
// Version : 1.7
|
55 |
|
|
//--
|
56 |
|
|
//--------------------------------------------------------------------------------
|
57 |
|
|
|
58 |
|
|
`include "board_common.v"
|
59 |
|
|
|
60 |
|
|
module pci_exp_usrapp_com ();
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
/* Local variables */
|
64 |
|
|
|
65 |
|
|
reg [31:0] rx_file_ptr;
|
66 |
|
|
reg [7:0] frame_store_rx[5119:0];
|
67 |
|
|
integer frame_store_rx_idx;
|
68 |
|
|
reg [31:0] tx_file_ptr;
|
69 |
|
|
reg [7:0] frame_store_tx[5119:0];
|
70 |
|
|
integer frame_store_tx_idx;
|
71 |
|
|
|
72 |
|
|
reg [31:0] log_file_ptr;
|
73 |
|
|
integer _frame_store_idx;
|
74 |
|
|
|
75 |
|
|
event rcvd_cpld, rcvd_memrd, rcvd_memwr;
|
76 |
|
|
event rcvd_cpl, rcvd_memrd64, rcvd_memwr64;
|
77 |
|
|
event rcvd_msg, rcvd_msgd, rcvd_cfgrd0;
|
78 |
|
|
event rcvd_cfgwr0, rcvd_cfgrd1, rcvd_cfgwr1;
|
79 |
|
|
event rcvd_iord, rcvd_iowr;
|
80 |
|
|
|
81 |
|
|
initial begin
|
82 |
|
|
|
83 |
|
|
frame_store_rx_idx = 0;
|
84 |
|
|
frame_store_tx_idx = 0;
|
85 |
|
|
|
86 |
|
|
rx_file_ptr = $fopen("rx.dat");
|
87 |
|
|
|
88 |
|
|
if (!rx_file_ptr) begin
|
89 |
|
|
|
90 |
|
|
$write("ERROR: Could not open rx.dat.\n");
|
91 |
|
|
$finish;
|
92 |
|
|
|
93 |
|
|
end
|
94 |
|
|
|
95 |
|
|
tx_file_ptr = $fopen("tx.dat");
|
96 |
|
|
|
97 |
|
|
if (!tx_file_ptr) begin
|
98 |
|
|
|
99 |
|
|
$write("ERROR: Could not open tx.dat.\n");
|
100 |
|
|
$finish;
|
101 |
|
|
end
|
102 |
|
|
end
|
103 |
|
|
|
104 |
|
|
/************************************************************
|
105 |
|
|
Task : TSK_PARSE_FRAME
|
106 |
|
|
Inputs : None
|
107 |
|
|
Outputs : None
|
108 |
|
|
Description : Parse frame data
|
109 |
|
|
*************************************************************/
|
110 |
|
|
|
111 |
|
|
task TSK_PARSE_FRAME;
|
112 |
|
|
input log_file;
|
113 |
|
|
|
114 |
|
|
reg [1:0] fmt;
|
115 |
|
|
reg [4:0] f_type;
|
116 |
|
|
reg [2:0] traffic_class;
|
117 |
|
|
reg td;
|
118 |
|
|
reg ep;
|
119 |
|
|
reg [1:0] attr;
|
120 |
|
|
reg [9:0] length;
|
121 |
|
|
reg payload;
|
122 |
|
|
reg [15:0] requester_id;
|
123 |
|
|
reg [15:0] completer_id;
|
124 |
|
|
reg [7:0] tag;
|
125 |
|
|
reg [7:0] byte_enables;
|
126 |
|
|
reg [7:0] message_code;
|
127 |
|
|
reg [31:0] address_low;
|
128 |
|
|
reg [31:0] address_high;
|
129 |
|
|
reg [9:0] register_address;
|
130 |
|
|
reg [2:0] completion_status;
|
131 |
|
|
reg [31:0] _log_file_ptr;
|
132 |
|
|
integer _frame_store_idx;
|
133 |
|
|
|
134 |
|
|
begin
|
135 |
|
|
|
136 |
|
|
if (log_file == `RX_LOG)
|
137 |
|
|
_log_file_ptr = rx_file_ptr;
|
138 |
|
|
else
|
139 |
|
|
_log_file_ptr = tx_file_ptr;
|
140 |
|
|
|
141 |
|
|
if (log_file == `RX_LOG) begin
|
142 |
|
|
|
143 |
|
|
_frame_store_idx = frame_store_rx_idx;
|
144 |
|
|
frame_store_rx_idx = 0;
|
145 |
|
|
|
146 |
|
|
end else begin
|
147 |
|
|
|
148 |
|
|
_frame_store_idx = frame_store_tx_idx;
|
149 |
|
|
frame_store_tx_idx = 0;
|
150 |
|
|
|
151 |
|
|
end
|
152 |
|
|
|
153 |
|
|
if (log_file == `RX_LOG) begin
|
154 |
|
|
|
155 |
|
|
$display("[%t] : TSK_PARSE_FRAME on Receive", $realtime);
|
156 |
|
|
|
157 |
|
|
end
|
158 |
|
|
else begin
|
159 |
|
|
|
160 |
|
|
$display("[%t] : TSK_PARSE_FRAME on Transmit", $realtime);
|
161 |
|
|
|
162 |
|
|
end
|
163 |
|
|
|
164 |
|
|
TSK_DECIPHER_FRAME (fmt, f_type, traffic_class, td, ep, attr, length, log_file);
|
165 |
|
|
|
166 |
|
|
// decode the packets received based on fmt and f_type
|
167 |
|
|
|
168 |
|
|
casex({fmt, f_type})
|
169 |
|
|
|
170 |
|
|
`PCI_EXP_MEM_READ32 : begin
|
171 |
|
|
|
172 |
|
|
$fdisplay(_log_file_ptr, "[%t] : Memory Read-32 Frame \n", $time);
|
173 |
|
|
payload = 0;
|
174 |
|
|
TSK_3DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
175 |
|
|
|
176 |
|
|
if (log_file == `RX_LOG)
|
177 |
|
|
-> rcvd_memrd;
|
178 |
|
|
end
|
179 |
|
|
|
180 |
|
|
`PCI_EXP_IO_READ : begin
|
181 |
|
|
|
182 |
|
|
$fdisplay(_log_file_ptr, "[%t] : IO Read Frame \n", $time);
|
183 |
|
|
payload = 0;
|
184 |
|
|
TSK_3DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
185 |
|
|
|
186 |
|
|
if (log_file == `RX_LOG)
|
187 |
|
|
-> rcvd_iord;
|
188 |
|
|
end
|
189 |
|
|
|
190 |
|
|
`PCI_EXP_CFG_READ0 : begin
|
191 |
|
|
|
192 |
|
|
$fdisplay(_log_file_ptr, "[%t] : Config Read Type 0 Frame \n", $time);
|
193 |
|
|
payload = 0;
|
194 |
|
|
TSK_3DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
195 |
|
|
|
196 |
|
|
if (log_file == `RX_LOG)
|
197 |
|
|
-> rcvd_cfgrd0;
|
198 |
|
|
end
|
199 |
|
|
|
200 |
|
|
`PCI_EXP_COMPLETION_WO_DATA: begin
|
201 |
|
|
|
202 |
|
|
$fdisplay(_log_file_ptr, "[%t] : Completion Without Data Frame \n", $time);
|
203 |
|
|
payload = 0;
|
204 |
|
|
TSK_3DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
205 |
|
|
|
206 |
|
|
if (log_file == `RX_LOG)
|
207 |
|
|
-> rcvd_cpl;
|
208 |
|
|
end
|
209 |
|
|
|
210 |
|
|
`PCI_EXP_MEM_READ64: begin
|
211 |
|
|
|
212 |
|
|
$fdisplay(_log_file_ptr, "[%t] : Memory Read-64 Frame \n", $time);
|
213 |
|
|
payload = 0;
|
214 |
|
|
TSK_4DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
215 |
|
|
|
216 |
|
|
if (log_file == `RX_LOG)
|
217 |
|
|
-> rcvd_memrd64;
|
218 |
|
|
end
|
219 |
|
|
|
220 |
|
|
`PCI_EXP_MSG_NODATA: begin
|
221 |
|
|
|
222 |
|
|
$fdisplay(_log_file_ptr, "[%t] : Message With No Data Frame \n", $time);
|
223 |
|
|
payload = 0;
|
224 |
|
|
TSK_4DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
225 |
|
|
|
226 |
|
|
if (log_file == `RX_LOG)
|
227 |
|
|
-> rcvd_msg;
|
228 |
|
|
end
|
229 |
|
|
|
230 |
|
|
`PCI_EXP_MEM_WRITE32: begin
|
231 |
|
|
|
232 |
|
|
$fdisplay(_log_file_ptr, "[%t] : Memory Write-32 Frame \n", $time);
|
233 |
|
|
payload = 1;
|
234 |
|
|
TSK_3DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
235 |
|
|
$fdisplay(_log_file_ptr, "\n");
|
236 |
|
|
|
237 |
|
|
if (log_file == `RX_LOG)
|
238 |
|
|
-> rcvd_memwr;
|
239 |
|
|
end
|
240 |
|
|
|
241 |
|
|
`PCI_EXP_IO_WRITE: begin
|
242 |
|
|
|
243 |
|
|
$fdisplay(_log_file_ptr, "[%t] : IO Write Frame \n", $time);
|
244 |
|
|
payload = 1;
|
245 |
|
|
TSK_3DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
246 |
|
|
$fdisplay(_log_file_ptr, "\n");
|
247 |
|
|
|
248 |
|
|
if (log_file == `RX_LOG)
|
249 |
|
|
-> rcvd_iowr;
|
250 |
|
|
end
|
251 |
|
|
|
252 |
|
|
`PCI_EXP_CFG_WRITE0: begin
|
253 |
|
|
|
254 |
|
|
$fdisplay(_log_file_ptr, "[%t] : Config Write Type 0 Frame \n", $time);
|
255 |
|
|
payload = 1;
|
256 |
|
|
TSK_3DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
257 |
|
|
$fdisplay(_log_file_ptr, "\n");
|
258 |
|
|
|
259 |
|
|
if (log_file == `RX_LOG)
|
260 |
|
|
-> rcvd_cfgwr0;
|
261 |
|
|
end
|
262 |
|
|
|
263 |
|
|
`PCI_EXP_COMPLETION_DATA: begin
|
264 |
|
|
|
265 |
|
|
$fdisplay(_log_file_ptr, "[%t] : Completion With Data Frame \n", $time);
|
266 |
|
|
payload = 1;
|
267 |
|
|
TSK_3DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
268 |
|
|
$fdisplay(_log_file_ptr, "\n");
|
269 |
|
|
|
270 |
|
|
if (log_file == `RX_LOG)
|
271 |
|
|
-> rcvd_cpld;
|
272 |
|
|
end
|
273 |
|
|
|
274 |
|
|
`PCI_EXP_MEM_WRITE64: begin
|
275 |
|
|
|
276 |
|
|
$fdisplay(_log_file_ptr, "[%t] : Memory Write-64 Frame \n", $time);
|
277 |
|
|
payload = 1;
|
278 |
|
|
TSK_4DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
279 |
|
|
$fdisplay(_log_file_ptr, "\n");
|
280 |
|
|
|
281 |
|
|
if (log_file == `RX_LOG)
|
282 |
|
|
-> rcvd_memwr64;
|
283 |
|
|
end
|
284 |
|
|
|
285 |
|
|
`PCI_EXP_MSG_DATA: begin
|
286 |
|
|
|
287 |
|
|
$fdisplay(_log_file_ptr, "[%t] : Message With Data Frame \n", $time);
|
288 |
|
|
payload = 1;
|
289 |
|
|
TSK_4DW(fmt, f_type, traffic_class, td, ep, attr, length, payload, _frame_store_idx, _log_file_ptr, log_file);
|
290 |
|
|
$fdisplay(_log_file_ptr, "\n");
|
291 |
|
|
|
292 |
|
|
if (log_file == `RX_LOG)
|
293 |
|
|
-> rcvd_msgd;
|
294 |
|
|
end
|
295 |
|
|
|
296 |
|
|
default: begin
|
297 |
|
|
$fdisplay(_log_file_ptr, "[%t] : Not a valid frame \n", $time);
|
298 |
|
|
$display(_log_file_ptr, "[%t] : Received an invalid frame \n", $time);
|
299 |
|
|
$finish(2);
|
300 |
|
|
end
|
301 |
|
|
|
302 |
|
|
endcase
|
303 |
|
|
end
|
304 |
|
|
endtask // TSK_PARSE_FRAME
|
305 |
|
|
|
306 |
|
|
/************************************************************
|
307 |
|
|
Task : TSK_DECIPHER_FRAME
|
308 |
|
|
Inputs : None
|
309 |
|
|
Outputs : fmt, f_type, traffic_class, td, ep, attr, length
|
310 |
|
|
Description : Deciphers frame
|
311 |
|
|
*************************************************************/
|
312 |
|
|
|
313 |
|
|
task TSK_DECIPHER_FRAME;
|
314 |
|
|
output [1:0] fmt;
|
315 |
|
|
output [4:0] f_type;
|
316 |
|
|
output [2:0] traffic_class;
|
317 |
|
|
output td;
|
318 |
|
|
output ep;
|
319 |
|
|
output [1:0] attr;
|
320 |
|
|
output [9:0] length;
|
321 |
|
|
input txrx;
|
322 |
|
|
|
323 |
|
|
begin
|
324 |
|
|
|
325 |
|
|
fmt = (txrx ? frame_store_tx[0] : frame_store_rx[0]) >> 5;
|
326 |
|
|
f_type = txrx ? frame_store_tx[0] : frame_store_rx[0];
|
327 |
|
|
traffic_class = (txrx ? frame_store_tx[1] : frame_store_rx[1]) >> 4;
|
328 |
|
|
td = (txrx ? frame_store_tx[2] : frame_store_rx[2]) >> 7;
|
329 |
|
|
ep = (txrx ? frame_store_tx[2] : frame_store_rx[2]) >> 6;
|
330 |
|
|
attr = (txrx ? frame_store_tx[2] : frame_store_rx[2]) >> 4;
|
331 |
|
|
length = (txrx ? frame_store_tx[2] : frame_store_rx[2]);
|
332 |
|
|
length = (length << 8) | (txrx ? frame_store_tx[3] : frame_store_rx[3]);
|
333 |
|
|
|
334 |
|
|
end
|
335 |
|
|
|
336 |
|
|
endtask // TSK_DECIPHER_FRAME
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
/************************************************************
|
340 |
|
|
Task : TSK_3DW
|
341 |
|
|
Inputs : fmt, f_type, traffic_class, td, ep, attr, length,
|
342 |
|
|
payload, _frame_store_idx
|
343 |
|
|
Outputs : None
|
344 |
|
|
Description : Gets variables and prints frame
|
345 |
|
|
*************************************************************/
|
346 |
|
|
|
347 |
|
|
task TSK_3DW;
|
348 |
|
|
input [1:0] fmt;
|
349 |
|
|
input [4:0] f_type;
|
350 |
|
|
input [2:0] traffic_class;
|
351 |
|
|
input td;
|
352 |
|
|
input ep;
|
353 |
|
|
input [1:0] attr;
|
354 |
|
|
input [9:0] length;
|
355 |
|
|
input payload;
|
356 |
|
|
input [31:0] _frame_store_idx;
|
357 |
|
|
input [31:0] _log_file_ptr;
|
358 |
|
|
input txrx;
|
359 |
|
|
|
360 |
|
|
reg [15:0] requester_id;
|
361 |
|
|
reg [7:0] tag;
|
362 |
|
|
reg [7:0] byte_enables;
|
363 |
|
|
reg [31:0] address_low;
|
364 |
|
|
reg [15:0] completer_id;
|
365 |
|
|
reg [9:0] register_address;
|
366 |
|
|
reg [2:0] completion_status;
|
367 |
|
|
reg [31:0] dword_data; // this will be used to recontruct bytes of data and sent to tx_app
|
368 |
|
|
|
369 |
|
|
integer _i;
|
370 |
|
|
|
371 |
|
|
begin
|
372 |
|
|
$fdisplay(_log_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
373 |
|
|
$fdisplay(_log_file_ptr, "\t TD: %h", td);
|
374 |
|
|
$fdisplay(_log_file_ptr, "\t EP: %h", ep);
|
375 |
|
|
$fdisplay(_log_file_ptr, "\t Attributes: 0x%h", attr);
|
376 |
|
|
$fdisplay(_log_file_ptr, "\t Length: 0x%h", length);
|
377 |
|
|
|
378 |
|
|
casex({fmt, f_type})
|
379 |
|
|
|
380 |
|
|
`PCI_EXP_CFG_READ0,
|
381 |
|
|
`PCI_EXP_CFG_WRITE0: begin
|
382 |
|
|
|
383 |
|
|
requester_id = txrx ? {frame_store_tx[4], frame_store_tx[5]} : {frame_store_rx[4], frame_store_rx[5]};
|
384 |
|
|
tag = txrx ? frame_store_tx[6] : frame_store_rx[6];
|
385 |
|
|
byte_enables = txrx ? frame_store_tx[7] : frame_store_rx[7];
|
386 |
|
|
completer_id = {txrx ? frame_store_tx[8] : frame_store_rx[8], txrx ? frame_store_tx[9] : frame_store_rx[9]};
|
387 |
|
|
register_address = txrx ? frame_store_tx[10] : frame_store_rx[10];
|
388 |
|
|
register_address = (register_address << 8) | (txrx ? frame_store_tx[11] : frame_store_rx[11]);
|
389 |
|
|
|
390 |
|
|
$fdisplay(_log_file_ptr, "\t Requester Id: 0x%h", requester_id);
|
391 |
|
|
$fdisplay(_log_file_ptr, "\t Tag: 0x%h", tag);
|
392 |
|
|
$fdisplay(_log_file_ptr, "\t Last and First Byte Enables: 0x%h", byte_enables);
|
393 |
|
|
$fdisplay(_log_file_ptr, "\t Completer Id: 0x%h", completer_id);
|
394 |
|
|
$fdisplay(_log_file_ptr, "\t Register Address: 0x%h \n", register_address);
|
395 |
|
|
|
396 |
|
|
if (payload == 1) begin
|
397 |
|
|
|
398 |
|
|
for (_i = 12; _i < _frame_store_idx; _i = _i + 1) begin
|
399 |
|
|
|
400 |
|
|
$fdisplay(_log_file_ptr, "\t 0x%h", txrx ? frame_store_tx[_i] : frame_store_rx[_i]);
|
401 |
|
|
|
402 |
|
|
end
|
403 |
|
|
end
|
404 |
|
|
end
|
405 |
|
|
|
406 |
|
|
`PCI_EXP_COMPLETION_WO_DATA,
|
407 |
|
|
`PCI_EXP_COMPLETION_DATA: begin
|
408 |
|
|
|
409 |
|
|
completer_id = txrx ? {frame_store_tx[4], frame_store_tx[5]} : {frame_store_rx[4], frame_store_rx[5]};
|
410 |
|
|
completion_status = txrx ? (frame_store_tx[6] >> 5) : (frame_store_rx[6] >> 5);
|
411 |
|
|
requester_id = txrx ? {frame_store_tx[8], frame_store_tx[9]} : {frame_store_rx[8], frame_store_rx[9]};
|
412 |
|
|
tag = txrx ? frame_store_tx[10] : frame_store_rx[10];
|
413 |
|
|
$fdisplay(_log_file_ptr, "\t Completer Id: 0x%h", completer_id);
|
414 |
|
|
$fdisplay(_log_file_ptr, "\t Completion Status: 0x%h", completion_status);
|
415 |
|
|
$fdisplay(_log_file_ptr, "\t Requester Id: 0x%h ", requester_id);
|
416 |
|
|
$fdisplay(_log_file_ptr, "\t Tag: 0x%h \n", tag);
|
417 |
|
|
|
418 |
|
|
if (payload == 1) begin
|
419 |
|
|
|
420 |
|
|
dword_data = 32'h0000_0000;
|
421 |
|
|
|
422 |
|
|
for (_i = 12; _i < _frame_store_idx; _i = _i + 1) begin
|
423 |
|
|
|
424 |
|
|
$fdisplay(_log_file_ptr, "\t 0x%h", txrx ? frame_store_tx[_i] : frame_store_rx[_i]);
|
425 |
|
|
if (!txrx) begin // if we are called from rx
|
426 |
|
|
|
427 |
|
|
dword_data = dword_data >> 8; // build a dword to send to tx app
|
428 |
|
|
dword_data = dword_data | {frame_store_rx[_i], 24'h00_0000};
|
429 |
|
|
end
|
430 |
|
|
end
|
431 |
|
|
`TX_TASKS.TSK_SET_READ_DATA(4'hf,dword_data); // send the data to the tx_app
|
432 |
|
|
end
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
end
|
436 |
|
|
|
437 |
|
|
// memory reads, io reads, memory writes and io writes
|
438 |
|
|
default: begin
|
439 |
|
|
|
440 |
|
|
requester_id = txrx ? {frame_store_tx[4], frame_store_tx[5]} : {frame_store_rx[4], frame_store_rx[5]};
|
441 |
|
|
tag = txrx ? frame_store_tx[6] : frame_store_rx[6];
|
442 |
|
|
byte_enables = txrx ? frame_store_tx[7] : frame_store_rx[7];
|
443 |
|
|
address_low = txrx ? frame_store_tx[8] : frame_store_rx[8];
|
444 |
|
|
address_low = (address_low << 8) | (txrx ? frame_store_tx[9] : frame_store_rx[9]);
|
445 |
|
|
address_low = (address_low << 8) | (txrx ? frame_store_tx[10] : frame_store_rx[10]);
|
446 |
|
|
address_low = (address_low << 8) | (txrx ? frame_store_tx[11] : frame_store_rx[11]);
|
447 |
|
|
$fdisplay(_log_file_ptr, "\t Requester Id: 0x%h", requester_id);
|
448 |
|
|
$fdisplay(_log_file_ptr, "\t Tag: 0x%h", tag);
|
449 |
|
|
$fdisplay(_log_file_ptr, "\t Last and First Byte Enables: 0x%h", byte_enables);
|
450 |
|
|
$fdisplay(_log_file_ptr, "\t Address Low: 0x%h \n", address_low);
|
451 |
|
|
if (payload == 1) begin
|
452 |
|
|
|
453 |
|
|
for (_i = 12; _i < _frame_store_idx; _i = _i + 1) begin
|
454 |
|
|
|
455 |
|
|
$fdisplay(_log_file_ptr, "\t 0x%h", (txrx ? frame_store_tx[_i] : frame_store_rx[_i]));
|
456 |
|
|
end
|
457 |
|
|
|
458 |
|
|
end
|
459 |
|
|
|
460 |
|
|
end
|
461 |
|
|
endcase
|
462 |
|
|
end
|
463 |
|
|
endtask // TSK_3DW
|
464 |
|
|
|
465 |
|
|
|
466 |
|
|
/************************************************************
|
467 |
|
|
Task : TSK_4DW
|
468 |
|
|
Inputs : fmt, f_type, traffic_class, td, ep, attr, length
|
469 |
|
|
payload, _frame_store_idx
|
470 |
|
|
Outputs : None
|
471 |
|
|
Description : Gets variables and prints frame
|
472 |
|
|
*************************************************************/
|
473 |
|
|
|
474 |
|
|
task TSK_4DW;
|
475 |
|
|
input [1:0] fmt;
|
476 |
|
|
input [4:0] f_type;
|
477 |
|
|
input [2:0] traffic_class;
|
478 |
|
|
input td;
|
479 |
|
|
input ep;
|
480 |
|
|
input [1:0] attr;
|
481 |
|
|
input [9:0] length;
|
482 |
|
|
input payload;
|
483 |
|
|
input [31:0] _frame_store_idx;
|
484 |
|
|
input [31:0] _log_file_ptr;
|
485 |
|
|
input txrx;
|
486 |
|
|
|
487 |
|
|
reg [15:0] requester_id;
|
488 |
|
|
reg [7:0] tag;
|
489 |
|
|
reg [7:0] byte_enables;
|
490 |
|
|
reg [7:0] message_code;
|
491 |
|
|
reg [31:0] address_high;
|
492 |
|
|
reg [31:0] address_low;
|
493 |
|
|
reg [2:0] msg_type;
|
494 |
|
|
|
495 |
|
|
integer _i;
|
496 |
|
|
|
497 |
|
|
begin
|
498 |
|
|
|
499 |
|
|
$fdisplay(_log_file_ptr, "\t Traffic Class: 0x%h", traffic_class);
|
500 |
|
|
$fdisplay(_log_file_ptr, "\t TD: %h", td);
|
501 |
|
|
$fdisplay(_log_file_ptr, "\t EP: %h", ep);
|
502 |
|
|
$fdisplay(_log_file_ptr, "\t Attributes: 0x%h", attr);
|
503 |
|
|
$fdisplay(_log_file_ptr, "\t Length: 0x%h", length);
|
504 |
|
|
|
505 |
|
|
requester_id = txrx ? {frame_store_tx[4], frame_store_tx[5]} : {frame_store_rx[4], frame_store_rx[5]};
|
506 |
|
|
tag = txrx ? frame_store_tx[6] : frame_store_rx[6];
|
507 |
|
|
byte_enables = txrx ? frame_store_tx[7] : frame_store_rx[7];
|
508 |
|
|
message_code = txrx ? frame_store_tx[7] : frame_store_rx[7];
|
509 |
|
|
address_high = txrx ? frame_store_tx[8] : frame_store_rx[8];
|
510 |
|
|
address_high = (address_high << 8) | (txrx ? frame_store_tx[9] : frame_store_rx[9]);
|
511 |
|
|
address_high = (address_high << 8) | (txrx ? frame_store_tx[10] : frame_store_rx[10]);
|
512 |
|
|
address_high = (address_high << 8) | (txrx ? frame_store_tx[11] : frame_store_rx[11]);
|
513 |
|
|
address_low = txrx ? frame_store_tx[12] : frame_store_rx[12];
|
514 |
|
|
address_low = (address_low << 8) | (txrx ? frame_store_tx[13] : frame_store_rx[13]);
|
515 |
|
|
address_low = (address_low << 8) | (txrx ? frame_store_tx[14] : frame_store_rx[14]);
|
516 |
|
|
address_low = (address_low << 8) | (txrx ? frame_store_tx[15] : frame_store_rx[15]);
|
517 |
|
|
|
518 |
|
|
$fdisplay(_log_file_ptr, "\t Requester Id: 0x%h", requester_id);
|
519 |
|
|
$fdisplay(_log_file_ptr, "\t Tag: 0x%h", tag);
|
520 |
|
|
|
521 |
|
|
casex({fmt, f_type})
|
522 |
|
|
|
523 |
|
|
`PCI_EXP_MEM_READ64,
|
524 |
|
|
`PCI_EXP_MEM_WRITE64: begin
|
525 |
|
|
|
526 |
|
|
$fdisplay(_log_file_ptr, "\t Last and First Byte Enables: 0x%h", byte_enables);
|
527 |
|
|
$fdisplay(_log_file_ptr, "\t Address High: 0x%h", address_high);
|
528 |
|
|
$fdisplay(_log_file_ptr, "\t Address Low: 0x%h \n", address_low);
|
529 |
|
|
if (payload == 1) begin
|
530 |
|
|
|
531 |
|
|
for (_i = 16; _i < _frame_store_idx; _i = _i + 1) begin
|
532 |
|
|
|
533 |
|
|
$fdisplay(_log_file_ptr, "\t 0x%h", txrx ? frame_store_tx[_i] : frame_store_rx[_i]);
|
534 |
|
|
|
535 |
|
|
end
|
536 |
|
|
end
|
537 |
|
|
end
|
538 |
|
|
|
539 |
|
|
`PCI_EXP_MSG_NODATA,
|
540 |
|
|
`PCI_EXP_MSG_DATA: begin
|
541 |
|
|
|
542 |
|
|
msg_type = f_type;
|
543 |
|
|
$fdisplay(_log_file_ptr, "\t Message Type: 0x%h", msg_type);
|
544 |
|
|
$fdisplay(_log_file_ptr, "\t Message Code: 0x%h", message_code);
|
545 |
|
|
$fdisplay(_log_file_ptr, "\t Address High: 0x%h", address_high);
|
546 |
|
|
$fdisplay(_log_file_ptr, "\t Address Low: 0x%h \n", address_low);
|
547 |
|
|
|
548 |
|
|
if (payload == 1) begin
|
549 |
|
|
|
550 |
|
|
for (_i = 16; _i < _frame_store_idx; _i = _i + 1) begin
|
551 |
|
|
|
552 |
|
|
$fdisplay(_log_file_ptr, "\t 0x%h", txrx ? frame_store_tx[_i] : frame_store_rx[_i]);
|
553 |
|
|
end
|
554 |
|
|
end
|
555 |
|
|
end
|
556 |
|
|
endcase
|
557 |
|
|
end
|
558 |
|
|
endtask // TSK_4DW
|
559 |
|
|
|
560 |
|
|
|
561 |
|
|
/************************************************************
|
562 |
|
|
Task : TSK_READ_DATA
|
563 |
|
|
Inputs : None
|
564 |
|
|
Outputs : None
|
565 |
|
|
Description : Consume clocks.
|
566 |
|
|
*************************************************************/
|
567 |
|
|
|
568 |
|
|
task TSK_READ_DATA;
|
569 |
|
|
input last;
|
570 |
|
|
input txrx;
|
571 |
|
|
input [63:0] trn_d;
|
572 |
|
|
input [3:0] trn_rem;
|
573 |
|
|
integer _i;
|
574 |
|
|
reg [7:0] _byte;
|
575 |
|
|
reg [63:0] _msk;
|
576 |
|
|
reg [3:0] _rem;
|
577 |
|
|
begin
|
578 |
|
|
|
579 |
|
|
_msk = 64'hff00000000000000;
|
580 |
|
|
_rem = last ? ((trn_rem == 8'h0F) ? 4 : 8) : 8;
|
581 |
|
|
for (_i = 0; _i < _rem; _i = _i + 1) begin
|
582 |
|
|
|
583 |
|
|
_byte = (trn_d & (_msk >> (_i * 8))) >> (((7) - _i) * 8);
|
584 |
|
|
|
585 |
|
|
if (txrx) begin
|
586 |
|
|
|
587 |
|
|
board.RP.com_usrapp.frame_store_tx[board.RP.com_usrapp.frame_store_tx_idx] = _byte;
|
588 |
|
|
board.RP.com_usrapp.frame_store_tx_idx = board.RP.com_usrapp.frame_store_tx_idx + 1;
|
589 |
|
|
|
590 |
|
|
end else begin
|
591 |
|
|
|
592 |
|
|
board.RP.com_usrapp.frame_store_rx[board.RP.com_usrapp.frame_store_rx_idx] = _byte;
|
593 |
|
|
board.RP.com_usrapp.frame_store_rx_idx = board.RP.com_usrapp.frame_store_rx_idx + 1;
|
594 |
|
|
end
|
595 |
|
|
|
596 |
|
|
end
|
597 |
|
|
end
|
598 |
|
|
endtask // TSK_READ_DATA
|
599 |
|
|
|
600 |
|
|
`include "pci_exp_expect_tasks.v"
|
601 |
|
|
|
602 |
|
|
endmodule // pci_exp_usrapp_com
|