Design a synchronous counter with JK flip-flops that counts 0, 1, 2, 3, 4, 5 and repeats. Then check what happens if it powers up in an unused state.
Sequential circuits add memory: outputs depend on present inputs and on stored state. Latches, flip-flops, registers, counters and finite-state machines are the heart of every processor, and PSC regularly asks characteristic equations, excitation tables, flip-flop counts and counter states.
A sequential circuit is combinational logic plus memory. The memory holds the circuit's state — a compact summary of everything relevant that has happened so far — and the outputs depend on both the present inputs and that state. Memory comes from feedback: outputs are fed back as inputs, so the circuit can keep a value after the input that caused it has gone.
With n flip-flops a circuit has at most 2ⁿ states. In a synchronous circuit every flip-flop is driven by one common clock, so the state changes only at clock edges and the logic in between has time to settle. In an asynchronous circuit the state changes as soon as the inputs do — faster, but prone to races and hazards. Almost all practical designs, and everything the syllabus calls 'synchronous sequential system design', are clocked.
The clock is a periodic square wave. Its period T is the time for one cycle and its frequency is f = 1/T (a 25 ns period means 40 MHz). The 0 → 1 transition is the positive (rising) edge, the 1 → 0 transition the negative (falling) edge, and the fraction of the period spent at 1 is the duty cycle.
The simplest memory is the SR latch: two cross-coupled NOR gates, each output feeding the other gate's input. S (set) = 1 forces Q = 1; R (reset) = 1 forces Q = 0; with S = R = 0 the feedback simply holds what was stored. S = R = 1 drives both Q and Q' to 0 — they are no longer complements — and if both inputs then return to 0 together, the final state depends on which gate is faster. That input is therefore forbidden.
| S | R | Q⁺ | Action |
|---|---|---|---|
| 0 | 0 | Q | No change (hold) |
| 0 | 1 | 0 | Reset |
| 1 | 0 | 1 | Set |
| 1 | 1 | — | Forbidden: Q = Q' = 0, then unpredictable |
Built from two cross-coupled NAND gates, the latch has active-low inputs S̅ and R̅: S̅ = 0 sets, R̅ = 0 resets, S̅ = R̅ = 1 holds, and S̅ = R̅ = 0 is forbidden because it forces Q = Q' = 1. It is the same behaviour with mirror-image input levels; the 74LS279 contains four such S̅R̅ latches, a favourite for debouncing switches.
| S̅ | R̅ | Q⁺ | Action |
|---|---|---|---|
| 0 | 0 | — | Forbidden: Q = Q' = 1 |
| 0 | 1 | 1 | Set |
| 1 | 0 | 0 | Reset |
| 1 | 1 | Q | No change (hold) |
A gated (clocked) SR latch adds an enable: two AND gates pass S and R to a NOR latch only while EN = 1 — or two NAND gates in front of a NAND latch, which also restores active-high inputs. The gated D latch feeds S = D and R = D', so S = R = 1 can never occur. While EN = 1 the output follows D (the latch is transparent); when EN falls, the last value is held.
A flip-flop changes state only at the active clock edge; its symbol has a small triangle at the clock input, with a bubble for negative-edge triggering. Four types are standard. The JK removes SR's forbidden input by making J = K = 1 toggle the output. The D (data or delay) flip-flop simply stores D at each edge. The T (toggle) flip-flop holds when T = 0 and complements when T = 1 — it is a JK with J and K tied together.
| Type | Inputs → Q⁺ | Characteristic equation | Typical IC / build |
|---|---|---|---|
| SR | 00 → Q, 01 → 0, 10 → 1, 11 → invalid | Q⁺ = S + R'Q, with S·R = 0 | Gated latch + edge detector |
| JK | 00 → Q, 01 → 0, 10 → 1, 11 → Q' (toggle) | Q⁺ = JQ' + K'Q | 74LS76, 74LS112 (negative edge) |
| D | 0 → 0, 1 → 1 | Q⁺ = D | 7474 (dual, positive edge) |
| T | 0 → Q (hold), 1 → Q' (toggle) | Q⁺ = TQ' + T'Q = T ⊕ Q | JK with J = K = T |
Race-around condition. In a level-triggered JK flip-flop with J = K = 1, the output toggles once every propagation delay tpd for as long as the clock stays high. If the clock pulse width tp exceeds tpd, the output toggles several times within one pulse and ends in an unpredictable state. Avoiding it needs tp < tpd < T, which is hard to guarantee, so practical designs use one of two cures.
Master–slave JK: two latches in series. The master is enabled while CLK = 1 and the slave, clocked by CLK', while CLK = 0. The master captures J and K during the high level, but the output changes only after the clock falls, when the master is already closed — so the output changes at most once per pulse. Its weakness is 1s catching: a brief glitch on J or K while CLK is high can be latched by the master. Edge-triggered flip-flops sample J and K only at the edge and avoid both problems, which is why they dominate modern logic.
Asynchronous inputs. Preset (PRE) and clear (CLR), usually active-low, force Q = 1 or Q = 0 immediately, overriding the clock. They initialise counters at power-up and load a ring counter's starting pattern; the 7474 provides both on each of its two D flip-flops.
The characteristic table answers 'given these inputs, what is Q⁺?'. Design needs the opposite question: 'to move from Q to the Q⁺ I want, which inputs must I apply?' The answer is the excitation table. X means don't care — either value works — and those X's are what make JK-based designs so economical.
| Q → Q⁺ | S R | J K | D | T |
|---|---|---|---|---|
| 0 → 0 | 0 X | 0 X | 0 | 0 |
| 0 → 1 | 1 0 | 1 X | 1 | 1 |
| 1 → 0 | 0 1 | X 1 | 0 | 1 |
| 1 → 1 | X 0 | X 0 | 1 | 0 |
| Required | From | Connection |
|---|---|---|
| T | JK | J = K = T |
| D | JK | J = D, K = D' |
| D | SR | S = D, R = D' |
| JK | SR | S = JQ', R = KQ |
| T | SR | S = TQ', R = TQ |
| T | D | D = T ⊕ Q |
| D | T | T = D ⊕ Q |
| JK | D | D = JQ' + K'Q |
| JK | T | T = JQ' + KQ |
Example: with tCQ = 10 ns, worst-case logic delay 25 ns and tsu = 5 ns, the period must be at least 10 + 25 + 5 = 40 ns, so fmax = 1/40 ns = 25 MHz. In a 4-bit ripple counter with tpd = 25 ns per stage, the last stage settles 4 × 25 = 100 ns after the edge, so the count can be read reliably only up to 10 MHz. The same four flip-flops in a synchronous counter are limited by just one tCQ plus an AND-gate delay plus tsu, however many stages there are.
A register is a group of n flip-flops sharing one clock, storing an n-bit word; a load (enable) input decides whether it takes new data at the next edge or keeps its contents. A shift register connects each flip-flop's output to the next one's input, so every clock edge moves the stored bits one place. Shifting left doubles an unsigned number and shifting right halves it.
| Type | Data in / out | Clocks to load n bits | Typical use / IC |
|---|---|---|---|
| SISO | Serial in, serial out | n (first bit reaches the output after n clocks; all n out after 2n − 1) | Delay line; 74LS91 (8-bit) |
| SIPO | Serial in, parallel out | n | Serial-to-parallel (UART receiver); 74164 |
| PISO | Parallel in, serial out | 1 to load, then n to shift out | Parallel-to-serial (UART transmitter); 74165 |
| PIPO | Parallel in, parallel out | 1 | Buffer/storage register; 74LS174, 74LS175 |
A universal shift register can hold, shift right, shift left or load in parallel. The 4-bit 74194 chooses with its mode inputs S₁S₀: 00 = hold, 01 = shift right, 10 = shift left, 11 = parallel load.
Feeding a shift register's output back to its input makes a shift-register counter. In a ring counter the last flip-flop's Q returns to the first, and a single 1 (preset as 1000) circulates: n flip-flops give only n states, but each state is self-decoding — exactly one flip-flop is high — so no decoder is needed. In a Johnson counter (twisted-ring, switch-tail or Möbius counter) the complement Q' of the last flip-flop is fed back, so the register fills with 1s and then empties with 0s: n flip-flops give 2n states, each decoded by one 2-input AND gate.
| Clock | 4-bit ring (Q₀Q₁Q₂Q₃) | 4-bit Johnson (Q₀Q₁Q₂Q₃) |
|---|---|---|
| 0 | 1000 | 0000 |
| 1 | 0100 | 1000 |
| 2 | 0010 | 1100 |
| 3 | 0001 | 1110 |
| 4 | 1000 (repeats) | 1111 |
| 5 | 0100 | 0111 |
| 6 | 0010 | 0011 |
| 7 | 0001 | 0001 |
| 8 | 1000 | 0000 (repeats) |
A counter steps through a fixed sequence of states on successive clock pulses; the number of distinct states is its modulus. A mod-N counter needs ⌈log₂N⌉ flip-flops — mod-10 needs 4, and mod-18 needs 5 because 2⁴ = 16 < 18 ≤ 32 = 2⁵ — and its output frequency is fclk/N. In a plain n-bit binary counter each flip-flop halves the frequency, so the last stage gives fclk/2ⁿ.
Ripple direction. With negative-edge flip-flops, clocking each stage from the previous Q gives an up counter; clocking from Q' instead (or using positive-edge flip-flops driven from Q) gives a down counter.
Mod-N by reset (truncated sequence). A ripple counter can be cut short by decoding state N and driving the asynchronous clear. In a decade (mod-10) counter, 1010 is the first state with Q₃ = Q₁ = 1, so a 2-input NAND of Q₃ and Q₁ clears the counter the instant it reaches 1010: the display shows 0–9, and 1010 lasts only nanoseconds. A mod-6 counter decodes 110 (Q₂Q₁) in the same way. Synchronous designs instead derive the inputs so that state N − 1 leads straight to 0, as in the worked examples.
A general synchronous sequential circuit is a finite-state machine (FSM). It is described by a state diagram — circles for states, arrows for transitions labelled with the input — or by the equivalent state table listing present state and input against next state and output. Two models exist, named after G. H. Mealy (1955) and E. F. Moore (1956).
Example — detect the pattern 101 (overlapping) on a serial input x. The Mealy machine needs 3 states: A (no progress), B (seen 1) and C (seen 10). From C, input 1 completes the pattern, so the transition C → B is labelled 1/1, and it returns to B because that final 1 can start the next pattern. The Moore machine needs a fourth state D (seen 101) whose output is 1; from D, x = 0 leads to C and x = 1 to B.
| Present state | x = 0: next / z | x = 1: next / z |
|---|---|---|
| A (nothing yet) | A / 0 | B / 0 |
| B (seen 1) | C / 0 | B / 0 |
| C (seen 10) | A / 0 | B / 1 |
Try the problem first, then reveal the working one step at a time.
Design a synchronous counter with JK flip-flops that counts 0, 1, 2, 3, 4, 5 and repeats. Then check what happens if it powers up in an unused state.
Design a synchronous counter with T flip-flops for the repeating sequence 0, 1, 3, 7, 6, 4, treating the unused states 2 and 5 as don't cares. Then check those states and correct the design if needed (a classic Mano problem).
Using the conversion procedure, find the logic to place in front of an SR flip-flop so that it behaves as a JK flip-flop.
A 4-bit Johnson counter (Q₀ is fed with Q₃') starts at 0000 and is clocked at 80 kHz. List its states, give a decoding gate for each state, and find the frequency and duty cycle of each output. Compare with a 4-bit ring counter.
(a) How many flip-flops are needed for a mod-50 counter and for a mod-1000 counter? (b) A 4-bit binary counter is clocked at 1 MHz; what is the frequency at its MSB? (c) How many states does a decade counter leave unused?
A negative-edge JK flip-flop starts with Q = 0. On five successive clock edges the inputs (J, K) are (1, 0), (0, 0), (1, 1), (1, 1), (0, 1). Give Q after each edge.
Design a 2-bit synchronous up/down counter with T flip-flops and a control input M (M = 0 counts up 0, 1, 2, 3; M = 1 counts down 0, 3, 2, 1).
Reduce this Mealy state table (next state / output). A: x = 0 → A/0, x = 1 → B/0. B: x = 0 → C/0, x = 1 → B/0. C: x = 0 → A/0, x = 1 → D/1. D: x = 0 → E/0, x = 1 → D/0. E: x = 0 → A/0, x = 1 → B/1.
In a synchronous circuit tCQ = 15 ns (minimum 5 ns), the slowest logic path is 30 ns, the fastest 2 ns, tsu = 5 ns and th = 4 ns. Find fmax and check the hold condition.
12 questions. 70 % passes the topic quiz (+30 XP, +20 more for 100 %). Exam scoring: +1 correct, −⅓ wrong.
Modelled on real KPSC questions (reworded) with the same concept and answer; each links to its original paper.