Boolean Circuits · NAND Game: Processor (Optional)
Lesson 5
To be of practical use, a computer must be capable of communicating with the external environment. Such communication is achieved through hardware devices, including the screen, the keyboard, touch sensors, network interfaces, and similar peripherals. In this task, integrate the system with simple hardware devices, namely a lamp and a button. The gate \(\operatorname{BUTTON}()\) has no inputs and writes one bit; \(\operatorname{LAMP}(on,off)\) consumes two bits and has no outputs. A lamp gate line therefore has the form \(\texttt{on off LAMP}\), with no output label. The gate \(\texttt{BUNDLE16}\), inverse to \(\texttt{SPLIT16}\), takes 16 bits from most to least significant and writes one 16-bit value.
Problem. Synthesize a circuit of size \(9\) over \(\{\operatorname{BUTTON},\allowbreak \operatorname{LAMP},\allowbreak \operatorname{SPLIT}_{16},\allowbreak \operatorname{BUNDLE}_{16},\allowbreak \operatorname{AND}_{2},\allowbreak \operatorname{NAND}_{2},\allowbreak \operatorname{ZERO}_{16}\}\) computing the interface function \[\operatorname{INPUTOUTPUT}_{16}(st,x,cl)=y.\] Here \(x\) and \(y\) are 16-bit values, while \(st\) and \(cl\) are bits. The most significant bit of \(y\) is the value produced by its single \(\operatorname{BUTTON}()\) call; all other bits are \(0\). It must also make exactly one \(\operatorname{LAMP}(\texttt{on},\texttt{off})\) call, where \(\texttt{on}=\texttt{st}\land\texttt{cl}\land\texttt{x}[1]\) and \(\texttt{off}=\texttt{st}\land\texttt{cl}\land\texttt{x}[0]\).