Boolean Circuits · NAND Game: Processor (Optional)

Lesson 4

Nikolai Chukhin · Alexander S. Kulikov

A program is a sequence of instructions, where each instruction consists of a set of bit flags that determine the following:

  • the ALU operation to be performed,

  • the registers to be used as inputs, and

  • the register or registers in which the result is to be stored.

The control unit chooses between data instructions and ALU instructions.

Problem. Construct the control unit. The labels \(\texttt{I}\), \(\texttt{A}\), \(\texttt{D}\), and \(\texttt{*A}\) are hardcoded 16-bit inputs, so you may use them directly in gate lines. The outputs of your circuit must be five labels, in the order \(\texttt{R a d *a j}\), where \(\texttt{R}\) is 16-bit and the other four outputs are bits.

Bit \(15\) of \(\texttt{I}\) selects the instruction type: \[\begin{array}{c | l} I[15] & \text{instruction type} \\ \hline 0 & \text{data instruction} \\ 1 & \text{ALU instruction}\end{array}\]

For ALU instructions, the outputs are exactly as in the previous task. In particular, \(\texttt{R}\) is the ALU result, and \(\texttt{a}\), \(\texttt{d}\), \(\texttt{*a}\), \(\texttt{j}\) are decoded from the instruction.

For a data instruction, the instruction value itself is written to the \(\texttt{A}\) register. So the outputs must be: \[R = I,\qquad a = 1,\qquad d = 0,\qquad *a = 0,\qquad j = 0.\]

You may use only the following functions: \[\begin{aligned}\operatorname{NAND}(a,b) &= \neg(a \land b), \\ \operatorname{OR}(a,b) &= a \lor b, \\ \operatorname{CONTROLSELECTOR}(s,R_1,a_1,d_1,*a_1,j_1,R_0,a_0,d_0,*a_0,j_0) &= \text{the selected control bus}, \\ \operatorname{ALUINSTR}(I,A,D,*A) &= \text{the ALU-instruction outputs}, \\ \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}(s,d_1,d_0) &= \begin{cases} d_0, & s=0, \\ d_1, & s=1, \end{cases} \\ \operatorname{SELECT}_{16}(s,d_1,d_0) &= \begin{cases} d_0, & s=0, \\ d_1, & s=1. \end{cases}\end{aligned}\]

For example, a line \(\texttt{R a d *a j i15 R1 a1 d1 *a1 j1 R0 a0 d0 *a0 j0 CONTROLSELECTOR}\) means that the five outputs are taken from bus \(0\) when \(\texttt{i15}\)=0 and from bus \(1\) when \(\texttt{i15}\)=1.

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

1 point