The four flip-flops side by side
| Feature | D | T | J-K | S-R |
|---|---|---|---|---|
| Data inputs | D | T | J and K | S and R |
| On the rising edge | Q becomes D | Q toggles if T is 1 | J=0 K=0 holds, J=1 K=1 toggles | S=1 sets, R=1 resets, both 1 holds |
| Level triggers | Offered in the Trigger list (see below) | Not tested | Not tested | Not tested |
| Typical use | One bit of a register | Counters | General purpose | Set and reset control |
All four share the same pins: data at the top left, the clock below it, Q and its complement on the right, Preset on top and Clear at the bottom (F66). J-K and S-R have two data inputs. The pin names come from the 5.0.0 tooltips; the data pins have none, so their names are ours.
Characteristic tables from our runs
One circuit holds all four flip-flops on a shared clock. A 14-step sequence drives it and Logisim 5.0.0 matched every step (F66). The columns are the inputs D J K S R T, the clock, Preset (PRE), Clear (CLR), and then Q and Q̅ of each flip-flop.
| # | D | J | K | S | R | T | CLK | PRE | CLR | qD | ND | qT | NT | qJK | NJK | qSR | NSR | <set> |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | |
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | |
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | |
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | |
| 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | |
| 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | |
| 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | |
| 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | |
| 1 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | |
| 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | |
| 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | |
| 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | |
| 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | |
| 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
Describe this circuit
Components: Input pin D; Input pin J; Input pin K; Input pin S; Input pin R; Input pin T; Input pin CLK; Input pin PRE; Input pin CLR; D Flip-Flop ffD; T Flip-Flop ffT; J-K Flip-Flop ffJK; S-R Flip-Flop ffSR; Output pin qD; Output pin ND; Output pin qT; Output pin NT; Output pin qJK; Output pin NJK; Output pin qSR; Output pin NSR.
- Input pin D connects to D Flip-Flop ffD (net D).
- Input pin J connects to J-K Flip-Flop ffJK (net J).
- Input pin K connects to J-K Flip-Flop ffJK (net K).
- Input pin S connects to S-R Flip-Flop ffSR (net S).
- Input pin R connects to S-R Flip-Flop ffSR (net R).
- Input pin T connects to T Flip-Flop ffT (net T).
- Input pin CLK connects to D Flip-Flop ffD, T Flip-Flop ffT, J-K Flip-Flop ffJK, S-R Flip-Flop ffSR (net CLK).
- Input pin PRE connects to D Flip-Flop ffD, T Flip-Flop ffT, J-K Flip-Flop ffJK, S-R Flip-Flop ffSR (net PRE).
- Input pin CLR connects to D Flip-Flop ffD, T Flip-Flop ffT, J-K Flip-Flop ffJK, S-R Flip-Flop ffSR (net CLR).
- D Flip-Flop ffD connects to Output pin qD (net qD).
- D Flip-Flop ffD connects to Output pin ND (net nqD, ND).
- T Flip-Flop ffT connects to Output pin qT (net qT).
- T Flip-Flop ffT connects to Output pin NT (net nqT, NT).
- J-K Flip-Flop ffJK connects to Output pin qJK (net qJK).
- J-K Flip-Flop ffJK connects to Output pin NJK (net nqJK, NJK).
- S-R Flip-Flop ffSR connects to Output pin qSR (net qSR).
- S-R Flip-Flop ffSR connects to Output pin NSR (net nqSR, NSR).
What the sequence showed (F66):
- Every flip-flop changed only on the rising clock edge. Changing inputs while the clock was 1, or the falling edge, changed nothing.
- J-K with J = K = 1 toggled.
- S-R with S = R = 1 on a clock edge left the state unchanged, from 0 and from 1.
Download circ-ff-compare.circ.
Rising edge, falling edge and level triggers
The Trigger attribute offers Rising Edge, Falling Edge, High Level and Low Level (strings in the 5.0.0 table, F73). Rising edge changes the state once per clock cycle. A level trigger lets the flip-flop follow its input for as long as the clock is at that level, which makes it a latch.
See the toggle pair on Oscillation apparent. To get a D latch, use a D flip-flop with Trigger = High Level.
Preset, clear and the starting value
Preset forces the state to 1 and Clear forces it to 0, immediately, with no clock. The state is kept after you release the pin. With Preset and Clear both 1, Clear won and the state stayed 0 after release (F66).
After Simulate, Reset Simulation every flip-flop was 0 (F66). A project option, Memory elements start in unknown/random state (rather than 0), changes the starting value; we did not test it. To start a state machine in a chosen state, drive Preset and Clear from a reset pin.
Latches built from gates
Labs often ask for an S-R latch from two NOR or NAND gates. In Logisim every gate has the same delay, so releasing S and R from 1 together makes both gates flip in step and the circuit oscillates (F76). The built-in flip-flops do not have this problem. The full explanation, the downloads and the fix are on Oscillation apparent.
Clock mistakes that make flip-flops misbehave
Do not AND the clock with an enable signal: it makes glitches. Give the counter or register an enable input instead (Clock and simulation). A toggle switch is a D flip-flop with its complement fed back to D; our rising-edge toggle circuit is the fixed file on the oscillation page.
Version differences
| Feature | 2.7.1 | 5.0.0 |
|---|---|---|
| Default D and T flip-flop ports | 2.7.1: yes7 ports | 5.0.0: yes6 ports (F23) |
| Default J-K and S-R flip-flop ports | 2.7.1: yes8 ports | 5.0.0: yes7 ports (F23) |
| Enable input | 2.7.1: untested | 5.0.0: yesnone on the default instance |
| Trigger options | 2.7.1: untested | 5.0.0: yesfour options (F73) |
Cells say untested where we did not run 2.7.1. See also all components.