Hi,
I have a few associative arrays in my class 1.
class1 {
int assoc_arr1[int] = '{default:0};
}
I instantiate the class in another class 2.
In class 2 , there is a loop within which i update the associative arrays of class1.Obj.
eg:
//snippet of class 2 code
task some_task;
@posedge clk:
for (int i = 0 ; i < Q_DEPTH ; i ++) begin
// some lines of code here
class1Obj.assoc_arr1[Q[i]]++;
end
some_Class1Queue.push_back(class1Obj);
endtask : some_task
Before entering the above for loop, i want to initialize all values of assoc_arr1.
Currently i am doing that by calling “new” after i enter the posedge clk block.
ie :
task some_task;
@posedge clk:
class1.Obj = new();
for (int i = 0 ; i < _DEPTH ; i ++) begin
// some lines of code here
class1Obj.assoc_arr1[Q[i]]++;
end
some_Class1Queue.push_back(class1Obj);
endtask : some_task
I feel that calling “new” every posedge clk would be a ‘time-consuming’ function call. [please correct me if i am wrong here].
How can i re-initialize my assoc_arr without calling the constructor and having a new object.