Arithmetic logic unit
This article is about computer arithmetic units.
An alternative meaning of ALU is Alu sequence (note lowercase).
The
arithmetic logic unit/
arithmetic-logic unit (
ALU) of a
computer's
CPU is a part of the
execution unit, a core component of all CPUs. ALUs are capable of calculating the results of a wide variety of basic
arithmetical computations. Virtually all modern computer ALUs use the
two's complement binary number representation. Early computers used a wide variety of number systems, including
one's complement,
sign-magnitude format, and even true decimal systems, with ten tubes per digit.
Mathematician
John von Neumann proposed the ALU concept in
1945, when he wrote a report on the foundations for a new computer called the
EDVAC (Electronic Discrete Variable Automatic Computer). Later in 1946, he worked with his colleagues in designing a computer for the Princeton Institute of Advanced Studies (IAS). The
IAS computer became the prototype for many later computers. In the proposal, von Neumann outlined what he believed would be needed in his machine, including an ALU.
Von Neumann stated that an ALU is a necessity for a computer because it is guaranteed that a computer will have to compute basic mathematical operations, including addition, subtraction, multiplication, and division
[Stallings page 19]. He therefore believed it was "reasonable that [the computer] should contain specialized organs for these operations"
[Stallings page 19].
Most of the computer's actions are performed by the ALU. The ALU gets data from
processor registers. This data is processed and the results of this operation are stored into ALU output registers. Other mechanisms move data between these registers and memory.
[Stallings page 290-291].
A
Control Unit controls the ALU, by setting circuits that tell the ALU what operations to perform.
ALU operations
Most ALUs can perform the following operations:
*
Integer arithmetic operations (
addition,
subtraction, and sometimes
multiplication, though this is more expensive)
*
Bitwise logic operations (
and,
not,
or,
xor)
*
Bit-shifting operations (shifting or rotating a word by a specified number of bits to the left or right, with or without
sign extension)
Many standard ALUs do not handle integer
division or any
floating point operations since they can be emulated in
software. However, several algorithms do exist for implementing
division in hardware. Optional methods for these types of calculations include:
*
Software emulation, commonly implemented in hand-written
assembly code and placed in a
library for use by other programs
(The slowest, but least expensive option. If these maths operations are rare, this is often the best overall choice.)*
Microcode programs using the ALU to emulate the missing operations
(This is a middle choice, costing more, but also gaining more speed. Some flexibility is lost.)*Separate hardware components, such as dividers and
floating point units (FPUs), sometimes in the form of arithmetic
coprocessors
(This is the fastest, most expensive and least flexible choice. It risks economic inefficiency, by mismatching the speed of the ALU to the speed of the rest of the computer.)Inputs and outputs
The inputs to the ALU are the data to be operated on (called
operands) and a code from the
control unit indicating which operation to perform. Its output is the result of the computation.
In many designs the ALU also takes or generates as inputs or outputs a set of condition codes from or to a
status register. These codes are used to indicate cases such as
carry-in or carry-out,
overflow,
divide-by-zero, etc
[Stallings page 290-291].
*
7400 series (chip # 74181)
*
adder (electronics)*
multiplication ALU*
digital circuit*
division (electronics)