verilog 中的错误:警告使用 System verilog 'N 位向量?
error in verilog : warning using System verilog 'N bit vector?
我正在使用 Icarus 编译器,我正在做一个 Mux 4:1。
密码是:
module mux (in,out,select);
input [3:0] in;
input [1:0] select;
output reg out;
always@(select or in)
begin
if (select == 2b'00)
out = in[0];
end
else if (select == 2b'01)
begin
out = in[1];
end
else if (select == 2b'10)
begin
out = in[2];
end
else if (select == 2b'11)
begin
out = in[3];
end
end
endmodule
但是,我从编译器那里得到了这条消息:
问题是因为我在 "if" 表达式而不是 "int" 表达式中使用位格式吗?
尝试(使用 verilog 2005 或更高版本):
module mux (
input [3:0] in,
input [1:0] select,
output reg out
);
always @* begin
out = in[select];
end
endmodule
您的代码的问题是您正在编写 2b'00
而不是 2'b00
并且 Icarus 认为您正在编写 SystemVerilog 代码而感到困惑,这也不正确。因此,要么修复你的文字,要么像 Morgan 发布的那样更有效地编写你的代码。
我正在使用 Icarus 编译器,我正在做一个 Mux 4:1。
密码是:
module mux (in,out,select);
input [3:0] in;
input [1:0] select;
output reg out;
always@(select or in)
begin
if (select == 2b'00)
out = in[0];
end
else if (select == 2b'01)
begin
out = in[1];
end
else if (select == 2b'10)
begin
out = in[2];
end
else if (select == 2b'11)
begin
out = in[3];
end
end
endmodule
但是,我从编译器那里得到了这条消息:
问题是因为我在 "if" 表达式而不是 "int" 表达式中使用位格式吗?
尝试(使用 verilog 2005 或更高版本):
module mux (
input [3:0] in,
input [1:0] select,
output reg out
);
always @* begin
out = in[select];
end
endmodule
您的代码的问题是您正在编写 2b'00
而不是 2'b00
并且 Icarus 认为您正在编写 SystemVerilog 代码而感到困惑,这也不正确。因此,要么修复你的文字,要么像 Morgan 发布的那样更有效地编写你的代码。