how to set wire value in always block

这篇博客探讨了Verilog中两种赋值方式的区别:Blocking和Non-Blocking。通过示例代码`assign test=input;`和`always@* test=input;`,解释了它们在行为上的差异。文章强调了在组合逻辑和时序逻辑中使用不同赋值方式的重要性,并提出了两条经验规则:1) 对于组合逻辑和级联敏感代码,以及时钟分配,应使用Blocking赋值;2) 对于在时钟边沿写入并在同一边沿读取的变量,应使用Non-Blocking赋值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

wire test;
//At all times, test equals input
assign test = input;

has the same behaviour as:

reg test;
//Each time input changes(with the always@*), test takes its value
always@*
  test = input;

there are two experience rule:

  1. Always use blocking assignments for combinatorial or level-sensitive code, as well a clock assignments
  2. Always use non-blocking assignments for variables that are written on a clock edge, and read on the same clock edge in another process.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值