Arithmetic-logical unit

from Wikipedia, the free encyclopedia
Scheme of the arithmetic-logic unit: A accumulator, B data register; R Result, F function, D status output

An arithmetic-logic unit ( English arithmetic logic unit , therefore often abbreviated to ALU ) is an electronic arithmetic unit that is used in processors .

Functions

The ALU calculates arithmetic and logical functions . It makes sense to perform at least the following minimal operations:

Typically, however, the following operations are also available, which can also be simulated using the upper three at the expense of computing time (in several cycles ):

  • Logical:
    • Disjunction (OR operation, OR)
    • Contra-valence (exclusive-or link, XOR, EOR )
    • Right and left shift (right, left shift, ASR - arithmetic shift right, ASL - arithmetic shift left, LSR - logical shift to the right, LSL - logical shift to the left)
    • Left and right rotation (ROL, ROR)
    • Register manipulation and bit changes (set, delete and test bits)
    • Sorting bits and bytes, AES commands, CRC commands

All ALUs process fixed point numbers . Floating point instructions are now standard in many current CPUs. Exceptions are smaller microcontrollers that are designed for low power consumption or low manufacturing costs. The trend over the past 15 years has been to convert ALUs to vector processing (as of 2015).

Structure and functionality

Before the success of integrated microprocessors ALUs were as separate modules (with a lesser degree of integration spread) as this 4-bit ALU SN74S181 from the 74xx series from Texas Instruments
A cascadable 8-bit ALU from Texas Instruments (SN74AS888)

An ALU can link two binary values ​​with the same number ( s ) of digits. One speaks of n -bit ALUs. Typical values ​​for n are 8, 16, 32 and 64. Historically, the 4-bit ALU 74LS181 and the 1-bit processor MC14500B from Motorola are also worth mentioning . (However, the corresponding unit is only called LU (Logic Unit)). Terms such as 32-bit - or 64-bit - CPU come from the width of the working register of the processor architecture. Usually this width also corresponds to that of the ALU; therefore, these terms (32-bit or 64-bit CPU) indicate that similar ALUs are also used in corresponding processors. The Z80 , for example , which works with a 4-bit ALU, is an exception .

Simple n -bit ALU
Control table for n -bit ALU
F 3 F 2 F 1 F 0 R.
0 0 0 0 0
0 0 0 1 A.
1 0 0 1 NOT A
0 1 0 0 A AND B
0 1 0 1 A OR B
0 1 1 0 A XOR B
0 1 1 1 A + B
1 1 1 1 B - A

The n -bit ALU is usually composed of individual 1-bit ALUs, which each pass on a carry bit to the higher-order ALU , with which a carry is identified at the respective point. (Other methods (e.g. carry-look-ahead ) are often used to accelerate this ; see also carry-ripple adder .) To switch the interconnected 1-bit ALUs to the required function type, each 1-bit ALU has in addition to the inputs for the values ​​to be linked and the carry bit, there is also an input for a control vector (op. code); when used in a processor, these inputs are supplied jointly by the control register (operation register, OR) of the processor.

The status register

In addition to the output vector for the result, the entire n -bit ALU also has a condition vector to signal its state. When used in a processor, this condition vector is stored in its status register (also called condition code register ).

This register usually contains four status bits. The individual values ​​of the status register can be queried by machine language commands and thus influence the further course of the program (e.g. conditional jumps):

  • Carry bit (C for engl. Carry bit ): indicates the carry of the addition at the n arises th bit (the highest point) of the operands. It is used as an indicator of over-range when viewing the result as an unsigned number (positive results only). If calculations are made using the 2's complement representation (negative numbers are also possible), the carry bit does not play a direct role for the range being exceeded.
  • Overflow bit (V for overflow bit ): Indicates that the number range is exceeded in the case of 2's complement calculation (carry over of the second highest digit of the operands). Other possible designations besides V are OF or O.
  • Zero bit (Z engl. Zero bit ): indicates whether the result of the previous arithmetic operation is zero (becomes 1 when contents of the accumulator register is 0).
  • Negative bit (N): Is set if the result of the operation can be interpreted as a negative number ( top bit of the accumulator register = 1).

There are other flags depending on the ALU type , for example:

  • Half carry bit (H): Indicates a carry between the low-order and high-order nibble. Interesting for the decimal correction when converting binary representation to BCD representation.
  • Parity bit (P): Depending on the processor, indicates even or odd parity of the accumulator register (number of bits with the value 1 is even or odd).

Related systems

Parallel Logic Units (PLUs) are ALUs specially tailored for bit manipulation. You can access the data in parallel, i.e. at the same time as other arithmetic units, and are therefore connected to the main memory via a separate data path. PLUs are part of some types of signal processors that are used as high-speed controllers .

Individual evidence

  1. Data sheet from 74LS181 (Fairchild) ( Memento from January 31, 2012 in the Internet Archive ) (PDF; 77 kB), ALU from the 74xx logic family
  2. Motorola MC14500B Industrial Control Unit Handbook , on Wikichip.org
  3. Michael Slater, Federico Faggin , Masatoshi Shima , Ralph Ungermann: Zilog Oral History Panel on the Founding of the Company and the Development of the Z80 Microprocessor , page 11, Ed .: Computer History Museum