Boolean Circuits · NAND Game: Arithmetic Logic Unit (Optional)
Lesson 4
The gate \(\operatorname{ZERO}_{16}()\) writes the 16-bit value \(0\).
Problem. Synthesize a circuit of size \(7\) over \(\{\operatorname{NAND}_{2},\allowbreak \operatorname{LOGICUNIT}_{16},\allowbreak \operatorname{ARITHUNIT}_{16},\allowbreak \operatorname{AND}_{16},\allowbreak \operatorname{ADD}_{16},\allowbreak \operatorname{SELECT}_{16},\allowbreak \operatorname{INV}_{16},\allowbreak \operatorname{ZERO}_{16}\}\) computing the 16-bit arithmetic-logic-unit function \[\operatorname{ALU}_{16}(u,op_{1},op_{0},zx,sw,x,y)=R.\] First, modify the operands as follows:
- If \(\texttt{sw}\)=1, then \(\texttt{x}\) and \(\texttt{y}\) are swapped.
- After that, if \(\texttt{zx}\)=1, then the left operand is replaced with \(0\).
Call the resulting operands \(x'\) and \(y'\). Then \(\texttt{u}\), \(\texttt{op1}\), and \(\texttt{op0}\) determine the value of \(R\): \[\begin{array}{c c c | l} u & op_1 & op_0 & R \\ \hline 0 & 0 & 0 & x' \land y' \\ 0 & 0 & 1 & x' \lor y' \\ 0 & 1 & 0 & x' \oplus y' \\ 0 & 1 & 1 & \neg x' \\ 1 & 0 & 0 & x' + y' \\ 1 & 0 & 1 & x' + 1 \\ 1 & 1 & 0 & x' - y' \\ 1 & 1 & 1 & x' - 1\end{array}\]