# How a circuit remembers

*The one idea that turns logic into memory*

Feedback is routing a circuit's output back into its own input so the circuit can hold a value after the inputs that set it go away, which is the one idea that turns combinational logic into memory.

Group: Memory
URL: https://digiwleea.wleeaf.dev/learn/feedback-and-memory/

> **KEY:** Every circuit so far, from a single gate up to the [full adder](https://digiwleea.wleeaf.dev/learn/fulladder/), has had a property you may not have noticed: its output depends *only* on its current inputs. Change the inputs and the output follows; remove the inputs and nothing is kept. This bridge introduces the single structural change, **feedback**, that lets a circuit *remember*, and it is the doorway to the [SR latch](https://digiwleea.wleeaf.dev/learn/srlatch/) and everything after it.

Here is why memory feels like a big leap. A gate is a function: same inputs in, same output out, with no sense of "before". Memory needs the opposite, a circuit whose output can differ even when the inputs look the same, because it depends on what happened *earlier*. How can a pile of stateless gates suddenly have a past? The answer is one wire.

The insight: **route an output back to feed one of the inputs.** Now the circuit's next state depends on its own current state, which depends on its previous state, and so on backward in time. The loop gives the circuit somewhere to hold a value that is not driven from outside. Break every feedback loop and a circuit can only ever be combinational; add one and it can store. See it happen: the [interactive latch simulator](https://digiwleea.wleeaf.dev/tools/memory-simulator/) sets a bit, then holds it after you release the input.

A concrete analogy: two people who each say "I'll keep doing this as long as you do." Once they start, each one's behavior is sustained by the other, so the pair holds its state with no outside push. Cross-couple two [NOR](https://digiwleea.wleeaf.dev/learn/nor/) gates the same way, each gate's output wired to the other's input, and the pair latches: a brief nudge sets it, and it *stays* set after the nudge is gone. That self-sustaining loop is a stored bit.

> **WARN:** Feedback is powerful and also the source of two new hazards that combinational logic never had. A badly built loop can **oscillate** (flip forever, shown as `~` in the simulator) instead of settling, and a stored bit can be corrupted if both control inputs are asserted at once. Memory circuits must be designed so the loop settles to exactly one stable value, which is precisely the care the latch and flip-flop lessons take.

**Q (Check yourself):** What is the structural difference between a circuit that can remember and one that cannot, and why does that difference create the ability to store a value?

**A:** A circuit that can remember contains a **feedback loop**, an output wired back to feed an input; one that cannot is purely feed-forward. The loop makes the output depend on the circuit's own earlier state rather than only on the current inputs, so a value set once is sustained by the loop and persists after the setting input is removed. That persistence is memory.

### FAQ

**Q:** How does a circuit remember a value?

**A:** By feedback: one of its outputs is wired back to feed an input, forming a loop. The loop sustains whatever value it holds, so the circuit keeps its state even after the inputs that set it are removed. That is the basis of every latch, flip-flop, and register.

**Q:** What is feedback in a digital circuit?

**A:** Feedback is connecting an output back to an input so the circuit's behavior depends on its own current state. It is the structural feature that separates memory (sequential) circuits from stateless combinational ones.

**Q:** Why can combinational logic not store a value?

**A:** Because it is purely feed-forward: its output is a fixed function of its current inputs, with no loop to sustain a value. Remove the inputs and nothing is kept. Storage requires a feedback path.

> **KEY:** Before building a memory cell, it pays to sharpen the distinction feedback creates. Next, [combinational versus sequential](https://digiwleea.wleeaf.dev/learn/combinational-vs-sequential/) names the two circuit families, then the [SR latch](https://digiwleea.wleeaf.dev/learn/srlatch/) makes feedback concrete.
