= Solution
Arrange each four-variable <Karnaugh map> in <Gray code> order $LG=00,01,11,10$ down the rows and $ab=00,01,11,10$ across the columns. For $L^+$ the row strings are `0100`, `0100`, `----`, `1110`; for $G^+$ they are `0001`, `1011`, `----`, `0001`. The maps are drawn alongside the <state-transition diagram> above.
In the $L^+$ map, group the whole `ab=01` column to obtain $\neg a\land b$. Group rows `11,10` with columns `00,01` to obtain $L\land\neg a$. Group those same rows with columns `01,11` to obtain $L\land b$. The unused-state row permits these larger groups. Symmetrically, in the $G^+$ map group column `ab=10`, rows `01,11` with columns `11,10`, and those same rows with columns `10,00` (wrapping around the map). This gives
$$
\boxed{\begin{aligned}
L^+&=(\neg a\land b)\lor(L\land\neg a)\lor(L\land b),\\
G^+&=(a\land\neg b)\lor(G\land a)\lor(G\land\neg b).
\end{aligned}}
$$
These expressions drive the D inputs of the two <D flip-flops>. With $a=b$, both copy their stored <bit>. With $ab=01$, they force `Lt`; with $ab=10$, they force `Gt`. The equations also specify a harmless extension at unused code `11`: equal inputs retain it and unequal inputs recover to a valid comparison state. Correct reset is still required. This extension was chosen using don't-cares; the circuit is not claimed to recover from every invalid state without reset.
Back to article page