Boolean Circuits · NAND Game: Arithmetic Logic Unit (Optional)

Lesson 1

Nikolai Chukhin · Alexander S. Kulikov

We now have a set of different operations available. The core of a processor is the ability to select among different operations based on input. We begin with a unit that selects among four distinct bitwise logical operations.

Problem. Construct a logic unit. The two bit-flags \(op_{1}\) and \(op_{0}\) select which of four operations is performed on two hardcoded 16-bit inputs \(x\) and \(y\). In this task, the labels \(\texttt{x}\) and \(\texttt{y}\) are already available and denote 16-bit input values, so you may use them directly in gate lines. The output of your circuit must be a single 16-bit label.

The selected operation is: \[\begin{array}{c c | l} op_1 & op_0 & \text{output} \\ \hline 0 & 0 & x \land y \\ 0 & 1 & x \lor y \\ 1 & 0 & x \oplus y \\ 1 & 1 & \neg x\end{array}\]

You may use only the following functions: \[\begin{aligned}\operatorname{NAND}(a,b) &= \neg(a \land b), \\ \operatorname{SELECT}_{16}(s,d_1,d_0) &= \begin{cases} d_0, & s=0, \\ d_1, & s=1, \end{cases} \\ \operatorname{INV}_{16}(a) &= \overline{a}, \\ \operatorname{AND}_{16}(a,b) &= a \land b, \\ \operatorname{OR}_{16}(a,b) &= a \lor b, \\ \operatorname{XOR}_{16}(a,b) &= a \oplus b.\end{aligned}\]

For example, a line \(\texttt{z x y AND16}\) means that \(\texttt{z}\) is a new 16-bit label equal to the bitwise AND of the hardcoded inputs \(\texttt{x}\) and \(\texttt{y}\).

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

1 point