簡體   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