NivaarExam PrepOfficial exam papers ↗

22-Elec-A4 Digital Systems and Computers · May 2013

Question 3 of 6: JK Finite State Machine — 2-Bit Up/Down Counter

Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)

Notes on this paper

Paper format. National Exams, May 2013 — 07-Elec-A4 Digital Systems & Computers. Three hours, closed book (one approved Casio or Sharp calculator). Six questions are printed; any five constitute a complete exam and all questions are worth 12 marks. An excitation table for the RS/JK/T/D flip-flops and a table of basic Boolean identities are supplied on the last page of the paper. All six questions are solved below, because this set is a study resource rather than a timed sitting.

Reference texts.

Convention used throughout. In the address/data expressions a prime denotes complement (\(\overline{A}\) is written A′ in the figures, where SVG text cannot carry an overbar). Hexadecimal constants keep the Motorola dollar-sign notation of the exam paper, written here as $7A01 in prose so that it cannot be mistaken for a mathematics delimiter.

Question 3: JK Finite State Machine — 2-Bit Up/Down Counter (12 marks)

Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.

Given. A synchronous machine with one control input $X$, two JK flip-flops holding the state $Q_1Q_0$ ($Q_1$ the most significant bit), and the JK excitation table supplied with the paper:

$Q \rightarrow Q^{+}$$J$$K$Meaning
$0 \rightarrow 0$0Xhold low
$0 \rightarrow 1$1Xset
$1 \rightarrow 0$X1reset
$1 \rightarrow 1$X0hold high

Find. The state diagram, the transition table annotated with $J_1, K_1, J_0, K_0$, the minimised excitation equations, and the gate-level schematic. Marks: (a) 3, (b) 3, (c) 3, (d) 3.

Approach. Write the two required sequences as one four-state ring traversed in opposite directions, tabulate present state and input against next state, convert each bit transition to $J$/$K$ requirements through the excitation table, minimise with the don't-cares, and draw the result.

  1. (a) State diagram. The machine has four states, one per value of $Q_1Q_0$, and one input. With $X = 0$ it advances $00 \rightarrow 01 \rightarrow 10 \rightarrow 11 \rightarrow 00$; with $X = 1$ it retraces the same ring in the opposite direction. Because the outputs are the state bits themselves, this is a Moore machine whose output labels can be omitted from the arcs.
    X=0X=0X=0X=0X=1X=1X=1X=100011011Clockwise = up-count (X = 0); counter-clockwise = down-count (X = 1)
    Question 3(a) - state transition diagram of the 2-bit up/down counter.
  2. (b) State-transition and excitation table. Each row lists the present state, the input, the required next state and the flip-flop inputs read from the excitation table (with d marking a don't-care):
    $X$$Q_1$$Q_0$$Q_1^{+}$$Q_0^{+}$$J_1$$K_1$$J_0$$K_0$
    000010d1d
    001101dd1
    01011d01d
    01100d1d1
    100111d1d
    101000dd1
    11001d11d
    11110d0d1
    Two structural facts jump out of the table. First, $Q_0$ inverts on every single row: an up-count and a down-count both toggle the least significant bit. Second, wherever $J_1$ is specified it equals the specified value of $K_1$ in the mirror row, which is the signature of a toggle flip-flop hidden inside a JK.
  3. (c) Minimise the excitation equations. For the least significant stage every specified entry of $J_0$ and $K_0$ is 1, so $$J_0 = K_0 = 1$$ and stage 0 is wired as a permanent toggle. For the most significant stage, collect the rows where $J_1$ is specified ($Q_1 = 0$): it is 1 for $(X,Q_0) = (0,1)$ and $(1,0)$, and 0 for $(0,0)$ and $(1,1)$. That is precisely the exclusive-OR pattern. The rows where $K_1$ is specified ($Q_1 = 1$) give the identical pattern. Hence $$J_1 = K_1 = \overline{X}Q_0 + X\overline{Q_0} = X \oplus Q_0$$ $$\boxed{\,J_0 = K_0 = 1, \qquad J_1 = K_1 = X \oplus Q_0\,}$$ The result is intuitive: the high bit must toggle when the low bit is about to roll over, and rolling over means $Q_0 = 1$ when counting up but $Q_0 = 0$ when counting down — exactly what $X \oplus Q_0$ expresses.
  4. Check the design against the specification. Substituting the equations into the JK characteristic equation $Q^{+} = J\overline{Q} + \overline{K}Q$ gives $Q_0^{+} = \overline{Q_0}$ and $Q_1^{+} = Q_1 \oplus (X \oplus Q_0)$. For $X = 0$ this is $Q_1 \oplus Q_0$, the binary up-count rule; for $X = 1$ it is $Q_1 \oplus \overline{Q_0}$, the down-count rule. All eight rows of the table are reproduced, and because both flip-flops share one clock the machine is fully synchronous — there is no ripple delay and the count may be decoded safely.
  5. (d) Draw the circuit. One exclusive-OR gate is the entire combinational network; the $J$ and $K$ inputs of each flip-flop are tied together, so each JK behaves as a T flip-flop.
    JKQQ'FF0 (LSB)JKQQ'FF1 (MSB)J0 = K0 = 1J1 = K1 = X (+) Q0Q0Q1CLK (common)Synchronous up/down counter: one XOR is the whole steering network
    Question 3(d) - logic circuit: two JK flip-flops wired as toggles, steered by one XOR gate.
PartQuantityResult
(a)State diagramFour-state ring; $X = 0$ clockwise (up), $X = 1$ counter-clockwise (down)
(b)Excitation table8 rows; $Q_0$ toggles unconditionally, $Q_1$ toggles when $X \oplus Q_0 = 1$
(c)LSB inputs$J_0 = K_0 = 1$
(c)MSB inputs$J_1 = K_1 = X \oplus Q_0 = \overline{X}Q_0 + X\overline{Q_0}$
(d)Gate countTwo JK flip-flops and one 2-input XOR gate