How can I fetch the dimensions of a vector port using the vpi PLI routines? For example, for the vector port declaration "output [2:1] out;", how can I get the left dimension as 2 and right dimension as 1? I tried using vpiRange property but it seems that vpiRange property is not supported for Ports. Thanks! Putting the code here for clarity.
vpiHandle lowconn = vpi_handle(vpiLowConn, portH);
int dim = 0;
int ldim[10];
int rdim[10];
vpiHandle range_itr = vpi_iterate(vpiRange, lowconn );
vpiHandle range;
while ((range = vpi_scan(range_itr))) {
ldim[dim] = vpi_get(vpiLeftRange, range);
rdim[dim] = vpi_get(vpiRightRange, range);
dim++;
}
int size = vpi_get(vpiSize, portH);
cout << endl << vpi_get_str(vpiName, portH) << " size = " << size << " LeftRange = " << vpi_get(vpiLeftRange, lowconn ) << " RightRange = " << vpi_get(vpiRightRange, lowconn );
for ( int i = 0; i < dim; i++ ) {
cout << vpi_get_str(vpiName, portH) << " = " << ldim[i] << ":" << rdim[i];
}
I am getting -1 from vpi_get(vpiLeft/RightRange) as well as in ldim and rdim. Is there anything erroneos with my code?