2014年6月3日 星期二

Blocking and Non-blocking Assignments

Procedure assignment can be evaluated in two ways: Blocking and nonblocking assignments. 

We will try to swap values in registers a and b, assume the value of a and b before the clock is a = 0 and b = 1.
always@ (posedge clk)
begin
    a = b;
    b = a;
end
//(1)both a and b becomes 1.
always@ (posedge clk)
begin
    a <= b;
    b <= a;
end
//(2)a becomes 1 and b becomes 0.
always@ (posedge clk)
fork
    a = b;
    b = a;
join
//(3)both a and b becomes 1.
always@ (posedge clk)
fork
    a <= b;
    b <= a;
join
//(4)both a and b becomes 1.
Here, code (1) and code (3) didn't give us required result. 

Code (2) and code (4) will simulate correctly.
Use non-blocking assignments to implement sequential logic and use blocking assignments to implement combinational logic. 

沒有留言:

張貼留言

ESP32 遠端感應控制系統

ESP32 遠端感應控制系統 目前的架構設計(結合了 ESP32、RFID、MQTT、Node-RED 與 Telegram 遠端雙向控制 ),這個系統的核心價值在於 即時感應、雲端中繼、智慧自動化與即時通訊回報 。 整個架構透過無線網路(Wi-Fi),將現場的硬體感測端、雲端訊...