An *arithmetic and logic unit*, or ALU, of a processor is a
combinatorial circuit that is capable of performing the basic
operations such as addition, subtraction, bitwise and, bitwise or,
etc.
We exclude mutiplication, since it is not implemented as a
combinatorial circuit.
A possible implementation of the ALU is that it performs all the
operations in parallel and, with the help of a
multiplexer selects one of the outputs according to the
operation wanted.
In our example computer, the ALU will have two 8-bit inputs, an
8-bit output (later extended to 9 for overflow and carry detection),
and 3 control lines. The three control lines will select the
operation to be performed. In our example computer, 000 means copy
(output is the same as first input), 001 means shift left (output is
the second input shifted left by one position), 010 means shift
right, 011 means add, 100 means subtract, 101 means logic and, 110
means logic or, and 111 means logic not (output is first input with
bits inverted).
The reason for using the second input instead of the first input
for the shift operation is that we might have to shift several
position. In that case, we can simply emit a sequence of shift
instructions. If we had taken the first input, we would have had to
copy from R1 to R0 between each shift instruction. |