0

我在 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("R0\tR1\tR2\tR3\tR4\tR5\tR6\tR7");
for(i=0; i<8; i=i+1)
$write("%d\t",uut.register_file_inst.reg_array[i]); <--- error points to this line

$display("\n------------------------------");
end
endtask

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

4

2 回答 2

1

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

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

于 2013-07-12T14:07:33.920 回答
0

在这种情况下,您在 register[index] 中的索引必须保持不变。在 reg_array[i] 中,i 是一个变量而不是固定的。要使用此代码进行仿真,您必须重新建模设计,使其不需要变量索引寄存器。这可能是特定于模拟器的对此功能的支持不足。如果是这种情况,您应该尝试不同的模拟器。

于 2013-07-12T05:39:05.030 回答