Day 3: Pre-Class Self-Check Quiz¶
Procedural Combinational Logic¶
Q1: Why must you use @(*) instead of a manual sensitivity list?
Answer
Manual lists risk sim/synth mismatch. If you forget a signal, simulation won't update when it changes, but synthesis will. @(*) automatically includes all signals read inside the block.
Q2: What causes an unintentional latch? Give an example.
Answer
Not assigning a signal in every possible path through always @(*). Example: if (sel) y = a; with no else — when sel=0, y must hold its value → latch inferred.
Q3: Name three techniques to prevent latch inference.
Answer
- Default assignment at the top of the block
- Complete
if/elsechains (always have anelse) defaultcase incasestatements
Q4: When do you use = vs <=?
Answer
= (blocking) for combinational always @(*). <= (nonblocking) for sequential always @(posedge clk). Never mix them in the same block.