如何修复"Illegal reference to memory A"错误



我创建了一个8位比较器,我想把它放在测试台中进行模拟,但我在测试台上有编译错误。

这是我的模块:

`include "BCS_RTL_VERILOG.v"
`timescale 1ns/1ns
module eight_bit_comparator(input [0:7] A, [0:7] B, E0, G0, output E8, G8);
wire [0:8] W1;
wire [0:8] W2;
assign W1[0] = E0;
assign W2[0] = G0;
genvar k;
generate
for(k=0; k<8; k=k+1) begin: BCSgates
RTL_BCS rtl_bcs(A[k], B[k], W1[k], W2[k], W1[k+1], W2[k+1]);
end
endgenerate
endmodule

这是我的模块的测试台,有6个错误:

`timescale 1ns/1ns
module comp_eight_tb();
wire E_out, G_out;
reg A[0:7], B[0:7], E_in, G_in;
eight_bit_comparator(A, B, E_in, G_in, E_out, G_out);
initial begin
#25 A[0]=1;
#25 A[1]=1;
#25 A[2]=1;
#25 A[3]=1;
#25 A[4]=1;
#25 A[5]=1;
#25 A[6]=1;
#25 A[7]=1;
#0 B[0]=1;
#0 B[1]=1;
#0 B[2]=1;
#0 B[3]=1;
#0 B[4]=1;
#0 B[5]=1;
#0 B[6]=1;
#0 B[7]=1;
#5 E_in=1;
#0 G_in=1;
#20 $stop;
end
endmodule

错误:

comp_eight_tb.v(5): (vlog-2110) Illegal reference to memory "B".
comp_eight_tb.v(5): (vlog-2110) Illegal reference to net array "#implicit-wire#1".
comp_eight_tb.v(5): (vlog-2110) Illegal reference to memory "B".
comp_eight_tb.v(5): (vlog-2110) Illegal reference to memory "A".
comp_eight_tb.v(5): (vlog-2110) Illegal reference to net array "#implicit-wire#0".
comp_eight_tb.v(5): (vlog-2110) Illegal reference to memory "A".

这些错误是针对测试台中的第5行,但我无法识别问题所在。有人能解决这个问题并解释原因吗?

在测试台中,您应该声明AB左侧的位范围。此外,更传统的做法是将MSB指定到LSB的左侧。由于您没有发布RTL_BCS模块的代码,所以我对它的实例进行了注释。这段代码为我编译而没有错误:

module eight_bit_comparator (
input [7:0] A,
input [7:0] B,
input E0,
input G0,
output E8,
output G8
);
wire [0:8] W1;
wire [0:8] W2;
assign W1[0] = E0;
assign W2[0] = G0;
/*
genvar k;
generate
for(k=0; k<8; k=k+1) begin: BCSgates
RTL_BCS rtl_bcs(A[k], B[k], W1[k], W2[k], W1[k+1], W2[k+1]);
end
endgenerate
*/
endmodule

`timescale 1ns/1ns
module comp_eight_tb();
wire E_out, G_out;
reg [7:0] A, B;
reg E_in, G_in;
eight_bit_comparator dut (A, B, E_in, G_in, E_out, G_out);
initial begin
#25 A[0]=1;
#25 A[1]=1;
#25 A[2]=1;
#25 A[3]=1;
#25 A[4]=1;
#25 A[5]=1;
#25 A[6]=1;
#25 A[7]=1;
#0 B[0]=1;
#0 B[1]=1;
#0 B[2]=1;
#0 B[3]=1;
#0 B[4]=1;
#0 B[5]=1;
#0 B[6]=1;
#0 B[7]=1;
#5 E_in=1;
#0 G_in=1;
#20 $stop;
end
endmodule

我通过在测试台中添加dut实例名称修复了另一个编译错误。

相关内容

最新更新