我是verilog的新手,但我不明白为什么这是非法引用net for signal(subcounter_of_counter)。我的意思是它的组合逻辑
提前感谢:)
wire [n-1:0] subcounter_of_counter;
reg [n-1:0] mask,free;
always @(*) begin //command or id or mask or free or subcounter_of_counter
if (command==increment) begin
for (int i = 0; i < n; i=i+1)begin
if (i<id) begin
subcounter_of_counter[i]=1'b0;
end else if (i==id) begin
subcounter_of_counter[i]=1'b1;
end else begin
if( (|mask[id+1:i]) || (|free[id+1:i]) ) begin
subcounter_of_counter[i]=1'b0;
end else begin
subcounter_of_counter[i]=1'b1;
end
end
end
end
end
答案 0 :(得分:2)
wire
是网络类型,无法在always
块或initial
块中分配网络类型。
将subcounter_of_counter
从wire
更改为reg
以解决您的问题。 reg
是逻辑类型的关键字,并不明确表示它将合成到寄存器。