Digital logic & computing · tree view
Feedback turns gates into latches with memory; edge-triggered flip-flops (D, JK, T) restrict state changes to a clock edge, synchronize circuits, and halve frequency when toggled.
Any digital circuit employing feedback is called a multivibrator. The example we just explored with the OR gate was a very simple example of what is called a bistable multivibrator. It is called "bistable" because it can hold stable in one of two possible output states, either 0 or 1.
The Q and not-Q outputs are supposed to be in opposite states. I say "supposed to" because making both the S and R inputs equal to 1 results in both Q and not-Q being 0. For this reason, having both S and R equal to 1 is called an invalid or illegal state for the S-R multivibrator.
An application for the D latch is a 1-bit memory circuit. You can "write" (store) a 0 or 1 bit in this latch circuit by making the enable input high (1) and setting D to whatever you want the stored bit to be. When the enable input is made low (0), the latch ignores the status of the D input and merrily holds the stored bit value, outputting at the stored value at Q, and its inverse on output not-Q.
Whenever we enable a multivibrator circuit on the transitional edge of a square-wave enable signal, we call it a flip-flop instead of a latch.
The triangle symbol next to the clock inputs tells us that these are edge-triggered devices, and consequently that these are flip-flops rather than latches.
The end result is that the S-R flip-flop's "invalid" state is eliminated (along with the race condition it engendered) and we get a useful feature as a bonus: the ability to toggle between the two (bistable) output states with every transition of the clock input signal.
There is no such thing as a J-K latch, only J-K flip-flops.
When the preset input is activated, the flip-flop will be set (Q=1, not-Q=0) regardless of any of the synchronous inputs or the clock. When the clear input is activated, the flip-flop will be reset (Q=0, not-Q=1), regardless of any of the synchronous inputs or the clock. So, what happens if both preset and clear inputs are activated? Surprise, surprise: we get an invalid state on the output, where Q and not-Q go to the same state, the same as our old friend, the S-R latch!
Flip-flops (FFs) are devices used in the digital field for a variety of purposes. When properly connected, flip-flops may be used to store data temporarily, to multiply or divide, to count operations, or to receive and transfer information.
To set the flip-flop requires a HIGH on the S input and a LOW on the R input. To reset, the opposite is required; S input LOW and R input HIGH. When both R and S are HIGH, the FF will hold or "latch" the condition that existed before both inputs went HIGH.
Since the output cycle is one-half the input cycle, this device can be used to divide the input by 2.
The J-K FF is the most widely used FF because of its versatility. When properly used it may perform the function of an R-S, T, or D FF.
A race condition occurs when two mutually-exclusive events are simultaneously initiated through different circuit elements by a single cause.
D FF is used to store data at a predetermined time.
COUNTERS are used to count operations, quantities, or periods of time. They can be used to divide frequencies, to address information in storage, or as temporary storage.
Two cross-coupled NOR gates: Q = NOR(S, Q′), Q′ = NOR(R, Q). S=1 sets (Q=1), R=1 resets (Q=0), and S=R=0 makes the loop remember whatever it was doing. The S=R=1 row forces both NOR outputs low at once — Q and Q′ are no longer complements, which is why it is the forbidden state.
To predict the outcome:
| s | r | q | q_not | state |
|---|---|---|---|---|
| 0 | 0 | Q (previous) | Q′ (previous) | hold / memory |
| 1 | 0 | 1 | 0 | set |
| 0 | 1 | 0 | 1 | reset |
| 1 | 1 | 0 | 0 | forbidden — outputs not complementary |
An edge-triggered D flip-flop samples D at the clock's rising edge (triangle symbol, no bubble) and holds it until the next edge. Between edges the clock level does nothing at all — that is what separates a flip-flop from a transparent D latch.
To predict the outcome:
| clock | d_at_edge | q_next | note |
|---|---|---|---|
| ↑ (0→1) | 0 | 0 | clean capture of 0 |
| ↑ (0→1) | 1 | 1 | clean capture of 1 |
| 0 level / 1 level / ↓ | any | no change | edge-triggered — levels are ignored |
| ↑ (0→1) | changing inside the sampling window | 1 or 0 (unpredictable) | timing violation — possible metastability |
Feedback from Q and Q′ gates the J and K inputs so they can never both reach the latch at once. The result: J=K=1 toggles Q on every active clock edge instead of entering the S-R illegal state.
To predict the outcome:
| j | k | q_old | q_next | action |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | hold |
| 0 | 0 | 1 | 1 | hold |
| 0 | 1 | 0 | 0 | reset (stays 0) |
| 0 | 1 | 1 | 0 | reset |
| 1 | 0 | 0 | 1 | set |
| 1 | 0 | 1 | 1 | set (stays 1) |
| 1 | 1 | 0 | 1 | toggle |
| 1 | 1 | 1 | 0 | toggle |
Wire J=K=1 (or use a T flip-flop) and Q flips on every rising clock edge. One full output cycle then needs two input cycles, so Q toggles at exactly half the clock frequency — the elementary frequency divider, and the reason flip-flops "multiply or divide" in NEETS' words.
To predict the outcome:
| clock_edges | q_after | q_not | output_note |
|---|---|---|---|
| 0 (start) | 0 | 1 | output low — f/2 waveform low |
| 1 | 1 | 0 | Q rises after 1 input edge |
| 2 | 0 | 1 | one complete Q cycle after 2 input edges |
| 3 | 1 | 0 | second output cycle begins |
| 4 | 0 | 1 | two output cycles per four edges — always f/2 |
An edge-triggered flip-flop needs D to be stable for a setup time before the active edge and a hold time after it. These windows are brief (a few nanoseconds) and specific values are data-sheet numbers — neither Kuphaldt nor NEETS tabulates them — but the outcome logic below follows directly from the edge-sampling principle.
To predict the outcome:
| event | timing | outcome |
|---|---|---|
| D stable before and after the edge | beyond both t_setup and t_hold | clean capture — Q = D reliably |
| D changes just before the edge | inside the setup window | capture uncertain — Q may settle wrong or go metastable |
| D changes just after the edge | inside the hold window | old value may or may not hold — data-sheet dependent |
| D changes long after the edge | outside both windows | ignored — Q keeps the captured bit until the next edge |