gpt4 book ai didi

非阻塞赋值的 Verilog 序列

转载 作者:行者123 更新时间:2023-12-04 10:26:12 29 4
gpt4 key购买 nike

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

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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com