如何使用 vpi PLI 例程获取矢量端口的尺寸?例如,对于向量端口声明“输出 [2:1] out;”,我怎样才能得到左维为 2 和右维为 1?我尝试使用 vpiRange 属性,但似乎端口不支持 vpiRange 属性。谢谢!为了清楚起见,将代码放在这里。
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];
}
我从 vpi_get(vpiLeft/RightRange) 以及 ldim 和 rdim 中得到 -1。我的代码有什么错误吗?