Can anybody explain how I can make a queue of associative arrays and parse them to see whether the element exists?
Basically I need an 3 associative arrays.
index[0][8] = 32'hABCD_0123;
index[1][7] = 32'hABCD_0123;
index[2][5] = 32'hABCD_0123;
if(index[0].exists(8)) begin
$display("element: %h found for sub-index 0 for Index: %0d",index[0][8],8);
end else
$display("Element not found...");
end
endmodule
But, I get an error, like the one below:
Error-[XMRE] Cross-module reference resolution error
queue_of_assoc_array.sv, 16
Error found while trying to resolve cross-module reference.
token ‘exists’. Originating module ‘test’.
Source info: index[0].exists(8)
(1) What is wrong with the above code ?
(2) In general how do we know in a multi-dimensional array which dimension is for what ?
I would also like to know how to build, load, parse data from , queue of queues, queue of associative/dynamic-arrays and vice versa or any combination of these.
Can anyone explain with an example ? or point me to a paper or source where this is explained with an example?
We strongly recommend declaring a type for the associative array index, rather than using the [*] wildcard index. A wildcard index is very restrictive if you try to use it with other constructs like a foreach loop. What you probably meant is
typedef bit [DEPTH_BITS-1:0] depth_t;
bit[WIDTH_BITS-1:0] index[3][depth_t];
And if you really wanted a queue of an associative arrays, that would be declared as
Yes, section_7.4.5 Multidimensional arrays_ of the 1800-2012 LRM explains this, although that section was written with examples that only show fixed sized arrays. You can substitute a fixed range (e.g. [10:0] or [11]) for an associative array ([int]) or queue ([$]). It’s better to think of arrays of arrays instead of mufti-dimentional arrays.
ndalia,
If by “register” you mean to use one of the `uvm_field macros, we strongly recommend that you do not use them because of the poor performance they introduce, confusion over auto-config, as well as the fact that they are limited in supporting a lot of SV types. See MacroCostBenefit | Verification Academy
Thanks for the answer. Referring to ndalia's question on registering the multi-dimensional arrays in config db you said there is a performance issue. Sometime back, I had posted a question https://verificationacademy.com/forums/uvm/generating-sequences-based-activity-other-interfaces
regarding passing some information an array / queue, which needs to be referred to modify the stimulus. If you can please refer and comment on whether there is a performance impact with the suggested approach, I would be grateful.