输出数组不会采用数组寄存器的值

Output array won't take the value of an array register

在一个简单的模块中,我定义了一个 4 位数组寄存器,我用它来为 4 位数组输出赋值。即使它被定义为 4 位数组,输出也像 1 位线一样。

`timescale 1ns/1ps

module test(input in,
            output wire [3:0] outpt);

    reg [3:0] A = 4;    
    assign outpt = A;

endmodule

module testbench1();

    test tst(in, outpt);
    initial begin
        $strobe("| %d | %d |",outpt,tst.A);
    end

endmodule

当我 运行 测试台时:如果 A = 5,则输出将为 1。如果 A = 4,则输出将为 0。即使我已将其定义为 4,输出仍像 1 位一样-位数组。

我正在使用 .v 文件和程序 Active HDL 10.2。

您在 test 中明确声明 outpt 为 4 位。由于您没有在 testbench1 中显式声明 outpt,因此它默认为 1 位。您应该将其声明为:

wire [3:0] outpt;

一些模拟器会生成关于此的警告消息。在 edaplayground 上试试你的代码。