Icarus Verilog模拟:范围索引表达式不是常量:i



我正在Icarus Verilog中模拟一个16位MIPS网表。这是我在测试台中得到的错误

mips_16_core_top_tb_0.v:144: error: Scope index expression is not constant: i
mips_16_core_top_tb_0.v:144: error: Unable to bind wire/reg/memory `uut.register_file_inst.reg_array[i]' in `mips_16_core_top_tb_0_v.display_all_regs'
Related code : 
task display_all_regs;
begin
$display("display_all_regs:");
$display("------------------------------");
$display("R0tR1tR2tR3tR4tR5tR6tR7");
for(i=0; i<8; i=i+1)
$write("%dt",uut.register_file_inst.reg_array[i]); <--- error points to this line
$display("n------------------------------");
end
endtask

当我模拟RTL时,我也会遇到同样的错误,但我仍然会把vcd文件转储掉。在网表的情况下,我甚至没有生成vcd文件。很高兴听到你的想法。

您的代码看起来不错,我刚刚在Icarus(当前版本,来自git)中测试了数组的跨模块变量索引,它可以工作。

我怀疑你的问题是你自己在编译mips_16_core_top_tb_0.v——如果你这样做了,Icarus会给出这个消息。所有的源文件都需要在Icarus中一起编译。其他一些模拟器将允许您自行编译该文件,然后只在细化过程中(即运行模拟时)检查错误,但Icarus这样做的方式是最初使用Verilog的方式。

在这种情况下,寄存器[index]中的索引必须是常量。在reg_array[i]中,i是一个变量,而不是固定的。要模拟使用此代码,您必须重新设计,使其不需要变量索引寄存器。这可能是模拟器特有的对此功能缺乏支持。如果是这样的话,你应该尝试不同的模拟器。

最新更新