1 |
12 |
juko |
/*
|
2 |
|
|
* .--------------. .----------------. .------------.
|
3 |
|
|
* | .------------. | .--------------. | .----------. |
|
4 |
|
|
* | | ____ ____ | | | ____ ____ | | | ______ | |
|
5 |
|
|
* | ||_ || _|| | ||_ \ / _|| | | .' ___ || |
|
6 |
|
|
* ___ _ __ ___ _ __ | | | |__| | | | | | \/ | | | |/ .' \_|| |
|
7 |
|
|
* / _ \| '_ \ / _ \ '_ \ | | | __ | | | | | |\ /| | | | || | | |
|
8 |
|
|
* (_) | |_) | __/ | | || | _| | | |_ | | | _| |_\/_| |_ | | |\ `.___.'\| |
|
9 |
|
|
* \___/| .__/ \___|_| |_|| ||____||____|| | ||_____||_____|| | | `._____.'| |
|
10 |
|
|
* | | | | | | | | | | | |
|
11 |
|
|
* |_| | '------------' | '--------------' | '----------' |
|
12 |
|
|
* '--------------' '----------------' '------------'
|
13 |
|
|
*
|
14 |
|
|
* openHMC - An Open Source Hybrid Memory Cube Controller
|
15 |
|
|
* (C) Copyright 2014 Computer Architecture Group - University of Heidelberg
|
16 |
|
|
* www.ziti.uni-heidelberg.de
|
17 |
|
|
* B6, 26
|
18 |
|
|
* 68159 Mannheim
|
19 |
|
|
* Germany
|
20 |
|
|
*
|
21 |
|
|
* Contact: openhmc@ziti.uni-heidelberg.de
|
22 |
|
|
* http://ra.ziti.uni-heidelberg.de/openhmc
|
23 |
|
|
*
|
24 |
|
|
* This source file is free software: you can redistribute it and/or modify
|
25 |
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
26 |
|
|
* the Free Software Foundation, either version 3 of the License, or
|
27 |
|
|
* (at your option) any later version.
|
28 |
|
|
*
|
29 |
|
|
* This source file is distributed in the hope that it will be useful,
|
30 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
31 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
32 |
|
|
* GNU Lesser General Public License for more details.
|
33 |
|
|
*
|
34 |
|
|
* You should have received a copy of the GNU Lesser General Public License
|
35 |
|
|
* along with this source file. If not, see .
|
36 |
|
|
*
|
37 |
|
|
*
|
38 |
|
|
*/
|
39 |
|
|
|
40 |
|
|
//
|
41 |
|
|
// hmc_packet
|
42 |
|
|
//
|
43 |
|
|
|
44 |
|
|
`ifndef HMC_PACKET_SV
|
45 |
|
|
`define HMC_PACKET_SV
|
46 |
|
|
|
47 |
|
|
`define HMC_TYPE_MASK 6'h38
|
48 |
|
|
|
49 |
|
|
class hmc_packet extends uvm_sequence_item;
|
50 |
|
|
|
51 |
|
|
// request header fields
|
52 |
|
|
rand bit [2:0] cube_ID; // CUB
|
53 |
|
|
rand bit [33:0] address; // ADRS
|
54 |
|
|
rand bit [8:0] tag; // TAG
|
55 |
|
|
rand bit [3:0] packet_length; // LNG 128-bit (16-byte) flits
|
56 |
|
|
rand bit [3:0] duplicate_length; // DLN
|
57 |
|
|
rand hmc_command_encoding command; // CMD
|
58 |
|
|
|
59 |
|
|
bit [127:0] payload[$]; // 16-byte granularity
|
60 |
|
|
|
61 |
|
|
// request tail fields
|
62 |
|
|
rand bit [4:0] return_token_count; // RTC
|
63 |
|
|
rand bit [2:0] source_link_ID; // SLID
|
64 |
|
|
rand bit [2:0] sequence_number; // SEQ
|
65 |
|
|
rand bit [7:0] forward_retry_pointer; // FRP
|
66 |
|
|
rand bit [7:0] return_retry_pointer; // RRP
|
67 |
|
|
rand bit [31:0] packet_crc; // CRC
|
68 |
|
|
|
69 |
|
|
// response header fields not used before
|
70 |
|
|
rand bit [8:0] return_tag; // TGA (Optional)
|
71 |
|
|
|
72 |
|
|
// response tail fields not used before
|
73 |
|
|
rand bit [6:0] error_status; // ERRSTAT
|
74 |
|
|
rand bit data_invalid; // DINV
|
75 |
|
|
|
76 |
|
|
// special bits for IRTRY
|
77 |
|
|
rand bit start_retry;
|
78 |
|
|
rand bit clear_error_abort;
|
79 |
|
|
|
80 |
|
|
// CRC status fields
|
81 |
|
|
rand bit poisoned; // Inverted CRC
|
82 |
|
|
rand bit crc_error;
|
83 |
|
|
|
84 |
|
|
// helper fields
|
85 |
|
|
rand int flit_delay;
|
86 |
|
|
|
87 |
|
|
`uvm_object_utils_begin(hmc_packet)
|
88 |
|
|
`uvm_field_int(flit_delay, UVM_ALL_ON | UVM_NOPACK | UVM_DEC | UVM_NOCOMPARE | UVM_DEC)
|
89 |
|
|
`uvm_field_int(cube_ID, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
90 |
|
|
`uvm_field_int(address, UVM_ALL_ON | UVM_NOPACK | UVM_HEX)
|
91 |
|
|
`uvm_field_int(tag, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
92 |
|
|
`uvm_field_int(packet_length, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
93 |
|
|
`uvm_field_int(duplicate_length, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
94 |
|
|
`uvm_field_enum(hmc_command_encoding, command, UVM_ALL_ON | UVM_NOPACK )
|
95 |
|
|
`uvm_field_queue_int(payload, UVM_ALL_ON | UVM_NOPACK)
|
96 |
|
|
`uvm_field_int(return_token_count, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
97 |
|
|
`uvm_field_int(source_link_ID, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
98 |
|
|
`uvm_field_int(sequence_number, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
99 |
|
|
`uvm_field_int(forward_retry_pointer, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
100 |
|
|
`uvm_field_int(return_retry_pointer, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
101 |
|
|
`uvm_field_int(packet_crc, UVM_ALL_ON | UVM_NOPACK | UVM_HEX)
|
102 |
|
|
`uvm_field_int(return_tag, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
103 |
|
|
`uvm_field_int(error_status, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
104 |
|
|
`uvm_field_int(data_invalid, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
105 |
|
|
`uvm_field_int(poisoned, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
106 |
|
|
`uvm_field_int(crc_error, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
|
107 |
|
|
`uvm_object_utils_end
|
108 |
|
|
|
109 |
|
|
//constraint c_payload_size { packet_length == 1 || payload.size() == packet_length - 1; }
|
110 |
|
|
constraint c_poisoned { poisoned == 0; }
|
111 |
|
|
constraint c_cube_id {cube_ID ==0;}
|
112 |
|
|
constraint c_address {address ==0;}
|
113 |
|
|
constraint c_crc_error { crc_error == 0; }
|
114 |
|
|
constraint c_matching_length { packet_length == duplicate_length; }
|
115 |
|
|
constraint c_return_tag { return_tag == 0; }
|
116 |
|
|
constraint c_packet_length { (
|
117 |
|
|
(packet_length == 2 && command == HMC_POSTED_WRITE_16) ||
|
118 |
|
|
(packet_length == 3 && command == HMC_POSTED_WRITE_32) ||
|
119 |
|
|
(packet_length == 4 && command == HMC_POSTED_WRITE_48) ||
|
120 |
|
|
(packet_length == 5 && command == HMC_POSTED_WRITE_64) ||
|
121 |
|
|
(packet_length == 6 && command == HMC_POSTED_WRITE_80) ||
|
122 |
|
|
(packet_length == 7 && command == HMC_POSTED_WRITE_96) ||
|
123 |
|
|
(packet_length == 8 && command == HMC_POSTED_WRITE_112) ||
|
124 |
|
|
(packet_length == 9 && command == HMC_POSTED_WRITE_128) ||
|
125 |
|
|
(packet_length == 2 && command == HMC_WRITE_16) ||
|
126 |
|
|
(packet_length == 3 && command == HMC_WRITE_32) ||
|
127 |
|
|
(packet_length == 4 && command == HMC_WRITE_48) ||
|
128 |
|
|
(packet_length == 5 && command == HMC_WRITE_64) ||
|
129 |
|
|
(packet_length == 6 && command == HMC_WRITE_80) ||
|
130 |
|
|
(packet_length == 7 && command == HMC_WRITE_96) ||
|
131 |
|
|
(packet_length == 8 && command == HMC_WRITE_112) ||
|
132 |
|
|
(packet_length == 9 && command == HMC_WRITE_128) ||
|
133 |
|
|
(packet_length > 1 && packet_length <= 9 && command == HMC_READ_RESPONSE) ||
|
134 |
|
|
(packet_length == 1 && command == HMC_WRITE_RESPONSE) ||
|
135 |
|
|
(packet_length == 1 && command == HMC_MODE_WRITE_RESPONSE) ||
|
136 |
|
|
(packet_length == 1 && command == HMC_ERROR_RESPONSE) ||
|
137 |
|
|
(packet_length == 2 && (command & `HMC_TYPE_MASK) == HMC_MISC_WRITE_TYPE) ||
|
138 |
|
|
(packet_length == 2 && (command & `HMC_TYPE_MASK) == HMC_POSTED_MISC_WRITE_TYPE) ||
|
139 |
|
|
(packet_length == 1 && (command & `HMC_TYPE_MASK) == HMC_MODE_READ_TYPE) ||
|
140 |
|
|
(packet_length == 1 && (command & `HMC_TYPE_MASK) == HMC_READ_TYPE) ||
|
141 |
|
|
(packet_length == 1 && (command & `HMC_TYPE_MASK) == HMC_FLOW_TYPE)
|
142 |
|
|
); }
|
143 |
|
|
constraint c_flit_delay {
|
144 |
|
|
soft flit_delay dist{0:/90, [1:8]:/8, [8:200]:/2 };
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
function new (string name = "hmc_packet");
|
148 |
|
|
super.new(name);
|
149 |
|
|
endfunction : new
|
150 |
|
|
|
151 |
|
|
function void post_randomize();
|
152 |
|
|
bit [127:0] rand_flit;
|
153 |
|
|
|
154 |
|
|
super.post_randomize();
|
155 |
|
|
|
156 |
|
|
if (packet_length > 9)
|
157 |
|
|
`uvm_fatal(get_type_name(),$psprintf("post_randomize packet_length = %0d",packet_length))
|
158 |
|
|
|
159 |
|
|
`uvm_info("AXI Packet queued",$psprintf("%0s packet_length = %0d",command.name(), packet_length), UVM_HIGH)
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
if (packet_length < 2)
|
163 |
|
|
return;
|
164 |
|
|
|
165 |
|
|
for (int i=0; i
|
166 |
|
|
randomize_flit_successful : assert (std::randomize(rand_flit));
|
167 |
|
|
payload.push_back(rand_flit);
|
168 |
|
|
end
|
169 |
|
|
if ((command == HMC_POSTED_DUAL_8B_ADDI)||
|
170 |
|
|
(command == HMC_DUAL_8B_ADDI)) begin
|
171 |
|
|
payload[0] [63:32] = 32'b0;
|
172 |
|
|
payload[0][127:96] = 32'b0;
|
173 |
|
|
end
|
174 |
|
|
|
175 |
|
|
if ((command == HMC_MODE_WRITE)|| (command == HMC_MODE_READ)) begin
|
176 |
|
|
payload[0][127:32] = 96'b0;
|
177 |
|
|
end
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
endfunction
|
181 |
|
|
|
182 |
|
|
function hmc_command_type get_command_type();
|
183 |
|
|
|
184 |
|
|
case(command & `HMC_TYPE_MASK)
|
185 |
|
|
HMC_FLOW_TYPE: return HMC_FLOW_TYPE;
|
186 |
|
|
HMC_READ_TYPE: return HMC_READ_TYPE;
|
187 |
|
|
HMC_MODE_READ_TYPE: return HMC_MODE_READ_TYPE;
|
188 |
|
|
HMC_POSTED_WRITE_TYPE: return HMC_POSTED_WRITE_TYPE;
|
189 |
|
|
HMC_POSTED_MISC_WRITE_TYPE: return HMC_POSTED_MISC_WRITE_TYPE;
|
190 |
|
|
HMC_WRITE_TYPE: return HMC_WRITE_TYPE;
|
191 |
|
|
HMC_MISC_WRITE_TYPE: return HMC_MISC_WRITE_TYPE;
|
192 |
|
|
HMC_RESPONSE_TYPE: return HMC_RESPONSE_TYPE;
|
193 |
|
|
default: uvm_report_fatal(get_type_name(), $psprintf("command with an illegal command type='h%0h!", command));
|
194 |
|
|
endcase
|
195 |
|
|
|
196 |
|
|
endfunction : get_command_type
|
197 |
|
|
|
198 |
|
|
/*
|
199 |
|
|
The CRC algorithm used on the HMC is the Koopman CRC-32K. This algorithm was
|
200 |
|
|
chosen for the HMC because of its balance of coverage and ease of implementation. The
|
201 |
|
|
polynomial for this algorithm is:
|
202 |
|
|
x32 + x30 + x29 + x28 + x26 + x20 + x19 + x17 + x16 + x15 + x11 + x10 + x7 + x6 + x4 + x2 + x + 1
|
203 |
|
|
|
204 |
|
|
bit [31:0] polynomial = 33'b1_0111_0100_0001_1011_1000_1100_1101_0111; // Normal
|
205 |
|
|
|
206 |
|
|
The CRC calculation operates on the LSB of the packet first. The packet CRC calculation
|
207 |
|
|
must insert 0s in place of the 32-bits representing the CRC field before generating or
|
208 |
|
|
checking the CRC. For example, when generating CRC for a packet, bits [63: 32] of the
|
209 |
|
|
Tail presented to the CRC generator should be all zeros. The output of the CRC generator
|
210 |
|
|
will have a 32-bit CRC value that will then be inserted in bits [63:32] of the Tail before
|
211 |
|
|
forwarding that FLIT of the packet. When checking CRC for a packet, the CRC field
|
212 |
|
|
should be removed from bits [63:32] of the Tail and replaced with 32-bits of zeros, then
|
213 |
|
|
presented to the CRC checker. The output of the CRC checker will have a 32-bit CRC
|
214 |
|
|
value that can be compared with the CRC value that was removed from the tail. If the two
|
215 |
|
|
compare, the CRC check indicates no bit failures within the packet.
|
216 |
|
|
*/
|
217 |
|
|
|
218 |
|
|
function bit [31:0] calculate_crc();
|
219 |
|
|
bit [32:0] polynomial = 33'h1741B8CD7; // Normal
|
220 |
|
|
bit [32:0] remainder = 33'h0;
|
221 |
|
|
bit bitstream[];
|
222 |
|
|
int bits_packed=0;
|
223 |
|
|
|
224 |
|
|
bits_packed = pack(bitstream);
|
225 |
|
|
packer_succeeded : assert (bits_packed > 0);
|
226 |
|
|
|
227 |
|
|
/*
|
228 |
|
|
if (bits_packed > 128) begin //DEBUG
|
229 |
|
|
bit [127:0] flits[9];
|
230 |
|
|
for( int i=0; i < bits_packed; i++)
|
231 |
|
|
flits[i/128][i%128] = bitstream[i];
|
232 |
|
|
for( int i=0; i < bits_packed/128; i++)
|
233 |
|
|
`uvm_info(get_type_name(),$psprintf("calculate_crc flits[%0x] %0x",i,flits[i]), UVM_HIGH)
|
234 |
|
|
end
|
235 |
|
|
*/
|
236 |
|
|
|
237 |
|
|
for( int i=0; i < bits_packed-32; i++ ) begin // without the CRC
|
238 |
|
|
remainder = {remainder[31:0], bitstream[i]};
|
239 |
|
|
if( remainder[32] ) begin
|
240 |
|
|
remainder = remainder ^ polynomial;
|
241 |
|
|
end
|
242 |
|
|
end
|
243 |
|
|
|
244 |
|
|
for( int i=0; i < 64; i++ ) begin // zeroes for CRC and remainder
|
245 |
|
|
remainder = {remainder[31:0], 1'b0};
|
246 |
|
|
if( remainder[32] ) begin
|
247 |
|
|
remainder = remainder ^ polynomial;
|
248 |
|
|
end
|
249 |
|
|
end
|
250 |
|
|
|
251 |
|
|
return remainder[31:0];
|
252 |
|
|
|
253 |
|
|
endfunction : calculate_crc
|
254 |
|
|
|
255 |
|
|
virtual function void do_pack(uvm_packer packer);
|
256 |
|
|
|
257 |
|
|
super.do_pack(packer);
|
258 |
|
|
packer.big_endian = 0;
|
259 |
|
|
|
260 |
|
|
// pack header half flit
|
261 |
|
|
case(command & `HMC_TYPE_MASK)
|
262 |
|
|
HMC_FLOW_TYPE:
|
263 |
|
|
case (command)
|
264 |
|
|
HMC_NULL: packer.pack_field( {64'h0}, 64);
|
265 |
|
|
HMC_PRET: packer.pack_field ( {3'h0, 3'h0, 34'h0, 9'h0, duplicate_length[3:0], packet_length[3:0], 1'b0, command[5:0]}, 64);
|
266 |
|
|
HMC_TRET: packer.pack_field ( {3'h0, 3'h0, 34'h0, 9'h0, duplicate_length[3:0], packet_length[3:0], 1'b0, command[5:0]}, 64);
|
267 |
|
|
HMC_IRTRY: packer.pack_field ( {3'h0, 3'h0, 34'h0, 9'h0, duplicate_length[3:0], packet_length[3:0], 1'b0, command[5:0]}, 64);
|
268 |
|
|
default: uvm_report_fatal(get_type_name(), $psprintf("pack function called for a hmc_packet with an illegal FLOW type='h%0h!", command));
|
269 |
|
|
endcase
|
270 |
|
|
HMC_READ_TYPE: packer.pack_field ( {cube_ID[2:0], 3'h0, 34'h0, tag[8:0], duplicate_length[3:0], packet_length[3:0], 1'b0, command[5:0]}, 64);
|
271 |
|
|
HMC_MODE_READ_TYPE: packer.pack_field ( {cube_ID[2:0], 3'h0, address[33:0], tag[8:0], duplicate_length[3:0], packet_length[3:0], 1'b0, command[5:0]}, 64);
|
272 |
|
|
HMC_POSTED_WRITE_TYPE: packer.pack_field ( {cube_ID[2:0], 3'h0, address[33:0], tag[8:0], duplicate_length[3:0], packet_length[3:0], 1'b0, command[5:0]}, 64);
|
273 |
|
|
HMC_WRITE_TYPE: packer.pack_field ( {cube_ID[2:0], 3'h0, address[33:0], tag[8:0], duplicate_length[3:0], packet_length[3:0], 1'b0, command[5:0]}, 64);
|
274 |
|
|
HMC_POSTED_MISC_WRITE_TYPE: packer.pack_field ( {cube_ID[2:0], 3'h0, address[33:0], tag[8:0], duplicate_length[3:0], packet_length[3:0], 1'b0, command[5:0]}, 64);
|
275 |
|
|
HMC_MISC_WRITE_TYPE: packer.pack_field ( {cube_ID[2:0], 3'h0, 34'h0, tag[8:0], duplicate_length[3:0], packet_length[3:0], 1'b0, command[5:0]}, 64);
|
276 |
|
|
HMC_RESPONSE_TYPE: packer.pack_field ( {22'h0, source_link_ID[2:0], 6'h0, return_tag[8:0], tag[8:0], duplicate_length[3:0], packet_length[3:0], 1'b0, command[5:0]}, 64);
|
277 |
|
|
default: uvm_report_fatal(get_type_name(), $psprintf("pack function called for a hmc_packet with an illegal command type='h%0h!", command));
|
278 |
|
|
endcase
|
279 |
|
|
|
280 |
|
|
// Allow for errors when packet_length != duplicate_length
|
281 |
|
|
if ((packet_length == duplicate_length) && payload.size() + 1 != packet_length && command != HMC_NULL)
|
282 |
|
|
uvm_report_fatal(get_type_name(), $psprintf("pack function size mismatch payload.size=%0d packet_length=%0d!", payload.size(), packet_length));
|
283 |
|
|
|
284 |
|
|
// pack payload
|
285 |
|
|
for( int i=0; i
|
286 |
|
|
|
287 |
|
|
// pack tail half flit
|
288 |
|
|
case(command & `HMC_TYPE_MASK)
|
289 |
|
|
HMC_FLOW_TYPE:
|
290 |
|
|
case (command)
|
291 |
|
|
HMC_NULL: packer.pack_field( {64'h0}, 64);
|
292 |
|
|
HMC_PRET: packer.pack_field ( {packet_crc[31:0], 5'h0, 3'h0, 5'h0, 3'h0, 8'h0, return_retry_pointer[7:0]}, 64);
|
293 |
|
|
HMC_TRET: packer.pack_field ( {packet_crc[31:0], return_token_count[4:0], 3'h0, 5'h0, sequence_number[2:0], forward_retry_pointer[7:0], return_retry_pointer[7:0]}, 64);
|
294 |
|
|
HMC_IRTRY: packer.pack_field ( {packet_crc[31:0], 5'h0, 3'h0, 5'h0, 3'h0, 6'h0, clear_error_abort, start_retry, return_retry_pointer[7:0]}, 64);
|
295 |
|
|
default: uvm_report_fatal(get_type_name(), $psprintf("pack function (tail) called for a hmc_packet with an illegal FLOW type='h%0h!", command));
|
296 |
|
|
endcase
|
297 |
|
|
HMC_READ_TYPE: packer.pack_field ( {packet_crc[31:0], return_token_count[4:0], source_link_ID[2:0], 5'h0, sequence_number[2:0], forward_retry_pointer[7:0], return_retry_pointer[7:0]}, 64);
|
298 |
|
|
HMC_POSTED_WRITE_TYPE: packer.pack_field ( {packet_crc[31:0], return_token_count[4:0], source_link_ID[2:0], 5'h0, sequence_number[2:0], forward_retry_pointer[7:0], return_retry_pointer[7:0]}, 64);
|
299 |
|
|
HMC_WRITE_TYPE: packer.pack_field ( {packet_crc[31:0], return_token_count[4:0], source_link_ID[2:0], 5'h0, sequence_number[2:0], forward_retry_pointer[7:0], return_retry_pointer[7:0]}, 64);
|
300 |
|
|
HMC_MODE_READ_TYPE: packer.pack_field ( {packet_crc[31:0], return_token_count[4:0], source_link_ID[2:0], 5'h0, sequence_number[2:0], forward_retry_pointer[7:0], return_retry_pointer[7:0]}, 64);
|
301 |
|
|
HMC_POSTED_MISC_WRITE_TYPE: packer.pack_field ( {packet_crc[31:0], return_token_count[4:0], source_link_ID[2:0], 5'h0, sequence_number[2:0], forward_retry_pointer[7:0], return_retry_pointer[7:0]}, 64);
|
302 |
|
|
HMC_MISC_WRITE_TYPE: packer.pack_field ( {packet_crc[31:0], return_token_count[4:0], source_link_ID[2:0], 5'h0, sequence_number[2:0], forward_retry_pointer[7:0], return_retry_pointer[7:0]}, 64);
|
303 |
|
|
HMC_RESPONSE_TYPE: packer.pack_field ( {packet_crc[31:0], return_token_count[4:0], error_status[6:0], data_invalid, sequence_number[2:0], forward_retry_pointer[7:0], return_retry_pointer[7:0]}, 64);
|
304 |
|
|
default: uvm_report_fatal(get_type_name(), $psprintf("pack function (tail) called for a hmc_packet with an illegal command type='h%0h!", command));
|
305 |
|
|
endcase
|
306 |
|
|
endfunction : do_pack
|
307 |
|
|
|
308 |
|
|
|
309 |
|
|
virtual function void do_unpack(uvm_packer packer);
|
310 |
|
|
bit [63:0] header;
|
311 |
|
|
bit [31:0] calculated_crc;
|
312 |
|
|
bit [21:0] rsvd22;
|
313 |
|
|
bit [5:0] rsvd6;
|
314 |
|
|
bit [4:0] rsvd5;
|
315 |
|
|
bit [2:0] rsvd3;
|
316 |
|
|
bit rsvd1;
|
317 |
|
|
|
318 |
|
|
super.do_unpack(packer);
|
319 |
|
|
packer.big_endian = 0;
|
320 |
|
|
|
321 |
|
|
// header
|
322 |
|
|
header = packer.unpack_field(64);
|
323 |
|
|
command[5:0] = header[5:0];
|
324 |
|
|
|
325 |
|
|
if (get_command_type != HMC_RESPONSE_TYPE)
|
326 |
|
|
{cube_ID[2:0], rsvd3, address[33:0], tag[8:0], duplicate_length[3:0], packet_length[3:0], rsvd1, command[5:0]} = header;
|
327 |
|
|
else
|
328 |
|
|
{rsvd22[21:0], source_link_ID[2:0], rsvd6[5:0], return_tag[8:0], tag[8:0], duplicate_length[3:0], packet_length[3:0], rsvd1, command[5:0]} = header;
|
329 |
|
|
|
330 |
|
|
// Unpack should not be called with length errors
|
331 |
|
|
if (duplicate_length != packet_length || packet_length == 0)
|
332 |
|
|
`uvm_fatal(get_type_name(), $psprintf("do_unpack: length mismatch dln=%0d len=%0d cmd=%0d!", duplicate_length, packet_length, command));
|
333 |
|
|
|
334 |
|
|
// payload
|
335 |
|
|
for (int i = 0; i < packet_length-1; i++)
|
336 |
|
|
payload.push_back(packer.unpack_field(128));
|
337 |
|
|
|
338 |
|
|
// tail
|
339 |
|
|
if (get_command_type != HMC_RESPONSE_TYPE)
|
340 |
|
|
{packet_crc[31:0], return_token_count[4:0], source_link_ID[2:0], rsvd5, sequence_number[2:0], forward_retry_pointer[7:0], return_retry_pointer[7:0]} = packer.unpack_field(64);
|
341 |
|
|
else
|
342 |
|
|
{packet_crc[31:0], return_token_count[4:0], error_status[6:0], data_invalid, sequence_number[2:0], forward_retry_pointer[7:0], return_retry_pointer[7:0]} = packer.unpack_field(64);
|
343 |
|
|
|
344 |
|
|
start_retry = (command == HMC_IRTRY ? forward_retry_pointer[0] : 1'b0);
|
345 |
|
|
clear_error_abort = (command == HMC_IRTRY ? forward_retry_pointer[1] : 1'b0);
|
346 |
|
|
|
347 |
|
|
calculated_crc = calculate_crc();
|
348 |
|
|
|
349 |
|
|
// Inverted CRC means poisoned
|
350 |
|
|
poisoned = (packet_crc == ~calculated_crc) ? 1'b1 : 1'b0;
|
351 |
|
|
|
352 |
|
|
crc_error = (packet_crc != calculated_crc && !poisoned) ? 1'b1 : 1'b0;
|
353 |
|
|
endfunction : do_unpack
|
354 |
|
|
|
355 |
|
|
|
356 |
|
|
virtual function bit compare_adaptive_packet(hmc_packet rhs, uvm_comparer comparer);
|
357 |
|
|
|
358 |
|
|
string name_string;
|
359 |
|
|
|
360 |
|
|
compare_adaptive_packet &= comparer.compare_field("packet_length", packet_length, rhs.packet_length, 64, UVM_DEC);
|
361 |
|
|
compare_adaptive_packet &= comparer.compare_field("payload.size()", payload.size(), rhs.payload.size(), 64, UVM_DEC);
|
362 |
|
|
|
363 |
|
|
for (int i=0; i
|
364 |
|
|
begin
|
365 |
|
|
if (!compare_adaptive_packet)
|
366 |
|
|
return 0;
|
367 |
|
|
$sformat(name_string, "payload[%0d]", i);
|
368 |
|
|
compare_adaptive_packet &= comparer.compare_field(name_string, payload[i], rhs.payload[i], 128, UVM_HEX);
|
369 |
|
|
end
|
370 |
|
|
|
371 |
|
|
compare_adaptive_packet &= comparer.compare_field("cube_ID", cube_ID, rhs.cube_ID, 64, UVM_DEC);
|
372 |
|
|
compare_adaptive_packet &= comparer.compare_field("address", address, rhs.address, 64, UVM_DEC);
|
373 |
|
|
compare_adaptive_packet &= comparer.compare_field("tag", tag, rhs.tag, 64, UVM_DEC);
|
374 |
|
|
compare_adaptive_packet &= comparer.compare_field("packet_length", packet_length, rhs.packet_length, 64, UVM_DEC);
|
375 |
|
|
compare_adaptive_packet &= comparer.compare_field("duplicate_length", duplicate_length, rhs.duplicate_length, 64, UVM_DEC);
|
376 |
|
|
compare_adaptive_packet &= comparer.compare_field("command", command, rhs.command, 64, UVM_DEC);
|
377 |
|
|
compare_adaptive_packet &= comparer.compare_field("return_token_count", return_token_count, rhs.return_token_count, 64, UVM_DEC);
|
378 |
|
|
compare_adaptive_packet &= comparer.compare_field("source_link_ID", source_link_ID, rhs.source_link_ID, 64, UVM_DEC);
|
379 |
|
|
compare_adaptive_packet &= comparer.compare_field("sequence_number", sequence_number, rhs.sequence_number, 64, UVM_DEC);
|
380 |
|
|
compare_adaptive_packet &= comparer.compare_field("forward_retry_pointer", forward_retry_pointer, rhs.forward_retry_pointer, 64, UVM_DEC);
|
381 |
|
|
compare_adaptive_packet &= comparer.compare_field("return_tag", return_tag, rhs.return_tag, 64, UVM_DEC);
|
382 |
|
|
compare_adaptive_packet &= comparer.compare_field("error_status", error_status, rhs.error_status, 64, UVM_DEC);
|
383 |
|
|
compare_adaptive_packet &= comparer.compare_field("data_invalid", data_invalid, rhs.data_invalid, 64, UVM_DEC);
|
384 |
|
|
compare_adaptive_packet &= comparer.compare_field("start_retry", start_retry, rhs.start_retry, 64, UVM_DEC);
|
385 |
|
|
compare_adaptive_packet &= comparer.compare_field("clear_error_abort", clear_error_abort, rhs.clear_error_abort, 64, UVM_DEC);
|
386 |
|
|
|
387 |
|
|
endfunction : compare_adaptive_packet
|
388 |
|
|
|
389 |
|
|
endclass : hmc_packet
|
390 |
|
|
|
391 |
|
|
`endif // HMC_PACKET_SV
|
392 |
|
|
|