D Latch
Introduction
A D latch is a level-sensitive memory element that stores one bit of data. When the enable (EN) signal is high, the output follows the D input. When EN is low, the output holds the previously stored value.
Problem Statement
Design a D latch that stores the input value when enable is high and holds the value when enable is low.
Specifications
-
Inputs: D (Data), EN (Enable)
​
-
Output: Q (Stored bit)
​
-
Operation: Q = D when EN=1, otherwise Q holds its value
Truth Table

Verilog RTL Code
Verilog
module d_latch (
input wire D,
input wire EN,
output reg Q
);
always @ (D or EN) begin
if (EN)
Q <= D;
end
endmodule
Testbench Code
Verilog
module tb_d_latch();
reg D, EN;
wire Q;
d_latch tb_d_latch (.D(D), .EN(EN), .Q(Q));
initial begin
$monitor("Time=%0t | EN=%b D=%b | Q=%b", $time, EN, D, Q);
EN = 0; D = 0;
#5 D = 1;
#5 EN = 1;
#5 D = 0;
#5 EN = 0; D = 1;
#5 EN = 1;
#5 $finish;
end
endmodule
Interview Questions & Answers
Q1. Why are latches called 'transparent' devices?
Answer:
A latch is called transparent because, when it’s enable signal is active, any change at the input instantly appears at the output. It’s like looking through a glass window — you see exactly what’s on the other side. When enabled, even tiny glitches in the input will pass through, which is why designers must be careful. When disabled, it becomes 'opaque' and holds its last value.
Q2. What is the main disadvantage of using latches in synchronous systems?
Answer:
Latches are level-sensitive, meaning they respond to the input as long as the enable signal is active. This can allow unwanted changes or “glitches” to pass through if the input changes at the wrong time. In synchronous systems, where precise timing is critical, this can make timing analysis harder and may lead to unpredictable results. That’s why designers often prefer edge-triggered flip-flops, which only react at a single moment in time.
Q3. How can you convert an SR latch to a D latch?
Answer:
To turn an SR latch into a D latch, you connect:
-
S input connected directly to D
-
R input connected to the opposite of D (NOT D)
This way:
-
If D = 1 , S = 1, R = 0 then latch sets Q
-
If D = 0 , S = 0, R = 1 then latch resets Q
It guarantees that S and R are never 1 at the same time, removing the “invalid” state.
​
​
Q4. Why is there an 'invalid' state in SR latches and how can it be avoided?
Answer:
In a NOR-based SR latch, when S = 1 and R = 1 at the same time, both outputs try to become 0. This breaks the rule that Q and QÌ… should be exact opposites that’s the “invalid” state. To avoid it:
-
Ensure the inputs never go high together (add control logic)
-
Or use a D latch or JK latch, which is designed to avoid this problem entirely
​
​
Q5. Why might latches cause race conditions in digital designs?
​
Answer:
Because latches are level-sensitive, the output can change multiple times while the enable signal is active. If one latch’s output is connected to another latch that is also enabled at the same time, signals can keep bouncing back and forth in the same clock period — that’s called a race condition. This can cause unstable or unpredictable results.
​
​
Q6. If a D latch has a propagation delay of 4 ns and EN is high for 10 ns, how many times can Q change?
​
Answer:
In theory, Q could change at most twice. This is because after each change, it takes 4 ns before the output can respond to a new change at the input. With EN high for 10 ns, only two changes can fit within that time.
​
​
Q7. What happens if EN is tied permanently high in a noisy signal environment?
​
Answer:
If EN is always high, the latch behaves like a simple wire — any change at D immediately appears at Q. In a noisy environment, even tiny spikes or unwanted changes at D will go straight to Q, possibly causing wrong outputs. This defeats the purpose of having a latch.
​
​
Q8. In an SR latch, if S goes high and R also goes high after 1 ns, what happens to Q?
Answer:
It depends on the delays inside the latch:
-
First, S = 1 will try to set Q to 1
​
-
Then, R = 1 arrives and tries to reset Q to 0
The short gap may cause Q to briefly be 1, then 0. In some cases, the latch might enter metastability, where it’s stuck in an unstable state for a short time before settling.
