Boolean Circuits · NAND Game: Processor (Optional)

Lesson 6

Nikolai Chukhin · Alexander S. Kulikov

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 level, we 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.

Problem. Synthesize a circuit of size \(9\) over \(\{\operatorname{BUTTON},\allowbreak \operatorname{LAMP},\allowbreak \operatorname{SPLIT},\allowbreak \operatorname{BUNDLE},\allowbreak \operatorname{SELECT},\allowbreak \operatorname{AND}_{2},\allowbreak \operatorname{NAND}_{2},\allowbreak 0\}\) computing an input/output interface: The input-label line is \(\texttt{st cl}\); the 16-bit label \(\texttt{X}\) is predefined; the circuit has one 16-bit output. Its most significant output bit is the value produced by its single \(\operatorname{BUTTON}()\) call and 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]\).

The token \(\texttt{0}\) writes one 16-bit zero; the lamp call is written \(\texttt{on off LAMP}\).