A gated SR flip‑flop, also known as a clocked SR flip‑flop, is a fundamental sequential logic element used to store a single bit of information in digital circuits. Consider this: unlike the basic SR latch, which changes state as soon as its inputs vary, the gated version only responds to the inputs when a control signal—commonly called the clock or enable line—is active. This gating mechanism provides designers with precise control over when data can be written, making the device indispensable in synchronous systems such as counters, registers, and finite‑state machines. Understanding its truth table is essential for predicting behavior, avoiding the forbidden state, and designing reliable logic networks Simple as that..
Working Principle of a Gated SR Flip‑Flop
The gated SR flip‑flop builds upon the classic NOR‑based SR latch by adding two AND gates that gate the S (set) and R (reset) inputs with a clock signal C (sometimes labeled EN for enable). When C = 0, the outputs of the AND gates are forced to 0 regardless of the states of S and R, so the latch sees both inputs as 0 and holds its previous state. When C = 1, the AND gates become transparent, passing the raw S and R values to the latch, which then behaves exactly like an ordinary SR latch That's the whole idea..
Because the latch is level‑sensitive (it responds while the clock is high), the device is sometimes referred to as a level‑clocked SR flip‑flop. Edge‑triggered variants exist, but the truth table presented below assumes the level‑sensitive form, which is the most common interpretation of a “gated” SR flip‑flop Practical, not theoretical..
Internal Diagram (textual description)
- Two NOR gates form the latch:
- NOR‑1 output = Q
- NOR‑2 output = Q̅ (complement of Q)
- Two AND gates gate the inputs:
- AND‑1 output = S·C (S AND C) feeds into NOR‑1
- AND‑2 output = R·C (R AND C) feeds into NOR‑2
When C = 0, both AND outputs are 0, forcing each NOR gate to see a 0 on its gated input, which results in the latch holding its previous state. When C = 1, the AND outputs equal the raw S and R values, and the latch reacts accordingly.
No fluff here — just what actually works That's the part that actually makes a difference..
Truth Table of the Gated SR Flip‑Flop
The truth table captures the relationship between the clock (C), the inputs (S, R), the present state (Qₚ), and the next state (Qₙ). The complement output Q̅ₙ is simply the inverse of Qₙ (except in the forbidden case where both outputs may become undefined) Simple, but easy to overlook..
| C (Clock) | S (Set) | R (Reset) | Qₚ (Present) | Qₙ (Next) | Q̅ₙ (Next) | Notes |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | Hold (no change) |
| 0 | 0 | 0 | 1 | 1 | 0 | Hold (no change) |
| 0 | 0 | 1 | 0 | 0 | 1 | Hold (clock disabled) |
| 0 | 0 | 1 | 1 | 1 | 0 | Hold (clock disabled) |
| 0 | 1 | 0 | 0 | 0 | 1 | Hold (clock disabled) |
| 0 | 1 | 0 | 1 | 1 | 0 | Hold (clock disabled) |
| 0 | 1 | 1 | 0 | 0 | 1 | Hold (clock disabled) |
| 0 | 1 | 1 | 1 | 1 | 0 | Hold (clock disabled) |
| 1 | 0 | 0 | 0 | 0 | 1 | No change (latent state) |
| 1 | 0 | 0 | 1 | 1 | 0 | No change (latent state) |
| 1 | 0 | 1 | 0 | 0 | 1 | Reset → Q = 0 |
| 1 | 0 | 1 | 1 | 0 | 1 | Reset → Q = 0 |
| 1 | 1 | 0 | 0 | 1 | 0 | Set → Q = 1 |
| 1 | 1 | 0 | 1 | 1 | 0 | Set → Q = 1 |
| 1 | 1 | 1 | 0 | X | X | Forbidden (both outputs may go to 0) |
| 1 | 1 | 1 | 1 | X | X | Forbidden (race condition) |
Key observations
- Hold mode – When C = 0, the flip‑flop ignores S and R; the output retains its previous value regardless of the inputs.
- Set mode – With C = 1, S = 1, R = 0 forces Qₙ = 1 (set).
- Reset mode – With C = 1, S = 0, R = 1 forces Qₙ = 0 (reset).
- No‑change mode – When C = 1 and both S = 0, R = 0, the latch maintains its current state (latent).
- Forbidden state – S = 1, R = 1 while the clock is active creates a conflict: both NOR gates try
both NOR gates try to drive their outputs low at the same time. Because the outputs are cross-coupled, this condition forces Qₙ and Q̅ₙ to assume the same logic level—typically 0 in a NOR-based implementation—violating the complementary relationship that defines a stable latch No workaround needed..
When the inputs are subsequently returned to an allowable combination or the clock is deasserted, the circuit does not settle predictably. The gate with the slightly shorter propagation delay tends to dominate, leaving the final value of Qₙ dependent on transient hardware characteristics rather than deterministic logic. This is the classic race condition of the SR flip-flop Most people skip this — try not to..
Because of this ambiguity, the S = R = 1 combination is normally prohibited in synchronous designs. Designers handle the restriction in one of two
One of two primary methods are employed to keep the SR latch within its safe operating region:
1. Explicit Input Gating
The most straightforward approach is to prevent the S = R = 1 condition while the clock is asserted. This is usually done with a small combinational network that monitors the clock (C) and the raw set/reset requests (S_raw, R_raw) and produces conditioned signals (S, R) that are fed to the latch Nothing fancy..
C ──┐ ┌─► S = C & S_raw
│ │
S_raw ──► AND ──► S ──┘
│
R_raw ──► AND ──► R ──┘
- How it works – The AND gates only pass a set or reset request when C = 1. If C = 0 the latch is placed in “hold” mode, regardless of the raw inputs.
- Advantages – Minimal area overhead, deterministic behavior, and easy to verify with static timing analysis.
- Drawbacks – The gating logic adds extra propagation delay, which can become a bottleneck in high‑frequency designs. Also worth noting, the designer must check that the gating never creates a momentary glitch that could momentarily produce S = R = 1 when C transitions.
A more sophisticated variant is the priority‑encoded latch. Here a small state machine gives one command precedence over the other (e.g., set‑has priority) But it adds up..
And yeah — that's actually more nuanced than it sounds The details matter here..
if (C == 1) begin
if (S_raw == 1 && R_raw == 0) begin S = 1; R = 0; end
else if (S_raw == 0 && R_raw == 1) begin S = 0; R = 1; end
else if (S_raw == 1 && R_raw == 1) begin
// Choose one – e.g., force set
S = 1; R = 0;
end
else begin S = 0; R = 0; end
end else begin S = 0; R = 0; end // hold
This guarantees that the forbidden combination never reaches the latch, at the cost of a modest amount of logic and a design‑time decision about which command dominates.
2. Replacing the Basic SR Latch with a Safer Flip‑Flop
Instead of trying to “fix” the SR latch, many designers simply avoid it altogether by using a flip‑flop that internally resolves the race condition. The two most common replacements are:
| Replacement | Core Idea | Typical Implementation | Design Impact |
|---|---|---|---|
| JK Flip‑Flop | Adds a toggle mode (J = K = 1) that is well‑defined rather than forbidden. | Master‑slave or edge‑triggered with internal feedback from Q and Q̅. | Retains the same clock interface; the toggle mode is useful for frequency division. |
Honestly, this part trips people up more than it should Easy to understand, harder to ignore..