将数组定义为非零常量

Ara*_*uhi 1 arrays verilog system-verilog

我有以下子模块:

module test
(
input [LENGTH : 1] array;
);

...

endmodule
Run Code Online (Sandbox Code Playgroud)

我从顶部模块调用它,如下所示:

...
wire [LENGTH-1 : 0] array_top;
test test_i
(
.array (array_top);
);
...
Run Code Online (Sandbox Code Playgroud)

假设LENGTH两个模块中的内容相同。

  1. 假设下降到零但下降到 1,将如何array_top映射到?arrayarray_toparray
  2. 为什么有人会定义一个数组到 1 而不是到 0?
  3. 会发生什么事呢array[0]

too*_*lic 6

您的问题可以通过一个小型测试平台来回答:

module tb;

reg [3:0] atop;
initial begin
    $monitor("array_top=%b, array=%b", array_top, test_i.array);
    #1 atop = 4'b0000;
    #1 atop = 4'b0001;
    #1 atop = 4'b0010;
    #1 atop = 4'b0100;
end

wire [3:0] array_top = atop;
test test_i (.array (array_top));

endmodule

module test (input [4:1] array);
endmodule
Run Code Online (Sandbox Code Playgroud)

输出:

array_top=xxxx, array=xxxx
array_top=0000, array=0000
array_top=0001, array=0001
array_top=0010, array=0010
array_top=0100, array=0100
Run Code Online (Sandbox Code Playgroud)
  1. 从您的连接: array[1] = array_top[0] 等。
  2. 有时人们想要省略连接信号的 LSB,例如存储器的地址,因为 LSB 没有任何作用。
  3. 没有array[0]信号。