Digital logic & computing · tree view
Flip-flops chained to toggle on a clock make counters (ripple vs synchronous) and shift registers; feed a register's state back through gates and you get a finite state machine — the standard way to build sequenced behaviour in hardware.
Note how the least significant bit (LSB) toggles between 0 and 1 for every step in the count sequence, while each succeeding bit toggles at one-half the frequency of the one before it. The most significant bit (MSB) only toggles once during the entire sixteen-step count sequence: at the transition between 7 (0111) and 8 (1000).
Instead of cleanly transitioning from a "0111" output to a "1000" output, the counter circuit will very quickly ripple from 0111 to 0110 to 0100 to 0000 to 1000, or from 7 to 6 to 4 to 0 and then to 8. This behavior earns the counter circuit the name of ripple counter, or asynchronous counter.
A counter is simply a device that counts. Counters may be used to count operations, quantities, or periods of time. They may also be used for dividing frequencies, for addressing information in storage, or for temporary storage.
The total number of counts or stable states a counter can indicate is called MODULUS.
The only way we can build such a counter circuit from J-K flip-flops is to connect all the clock inputs together, so that each and every flip-flop receives the exact same clock pulse at the exact same time:
A register is a temporary storage device. Registers are used to store data, memory addresses, and operation codes.
A shift register is a register in which the contents may be shifted one or more places to the left or right.
SCALING means to change the magnitude of a number. Shifting binary numbers to the left increases their value, and shifting to the right decreases their value. The increase or decrease in value is based on powers of 2.
A circuit whose output depends not only on the present input but also on the history of the input is called a sequential circuit.
The Finite State Machine is an abstract mathematical model of a sequential logic function. It has finite inputs, outputs and number of states. FSMs are implemented in real-life circuits through the use of Flip Flops
Ripple counters are so named because the count is like a chain reaction that ripples through the counter because of the time involved.
High-frequency operations require that all the FFs of a counter be triggered at the same time to prevent errors. We use a SYNCHRONOUS counter for this type of operation.
Thus, a four stage shift register delays "data in" by four clocks to "data out". The stages in a shift register are delay stages, typically type "D" Flip-Flops or type "JK" Flip-flops.
There are shift registers which will shift data either left or right.
If the serial output of a shift register is connected to the serial input, data can be perpetually shifted around the ring as long as clock pulses are present.
A ring counter is defined as a loop of bistable devices (flip-flops) interconnected in such a manner that only one of the devices may be in a specified state at one time.
Make a note that this is a Moore Finite State Machine. Its output is a function of only its current state, not its input. That is in contrast with the Mealy Finite State Machine, where input affects the output.
Four toggle flip-flops in a ripple (asynchronous) chain: Q0's falling edge clocks Q1, Q1's clocks Q2, and so on. Each stage reacts only after the previous one has flipped, so a carry from 7 to 8 passes through false intermediate values — exactly the sequence Kuphaldt quotes. Each row is one flip-flop propagation delay later.
To predict the outcome:
| time | q3_q2_q1_q0 | value_seen | verdict |
|---|---|---|---|
| t0 — clock edge | 0111 | 7 | correct count |
| t0 + 1 delay (Q0 flipped) | 0110 | 6 | false transient |
| t0 + 2 delays (Q1 flipped) | 0100 | 4 | false transient |
| t0 + 3 delays (Q2 flipped) | 0000 | 0 | false transient |
| t0 + 4 delays (Q3 flipped) | 1000 | 8 | correct count, settled |
NEETS defines the modulus as "the total number of counts or stable states a counter can indicate." N free-running toggle stages give 2^N states, max count 2^N − 1, and an output frequency of f/2^N. Reset early (the decade counter NANDs outputs at count 10) and the modulus shrinks to whatever you reset at.
To predict the outcome:
| stages | max_count | modulus | output_frequency |
|---|---|---|---|
| 1 | 1 | 2 | f / 2 |
| 3 | 7 | 8 | f / 8 |
| 4 | 15 | 16 | f / 16 |
| 4 + NAND reset at 10 (decade) | 9 | 10 | f / 10 |
| 8 | 255 | 256 | f / 256 |
With every flip-flop clocked simultaneously, a stage must decide electronically whether to toggle. Kuphaldt's rule: just before a bit toggles, all lower-order bits are high — so Q1 toggles when Q0 = 1, Q2 when Q1 = Q0 = 1, and AND gates on the lower outputs enable each stage's J-K inputs. Predict the next count column-wise from the present one.
To predict the outcome:
| present_q2_q1_q0 | q0_toggles | q1_toggles | q2_toggles | next_count |
|---|---|---|---|---|
| 000 (0) | yes | no (Q0 = 0) | no | 001 (1) |
| 001 (1) | yes | yes (Q0 = 1) | no | 010 (2) |
| 010 (2) | yes | no (Q0 = 0) | no | 011 (3) |
| 011 (3) | yes | yes | yes (Q1 = Q0 = 1) | 100 (4) |
| 100 (4) | yes | no | no | 101 (5) |
| 111 (7) | yes | yes | yes | 000 (0) — wraps |
A serial-in/serial-out register of four D flip-flops: on each clock the input bit enters stage D0 and every other bit moves one stage to the right. Kuphaldt: "a four stage shift register delays 'data in' by four clocks to 'data out.'" Below, the stream 1,1,0,1 (then idle 0s) is shifted in; shifting left multiplies by 2 per place, right divides — NEETS' "scaling."
To predict the outcome:
| clock | d3 | d2 | d1 | d0 | serial_out |
|---|---|---|---|---|---|
| 0 (reset) | 0 | 0 | 0 | 0 | 0 |
| 1 (in = 1) | 0 | 0 | 0 | 1 | 0 |
| 2 (in = 1) | 0 | 0 | 1 | 1 | 0 |
| 3 (in = 0) | 0 | 1 | 1 | 0 | 0 |
| 4 (in = 1) | 1 | 0 | 1 | 1 | 1 |
| 5 (in = 0) | 0 | 1 | 0 | 1 | 1 |
A Moore FSM: outputs depend only on the current state. Two state bits Q1Q0 encode four states of an intersection; the only input is T (timer expired). On each clock edge, T = 1 advances the ring, T = 0 holds. Kuphaldt's design recipe: list states, assign binary codes, fill the state table, then realize next-state logic with flip-flops and gates.
To predict the outcome:
| state_q1_q0 | meaning | ns_light | ew_light | input_t | next_state |
|---|---|---|---|---|---|
| 00 | north-south green | G | R | 1 | 01 |
| 00 | north-south green | G | R | 0 | 00 (hold) |
| 01 | north-south yellow | Y | R | 1 | 10 |
| 10 | east-west green | R | G | 1 | 11 |
| 11 | east-west yellow | R | Y | 1 | 00 — ring closes |