22-Elec-A4 Digital Systems and Computers · Undated paper
Question 2 of 6: Synchronous up/down counter with JK flip-flops (12 pts)
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Notes on this paper
Paper format. National Exams, 22-Elec-A4 — Digital Systems and Computers. Closed book; non-programmable calculator permitted; 3 hours. Six questions, each worth 12 points; “any five constitute a complete paper,” so all six are solved here as a study resource.
Reference texts. M. M. Mano & M. D. Ciletti, Digital Design, 5th/6th ed. (Pearson) — K-maps, hazards, PLA/PAL, flip-flop excitation and synchronous-counter design (ch. 3–6); J. F. Wakerly, Digital Design: Principles and Practices (static hazards, memory decoding); Motorola/Freescale M68HC11 Reference Manual (address decoding and memory-mapped I/O for Q5). Boolean identities and the flip-flop excitation tables printed on the exam cover sheet are used throughout.
Note on the figures. Where a single wire or junction in the Q4 figure is genuinely ambiguous, the reading used is stated and the alternative is flagged in a check callout, per the exam’s own instruction to “submit a clear statement of any assumptions made.”
Question 2 — Synchronous up/down counter with JK flip-flops (12 pts)
Given. Two state bits $AB$ ($A$ = MSB), enable $E$ and direction $X$. The $E=1,X=1$ sequence is the binary up count and $E=1,X=0$ is the binary down count; $E=0$ freezes the state. The JK excitation table is $0\!\to\!0:J{=}0,K{=}\!\times$; $0\!\to\!1:J{=}1,K{=}\!\times$; $1\!\to\!0:J{=}\!\times,K{=}1$; $1\!\to\!1:J{=}\!\times,K{=}0$.
Find. $J_A,K_A,J_B,K_B$ as functions of $A,B,E,X$, and the resulting diagram, table and gate circuit.
(a) State diagram. Edge label $=EX$: “$11$” = enabled up, “$10$” = enabled down, “$0{-}$” = hold ($E=0$).
Approach. Recognise the specification as an enabled up/down counter ($X$ = direction), tabulate the next state, read the JK excitations, and minimise.
(b) State/excitation table. With $s=2A+B$, the next state is $s$ (hold) for $E=0$, $(s{+}1)\bmod4$ for $E{=}1,X{=}1$, and $(s{-}1)\bmod4$ for $E{=}1,X{=}0$. Reading the JK table for each bit gives the excitations below.
State/excitation table ($\times$ = don’t care)
$E$
$X$
$A\,B$
$A^{+}B^{+}$
$J_A$
$K_A$
$J_B$
$K_B$
0
–
any
hold
0
0
0
0
1
1
00
01
0
×
1
×
1
1
01
10
1
×
×
1
1
1
10
11
×
0
1
×
1
1
11
00
×
1
×
1
1
0
00
11
1
×
1
×
1
0
11
10
×
0
×
1
1
0
10
01
×
1
1
×
1
0
01
00
0
×
×
1
(c) K-map simplification. Bit $B$ toggles on every enabled clock in both directions, so $J_B=K_B=E$. Bit $A$ toggles only on the carry ($B{=}1$ while counting up) or the borrow ($B{=}0$ while counting down), i.e. when $B\odot X$ (equal); the enable $E$ multiplies every term. Hence$$\boxed{J_A=K_A=E\,(B\odot X)=E\,(BX+\overline B\,\overline X)\qquad J_B=K_B=E}$$The common factor $E$ realises the hold with $J{=}K{=}0$ — there is no need to gate the clock.
(d) Circuit. One XNOR forms $B\odot X$; one AND gates it with $E$ to drive $J_A$ and $K_A$ (tied together); $E$ drives $J_B$ and $K_B$ directly. Both flip-flops share the clock.
(d) Resulting logic circuit: $J_A{=}K_A{=}E(B\odot X)$ and $J_B{=}K_B{=}E$.