# 5.5: Implementing the CU

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$ $$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$ $$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$ $$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$$$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

It is now possible to specify how to set the control wires from the CU. First the ALU opt is the value of bits 8-11 of the ALU, so these are split off and sent to control the ALU.

The top 4 bits, bits 12-15, are used to set the other control wires, and from the previous discussion can be set according to the following table2.

 Operation Code WriteAc ALUSrc ClrAc MemWr Beqz Immediate Operation3 0x1 1 1 0 0 0 Memory Operation4 0x2 1 0 0 0 0 clac 0x3 1 x 1 0 0 stor 0x4 0 x x 1 0 beqz 0x5 0 x x 0 1

To implement this table, a decoder is implemented to split out the individual operations. These operations are then combined to produce the correct output behavior. The CU is shown in the figure below.

2 An “x” in the table means a don’t care condition, e.g. the value can be either 0 or 1 as it does not affect the working of the CPU. As a convention, all x values should be coded as 0.