Boolean Circuits · NAND Game: Memory (Optional)
Lesson 6
The next task is to construct a counter that increments a number at each clock cycle. Counters constitute a fundamental component of a processor, as they govern the execution of instructions. The token \(\texttt{REGISTER}\) is now the 16-bit form of the register constructed above: it takes a store bit \(st\), a 16-bit value \(x\), and a clock bit \(cl\), in that order, and writes one 16-bit value; in the following tasks it is initialized to \(0\). The token \(\texttt{INC16}\) takes one 16-bit value \(x\) and writes \(x+1 \pmod{2^{16}}\); the token \(\texttt{0}\) has no inputs and writes one bit.
Problem. Synthesize a circuit of size \(5\) over \(\{\operatorname{NAND}_{2}, \operatorname{INV}_{1}, \operatorname{REGISTER}, \operatorname{INC}, \operatorname{SELECT}, 0\}\) computing the 16-bit counter function \(\operatorname{COUNTER}(st,x,cl)\): The input-label line is \(\texttt{st cl}\); the 16-bit label \(\texttt{x}\) is predefined; the circuit has one 16-bit output. It starts at \(0\); on each falling clock edge, set the output to \(\texttt{x}\) if \(\texttt{st}\)=1, and otherwise increment it modulo \(2^{16}\). Assume \(\texttt{st}\) and \(\texttt{x}\) do not change while \(\texttt{cl}\)=1.