(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)

相关推荐
Terasic友晶科技16 小时前
答疑解惑|为DE25-Nano开发板配置Linux kernel时.config文件没有起作用是什么原因?
linux·服务器·fpga开发·linux kernel·de25-nano
8K超高清18 小时前
CCBN展会多图回顾
人工智能·算法·fpga开发·接口隔离原则·智能硬件
小眼睛FPGA19 小时前
【紫光HiYou开源入门轻量级PCIE开发板PG2L25G】实验例程5-DDR3 读写实验例程
fpga开发
unicrom_深圳市由你创科技19 小时前
如何做FPGA的功耗优化?动态功耗管理怎么实现?
fpga开发
不会武功的火柴19 小时前
SystemVerilog语法(9)-验证基础与简单Testbench
嵌入式硬件·fpga开发·fpga·systemverilog·硬件描述语言·rtl·uvm验证
kaizq20 小时前
MuleRun助力MakerChip-FPGA在线编程模拟仿真操练
fpga开发·verilog·龙虾机器人·mulerun·makerchip·在线模拟仿真
c-u-r-ry3020 小时前
vivado处理硬件设计差分对布线极性翻转的问题
经验分享·fpga开发
XINVRY-FPGA20 小时前
XC7Z020-2CLG484I Xilinx Zynq-7000 SoC FPGA
嵌入式硬件·fpga开发·云计算·硬件工程·fpga
小眼睛FPGA20 小时前
【紫光HiYou开源入门轻量级PCIE开发板PG2L25G】实验例程2-基于紫光FPGA 的键控流水灯实验例程
fpga开发
XMAIPC_Robot20 小时前
电力设备RK3568/RK3576+FPGA,多系统混合部署Linux+RTOS RT-THREAD,强实时性
linux·运维·fpga开发