2

下面是一个例子

module a_mod ( u );
input bit [2:0] u [1:0];
...
endmodule

module b_mod ();

bit [2:0] c1, c2;
a_mod a_mod_inst ( 
  .u ( {c1,c2} ) // won't work
);

endmodule

进行 u[0] == c2 和 u[1] == c1 的连接的最简单方法是什么?

顺便说一句,我知道我可以做我下面展示的,但是寻找一个更优雅的选择

bit [2:0] tmp_u [1:0];
assign tmp_u[0] = c2;
assign tmp_u[1] = c1;

a_mod a_mod_inst (
.u ( tmp_u )  // works for sure
);
4

1 回答 1

3

尝试:

bit [2:0] c1, c2;
a_mod a_mod_inst ( 
  .u ( '{c1,c2} ) // note the single quote before the open curly bracket
);

请参阅 IEEE1800-2012 第 10.9 节。'{用于分配或传递未打包的数组。

于 2013-04-22T22:18:20.113 回答