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

相关推荐
勇闯天涯&波仔1 小时前
verilog阻塞赋值和非阻塞赋值的区别
后端·fpga开发·硬件架构·硬件工程
FPGA-李宇航3 小时前
FPGA中,“按键控制LED灯实验”学习中常见问题、解决思路和措施以及经验总结!!!(新手必看)
学习·fpga开发·按键控制led灯
czhaii6 小时前
STC32G144K246,高速PWM@240Mhz 运行测试
stm32·单片机·fpga开发
Moonnnn.7 小时前
【FPGA】设计流程——Verilog输入
fpga开发
国科安芯8 小时前
AS32S601ZIT2抗辐照MCU在商业卫星飞轮系统中的可靠性分析
服务器·网络·人工智能·单片机·嵌入式硬件·fpga开发·1024程序员节
promising-w11 小时前
【FPGA】三八译码器verilog实现
fpga开发
风已经起了11 小时前
FPGA学习笔记——用Vitis IDE生成工程(串口发送)
笔记·学习·fpga开发·fpga·1024程序员节
竹一阁15 小时前
数字阵列雷达系统(一)——概念及组成
fpga开发·信号处理
Moonnnn.20 小时前
【FPGA】设计流程——仿真验证
fpga开发
千歌叹尽执夏1 天前
Quartus25.3:Agilex5A EMIF学习调用(DDR5)
fpga开发·1024程序员节·ddr5·agilex5·emif