3.5.3 · HinglishHDL & Digital Design Flow

Sequential logic and always blocks

1,975 words9 min readRead in English

3.5.3 · Hardware › HDL & Digital Design Flow


WHY: hume sequential logic ki zaroorat kyun hai?


WHAT: always block kya hota hai?


HOW: do golden rules

Do assignment operators aur do block styles hain. Inhe sahi choose karna 80% bugs se bachata hai.

Blocking = vs non-blocking <= — is baat se derive kiya gaya ki yeh kaunsa hardware represent karte hain


Figure — Sequential logic and always blocks

D flip-flop ko scratch se derive karna


Combinational always (contrast, taaki confuse na ho)




Recall Feynman: ek 12-saal ke bacche ko explain karo

Socho ek class jahan sab log ek mini-whiteboard par jawab likhte hain. Combinational baccha question dekhte hi jawab chilla deta hai. Sequential baccha apna board sirf tab paltata hai jab teacher ghanti bajati hai (woh clock hai) — tab tak woh apna pichla jawab pakde rehta hai. Ab, tricky part yeh hai: jab ghanti bajti hai, sab bacchon ko woh dikhaana chahiye jo unhone ghanti se pehle likha tha — apne neighbour ke naaye board ki nakal nahi karni. Non-blocking <= yeh rule hai "pehle sab ke purane board padho, phir saath mein palto." Blocking = hai "ek-ek karke karo," jo chillane-wale bacchon ke liye theek hai lekin ghanti-wale bacchon ke liye gada machaa deta hai.


Active-recall

Sequential always block ko kya trigger karta hai?
Ek clock edge, jaise always @(posedge clk).
Clocked/sequential logic ke liye kaun sa assignment use karte hain?
Non-blocking <=.
Combinational logic ke liye kaun sa assignment use karte hain?
Blocking =.
Non-blocking <= flip-flops ko sahi model kyun karta hai?
Saare RHS old values se evaluate hote hain, phir saare LHS ek saath update hote hain — jo parallel flops ke saath clocking karne se match karta hai.
Blocking = shift register ko kyun tod deta hai?
Baad ki lines abhi-abhi-update ki hui value dekhti hain, jo stages ko shift karne ki jagah collapse kar deti hai.
Kya always @(posedge clk) ek loop hai?
Nahi — yeh event-driven hai; yeh triggering edge par ek baar run karta hai phir so jaata hai.
Inferred latch kya hota hai aur kab hota hai?
Ek unwanted memory element jo tab create hota hai jab always @(*) output har branch mein assign nahi hoti.
Inferred latches se kaise bacha jaaye?
Har branch mein har output assign karo, ya block ke upar defaults set karo.
Async aur sync reset mein kya fark hai?
Async reset sensitivity list mein hota hai aur turant act karta hai; sync reset sirf clock edge par act karta hai.
Reset flop ke if mein rst pehle kyun daala jaata hai?
Reset ko normal data capture par priority dene ke liye.
always @(*) ka matlab kya hai?
Combinational logic jo block ke andar read hone wale kisi bhi signal ke liye sensitive hai.
Agar do always blocks ek hi reg drive karen toh kya error aata hai?
Multiple-driver / race condition.

Connections

Concept Map

lacks

has

stored in

samples on

triggered by

models

models

use

use

reads old values then assigns

enables

Combinational logic

Sequential logic

Memory of past state

Flip-flop

Clock edge

always block

Sensitivity list

always @posedge clk

always @star

Non-blocking <=

Blocking =

Shift register