Boolean Circuits · NAND Game: Processor (Optional)

Lesson 4

Nikolai Chukhin · Alexander S. Kulikov

You have reached the final challenge. Upon 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}_{16}(PC)\) takes one 16-bit address and writes one 16-bit instruction. The ROM contains four words and reads the cell at address \(PC\bmod 4\); its four-word program varies between tests, so its contents must not be hard-coded.

Problem. Synthesize a circuit of size \(5\) over \[\begin{aligned}\{&\operatorname{NAND}_2, \operatorname{INV}_1, \operatorname{AND}_2, \operatorname{OR}_2, \operatorname{CONTROLUNIT}_{16},\\ &\operatorname{MEMORY}_{16}, \operatorname{ROM}_{16}, \operatorname{PROGRAMCOUNTER}_{16}, \operatorname{CLOCK}\}\end{aligned}\] computing \[\operatorname{COMPUTER}()=(\texttt{PC},\texttt{A},\texttt{D},\texttt{*A}),\] where all four results are 16-bit values. In this task, cycles in the circuit are allowed: a gate may use a label defined on a later gate line.

Wire the available blocks so that \[\begin{align*}\texttt{cl}&=\operatorname{CLOCK}(),\\ \texttt{PC}&=\operatorname{PROGRAMCOUNTER}_{16}(\texttt{j},\texttt{A},\texttt{cl}), \\ \texttt{I}&=\operatorname{ROM}_{16}(\texttt{PC}),\\ (\texttt{R},\texttt{a},\texttt{d},\texttt{*a},\texttt{j})&=\operatorname{CONTROLUNIT}_{16}(\texttt{I},\texttt{A},\texttt{D},\texttt{*A}),\\ (\texttt{A},\texttt{D},\texttt{*A})&=\operatorname{MEMORY}_{16}(\texttt{a},\texttt{d},\texttt{*a},\texttt{R},\texttt{cl}).\end{align*}\] Initially, \(\texttt{PC}\), \(\texttt{A}\), \(\texttt{D}\), and both RAM cells are \(0\).

String task, Advanced problem