ALU (arithmetic an logic unit) is the execution unit of the central processing unit (CPU), which is the core component of all central processors, and the arithmetic logic composed of "And Gate" (AND gate) and "Or Gate" (OR gate) Unit, the main function is to perform two-bit arithmetic operations, such as addition, subtraction and multiplication (excluding integer division). Basically, in all modern CPU architectures, binary is represented in the form of complement.
Arithmetic and logic unit (arithmetic and logic unit) is a combinational logic circuit that can realize multiple sets of arithmetic operations and logic operations, or ALU for short.
Arithmetic&logical Unit is the execution unit of the central processing unit (CPU), which is the core component of all central processing units, and is composed of "And Gate" (AND Gate) and "Or Gate" (OR Gate) arithmetic logic Unit, the main function is to perform two-bit arithmetic operations, such as addition, subtraction and multiplication (excluding integer division). Basically, in all modern CPU architectures, binary is represented in the form of complement.
Arithmetic logic unit (ALU) is a structure that performs integer operations. At this stage, it is implemented with a circuit, which is used in computer chips.
In a computer, an arithmetic logic unit (ALU) is a digital circuit that specifically performs arithmetic and logical operations. ALU is the most important part of the computer's central processor. Even the smallest microprocessor contains ALU as a counting function. Modern CPUs and GPU processors already contain powerful and complex ALUs; a single component may also contain ALUs.
In 1945, the mathematician von Neumann proposed the concept of ALU in a report introducing the basic structure of a new computer called EDVAC.
Early development
In 1946, von Neumann worked with colleagues to design a computer for the Princeton Advanced Learning Institute (IAS). Then the IAS computer became the prototype of the later computer. In the paper, von Neumann mentions the parts he believes are needed in computers, including ALU. Von Neumann wrote that ALU is an essential part of a computer because it has been determined that the computer must complete basic mathematical operations, including addition, subtraction, multiplication and division. So he believed that "(the computer) should contain components that specifically perform such operations.
Digital system
The ALU must use the same format for digital processing as the rest of the digital circuit. For modern processors, the values are always expressed in two's complement. Earlier computers used many digital systems, including inverse codes, symbolic numeric codes, and even decimal codes, each using ten tubes. The ALUs corresponding to each of the above digital systems have different designs, and this also affects the current preference for two's complement, because two's complement can simplify ALU addition and subtraction operations. A simple 2-bit ALU that can perform NAND AND AND addition.
Feasibility Analysis
Most computer instructions are executed by ALU. ALU takes data from the register. The data is processed and the operation result is stored in the ALU output register. Other components are responsible for transferring data between registers and memory. The control unit controls the ALU and tells the ALU what operation to perform through the control circuit.
Simple operation
Most ALUs can complete the following operations:
Integer arithmetic operations (addition and subtraction, sometimes including multiplication and division, but the cost is higher)
Bit logic operation (AND, OR, NOT, XOR)
Shift operation (shift or float a word to the left or right by a specific bit without unsigned extension), the shift can be considered as multiplying by 2 or dividing by 2.
Complex operations
Engineers can design an ALU that can perform any operation, no matter how complex the operation is; the problem is that the more complex the operation, the higher the cost of the ALU, the more space it takes in the processor, and the more power it consumes. As a result, engineers often calculate a compromise solution and provide the processor (or other circuit) with an ALU that can make it operate at high speed, but at the same time avoid the ALU design being too complicated and expensive. Imagine that you need to calculate the square root of a number. The digital engineer will evaluate the following options to accomplish this:
Design an extremely complex ALU, which can complete the square root operation of any number in one step. This is called single clock calculation.
Design a very complex ALU, which can complete the square root operation of a number in several steps. However, there is a trick here, the intermediate result goes through a series of circuits, like a production line in a factory. This even allows the ALU to accept new numbers before completing the previous operation. This allows the ALU to produce numbers at the same speed as a single clock pulse, although the results output from the ALU have an initial delay. This is called a calculation pipeline.
Design a complex ALU that can calculate the square root of a number in several steps. This is called interactive computing and often relies on complex control units with embedded microcode.
Design a simple ALU in the processor, remove an expensive processor dedicated to this operation, and choose one of the above three options. This is called a coprocessor.
told programmers that there were no coprocessors and emulated devices, so they had to write their own algorithms to calculate the square root in software. This is done by the software library.
Simulate the coprocessor, that is to say, whenever a program wants to calculate the square root, let the processor check whether there is a coprocessor. If there is, use it to calculate, if not, interrupt the program process and call the operating system to complete the square root calculation through the software algorithm. This is called software emulation.
The options given above are ranked from fastest and most expensive to slowest and most economical. So, even the simplest computer can calculate the most complex formulas, but the simplest computer often takes a lot of time and can be completed in several steps. Powerful processors such as the Intel Core and AMD64 series use option 1 for some simple operations, option 2 for the most common complex operations, and option 3 for extremely complex operations. This is premised on the ability to construct very complex ALUs in the processor.
Input and output
The input of the ALU is the data to be operated (called operands) and the instruction code from the control unit, which is used to indicate which operation to perform. Its output is the operation result. In many designs, the ALU also receives or sends input or output condition codes to (or from) the status register. These codes are used to indicate some conditions, such as carry or borrow, overflow, and division by zero.
ALU and FPU
The floating-point unit also performs arithmetic operations on two values, but this operation has been represented by floating-point numbers, which is much more complicated than the two's complement representation method generally used in ALU. In order to complete such operations, multiple complex circuits are embedded in the FPU, including some internal ALUs. Engineers generally think that ALU is a circuit that handles arithmetic operations of integer types (such as complement and BCD), while circuits that calculate more complex formats (such as floating-point and complex numbers) have a more matching title.
ALU is used to perform arithmetic and logic operations in the computer instruction set;
In some processors, the ALU is divided into two parts, the arithmetic unit (AU) and the logic unit (LU). Some processors contain more than one AU, for example, one for fixed-point operations and another for floating-point operations. (In personal computers, floating-point operations are sometimes performed by floating-point units called digital coprocessors).
Generally speaking, ALU has the right to read and write directly to the processor controller, memory and input and output devices. Input and output are performed via the bus. The input instruction contains an instruction word, sometimes called a machine instruction word, which includes an operation code, a single or multiple operands, and sometimes a format code; the operation code indicates what operation the ALU machine is to perform, and in this operation How many operands. For example, two operands can be compared or added. The format code can be combined with the opcode to tell whether this is a fixed-point or floating-point instruction; the output includes the result stored in the storage register and the setting that shows whether the operation was successful. If the operation fails, there will be a corresponding status display in the machine status word.
Generally, the storage locations of input operands, operands, accumulated sums, and conversion results are all in the ALU. In the arithmetic unit, the multiplication and division operations are obtained through a series of addition and subtraction operations. There are multiple ways to represent negative numbers in machine code.
In the logical unit, one of 16 possible logical operations is executed at a time.
The design of the ALU is a key part of the processor design. Continue to study how to increase the processing speed of instructions.
FPGA Virtex-II Family 1M Gates 11520 Cells 650MHz 0.15um Technology 1.5V 575-Pin BGA
FPGA Spartan-3A Family 700K Gates 13248 Cells 667MHz 90nm Technology 1.2V 400-Pin FBGA
FPGA Spartan-3A Family 700K Gates 13248 Cells 667MHz 90nm Technology 1.2V 256-Pin FTBGA
FPGA Virtex-II Family 1M Gates 11520 Cells 750MHz 0.15um Technology 1.5V 575-Pin BGA
FPGA Virtex-II Family 1M Gates 11520 Cells 750MHz 0.15um Technology 1.5V 456-Pin FBGA
Support