For example
// test.sv
class cls;
int b;
endclass
module m
cls testObj;
int map[cls];
initial begin
inst = new;
inst.b = 10;
map[cls] = 12;
$VPIcall;
end
endmoudle
// pseudocode vpi c
vpiHandle mapHandle = vpi_handle_by_name("m.map", 0); // return valid handle
vpiHandle valueHandle = vpi_handle_by_name("map[testObj]", mapHandle); // return zero
seems we could not get valueHandle like this and I wonder whether is it possible to iterate or get value stored in associative array through VPI?
Notes:
Here is a sample that works for me with vcs:
verilog:
vpi:
Alternatively, for simpler associative arrays, like the once using strings for associations, it is easy to use an export dpi functions to do direct access, like in the following example: