(Verilog) wire和reg,以及always

For combinational always blocks, always use a sensitivity list of (*). Explicitly listing out the signals is error-prone (if you miss one), and is ignored for hardware synthesis. If you explicitly specify the sensitivity list and miss a signal, the synthesized hardware will still behave as though (*) was specified, but the simulation will not and not match the hardware's behaviour. (In SystemVerilog, use always_comb.)

A note on wire vs. reg: The left-hand-side of an assign statement must be a net type (e.g., wire), while the left-hand-side of a procedural assignment (in an always block) must be a variable type (e.g., reg). These types (wire vs. reg) have nothing to do with what hardware is synthesized, and is just syntax left over from Verilog's use as a hardware simulation language.

对于组合always块,总是使用(*)的敏感性列表。明确列出信号是容易出错的(如果你漏掉一个),并且在硬件合成中会被忽略。如果你明确指定了敏感性列表但漏掉了一个信号,合成后的硬件将仍然按照(*)指定的方式工作,但仿真将不会与硬件的行为相匹配。(在SystemVerilog中,请使用always_comb)。

关于wire和reg的注意事项:assign语句的左边必须是一个网络类型(如wire),而过程赋值(在always块中)的左边必须是一个变量类型(如reg)。这些类型(wire vs. reg)与合成的硬件无关,只是Verilog作为硬件仿真语言的语法剩下的部分。

相关推荐
IM_DALLA7 小时前
【Verilog学习日常】—牛客网刷题—Verilog进阶挑战—VL25
学习·fpga开发·verilog学习
辣个蓝人QEX8 小时前
【FPGA开发】Modelsim如何给信号分组
fpga开发·modelsim·zynq
li星野11 小时前
ZYNQ:点亮LED灯
fpga开发·zynq·7010
9527华安11 小时前
FPGA实现PCIE视频采集转HDMI输出,基于XDMA中断架构,提供3套工程源码和技术支持
fpga开发·音视频·pcie·xdma·ov5640·hdmi
乌恩大侠12 小时前
【Xcode Command Line Tools】安装指南
macos·fpga开发·c
apple_ttt13 小时前
从零开始讲PCIe(9)——PCIe总线体系结构
fpga开发·fpga·pcie
Little Tian16 小时前
信号用wire类型还是reg类型定义
fpga开发
XiaoChaoZhiNeng1 天前
基于Zynq SDIO WiFi移植二(支持2.4/5G)
5g·fpga·zynq·sdio
apple_ttt1 天前
从零开始讲PCIe(6)——PCI-X概述
fpga开发·fpga·pcie
水饺编程2 天前
【英特尔IA-32架构软件开发者开发手册第3卷:系统编程指南】2001年版翻译,1-2
linux·嵌入式硬件·fpga开发