您将学到什么

  • Identify the SR latch as the simplest memory element.
  • Recognize the four input combinations: Set, Reset, Hold, Forbidden.
  • Trace the cross-coupled feedback that creates bistable storage.
  • Distinguish level-sensitive latches from edge-triggered flip-flops.
  • Apply SR latches to debounce, arbitration, and SRAM cells.

工作原理

An SR latch is the simplest memory element — two cross-coupled NOR (or NAND) gates that can hold one bit indefinitely. It has two inputs (S = Set, R = Reset) and two complementary outputs (Q, ¬Q). The cross-coupling creates a bistable feedback loop: when both inputs are quiet, whatever value is currently on Q stays there.

NOR-based active-high SR latch behaviour: - Set (S=1, R=0): Q goes to 1 (and stays there after S returns to 0). - Reset (S=0, R=1): Q goes to 0 (and stays there). - Hold (S=0, R=0): Q keeps its previous value — the latch "remembers." - Forbidden (S=1, R=1): Both inputs high force both outputs to 0 simultaneously, breaking the Q = ¬Q invariant. When inputs return to 00 the final state depends on which input releases last — non-deterministic.

The SR latch is the seed of all sequential logic. Every flip-flop, register, and SRAM cell starts with two cross-coupled inverters (effectively a SR latch with hidden control). Latches were used as registers throughout early CPUs before edge-triggered flip-flops became dominant.

Key insight: latches are level-sensitive (output reflects input continuously while enabled), unlike flip-flops which are edge-triggered (output samples only on a clock edge).

真值表

SR latch behaviour table. Q' is the previous Q value (memory). Forbidden state when S=R=1.

输入 输出
SR QBehaviour
00 0 Hold — Q stays at previous value
01 0 Reset — Q forced to 0
10 1 Set — Q forced to 1
11 0 Forbidden — both outputs go to 0, invariant broken

布尔表达式

Qnext=S+RQQ_{next} = S + \overline{R} \cdot Q

Next-state equation: Q is set if S asserted, kept if Reset is low, cleared if Reset asserted.

Q=NOR(R,Qold),    Q=NOR(S,Qold)\overline{Q} = \text{NOR}(R, \overline{Q}_{old}),\;\; Q = \text{NOR}(S, Q_{old})

Cross-coupled NOR implementation. The two outputs feed each other's NOR inputs.

逐步尝试

在上方嵌入式电路中设置输入,然后阅读预期结果并验证。

  1. 1
    S = 1 R = 0
    预期: Q = 1
    您将看到: Set the latch — Q goes high. Now release S back to 0 and Q stays high. The latch remembers.
  2. 2
    S = 0 R = 0
    预期: Q unchanged
    您将看到: After setting, both inputs low → latch holds. Q stays at whatever it was. This is the memory function.
  3. 3
    S = 0 R = 1
    预期: Q = 0
    您将看到: Reset — Q drops to 0. Release R and Q stays at 0. Latch now in the reset state, awaiting next Set.
  4. 4
    S = 1 R = 1
    预期: Both Q and ¬Q = 0 (forbidden)
    您将看到: Forbidden state — the latch breaks its Q = ¬Q invariant. When inputs return to 00, the final state is unpredictable. Avoid in real designs.

使用的组件

实际应用

SRAM cell. A 6-transistor SRAM cell is two cross-coupled inverters with access transistors — functionally an SR latch with bit-line control. Every byte of cache memory in a modern CPU is millions of these.

Bus master arbitration. A two-master arbiter often uses an SR latch where Set comes from master A's request and Reset comes from master B's. The latch state determines who currently owns the bus.

Push-button debouncing. A bouncing physical switch generates multiple transitions; an SR latch with the bounce-up signal on Set and bounce-down on Reset filters noise into a single clean transition.

Manual reset circuits. Many embedded systems use SR latches to capture power-on reset until firmware acknowledges and clears it.

Race-condition detectors. Two parallel signals racing into Set and Reset; whichever wins determines the latch state. Used in metastability detectors and arbiter circuits.

常见问题

Why is S=R=1 called forbidden?
Because both NOR outputs are forced to 0 simultaneously, violating the latch's invariant that Q and ¬Q are always opposites. When the inputs eventually go back to 00, the final state depends on subtle timing — non-deterministic. Real designs avoid this state via logic that ensures S and R are never both high.
What's the difference between SR latch and SR flip-flop?
An SR latch is asynchronous (output changes immediately when inputs change). An SR flip-flop is clocked (output changes only on a clock edge). Flip-flops have an extra clock input that gates when the latch can change.
How does SRAM use this?
Each SRAM cell is two cross-coupled CMOS inverters (effectively an SR latch's two NORs become two inverters when one input is fixed at 0). Two access transistors connect the cell to the bit lines for read/write. The bistable storage holds the bit between accesses.
Can I make an SR latch from NAND gates?
Yes — two cross-coupled NANDs make an active-low SR latch, often labeled S̄ R̄. The behaviour is mirror-imaged: S̄=0 sets Q=1; R̄=0 resets Q=0; S̄=R̄=1 holds; S̄=R̄=0 is forbidden. Same circuit, inverted polarities.
What about latches with no forbidden state?
D-latches (next templates) eliminate the forbidden state by having a single data input plus an enable. There's no way to assert both Set and Reset simultaneously because they're derived from the same D input through inverter logic.

继续学习