Verilog blocking/nonblocking assignment in clk generator with self triggered

时光毁灭记忆、已成空白 提交于 2019-12-06 16:15:40

It has to do with the verilog scheduler.

@ will wait for a new event, it will ignore any past events. Within the same time step, execution order matters.

clk = ~clk is a blocking assignment, meaning clk will be update before scheduling the next @. The clk event will be missed.

clk <= ~clk is a non-blocking assignment, meaning clk will be update after scheduling the next @. The clk event will be sensed.


Self triggering blocks are not very common in practice. always blocks are not required to have a sensitivity list. They should have at least one reachable time blocking delay (e.g. @(_list_), #(_timeunit_)) within the block; else there is a zero time infinite loop and the simulation hangs.

Clock generator are usually implanted something similar to:

reg clk;
initial begin
  #10 clk = 0;
  forever #10 clk = ~clk;
end

Or

reg clk;
always #10 clk = (clk===1'b0);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!