Monday, October 17, 2011

ALU - Arithmetic Logic Unit


ALU (Arithmetic Logic Unit)

An arithmetic logic unit (ALU) is a digital circuit that performs arithmetic and logical operations. The processors inside modern CPUs and graphics processing units (GPUs) accommodate very powerful and very complex ALUs and may contain a number of ALUs.  Mathematician John von Neumann proposed the ALU in 1945, in his paper EDVAC.  

An ALU must use the same format as the rest of the digital circuit which is almost always the two’s complement binary number representation which makes it easier for calculating addition and subtraction.]
The ones' complement and two's complement number systems allow for subtraction to be accomplished by adding the negative of a number in a very simple way which negates the need for specialized circuits to do subtraction; however, calculating the negative in two's complement requires adding a one to the low order bit and propagating the carry. An alternative way to do two's complement subtraction of A−B is to present a one to the carry input of the adder and use ¬B rather than B as the second input.
Most of a processor's operations are performed by one or more ALUs with data loads from input registers, then the CU tells the ALU the operations to perform on the data and finally the ALU stores its result in an output register. The CU is responsible for moving the processed data between these registers, ALU and memory.
A simple example arithmetic logic unit (2-bit ALU) that does AND, OR, XOR, and addition
Most ALUs can perform the following operations:
  • Bitwise logic operations (AND, NOT, OR, XOR)
  • Integer arithmetic operations (addition, subtraction, and sometimes multiplication and division, though this is more expensive)
  • Bit-shifting operations (shifting or rotating a word by a specified number of bits to the left or right, with or without sign extension). Shifts can be seen as multiplications and divisions by a power of two.
The more complex the operation, the more expensive the ALU is, the more space it uses in the processor, the more power it uses. Compromising, engineers make the ALU powerful enough to make the processor fast, but not prohibitive. For example, computing the square root of a number might use:
  1. Calculation in a single clock Design an extraordinarily complex ALU that calculates the square root of any number in a single step.
  2. Calculation pipeline Design a very complex ALU that calculates the square root of any number in several steps.  The ALU can accept new numbers to calculate simultaneously as fast as a single-clock ALU, with only an initial delay.
  3. Iterative calculation Design a complex ALU that calculates the square root through several steps controlled by a complex CU with built-in microcode.
  4. Co-processor Design a simple ALU in the processor, with option to purchase specialized and costly processor per customer requirements.
  5. Software libraries No co-processor and no emulation requiring programmers to write their own algorithms to calculate square roots by software.
  6. Software emulation Emulate the co-processor, or whenever a program attempts to perform the square root calculation, make the processor check if there is a co-processor and use it if there is one; if there isn't one, interrupt the processing of the program and invoke the OS to perform the square root calculation through some software algorithm.
Powerful processors like the Intel Core and AMD64 implement option #1 for several simple operations, #2 for the most common complex operations and #3 for the extremely complex operations.
The inputs to the ALU are the data to be operated on (operands) and a code from the CU 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 to indicate carry-in or carry-out, overflow, divide-by-zero, etc.
ALU versus FPU
A floating-point unit also performs arithmetic operations between two values, but for numbers in floating-point representation, and more complicated than the two’s complement representation in a typical ALU. In order to do these calculations, a FPU has several complex circuits built-in and ALUs.
Engineers refer to the ALU as the circuit that performs integer arithmetic operations (e.g., two’s complement and BCD). Circuits that calculate more complex formats like floating point, complex numbers, etc. are specifically called FPU.(1,2,3)


WORKS CITED
1 Reference Manual, 7070 Data Processing System, A22-7003-01.
2[http://bitsavers.org/pdf/Univac/uss/SolidState90 Specs.pdf. UNIVAC SOLID-STATE 90 Specification Features]
3650 Data Processing Machine Manual of Operation, 22-6060-2.