【问题标题】:Is the ++ operator in System Verilog blocking or non-blocking?System Verilog 中的 ++ 运算符是阻塞的还是非阻塞的?
【发布时间】:2014-03-19 14:08:45
【问题描述】:

良好的编码约定表明我们应该在组合块中使用阻塞分配,在顺序块中使用非阻塞分配。我想在组合块中使用++ 运算符,但我不知道它是否阻塞。这段代码也是:

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

相当于这个:

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

我确实查看了 1800-2012 标准,但无法弄清楚。将我指向标准中适当部分的答案将不胜感激。

【问题讨论】:

    标签: system-verilog


    【解决方案1】:

    根据IEEE Std 1800-2012 的第 11.4.2 节,它是阻塞的。

    SystemVerilog 包括 C 递增和递减赋值运算符 ++i 、 --i 、 i++ 和 i-- 。这些在表达式中使用时不需要括号。这些递增和递减赋值运算符表现为阻塞赋值。

    【讨论】:

    • 那么是否有一个非阻塞等价于 ++ 或者我们是否必须详细编码:count_ones
    猜你喜欢
    • 2012-11-13
    • 2014-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多