Boolean Circuits · NAND Game: Processor (Optional)
Lesson 5
You have reached the final challenge. Upon successful completion of this task, you will have constructed a fully functional programmable microprocessor using only NAND gates! Two environment blocks are provided: \(\operatorname{CLOCK}()\) writes one bit and alternates \(0,1,0,1,\dotsc\), while \(\operatorname{ROM}(PC)\) takes one 16-bit address and writes one 16-bit instruction.
Problem. Synthesize a circuit of size \(5\) over \(\{\operatorname{NAND}_{2},\allowbreak \operatorname{INV}_{1},\allowbreak \operatorname{AND}_{2},\allowbreak \operatorname{OR}_{2},\allowbreak \operatorname{CONTROLUNIT},\allowbreak \operatorname{MEMORY},\allowbreak \operatorname{ROM},\allowbreak \operatorname{COUNTER},\allowbreak \operatorname{CLOCK}\}\) computing a computer: There are no explicit inputs, so omit the input-label line; list the 16-bit outputs as \(\texttt{PC A D *A}\). Wire the available blocks so that \(\texttt{cl}=\operatorname{CLOCK}()\), \(\texttt{PC}=\operatorname{COUNTER}(\texttt{j},\texttt{A},\texttt{cl})\), \(\texttt{I}=\operatorname{ROM}(\texttt{PC})\), \((\texttt{R},\texttt{a},\texttt{d},\texttt{*a},\texttt{j})=\operatorname{CONTROLUNIT}(\texttt{I},\texttt{A},\texttt{D},\texttt{*A})\), and \((\texttt{A},\texttt{D},\texttt{*A})=\operatorname{MEMORY}(\texttt{a},\texttt{d},\texttt{*a},\texttt{R},\texttt{cl})\). Initially, \(\texttt{PC}\), \(\texttt{A}\), \(\texttt{D}\), and both RAM cells are \(0\). The four-word ROM is addressed modulo \(4\) and may contain different programs in different tests; the clock alternates \(0,1,0,1,\dotsc\). Circuit feedback is allowed: a gate may use a label defined on a later gate line.
The function \(\operatorname{CONTROLUNIT}\) writes five outputs, and \(\operatorname{MEMORY}\) writes three 16-bit outputs.