未确定大小的常量的非法串联
Illegal concatenation of an unsized constant
我编写了以下测试平台:
// 4->1 multiplexer TB template
module mux4_tb;
//Some code
initial begin
d0={0,0,0,0};
end
endmodule
但是,当我 运行 它时,我得到 24 个这样的错误:
Error (suppressible): mux4_tb.sv(23): (vlog-2121) Illegal concatenation of an unsized constant. Will treat it as a 32-bit value.
我上面的代码有什么问题?
如果您需要它:
// 4->1 multiplexer template
module mux4 (
input logic[3:0] d0, // Data input 0
input logic[3:0] d1, // Data input 1
input logic[3:0] d2, // Data input 2
input logic[3:0] d3, // Data input 3
input logic[1:0] sel, // Select input
output logic[3:0] z // Output
);
{0,0,0,0}
是四个 32 位值(根据消息)的串联,产生 128 位的零。我猜你是想连接 4 位,应该是这样的
{1'b0, 1'b0, 1'b0, 1'b0}
如果您在 1800-2017 LRM(或任何更早的 Verilog 版本)的第 11.4.12 节中查看串联运算符的定义,它说
Unsized constant numbers shall not be allowed in concatenations.
这是因为在早期版本中,整数和整数常量文字的大小取决于实现。但即使在当前版本中,整数大小为 32 位,许多人仍然忘记了简单的未大小化文字 0
和 0
不是单个位。它们隐含地 32’sd0
。 (32 位有符号十进制文字 0)您需要编写以下内容才能使用串联:
d0={1'b0,1'b0,1'b0,1'b0};
或者您可以只使用二进制文字:
d0 = 4'b0_0_0_0;
你的错误正是限制在串联中不允许未压缩(实际上 隐式 大小)文字的动机。
我编写了以下测试平台:
// 4->1 multiplexer TB template
module mux4_tb;
//Some code
initial begin
d0={0,0,0,0};
end
endmodule
但是,当我 运行 它时,我得到 24 个这样的错误:
Error (suppressible): mux4_tb.sv(23): (vlog-2121) Illegal concatenation of an unsized constant. Will treat it as a 32-bit value.
我上面的代码有什么问题?
如果您需要它:
// 4->1 multiplexer template
module mux4 (
input logic[3:0] d0, // Data input 0
input logic[3:0] d1, // Data input 1
input logic[3:0] d2, // Data input 2
input logic[3:0] d3, // Data input 3
input logic[1:0] sel, // Select input
output logic[3:0] z // Output
);
{0,0,0,0}
是四个 32 位值(根据消息)的串联,产生 128 位的零。我猜你是想连接 4 位,应该是这样的
{1'b0, 1'b0, 1'b0, 1'b0}
如果您在 1800-2017 LRM(或任何更早的 Verilog 版本)的第 11.4.12 节中查看串联运算符的定义,它说
Unsized constant numbers shall not be allowed in concatenations.
这是因为在早期版本中,整数和整数常量文字的大小取决于实现。但即使在当前版本中,整数大小为 32 位,许多人仍然忘记了简单的未大小化文字 0
和 0
不是单个位。它们隐含地 32’sd0
。 (32 位有符号十进制文字 0)您需要编写以下内容才能使用串联:
d0={1'b0,1'b0,1'b0,1'b0};
或者您可以只使用二进制文字:
d0 = 4'b0_0_0_0;
你的错误正是限制在串联中不允许未压缩(实际上 隐式 大小)文字的动机。