IMPORTANT NOTICE: Please be advised that the Verification Academy Forums will be offline for scheduled maintenance on Sunday, April 6th at 2:00 US/Pacific.
I am trying a struct of arrays, something like this,
typedef struct {
int hash_id;
int hash_index;
} hash_t;
class something_here
hash_t hash [int];
int temp_value = 13;
hash[temp_value].hash_id[0] = 21;
hash[temp_value].hash_id[1] = 22;
hash[temp_value].hash_id[2] = 23;
hash[temp_value].hash_id[3] = 24;
foreach (hash[temp_value].hash_id[i]) begin
// display statements and some other code here
end
endclass
But, somehow the foreach loop is not even executed and the prints and the code is not getting executed after that. But, i was wondering if what i have done is right for the creation of the hash and if the syntax for the foreach loop is correct.
hash_id and hash_index are dynamic arrays and need to be allocated with the new[] operator. Or did you mean to declare these as associative arrays as well?
Hi, Would it be possible to post your fixed code with the memory allocation ? I’m trying out a couple of things, but i’m unable to allocate memory using the new operator inside a class.
I’m able to do it in a module, but not in a class.