“Reference signal name from parent module” 可以翻译为 “来自父模块的参考信号名称”。

huangapple go评论46阅读模式
英文:

Reference signal name from parent module

问题

我想引用我的模块输入上的一个信号的名称。

例如,目前我写的是这样的。

sigref_checker
#(.reltol(0.0),
  .abstol(0.1),
  .startTime (111111ps),
  .stopTime(911111ps),
  ._signal("OUT1"),
  ._ref_signal("OUT2")
  )

  chk1 (
  .signal(OUT1),
  .ref_signal(OUT2),
  .enable_signal(1'b1)
  );

如果 "._signal" 和 "._ref_signal" 能在 chk1 模块内部被推断出来,那就好了,这样我的 chk1 模块会打印:

top.chk1.sig_ref_chk FAIL: OUT1 < OUT2-tol (1.666667 < 1.876363)

而不是:

top.chk1.sig_ref_chk FAIL: signal < ref_signal-tol (1.666667 < 1.876363)

我尝试在模块内部使用宏,但无法从模块内部引用父信号名称。

英文:

I want to reference the name of a signal that is on the input of my module.

For example, currently I write this.

sigref_checker
#(.reltol(0.0),
  .abstol(0.1),
  .startTime (111111ps),
  .stopTime(911111ps),
  ._signal(&quot;OUT1&quot;),
  ._ref_signal(&quot;OUT2&quot;)
  )

  chk1 (
  .signal(OUT1),
  .ref_signal(OUT2),
  .enable_signal(1&#39;b1)
  );

It would be nice if "._signal" and "._ref_signal" could be inferred internally in the chk1 module, so that my chk1 module prints:

> top.chk1.sig_ref_chk FAIL: OUT1 < OUT2-tol (1.666667 < 1.876363)

Instead of:

> top.chk1.sig_ref_chk FAIL: signal < ref_signal-tol (1.666667 <
> 1.876363)

I tried using macros inside the module, but I was not able to reference the parent signal name from within the module

答案1

得分: 1

这是您提供的代码的翻译部分:

在您的检查器模块内部,您可以调用 `$getParentName(signal);`。

但更简单的方式可能是创建一个宏来实例化您的检查器模块。

`define sigref_checker_inst(R,A,START,STOP,SIGNAL,REF) \
#(.reltol(R), \
  .abstol(A),\
  .startTime (START),\
  .stopTime(STOP),\
  ._signal(`&quot;SIGNAL`&quot;),\
  ._ref_signal(`&quot;REF`&quot;)\
  )\
  chk1 (\
  .signal(SIGNAL),\
  .ref_signal(REF),\
  .enable_signal(1&#39;b1)\
  );

请注意,代码中的特殊字符和宏名称保持不变。

英文:

It is possible to do this creating a C function using SystemVerilog's VPI.

int getParentName(char *user data) {
    vpiHandle system_h, arg_itr, in_h, , out_h, parent_handle;
    s_vpi_value out_s;
   // all this code just to get a handle to the function&#39;s argument
   // and without proper error checking
   sys_h = vpi_handle(vpiSysTfCall, NULL);
   arg_itr = vpi_iterate(vpiArgument, sys_h);
   in_h = vpi_scan(arg_itr);
   out_h = vpi_scan(arg_itr);
   // now get its parent net
   parent_h = vpi_get(vpiHighConn, in_h);
   // return the name of the net
   out_s.format = vpiStringVal;
   out_s.str = vpi_get_str(vpiName,parent_h);
   vpi_put_value(out_h,&amp;out_s);
}

Inside your checker module you would call $getParentName(signal);

But it might be just easier to create a macro that instantiates your checker module

`define sigref_checker_inst(R,A,START,STOP,SIGNAL,REF) \
#(.reltol(R), \
  .abstol(A),\
  .startTime (START),\
  .stopTime(STOP),\
  ._signal(`&quot;SIGNAL`&quot;),\
  ._ref_signal(`&quot;REF`&quot;)\
  )\
  chk1 (\
  .signal(SIGNAL),\
  .ref_signal(REF),\
  .enable_signal(1&#39;b1)\
  );

 





</details>



huangapple
  • 本文由 发表于 2023年5月24日 21:27:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76324073.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定