我得到错误:
concurrent assignment to a non-net 'A' is not permitted
concurrent assignment to a non-net 'B' is not permitted
Static elaboration of top level Verilog design unit(s) in library work failed.
我做错了什么?
module ex1( input reg [1:0] a,
input reg [1:0]b,
output wire c,
);
assign c=(a>b)?(a=1'b1):(c=1'b0);
endmodule
module testbench(
);
reg[1:0]a=2'b11;
reg [1:0]b=2'b00;
wire c;
always#10
begin
a=a-2'b01;
b=b-2'b01;
end
initial
#150 $finish;
ex1 testbench2 (.a(a),
.b(b),.c(c));
endmodule
我在ex1
模块中得到3个语法错误。
端口列表中的尾部逗号是非法的。更改:
output wire c,
至:
output wire c
将值分配给模块内的输入端口是非法的。这是非法的:a=1'b1
。假设在那里使用a
是一个拼写错误,并且您确实想键入c
,那么您应该更改:
assign c=(a>b)?(a=1'b1):(c=1'b0);
至:
assign c = (a>b) ? 1'b1 : 1'b0;
您通常不希望像代码那样在条件运算符中进行赋值。
一个模拟器还抱怨将input
端口声明为reg
类型。对于a
和b
,应省略reg
。这是重新编码的模块:
module ex1 (
input [1:0] a,
input [1:0] b,
output wire c
);
assign c = (a>b) ? 1'b1 : 1'b0;
endmodule