我创建了一个8位的比较器,我想把它放在testbench中进行模拟,但是我已经为testbench编译了错误。
这是我的模块:
`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".
这些错误是针对testbench中的第5行的,但我无法识别问题所在。有人能解决这个问题并解释原因吗?
发布于 2020-11-03 20:16:03
在testbench中,您应该声明A
和B
左边的位范围。另外,更传统的做法是在LSB的左边指定MSB。由于您没有发布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
我在testbench中添加了dut
实例名,从而修正了另一个编译错误。
https://stackoverflow.com/questions/64669763
复制相似问题