Question 5 of 5: JK Flip-Flop Synthesis and 2's-Complement Circuit
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Notes on this paper
04-BS-8 Digital Logic Circuits — May 2019
National Exams, closed book (approved calculator only; one hand-written 8.5"×11" aid sheet permitted). Format: five questions offered, each worth 25 marks; all five are solved below for completeness.
The printed question is internally ambiguous in two places: Figure Q5 is described with inputs J, K, Clock while the question text asks for behaviour "for all combinations of inputs A and B" (two waveform traces, not J/K) — the most defensible reading, taken here, is that A and B ARE the flip-flop's J and K inputs under this question's own labelling (a common textbook variant). Sub-part (b)'s "12 binary numbers" is very likely a misprint of "n-bit binary numbers" (a numeral where a variable belongs) and is treated as such below, worked for a representative 4-bit word. Printed sub-marks (10+10=20) are 5 short of this question's nominal 25; both gaps are flagged rather than silently patched.
Given.Part (a): two 3-input AND gates — one gated by ($A\equiv J$, CLK, $\bar Q$ feedback), the other by ($B\equiv K$, CLK, $Q$ feedback) — feeding a cross-coupled 2-input NOR latch that outputs $Q,\bar Q$; clock triangle drawn for a rising-edge transition. Part (b): an $n$-bit unsigned binary number $b_{n-1}\ldots b_1b_0$ (worked below for $n=4$).
Find.(a) the characteristic (next-state) table for all four (A,B) combinations and the active clock edge. (b) a combinational (no adder) circuit producing the 2's complement.
Part (a). The AND gates are enabled only while CLK is asserted; whichever one is enabled steers the cross-coupled NOR latch, giving the classic gated-latch synthesis of a JK flip-flop.
Part (a) — synthesis. With CLK asserted: if $A{=}1,B{=}0$ the top AND gate (gated by $\bar Q$) can fire, forcing the latch to $Q{=}1$ (set); if $A{=}0,B{=}1$ the bottom AND gate (gated by $Q$) can fire, forcing $Q{=}0$ (reset); if $A{=}B{=}0$ neither AND gate fires and the latch holds its last value; if $A{=}B{=}1$ both AND gates are enabled but each is gated by the OTHER'S present output ($\bar Q$ and $Q$ respectively), so exactly one fires depending on the current state, flipping it — a toggle. This reproduces the JK characteristic table exactly.
Active clock transition. The circuit is level-sensitive while CLK is asserted; drawn with a rising-edge clock triangle at Figure Q5, the design is read as triggering on the rising edge of CLK, i.e. the state changes are latched in at that instant and held stable while CLK stays high (avoiding the 1s-catching race by treating CLK as a narrow pulse synchronized to the rising edge, the standard simplification used when this gate topology is taught as "the" edge-triggered JK).
All four (A,B) combinations reproduce the standard JK table: hold, reset, set, toggle.
Part (b) — combinational 2's complement. The bit-manipulation shortcut (no adder needed): scanning from the LSB upward, copy every bit unchanged up to and including the first 1 encountered; invert every bit above it. Formalize with a running OR $P_i=b_0+b_1+\cdots+b_{i-1}$ (has a 1 already occurred strictly below bit $i$?), $P_0=0$: $$y_i = b_i \oplus P_i,\qquad P_i = P_{i-1}+b_{i-1}$$ Each $P_i$ costs one more OR gate feeding forward (a ripple chain), and each output bit is one XOR gate.
Part (b). Worked for $n=4$; the same $P_i=P_{i-1}+b_{i-1}$, $y_i=b_i\oplus P_i$ pattern extends to any word width $n$ by adding one more OR/XOR stage per bit.
Worked example: $B=0110_2=6_{10}$. $P_0{=}0\Rightarrow y_0{=}0{\oplus}0{=}0$. $P_1{=}P_0{+}b_0{=}0\Rightarrow y_1{=}1{\oplus}0{=}1$. $P_2{=}P_1{+}b_1{=}0{+}1{=}1\Rightarrow y_2{=}1{\oplus}1{=}0$. $P_3{=}P_2{+}b_2{=}1{+}1{=}1\Rightarrow y_3{=}0{\oplus}1{=}1$. Result $1010_2$ — the correctly-signed 2's complement of $+6$ is $-6$ (4-bit signed value $1010_2=-6$), confirming the circuit.