verilog,为什么这是对 net 的非法引用
verilog, why is this illegal reference to net
我是 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
一个wire
是一个网络类型,不能在always
块或initial
块中分配网络类型。
将 subcounter_of_counter
从 wire
更改为 reg
以解决您的问题。 reg
是逻辑类型的关键字,并不明确表示它将综合为寄存器。
我是 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
一个wire
是一个网络类型,不能在always
块或initial
块中分配网络类型。
将 subcounter_of_counter
从 wire
更改为 reg
以解决您的问题。 reg
是逻辑类型的关键字,并不明确表示它将综合为寄存器。