OpenCores
URL https://opencores.org/ocsvn/openhmc/openhmc/trunk

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [sim/] [UVC/] [hmc_base_types/] [sv/] [hmc_packet.sv] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
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 15 juko
        rand bit [33:0]         address;                                // ADRS
54 12 juko
        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 15 juko
        rand bit [31:0]         packet_crc;                             // CRC
68 12 juko
 
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 15 juko
 
87
        int                                             timestamp;
88 12 juko
 
89
        `uvm_object_utils_begin(hmc_packet)
90
                `uvm_field_int(flit_delay, UVM_ALL_ON | UVM_NOPACK | UVM_DEC | UVM_NOCOMPARE | UVM_DEC)
91
                `uvm_field_int(cube_ID, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
92
                `uvm_field_int(address, UVM_ALL_ON | UVM_NOPACK | UVM_HEX)
93
                `uvm_field_int(tag, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
94
                `uvm_field_int(packet_length, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
95
                `uvm_field_int(duplicate_length, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
96
                `uvm_field_enum(hmc_command_encoding, command, UVM_ALL_ON | UVM_NOPACK )
97
                `uvm_field_queue_int(payload, UVM_ALL_ON | UVM_NOPACK)
98
                `uvm_field_int(return_token_count, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
99
                `uvm_field_int(source_link_ID, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
100
                `uvm_field_int(sequence_number, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
101
                `uvm_field_int(forward_retry_pointer, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
102
                `uvm_field_int(return_retry_pointer, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
103
                `uvm_field_int(packet_crc, UVM_ALL_ON | UVM_NOPACK | UVM_HEX)
104
                `uvm_field_int(return_tag, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
105
                `uvm_field_int(error_status, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
106
                `uvm_field_int(data_invalid, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
107
                `uvm_field_int(poisoned, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
108
                `uvm_field_int(crc_error, UVM_ALL_ON | UVM_NOPACK | UVM_DEC)
109
        `uvm_object_utils_end
110
 
111
        constraint c_poisoned { poisoned == 0; }
112
        constraint c_cube_id {cube_ID ==0;}
113 15 juko
        constraint c_address {
114
                soft address < 80000000;
115
                ((command & `HMC_TYPE_MASK) == HMC_FLOW_TYPE) -> address == 0;
116
                soft address[3:0]==4'h0;
117
        }
118
        constraint c_source_link_ID {source_link_ID ==0;}
119 12 juko
        constraint c_crc_error { crc_error == 0; }
120
        constraint c_matching_length { packet_length == duplicate_length; }
121
        constraint c_return_tag { return_tag == 0; }
122
        constraint c_packet_length { (
123
                                                (packet_length == 2 && command == HMC_POSTED_WRITE_16) ||
124
                                                (packet_length == 3 && command == HMC_POSTED_WRITE_32) ||
125
                                                (packet_length == 4 && command == HMC_POSTED_WRITE_48) ||
126
                                                (packet_length == 5 && command == HMC_POSTED_WRITE_64) ||
127
                                                (packet_length == 6 && command == HMC_POSTED_WRITE_80) ||
128
                                                (packet_length == 7 && command == HMC_POSTED_WRITE_96) ||
129
                                                (packet_length == 8 && command == HMC_POSTED_WRITE_112) ||
130
                                                (packet_length == 9 && command == HMC_POSTED_WRITE_128) ||
131
                                                (packet_length == 2 && command == HMC_WRITE_16) ||
132
                                                (packet_length == 3 && command == HMC_WRITE_32) ||
133
                                                (packet_length == 4 && command == HMC_WRITE_48) ||
134
                                                (packet_length == 5 && command == HMC_WRITE_64) ||
135
                                                (packet_length == 6 && command == HMC_WRITE_80) ||
136
                                                (packet_length == 7 && command == HMC_WRITE_96) ||
137
                                                (packet_length == 8 && command == HMC_WRITE_112) ||
138
                                                (packet_length == 9 && command == HMC_WRITE_128) ||
139
                                                (packet_length > 1 && packet_length <= 9 && command == HMC_READ_RESPONSE) ||
140
                                                (packet_length == 1 && command == HMC_WRITE_RESPONSE) ||
141
                                                (packet_length == 1 && command == HMC_MODE_WRITE_RESPONSE) ||
142
                                                (packet_length == 1 && command == HMC_ERROR_RESPONSE) ||
143
                                                (packet_length == 2 && (command & `HMC_TYPE_MASK) == HMC_MISC_WRITE_TYPE) ||
144
                                                (packet_length == 2 && (command & `HMC_TYPE_MASK) == HMC_POSTED_MISC_WRITE_TYPE) ||
145
                                                (packet_length == 1 && (command & `HMC_TYPE_MASK) == HMC_MODE_READ_TYPE) ||
146
                                                (packet_length == 1 && (command & `HMC_TYPE_MASK) == HMC_READ_TYPE) ||
147
                                                (packet_length == 1 && (command & `HMC_TYPE_MASK) == HMC_FLOW_TYPE)
148
                ); }
149
        constraint c_flit_delay {
150
                soft flit_delay dist{0:/90, [1:8]:/8, [8:200]:/2  };
151
        }
152 15 juko
        constraint c_error_status {
153
                soft error_status == 0;
154
        }
155 12 juko
 
156 15 juko
        constraint c_data_invalid {
157
                soft data_invalid == 0;
158
        }
159
 
160
 
161
        constraint c_pret {
162
                (command == HMC_PRET)-> forward_retry_pointer   ==0;
163
                (command == HMC_PRET)-> sequence_number                 ==0;
164
        }
165
        constraint c_irtry{
166
                (command == HMC_IRTRY)                                                  -> start_retry                  != clear_error_abort;
167
                ((command == HMC_IRTRY)&&(start_retry)) 		->forward_retry_pointer == 1;
168
                ((command == HMC_IRTRY)&&(clear_error_abort))	->forward_retry_pointer == 2;
169
                (command == HMC_IRTRY)                                                  -> sequence_number              == 0;
170
        }
171
 
172
        constraint c_flow {
173
                ((command & `HMC_TYPE_MASK) == HMC_FLOW_TYPE) -> tag == 0;
174
                ((command & `HMC_TYPE_MASK) == HMC_FLOW_TYPE) -> cube_ID == 0;
175
        }
176
 
177 12 juko
        function new (string name = "hmc_packet");
178
                super.new(name);
179
        endfunction : new
180
 
181
    function void post_randomize();
182
                bit [127:0] rand_flit;
183
 
184
        super.post_randomize();
185
 
186
                if (packet_length > 9)
187
                        `uvm_fatal(get_type_name(),$psprintf("post_randomize packet_length = %0d",packet_length))
188
 
189
                `uvm_info("AXI Packet queued",$psprintf("%0s packet_length = %0d",command.name(), packet_length), UVM_HIGH)
190
 
191
                if (packet_length < 2)
192
                        return;
193
 
194
                for (int i=0; i
195
                        randomize_flit_successful : assert (std::randomize(rand_flit));
196
                        payload.push_back(rand_flit);
197
                end
198
                if ((command == HMC_POSTED_DUAL_8B_ADDI)||
199
                        (command == HMC_DUAL_8B_ADDI)) begin
200
                        payload[0] [63:32] = 32'b0;
201
                        payload[0][127:96] = 32'b0;
202
                end
203
 
204
                if ((command == HMC_MODE_WRITE)|| (command == HMC_MODE_READ)) begin
205
                        payload[0][127:32] = 96'b0;
206
                end
207
    endfunction
208
 
209
        function hmc_command_type get_command_type();
210
 
211
                case(command & `HMC_TYPE_MASK)
212
                        HMC_FLOW_TYPE:                          return HMC_FLOW_TYPE;
213
                        HMC_READ_TYPE:                          return HMC_READ_TYPE;
214
                        HMC_MODE_READ_TYPE:                     return HMC_MODE_READ_TYPE;
215
                        HMC_POSTED_WRITE_TYPE:          return HMC_POSTED_WRITE_TYPE;
216
                        HMC_POSTED_MISC_WRITE_TYPE:     return HMC_POSTED_MISC_WRITE_TYPE;
217
                        HMC_WRITE_TYPE:                         return HMC_WRITE_TYPE;
218
                        HMC_MISC_WRITE_TYPE:            return HMC_MISC_WRITE_TYPE;
219
                        HMC_RESPONSE_TYPE:                      return HMC_RESPONSE_TYPE;
220
                        default: uvm_report_fatal(get_type_name(), $psprintf("command with an illegal command type='h%0h!", command));
221
                endcase
222
 
223
        endfunction : get_command_type
224
 
225
/*
226
                The CRC algorithm used on the HMC is the Koopman CRC-32K. This algorithm was
227
                chosen for the HMC because of its balance of coverage and ease of implementation. The
228
                polynomial for this algorithm is:
229
                x32 + x30 + x29 + x28 + x26 + x20 + x19 + x17 + x16 + x15 + x11 + x10 + x7 + x6 + x4 + x2 + x + 1
230
 
231
                bit [31:0] polynomial = 33'b1_0111_0100_0001_1011_1000_1100_1101_0111;  // Normal
232
 
233
                The CRC calculation operates on the LSB of the packet first. The packet CRC calculation
234
                must insert 0s in place of the 32-bits representing the CRC field before generating or
235
                checking the CRC. For example, when generating CRC for a packet, bits [63: 32] of the
236
                Tail presented to the CRC generator should be all zeros. The output of the CRC generator
237
                will have a 32-bit CRC value that will then be inserted in bits [63:32] of the Tail before
238
                forwarding that FLIT of the packet. When checking CRC for a packet, the CRC field
239
                should be removed from bits [63:32] of the Tail and replaced with 32-bits of zeros, then
240
                presented to the CRC checker. The output of the CRC checker will have a 32-bit CRC
241
                value that can be compared with the CRC value that was removed from the tail. If the two
242
                compare, the CRC check indicates no bit failures within the packet.
243
*/
244
 
245
        function bit [31:0] calculate_crc();
246 15 juko
                bit bitstream[];
247
                packer_succeeded : assert (pack(bitstream) > 0);
248
                return calc_crc(bitstream);
249
        endfunction : calculate_crc
250
 
251
        function bit [31:0] calc_crc(bit bitstream[]);
252 12 juko
                bit [32:0] polynomial = 33'h1741B8CD7; // Normal
253 15 juko
 
254 12 juko
                bit [32:0] remainder = 33'h0;
255 15 juko
                for( int i=0; i < bitstream.size()-32; i++ ) begin      // without the CRC
256 12 juko
                        remainder = {remainder[31:0], bitstream[i]};
257
                        if( remainder[32] ) begin
258
                                remainder = remainder ^ polynomial;
259
                        end
260
                end
261
 
262
                for( int i=0; i < 64; i++ ) begin       // zeroes for CRC and remainder
263
                        remainder = {remainder[31:0], 1'b0};
264
                        if( remainder[32] ) begin
265
                                remainder = remainder ^ polynomial;
266
                        end
267
                end
268
 
269
                return remainder[31:0];
270 15 juko
        endfunction : calc_crc
271 12 juko
 
272
        virtual function void do_pack(uvm_packer packer);
273
 
274
                super.do_pack(packer);
275
                packer.big_endian = 0;
276
 
277
                // pack header half flit
278
                case(command & `HMC_TYPE_MASK)
279
                        HMC_FLOW_TYPE:
280
                                case (command)
281
                                        HMC_NULL:               packer.pack_field( {64'h0}, 64);
282
                                        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);
283
                                        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);
284
                                        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);
285
                                        default: uvm_report_fatal(get_type_name(), $psprintf("pack function called for a hmc_packet with an illegal FLOW type='h%0h!", command));
286
                                endcase
287 15 juko
                        HMC_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);
288
                        HMC_MODE_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);
289 12 juko
                        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);
290
                        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);
291
                        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);
292 15 juko
                        HMC_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);
293 12 juko
                        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);
294
                        default: uvm_report_fatal(get_type_name(), $psprintf("pack function called for a hmc_packet with an illegal command type='h%0h!", command));
295
                endcase
296
 
297
                // Allow for errors when packet_length != duplicate_length
298
                if ((packet_length == duplicate_length) && payload.size() + 1 != packet_length && command != HMC_NULL)
299
                        uvm_report_fatal(get_type_name(), $psprintf("pack function size mismatch payload.size=%0d packet_length=%0d!", payload.size(), packet_length));
300
 
301
                // pack payload
302
                for( int i=0; i
303
 
304
                // pack tail half flit
305
                case(command & `HMC_TYPE_MASK)
306
                        HMC_FLOW_TYPE:
307
                                case (command)
308
                                        HMC_NULL:               packer.pack_field( {64'h0}, 64);
309
                                        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);
310
                                        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);
311
                                        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);
312
                                        default: uvm_report_fatal(get_type_name(), $psprintf("pack function (tail) called for a hmc_packet with an illegal FLOW type='h%0h!", command));
313
                                endcase
314
                        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);
315
                        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);
316
                        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);
317
                        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);
318
                        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);
319
                        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);
320
                        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);
321
                        default: uvm_report_fatal(get_type_name(), $psprintf("pack function (tail) called for a hmc_packet with an illegal command type='h%0h!", command));
322
                endcase
323
        endfunction : do_pack
324
 
325
 
326
        virtual function void do_unpack(uvm_packer packer);
327
                bit [63:0]      header;
328 15 juko
                bit [63:0]      tail;
329 12 juko
                bit [31:0]      calculated_crc;
330
                bit [21:0]      rsvd22;
331
                bit [5:0]       rsvd6;
332
                bit [4:0]       rsvd5;
333
                bit [2:0]       rsvd3;
334
                bit             rsvd1;
335
 
336 15 juko
                bit bitstream[];
337
 
338 12 juko
                super.do_unpack(packer);
339
                packer.big_endian = 0;
340
 
341 15 juko
                packer.get_bits(bitstream);
342
 
343
                for (int i = 0; i <32; i++)begin
344
                        packet_crc[i] = bitstream[bitstream.size()-32 +i];
345
                end
346
 
347
                calculated_crc = calc_crc(bitstream);
348 12 juko
                // header
349
                header = packer.unpack_field(64);
350 15 juko
                command[5:0] = header[5:0];//-- doppelt?
351 12 juko
 
352
                if (get_command_type != HMC_RESPONSE_TYPE)
353
                        {cube_ID[2:0], rsvd3, address[33:0], tag[8:0], duplicate_length[3:0], packet_length[3:0], rsvd1, command[5:0]}  = header;
354
                else
355
                        {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;
356
                // Unpack should not be called with length errors
357
                if (duplicate_length != packet_length || packet_length == 0)
358
                        `uvm_fatal(get_type_name(), $psprintf("do_unpack: length mismatch dln=%0d len=%0d cmd=%0d!", duplicate_length, packet_length, command));
359
 
360
                // payload
361
                for (int i = 0; i < packet_length-1; i++)
362
                        payload.push_back(packer.unpack_field(128));
363
 
364
                // tail
365 15 juko
                tail = packer.unpack_field(64);
366
                if (get_command_type != HMC_RESPONSE_TYPE)
367
                        {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]}    = tail;
368 12 juko
                else
369 15 juko
                        {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]}       = tail;
370 12 juko
 
371
                start_retry                     = (command == HMC_IRTRY ? forward_retry_pointer[0] : 1'b0);
372
                clear_error_abort       = (command == HMC_IRTRY ? forward_retry_pointer[1] : 1'b0);
373
 
374 15 juko
                crc_error = 0;
375 12 juko
 
376
                poisoned = (packet_crc == ~calculated_crc) ? 1'b1 : 1'b0;
377 15 juko
                if (packet_crc != calculated_crc &&  !poisoned )
378
                begin
379
                        crc_error = 1;
380
                end
381 12 juko
        endfunction : do_unpack
382
 
383
 
384
        virtual function bit compare_adaptive_packet(hmc_packet rhs, uvm_comparer comparer);
385
 
386
                string name_string;
387
 
388
                compare_adaptive_packet &= comparer.compare_field("packet_length", packet_length, rhs.packet_length, 64, UVM_DEC);
389
                compare_adaptive_packet &= comparer.compare_field("payload.size()", payload.size(), rhs.payload.size(), 64, UVM_DEC);
390
 
391
                for (int i=0; i
392
                begin
393
                        if (!compare_adaptive_packet)
394
                                return 0;
395
                        $sformat(name_string, "payload[%0d]", i);
396
                        compare_adaptive_packet &= comparer.compare_field(name_string, payload[i], rhs.payload[i], 128, UVM_HEX);
397
                end
398
 
399
                compare_adaptive_packet &= comparer.compare_field("cube_ID", cube_ID, rhs.cube_ID, 64, UVM_DEC);
400
                compare_adaptive_packet &= comparer.compare_field("address", address, rhs.address, 64, UVM_DEC);
401
                compare_adaptive_packet &= comparer.compare_field("tag", tag, rhs.tag, 64, UVM_DEC);
402
                compare_adaptive_packet &= comparer.compare_field("packet_length", packet_length, rhs.packet_length, 64, UVM_DEC);
403
                compare_adaptive_packet &= comparer.compare_field("duplicate_length", duplicate_length, rhs.duplicate_length, 64, UVM_DEC);
404
                compare_adaptive_packet &= comparer.compare_field("command", command, rhs.command, 64, UVM_DEC);
405
                compare_adaptive_packet &= comparer.compare_field("return_token_count", return_token_count, rhs.return_token_count, 64, UVM_DEC);
406
                compare_adaptive_packet &= comparer.compare_field("source_link_ID", source_link_ID, rhs.source_link_ID, 64, UVM_DEC);
407
                compare_adaptive_packet &= comparer.compare_field("sequence_number", sequence_number, rhs.sequence_number, 64, UVM_DEC);
408
                compare_adaptive_packet &= comparer.compare_field("forward_retry_pointer", forward_retry_pointer, rhs.forward_retry_pointer, 64, UVM_DEC);
409
                compare_adaptive_packet &= comparer.compare_field("return_tag", return_tag, rhs.return_tag, 64, UVM_DEC);
410
                compare_adaptive_packet &= comparer.compare_field("error_status", error_status, rhs.error_status, 64, UVM_DEC);
411
                compare_adaptive_packet &= comparer.compare_field("data_invalid", data_invalid, rhs.data_invalid, 64, UVM_DEC);
412
                compare_adaptive_packet &= comparer.compare_field("start_retry", start_retry, rhs.start_retry, 64, UVM_DEC);
413
                compare_adaptive_packet &= comparer.compare_field("clear_error_abort", clear_error_abort, rhs.clear_error_abort, 64, UVM_DEC);
414
 
415
        endfunction : compare_adaptive_packet
416
 
417
endclass : hmc_packet
418
 
419
`endif // HMC_PACKET_SV
420
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.