module tb;
bit [31:0] assoc_q[int][$];
int tag_id;
initial begin
tag_id = 7;
assoc_q[tag_id][0] = 4;
$display("assoc_q[%d][0]=%d",tag_id,assoc_q[tag_id][0]);
assoc_q[tag_id][6] = 5;
$display("assoc_q[%d][6]=%d",tag_id,assoc_q[tag_id][6]);
end
endmodule
Following is the simulator o/p where I am getting WARNING message “SystemVerilog queue index 6 is beyond the queue’s writable range [0:1]”.
Can someone help me fix the code and/or suggest an alternate to get rid of this warning?
Thank you for your support in advance.
Shailesh
====
assoc_q[ 7][0]= 4
assoc_q[tag_id][6] = 5;
|
ncsim: *W,RTSVQI (./testbench.sv,12|19): SystemVerilog queue index 6 is beyond the queue’s writable range [0:1].
assoc_q[ 7][6]= 0
Simulation complete via implicit call to $finish(1) at time 0 FS + 1
./testbench.sv:4 program tb;
The major difference between queues, associative, and dynamic arrays is how elements get allocated. Once they are allocated, you can access them the same with a valid index.
A queue works best when you expect to be adding and removing elements one at a time. Otherwise, consider using a dynamic array.