System verilog 是++;系统中的操作员Verilog阻塞还是非阻塞?
良好的编码惯例表明,我们应该在组合块中使用阻塞分配,在顺序块中使用非阻塞分配。我想在组合块中使用System verilog 是++;系统中的操作员Verilog阻塞还是非阻塞?,system-verilog,System Verilog,良好的编码惯例表明,我们应该在组合块中使用阻塞分配,在顺序块中使用非阻塞分配。我想在组合块中使用++操作符,但我不知道它是否是块。这就是代码: input [3:0] some_bus; logic [2:0] count_ones; always_comb begin count_ones = '0; for(int i=0; i<4; i++) begin if(some_bus[i]) count_ones++; end end 输入[3:0]一些_
++
操作符,但我不知道它是否是块。这就是代码:
input [3:0] some_bus;
logic [2:0] count_ones;
always_comb begin
count_ones = '0;
for(int i=0; i<4; i++) begin
if(some_bus[i])
count_ones++;
end
end
输入[3:0]一些_总线;
逻辑[2:0]计数;
总是从梳子开始
count_one='0;
对于(int i=0;i,根据的第11.4.2节,它是阻塞的
SystemVerilog包括C递增和递减赋值运算符++i、-i、i++和i-。这些运算符在表达式中使用时不需要括号。这些递增和递减赋值运算符的行为类似于块赋值
那么,是否有一个与++等价的非阻塞代码,或者我们必须详细地编写代码:count\u one
input [3:0] some_bus;
logic [2:0] count_ones;
always_comb begin
count_ones = '0;
for(int i=0; i<4; i++) begin
if(some_bus[i])
count_ones = count_ones + 1;
end
end
input [3:0] some_bus;
logic [2:0] count_ones;
always_comb begin
count_ones = '0;
for(int i=0; i<4; i++) begin
if(some_bus[i])
count_ones <= count_ones + 1;
end
end