Logical arithmetic unit
In computing, the arithmetic logical unit or arithmetic-logical unit, also known as the ALU. logic unit), is a digital circuit that performs arithmetic operations (addition, subtraction) and logic operations (IF, AND, OR, NOT) between the values of the arguments (one or two)
By far the most complex electronic circuits are those built into modern microprocessor chips. Therefore, these processors have within them a very complex and powerful ALU. In fact, a modern microprocessor (and mainframes) can have multiple cores, each core with multiple execution units, each with multiple ALUs.
Many other circuits can contain an arithmetic logic unit inside: graphics processing units like the ones in modern GPUs, FPUs like the old 80387 math coprocessor, and digital signal processors like the ones found in graphics cards. sound, CD players and high definition televisions. All of these have several powerful and complex ALUs inside.
History: Von Neumann's Proposal
Mathematician John von Neumann proposed the ALU concept in 1945, when he wrote a paper on the foundations for a new computer called the Electronic Discrete Variable Automatic Computer (EDVAC). Later, in 1946, he worked with his colleagues designing a computer for the Princeton Institute of Advanced Studies (IAS). The IAS machine became the prototype for many later computers. In this proposal, von Neumann outlined what he believed would be needed in his machine, including an ALU.
Von Neumann explained that an ALU is a fundamental requirement for a computer because it needs to perform basic mathematical operations: addition, subtraction, multiplication, and division. Therefore, he believed it was "reasonable that a computer should contain specialized bodies for these operations".
Number Systems
An ALU must process numbers using the same format as the rest of the digital circuitry. For modern processors, this format is almost always the representation of two's complement binary number. 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.
The ALUs for each of these number systems displayed different designs, and this influenced the current preference for two's complement, since this is the simplest representation, for the ALU electronic circuitry, to compute additions, subtractions etc
Practical introduction
The ALU is basically made up of: Operational Circuit, Input Registers, Accumulator Register and a State Register, a set of registers that make it possible to carry out each one of the operations.
Most of the computer's actions are performed by the ALU. The ALU takes data from the processor registers. This data is processed and the results of this operation are stored in the output registers of the ALU. Other mechanisms move data between these registers and memory.
A control unit controls the ALU by setting up circuitry that tells the ALU what operations to perform.
Detail
The image shows a 2-bit ALU with two inputs (operands) called A and B: A[0] and B[0] correspond to the least significant bit and A[1] and B[1] correspond to the most significant bit.
Each bit of the ALU is processed identically, with the exception of the addressing of the carry bit. The handling of this bit is explained later.
Inputs A and B go into the four gates on the right, top to bottom, XOR, AND, OR. The first three gates perform XOR, AND, and OR operations on data A and B. The last XOR gate is the initial gate of a full adder.
The final step of the operations on each bit is the multiplexing of the data. The 3-bit OP input, OP[0], OP[1] and OP[2] (from the control unit) determines which of the functions will be performed:
- OP = 000 → XOR
- OP = 001 → AND
- OP = 010 → OR
- OP = 011 → Addendum
Clearly it can be seen that the other four multiplexer inputs are free for other operations (subtraction, multiplication, division, NOT A, NOT B, etc). Although OP[2] is currently not used in this assembly (despite being included and connected), it would be used when performing other operations than the 4 operations listed above.
The carry-in and carry-out data, called flags, are typically connected to some sort of status register.
Simple operations
Most ALUs can perform the following operations:
- Arithmetic operations of integers (addition, subtraction, and sometimes multiplication and division, although this is more complex)
- Logical bit operation (AND, NOT, OR, XOR, XNOR)
- Bit scrolling operation (Displace or rotate a word in a specific number of bits to the left or right, with or without sign extension). Displacement can be interpreted as multiplication or divisions by 2.
Complex operations
An engineer can design an ALU to compute any operation, no matter how complex; the problem is that the more complex the operation, the more expensive the ALU will be, the more space it will use on the processor, and the more power it will dissipate, etc.
Therefore, engineers always calculate a compromise, to provide the processor (or other circuitry) with an ALU powerful enough to compute fast, but not of such complexity as to make an ALU cost prohibitive. Imagine that you need to calculate, say, the square root of a number; the digital engineer will examine the following options to implement this operation:
- Design a very complex ALU that calculates the square root of any number in one step. This is called calculation in a single watch cycle.
- Design a complex ALU that calculates the square root with several steps (such as the algorithm that some of us have learned at school). This is called iterative calculationand generally rely on the control of a complex control unit with built-in microcode.
- Design a simple ALU in the processor, and sell a separate, specialized and expensive processor, that the customer can install additional to the processor, and implement one of the above options. This is called coprocessor or floating comma unit.
- Emulate the existence of the coprocessor, that is, whenever a program tries to perform the calculation of the square root, make the processor check if there is a coprocessor and use it if there is; if there is no one, interrupt the process of the program and invoke the operating system to perform the calculation of the square root through a certain software algorithm. This is called emulation by software.
- Tell programmers that there is no coprocessor and there is no emulation, so they will have to write their own algorithms to calculate square roots by software. This is done by software libraries.
The top options range from fastest and most expensive to slowest and cheapest. Therefore, while even the simplest computer can calculate the most complicated formula, the simplest computers will generally take a long time because several of the steps in calculating the formula will involve options #3, #4, and #5 above.
Complex processors such as the Pentium IV and AMD Athlon 64 implement option #1 for the most complex operations and the slowest #2 for extremely complex operations. That is possible because of the ability to build very complex ALUs on these processors.
Inputs and outputs
The inputs to the ALU are the data on which the operations will be performed (called operands) and a code from the control unit indicating which operation to perform. Its output is the result of the computation of the operation.
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, division by zero, etc.
ALU vs. UPF
A floating-point unit, Floating Point Unit (FPU), also performs arithmetic between two values, but it does so for numbers in floating-point representation, which is much more complicated than the floating-point representation. two's complement commonly used in an ALU. To make these calculations, an FPU has several complex circuits built into it, including some internal ALUs.
A circuit that performs arithmetic in integer formats (such as two's complement and BCD) is generally called ALU by engineers, while circuits that compute in more complex formats such as floating point, complex numbers, etc. are generally given a more specific name, such as FPU.
Contenido relacionado
Bailey-Borwein-Plouffe formula
Motorola 6809
Python