【问题标题】:Concurrent assignment to a non-net '_' is not permitted不允许同时分配给非网络“_”
【发布时间】:2021-12-31 19:21:01
【问题描述】:

我收到了错误:

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

【问题讨论】:

  • 从输入中删除“reg”。同样在您的分配语句中使用 RHS 中的“==”。我假设您希望在 RHS 中进行比较。

标签: verilog vivado


【解决方案1】:

我在您的 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 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-07
    • 2022-06-14
    • 2022-08-08
    相关资源
    最近更新 更多