如何使用PLI例程获取verilog向量端口的维度?

时间:2018-02-25 15:34:50

标签: verilog vpi

如何使用vpi PLI例程获取矢量端口的尺寸?例如,对于矢量端口声明"输出[2:1]输出;",如何将左维度设为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。我的代码有什么错误吗?

0 个答案:

没有答案