在仿真代码中访问 Verilog genvar 生成的实例
这是一个与 Verilog 相关的问题。我正在使用 XILINX ISE 作为开发环境。
我正在尝试访问模拟中使用 genvar 自动生成的变量,但收到以下错误 -> HDLCompiler:71
问题示例:
genvar i;
generate
for(i=0; i < N; i=i+1)
begin:Sys_Modules
TypeXModule #(.width(10)) xmod(.dataY(dataY)));
end
endgenerate
当我运行综合或模拟时,我可以看到创建了 Sys_Modules[0..N-1].xmod 实例。
当我尝试向访问 Sys_Modules 数组的模拟添加一行:
Sys_Modules[i].xmod.dataY
时,出现以下错误:
HDLCompiler:71 dataY is not statements under prefix xmod
有没有办法访问自动生成的值模拟?
谢谢!
This is a Verilog releated question. I am working with XILINX ISE as a dev environment.
I am trying to access variables in the simulation that are automatically generated using genvar but I am receiving the following error -> HDLCompiler:71
Problem Example:
genvar i;
generate
for(i=0; i < N; i=i+1)
begin:Sys_Modules
TypeXModule #(.width(10)) xmod(.dataY(dataY)));
end
endgenerate
When I ran synthesis or simulation I can see that Sys_Modules[0..N-1].xmod instances are created.
When I try to add a line to the simulation accessing the Sys_Modules array:
Sys_Modules[i].xmod.dataY
I get the following error:
HDLCompiler:71 dataY is not declared under prefix xmod
Is there any way to access automatically generated values in the simulation?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
向生成的实例写入分层引用是合法的。 IEEE Verilog 标准的 2.7.2 和 12.1.3 节描述了该功能。但是,实例下标必须是常量,以便可以在编译时解析。
It is legal to write a hierarchical reference to a generated instance. The functionality is described in sections 2.7.2 and 12.1.3 of the IEEE Verilog standard. However, the instance subscript must be a constant so that it can be resolved at compile time.
您不能在合成的 Verilog 中使用跨实例分层引用。
You cannot use cross-instance hierarchical references in synthesized Verilog.
我想你运气不好。正如您所发现的,模拟器似乎不喜欢指向生成块的模块外引用(OOMR)。
我最近在制作可参数化的测试台监视器时遇到了类似的问题。我根据
参数
实例化了可变数量的子块。其中,我需要有一个顶级.start()
任务来调用每个实例化模块中的.start()
任务。由于 OOMR 问题,我无法使用for
循环来执行此操作。所以我最终不得不:
.start()
任务切换的reg
上触发的
always @
块>reggenerate
部分,以在每个子模块上调用.start()
。如果您确实需要查看您的
generate
d 模块,也许您可以尝试像上面这样的解决方法?例如,在顶层有一个总线,并使用generate
语句来查看原始generate
d实例,以将有趣的信号复制/分配到该顶层总线上。I think you're out of luck. Simulators don't seem to like out-of-module references (OOMRs) pointing into generated blocks as you've discovered.
I encountered a similar problem recently when making a parameterizable testbench monitor. I'd a variable number of sub-blocks instantiated depending on a
parameter
. Within this, I needed to have a toplevel.start()
task that called the.start()
tasks in each of the instantiated modules. I couldn't use afor
loop to do this because of this OOMR problem.So I ended up having to:
reg
that the toplevel.start()
task toggledalways @
block triggered on thisreg
generate
section within this always block to call.start()
on each of the sub-modules.If you really need to peek into your
generate
d modules, maybe you could try a workaround like above? For instance, have a bus at the toplevel, and use agenerate
statement to peek inside your originalgenerate
d instantiations to copy/assign interesting signals on to this toplevel bus.我找到并使用了另一个解决方案,将其发布在这里以防有人发现它有用。在 Vivado 2020 中为我工作。
步骤:
in tb:声明您需要打印的所有数据(声明电线)
例如:对于
Sys_Modules[0..N-1]
,如果您想要Sys_Modules[i].xmod.dataY
,请声明使用生成块生成所有连接
例如:(
N
应该是定义/参数)$display
线来自 tb:例如:
I have found and used another solution, posting it here in case someone will find it useful. Worked for me in Vivado 2020.
Steps:
in tb: declare all data you need to print (declare wires)
ex: for
Sys_Modules[0..N-1]
, if you wantSys_Modules[i].xmod.dataY
, declaregenerate all connections using a generate block
ex: (
N
should be a define/parameter)$display
wire from tb:ex: