HDL & Verification
Intending combinational logic, someone writes the code above. What does logic synthesis produce?
always @(*) begin
if (en)
y = d;
end
- ACombinational logic where y automatically becomes 0 when en is 0
- BA clocked D flip-flop
- CBecause y must hold its value when en is 0, an unintended latch is created
Show answer and explanation
Answer: C. Because y must hold its value when en is 0, an unintended latch is created
When en is 0 nothing is assigned to y, so y must remember its previous value. Combinational logic has no memory, so synthesis creates a latch to hold it. Latches complicate timing analysis and can malfunction from glitches, so unintended ones are avoided. Assigning a value in every case, for example "else y = 0;", yields combinational logic.
- A. Nothing assigns 0, so it does not become 0.
- B. No clock is used, so it is not a flip-flop.
- C. Correct. The missing else is the cause.