繁体   English   中英

不允许同时分配给非网络“_”

[英]Concurrent assignment to a non-net '_' is not permitted

我收到错误:

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类型。 您应该为ab省略reg 这是重新编码的模块:

module ex1 (
    input [1:0] a,
    input [1:0] b,
    output wire c
);
    assign c = (a>b) ? 1'b1 : 1'b0;     
endmodule 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM