Arithmetic Logic Unit
Arithmetic Logic Unit
An arithmetic logic unit (ALU) is a digital electronic and match the native word size of the encapsulating CPU
circuit that performs arithmetic and bitwise logical op- (or other processor).
erations on integer binary numbers. This is in contrast
to a oating-point unit (FPU), which operates on oating
point numbers. An ALU is a fundamental building block 1.2 Opcode
of many types of computing circuits, including the central
processing unit (CPU) of computers, FPUs, and graphics The opcode input is a parallel bus that conveys to the
processing units (GPUs). A single CPU, FPU or GPU ALU an operation selection code, which is an enumer-
may contain multiple ALUs. ated value that species the desired arithmetic or logic
operation to be performed by the ALU. The opcode size
The inputs to an ALU are the data to be operated on, (its bus width) is related to the number of dierent oper-
called operands, and a code indicating the operation to ations the ALU can perform; for example, a four-bit op-
be performed; the ALUs output is the result of the code can specify up to sixteen dierent ALU operations.
performed operation. In many designs, the ALU also Generally, an ALU opcode is not the same as a machine
exchanges additional information with a status register, language opcode, though in some cases it may be directly
which relates to the result of the current or previous op- encoded as a bit eld within a machine language opcode.
erations.
1.3 Status
1 Signals
The status outputs are various individual signals that con-
vey supplemental information about the result of an ALU
operation. These outputs are usually stored in registers so
they can be used in future ALU operations or for control-
ling conditional branching. The collection of bit registers
that store the status outputs are often treated as a single,
multi-bit register, which is referred to as the status regis-
ter or condition code register. General-purpose ALUs
commonly have status signals such as:
1
2 3 FUNCTIONS
the operand by only one bit position, whereas more com- 5 History
plex ALUs employ barrel shifters that allow them to shift
the operand by an arbitrary number of bits in one opera-
Mathematician John von Neumann proposed the ALU
tion. In all single-bit shift operations, the bit shifted out
concept in 1945 in a report on the foundations for a new
of the operand appears on carry-out; the value of the bit
computer called the EDVAC.[1]
shifted into the operand depends on the type of shift.
The cost, size, and power consumption of electronic cir-
cuitry was relatively high throughout the infancy of the
Arithmetic shift: the operand is treated as a twos
information age. Consequently, all serial computers and
complement integer, meaning that the most signi-
many early computers, such as the PDP-8, had a simple
cant bit is a sign bit and is preserved.
ALU that operated on one data bit at a time, although
Logical shift: a logic zero is shifted into the operand. they often presented a wider word size to programmers.
This is used to shift unsigned integers. One of the earliest computers to have multiple discrete
single-bit ALU circuits was the 1948 Whirlwind I, which
Rotate: the operand is treated as a circular buer of employed sixteen of such math units to enable it to op-
bits so its least and most signicant bits are eec- erate on 16-bit words.
tively adjacent.
In 1967, Fairchild introduced the rst ALU implemented
Rotate through carry: the carry bit and operand are as an integrated circuit, the Fairchild 3800, consisting of
collectively treated as a circular buer of bits. an eight-bit ALU with accumulator.[2] Other integrated-
circuit ALUs soon emerged, including four-bit ALUs
such as the Am2901 and 74181. These devices were typ-
ically "bit slice" capable, meaning they had carry look
4 Complex operations ahead signals that facilitated the use of multiple inter-
connected ALU chips to create an ALU with a wider
Although an ALU can be designed to perform complex word size. These devices quickly became popular and
functions, the resulting higher circuit complexity, cost, were widely used in bit-slice minicomputers.
power consumption and larger size makes this imprac-
tical in many cases. Consequently, ALUs are often lim- Microprocessors began to appear in the early 1970s.
ited to simple functions that can be executed at very high Even though transistors had become smaller, there was
speeds (i.e., very short propagation delays), and the ex- often insucient die space for a full-word-width ALU
ternal processor circuitry is responsible for performing and, as a result, some early microprocessors employed a
complex functions by orchestrating a sequence of simpler narrow ALU that required multiple cycles per machine
ALU operations. language instruction. Examples of this include the origi-
nal Motorola 68000, which performed a 32-bit add in-
For example, computing the square root of a number struction in two cycles with a 16-bit ALU, and the popu-
might be implemented in various ways, depending on lar Zilog Z80, which performed eight-bit additions with a
ALU complexity: four-bit ALU.[3] Over time, transistor geometries shrank
further, following Moores law, and it became feasible to
Calculation in a single clock: a very complex ALU build wider ALUs on microprocessors.
that calculates a square root in one operation. Modern integrated circuit (IC) transistors are orders of
Calculation pipeline: a group of simple ALUs that magnitude smaller than those of the early microproces-
calculates a square root in stages, with intermedi- sors, making it possible to t highly complex ALUs on
ate results passing through ALUs arranged like a ICs. Today, many modern ALUs have wide word widths,
factory production line. This circuit can accept and architectural enhancements such as barrel shifters
new operands before nishing the previous ones and and binary multipliers that allow them to perform, in a
produces results as fast as the very complex ALU, single clock cycle, operations that would have required
though the results are delayed by the sum of the multiple operations on earlier ALUs.
propagation delays of the ALU stages.
7 References
[1] Philip Levis (November 8, 2004). Jonathan von Neu-
mann and EDVAC (PDF). cs.berkeley.edu. pp. 1, 3. Re-
trieved January 20, 2015.
[3] Ken Shirri. The Z-80 has a 4-bit ALU. Heres how it
works. 2013.
8 External links
ALU and its Micro-operations: Bitwise, Arithmetic
and Shift
A Simulator of Complex ALU in MATLAB
5
9.2 Images
File:74181aluschematic.png Source: https://upload.wikimedia.org/wikipedia/commons/c/c0/74181aluschematic.png License: CC-BY-
SA-3.0 Contributors: ? Original artist: ?
File:ALU_block.gif Source: https://upload.wikimedia.org/wikipedia/commons/0/0f/ALU_block.gif License: CC BY-SA 4.0 Contribu-
tors: Own work Original artist: Lambtron
File:Commons-logo.svg Source: https://upload.wikimedia.org/wikipedia/en/4/4a/Commons-logo.svg License: CC-BY-SA-3.0 Contribu-
tors: ? Original artist: ?
File:Computer-aj_aj_ashton_01.svg Source: https://upload.wikimedia.org/wikipedia/commons/d/d7/Desktop_computer_clipart_-_
Yellow_theme.svg License: CC0 Contributors: https://openclipart.org/detail/105871/computeraj-aj-ashton-01 Original artist: AJ from
openclipart.org
File:Rotate_left.svg Source: https://upload.wikimedia.org/wikipedia/commons/0/09/Rotate_left.svg License: CC-BY-SA-3.0 Contribu-
tors: This vector image was created with Inkscape. Original artist: en:User:Cburnett
File:Rotate_left_logically.svg Source: https://upload.wikimedia.org/wikipedia/commons/5/5c/Rotate_left_logically.svg License: CC-
BY-SA-3.0 Contributors: This vector image was created with Inkscape. Original artist: en:User:Cburnett
File:Rotate_left_through_carry.svg Source: https://upload.wikimedia.org/wikipedia/commons/7/71/Rotate_left_through_carry.svg Li-
cense: CC-BY-SA-3.0 Contributors: This vector image was created with Inkscape. Original artist: en:User:Cburnett
File:Rotate_right.svg Source: https://upload.wikimedia.org/wikipedia/commons/3/37/Rotate_right.svg License: CC-BY-SA-3.0 Con-
tributors: This vector image was created with Inkscape. Original artist: en:User:Cburnett
File:Rotate_right_arithmetically.svg Source: https://upload.wikimedia.org/wikipedia/commons/3/37/Rotate_right_arithmetically.svg
License: CC-BY-SA-3.0 Contributors: This vector image was created with Inkscape. Original artist: en:User:Cburnett
File:Rotate_right_logically.svg Source: https://upload.wikimedia.org/wikipedia/commons/6/64/Rotate_right_logically.svg License:
CC-BY-SA-3.0 Contributors: This vector image was created with Inkscape. Original artist: en:User:Cburnett
File:Rotate_right_through_carry.svg Source: https://upload.wikimedia.org/wikipedia/commons/2/27/Rotate_right_through_carry.svg
License: CC-BY-SA-3.0 Contributors: This vector image was created with Inkscape. Original artist: en:User:Cburnett