【问题标题】:How to fix the "Illegal reference to memory A" error如何修复“非法引用内存 A”错误
【发布时间】:2020-11-03 19:58:18
【问题描述】:

我创建了一个 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".

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

【问题讨论】:

    标签: verilog


    【解决方案1】:

    在测试台中,您应该声明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 实例名称修复了另一个编译错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-15
      • 1970-01-01
      • 1970-01-01
      • 2020-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-07
      相关资源
      最近更新 更多