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.

Problem. Construct the input/output interface. The explicit inputs are the bits \(\texttt{st}\) and \(\texttt{cl}\). The label \(\texttt{X}\) is a hardcoded 16-bit input, so you may use it directly in gate lines. The output of your circuit must be one 16-bit label.

The interface has two devices: a button for input and a lamp for output. The button state must be readable immediately. If the button is pressed, then bit \(15\) of the output must be \(1\). If the button is not pressed, then bit \(15\) of the output must be \(0\). All other output bits must be \(0\).

The lamp is controlled by the two lowest bits of \(\texttt{X}\), but only when both \(\texttt{st}\)=1 and \(\texttt{cl}\)=1. In that case: \[\text{on}= X[1],\qquad \text{off}= X[0].\] If either \(\texttt{st}\)=0 or \(\texttt{cl}\)=0, then both lamp signals must be \(0\).

You may use only the following functions: \[\begin{aligned}\operatorname{BUTTON}() &= \text{the current button bit}, \\ \operatorname{LAMP}(\text{on},\text{off}) &= \text{send the current signals to the lamp}, \\ \operatorname{SPLIT}_{16}(x) &= (x_{15},x_{14},\dotsc,x_0), \\ \operatorname{BUNDLE}_{16}(x_{15},x_{14},\dotsc,x_0) &= (x_{15}\dotsm x_0), \\ \operatorname{SELECT}_{16}(s,d_1,d_0) &= \begin{cases} d_0, & s=0, \\ d_1, & s=1, \end{cases} \\ \operatorname{AND}(a,b) &= a \land b, \\ \operatorname{NAND}(a,b) &= \neg(a \land b), \\ 0() &= 0000000000000000.\end{aligned}\]

For example, a line \(\texttt{b BUTTON}\) means that \(\texttt{b}\) is a new bit equal to the current button state. A line \(\texttt{on off LAMP}\) means that the current signals \(\texttt{on}\) and \(\texttt{off}\) are sent to the lamp.

The authors' solution uses \(10\) gates.

1 point