非阻塞赋值的 Verilog 序列

标签 verilog synthesis

说以下代码部分(同一块):

A <= 1
A <= 2

变量 A 总是被赋值为 2 吗?还是会出现竞争条件并分配 1 或 2?

我对非阻塞赋值的理解是,由硬件在 future 分配变量 A,因此它可能是一个随机结果。然而,这是不直观的。模拟显示 2 总是被分配,但我想知道这是否绝对是硬件综合的情况。

最佳答案

模拟时 A 为 2,最后定义的值生效。如果它们不在同一个块中,则可能存在竞争条件,具体取决于模拟器调度程序在模拟中最后定义哪个。

我已经看到这种技术使用了很多,并且在合成后从未见过任何意想不到的结果。

来自 Verilog IEEE 1364-2005 Section 11.4.1 Determinism

Statements within a begin-end block shall be executed in the order in which they appear in that begin-end block. Execution of statements in a particular begin-end block can be suspended in favor of other processes in the model; however, in no case shall the statements in a begin-end block be executed in any order other than that in which they appear in the source.



这也在 SystemVerilog-IEEE1800 2012 中作为第 4.6 节确定性

这可能是一个 FSM,它稀疏地定义了它的输出:
always @(posedge clk) begin
  out_one <= 1'b0;
  out_two <= 1'b0;
  out_thr <= 1'b0;
  case (state)
    2'd1 : out_one <= 1'b1;
    2'd2 : out_two <= 1'b1;
    2'd3 : out_thr <= 1'b1;
  endcase
end

关于非阻塞赋值的 Verilog 序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15718192/

相关文章:

verilog - Verilog 有什么区别!还有~?

verilog - 如何在quartus中初始化具有不同内容的多个实例的ram

VHDL syn_looplimit 和综合

vhdl - 综合全局实例计数

eclipse - 如何设置 Eclipse 以进行 VHDL 和 Verilog 中的 FPGA 设计?

syntax - Verilog语法解释

verilog - verilog 中的数据类型错误

vhdl - 综合结果中的 "gate count"是什么以及如何计算

verilog - vivado中工程模式和非工程模式的主要区别是什么?