# What is ALU (Arithmetic Logic Unit)?

In the computer system, ALU is a main component of the central processing unit, which stands for arithmetic logic unit and performs arithmetic and logic operations. It is also known as an integer unit (IU) that is an integrated circuit within a CPU or GPU, which is the last component to perform calculations in the processor. It has the ability to perform all processes related to arithmetic and logic operations such as addition, subtraction, and shifting operations, including Boolean comparisons (XOR, OR, AND, and NOT operations). Also, binary numbers can accomplish mathematical and bitwise operations. The arithmetic logic unit is split into AU (arithmetic unit) and LU (logic unit). The operands and code used by the ALU tell it which operations have to perform according to input data. When the ALU completes the processing of input, the information is sent to the computer's memory.

Except performing calculations related to addition and subtraction, ALUs handle the multiplication of two integers as they are designed to execute integer calculations; hence, its result is also an integer. However, division operations commonly may not be performed by ALU as division operations may produce a result in a floating-point number. Instead, the floating-point unit (FPU) usually handles the division operations; other non-integer calculations can also be performed by FPU.

Additionally, engineers can design the ALU to perform any type of operation. However, ALU becomes more costly as the operations become more complex because ALU destroys more heat and takes up more space in the CPU. This is the reason to make powerful ALU by engineers, which provides the surety that the CPU is fast and powerful as well.

The calculations needed by the CPU are handled by the arithmetic logic unit (ALU); most of the operations among them are logical in nature. If the CPU is made more powerful, which is made on the basis of the ALU is designed. Then it creates more heat and takes more power or energy. Therefore, it must be moderation between how complex and powerful ALU is and not be more costly. This is the main reason the faster CPUs are more costly; hence, they take much power and destroy more heat. Arithmetic and logic operations are the main operations that are performed by the ALU; it also performs bit-shifting operations.

Although the ALU is a major component in the processor, the ALU's design and function may be different in the different processors. For case, some ALUs are designed to perform only integer calculations, and some are for floating-point operations. Some processors include a single arithmetic logic unit to perform operations, and others may contain numerous ALUs to complete calculations. The operations performed by ALU are:

• Logical Operations: The logical operations consist of NOR, NOT, AND, NAND, OR, XOR, and more.
• Bit-Shifting Operations: It is responsible for displacement in the locations of the bits to the by right or left by a certain number of places that are known as a multiplication operation.
• Arithmetic Operations: Although it performs multiplication and division, this refers to bit addition and subtraction. But multiplication and division operations are more costly to make. In the place of multiplication, addition can be used as a substitute and subtraction for division.

## Arithmetic Logic Unit (ALU) Signals

A variety of input and output electrical connections are contained by the ALU, which led to casting the digital signals between the external electronics and ALU.

ALU input gets signals from the external circuits, and in response, external electronics get outputs signals from ALU.

Data: Three parallel buses are contained by the ALU, which include two input and output operand. These three buses handle the number of signals, which are the same.

Opcode: When the ALU is going to perform the operation, it is described by the operation selection code what type of operation an ALU is going to perform arithmetic or logic operation.

Status

• Output: The results of the ALU operations are provided by the status outputs in the form of supplemental data as they are multiple signals. Usually, status signals like overflow, zero, carry out, negative, and more are contained by general ALUs. When the ALU completes each operation, the external registers contained the status output signals. These signals are stored in the external registers that led to making them available for future ALU operations.
• Input: When ALU once performs the operation, the status inputs allow ALU to access further information to complete the operation successfully. Furthermore, stored carry-out from a previous ALU operation is known as a single "carry-in" bit.

## Configurations of the ALU

The description of how ALU interacts with the processor is given below. Every arithmetic logic unit includes the following configurations:

• Instruction Set Architecture
• Accumulator
• Stack
• Register to Register
• Register Stack
• Register Memory

### Accumulator

The intermediate result of every operation is contained by the accumulator, which means Instruction Set Architecture (ISA) is not more complex because there is only required to hold one bit.

Generally, they are much fast and less complex but to make Accumulator more stable; the additional codes need to be written to fill it with proper values. Unluckily, with a single processor, it is very difficult to find Accumulators to execute parallelism. An example of an Accumulator is the desktop calculator.

### Stack

Whenever the latest operations are performed, these are stored on the stack that holds programs in top-down order, which is a small register. When the new programs are added to execute, they push to put the old programs.

### Register-Register Architecture

It includes a place for 1 destination instruction and 2 source instructions, also known as a 3-register operation machine. This Instruction Set Architecture must be more in length for storing three operands, 1 destination and 2 sources. After the end of the operations, writing the results back to the Registers would be difficult, and also the length of the word should be longer. However, it can be caused to more issues with synchronization if write back rule would be followed at this place.

The MIPS component is an example of the register-to-register Architecture. For input, it uses two operands, and for output, it uses a third distinct component. The storage space is hard to maintain as each needs a distinct memory; therefore, it has to be premium at all times. Moreover, there might be difficult to perform some operations.

### Register - Stack Architecture

Generally, the combination of Register and Accumulator operations is known as for Register - Stack Architecture. The operations that need to be performed in the register-stack Architecture are pushed onto the top of the stack. And its results are held at the top of the stack. With the help of using the Reverse polish method, more complex mathematical operations can be broken down. Some programmers, to represent operands, use the concept of a binary tree. It means that the reverse polish methodology can be easy for these programmers, whereas it can be difficult for other programmers. To carry out Push and Pop operations, there is a need to be new hardware created.

### Register and Memory

In this architecture, one operand comes from the register, and the other comes from the external memory as it is one of the most complicated architectures. The reason behind it is that every program might be very long as they require to be held in full memory space. Generally, this technology is integrated with Register-Register Register technology and practically cannot be used separately.

ALU has various advantages, which are as follows:

• It supports parallel architecture and applications with high performance.
• It has the ability to get the desired output simultaneously and combine integer and floating-point variables.
• It has the capability of performing instructions on a very large set and has a high range of accuracy.
• Two arithmetic operations in the same code like addition and multiplication or addition and subtraction, or any two operands can be combined by the ALU. For case, A+B*C.
• Through the whole program, they remain uniform, and they are spaced in a way that they cannot interrupt part in between.
• In general, it is very fast; hence, it provides results quickly.
• There are no sensitivity issues and no memory wastage with ALU.
• They are less expensive and minimize the logic gate requirements.

The disadvantages of ALU are discussed below:

• With the ALU, floating variables have more delays, and the designed controller is not easy to understand.
• The bugs would occur in our result if memory space were definite.
• It is difficult to understand amateurs as their circuit is complex; also, the concept of pipelining is complex to understand.
• A proven disadvantage of ALU is that there are irregularities in latencies.
• Another demerit is rounding off, which impacts accuracy.