verilog VPI 回调
VPI 回调 cbValueChange
应该做什么以及它如何工作?
假设我想在信号的 posege
处执行一个函数 X
(大约 2000 个周期)。我应该使用回调 cbValueChange
还是从测试台调用代码?
always @posedge(X)
begin
$pli
end
哪个更有效率?
What is VPI call back cbValueChange
supposed to do and how does it work?
Suppose I want to execute a function at the posedge
of signalX
(about 2000 cycles). Should I use call back cbValueChange
or call the code from the test bench?
always @posedge(X)
begin
$pli
end
Which would be more efficient?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就效率而言,这可能并不重要。如果没有更好地了解您的情况,很难提供可靠的建议,但我建议您使用 $pli 调用,如您的示例所示。使用 cbValueChange 意味着注册一些 C 代码,以便在变量值更改时由模拟器执行。发生这种情况时,无需在值更改时调用用户定义的 $pli 例程。由于这对于任何阅读 Verilog 代码的人来说都是完全不可见的,因此如果您的 C 代码进行了影响模拟的任何更改,那么任何试图了解正在发生的情况的人都会感到沮丧。
Efficiency wise it probably doesn't matter much. Without a better understanding of your situation it's tough to give solid advice but I recommend the $pli call as in your example. Using cbValueChange means registering some C code to be executed by the simulator when the value of a variable changes. This happens without a user defined $pli routine being called at the time the value changes. Since this is completely invisible to anybody reading the Verilog code, you will frustrate anybody trying to understand what is going on if your C code makes any changes that affect the simulation.
cbValueChange
是用于通过vpi_register_cb()
注册/接收已注册信号的值更改事件的原因。因此,当信号值发生翻转或更改时,模拟器将在适当的模拟阶段调用回调函数。如果您只想调用自己的 PLI/VPI 函数,您可以在 http 中查看详细示例://www.asic-world.com/verilog/pli5.htmlcbValueChange
is the reason used to register/receive value change event for a registered signal viavpi_register_cb()
. So when the signal value got flipped or changed, the simulator will invoke the callback function at the proper simulation phase. If you want to invoke your own PLI/VPI function only, you can see the detail example in http://www.asic-world.com/verilog/pli5.html