(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作为硬件仿真语言的语法剩下的部分。

相关推荐
ooo-p12 小时前
FPGA学习篇——Verilog学习之“呼吸灯”
学习·fpga开发
雨洛lhw16 小时前
STFT性能测试记录笔记(verilog )
fpga开发
runningshark18 小时前
【FPGA】频率计(等精度测量法)
fpga开发
坏孩子的诺亚方舟19 小时前
FPGA设计基于团队的最佳实践0
fpga开发·团队设计
FPGA_小田老师20 小时前
FPGA例程(7):UART串口接收程序--状态机的编写
fpga开发·uart·状态机·串口接收·uart_rx·串口程序·115200bps
FPGA小c鸡21 小时前
FPGA做AI:从入门到实战 | 边缘智能时代的硬件加速秘密
人工智能·fpga开发
思尔芯S2C21 小时前
思尔芯、MachineWare与Andes晶心科技联合推出RISC-V协同仿真方案,加速芯片开发
人工智能·科技·fpga开发·risc-v·prototyping
松涛和鸣1 天前
63、IMX6ULL ADC驱动开发
c语言·arm开发·驱动开发·单片机·gpt·fpga开发
扣脑壳的FPGAer1 天前
Xilinx Dual Quad Flash SPI加载方式下的文件处理
fpga开发
ShiMetaPi1 天前
GM-3568JHF丨ARM+FPGA异构开发板应用开发教程:07 FPGA FSPI 通信案例
arm开发·fpga开发·rk3568