(Verilog) 阻塞型和非阻塞型的assign语句

For hardware synthesis, there are two types of always blocks that are relevant:

  • Combinational: always @(*)
  • Clocked: always @(posedge clk)

Clocked always blocks create a blob of combinational logic just like combinational always blocks, but also creates a set of flip-flops (or "registers") at the output of the blob of combinational logic. Instead of the outputs of the blob of logic being visible immediately, the outputs are visible only immediately after the next (posedge clk).

Blocking vs. Non-Blocking Assignment

There are three types of assignments in Verilog:

  • Continuous assignments (assign x = y;). Can only be used when not inside a procedure ("always block").
  • Procedural blocking assignment: (x = y;). Can only be used inside a procedure.
  • Procedural non-blocking assignment: (x <= y;). Can only be used inside a procedure.

In a combinational always block, use blocking assignments. In a clocked always block, use non-blocking assignments. A full understanding of why is not particularly useful for hardware design and requires a good understanding of how Verilog simulators keep track of events. Not following this rule results in extremely hard to find errors that are both non-deterministic and differ between simulation and synthesized hardware.

对于硬件合成,有两种相关的always块类型:

组合型:always @(*)

时钟型:always @(posedge clk)

时钟型always块创建了一个与组合型always块类似的组合逻辑块,但还在组合逻辑块的输出处创建了一组触发器(或"寄存器")。与组合逻辑块的输出立即可见不同,输出只在下一个(posedge clk)之后立即可见。

阻塞式赋值和非阻塞式赋值

Verilog中有三种类型的赋值:

连续赋值(continuous assignments)(assign x = y;)。仅在不在过程("always block")中使用时可用。

过程阻塞式赋值:(x = y;)。仅在过程中使用时可用。

过程非阻塞式赋值:(x <= y;)。仅在过程中使用时可用。

在组合型always块中使用阻塞式赋值,在时钟型always块中使用非阻塞式赋值。要完全理解其中原因对于硬件设计并不特别有用,而且需要对Verilog仿真器如何跟踪事件有一定的了解。不遵循此规则会导致非确定性且在仿真和合成的硬件之间不同的极难发现的错误。

参考Verilog语法之六:阻塞赋值与非阻塞赋值 - 知乎 (zhihu.com)

相关推荐
tiantianuser3 小时前
RDMA简介5之RoCE v2队列
fpga开发·verilog·fpga·rdma·高速传输·rocev2
碎碎思4 小时前
打破延迟极限的 FPGA 机械键盘
fpga开发·计算机外设
ALINX技术博客14 小时前
【新品解读】一板多能,AXRF49 定义新一代 RFSoC FPGA 开发平台
射频工程·fpga·amd·rfsoc·alinx
hahaha60161 天前
Flash烧录速度和加载配置速度(纯FPGA & ZYNQ)
fpga开发
hahaha60161 天前
ARINC818编解码设计FPGA实现
fpga开发
XMAIPC_Robot1 天前
基于RK3568的多网多串电力能源1U机箱解决方案,支持B码,4G等
linux·fpga开发·能源·边缘计算
迎风打盹儿1 天前
FPGA仿真中阻塞赋值(=)和非阻塞赋值(<=)区别
verilog·fpga·阻塞赋值·非阻塞赋值·testbench仿真
广药门徒1 天前
在使用一些不用驱动大电流的设备就可以用stm32的自己的上下拉但是本身上下拉不就是给iicspi这些他通信给信号的吗中怎么还跟驱动能力扯上了有什么场景嘛
stm32·单片机·fpga开发
hahaha60161 天前
XDMA pcie环路测试
fpga开发
tiantianuser2 天前
RDMA简介3之四种子协议对比
verilog·fpga·vivado·rdma·高速传输