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

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

提问人:TomatoLV 提问时间:11/9/2019 最后编辑:toolicTomatoLV 更新时间:3/27/2020 访问量:149

问:

在一个简单的模块中,我定义了一个 4 位数组寄存器,并用它来为 4 位数组输出分配一个值。输出就像一根 1 位线,即使它被定义为 4 位数组也是如此。

`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。输出类似于 1 位,即使我将其定义为 4 位数组。

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

Verilog Active-HDL

评论


答:

1赞 toolic 11/9/2019 #1

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

wire [3:0] outpt;

某些模拟器会生成有关此情况的警告消息。在 edaplayground 上尝试您的代码。