## Arithmetic Logic Unit

## What Is Arithmetic Logic Unit ( ALU ) ?

In computer architecture, the arithmetic logic unit ( ALU ) is an combinational digital electronic circuit and fundamental building block of all Â microprocessor chips.

The ALU essentially works as a mathematical brain of the all processor chips. It performs all the arithmetic and logical operations performed by the processor.

The main function microprocessor ( CPU ) Â is to execute the computer program. The computer program contains set of machine instructions. The CPU executes the program.

In order to execute the program, the CPU has to perform number of arithmetic and logical operations as per the program instructions. These operations are performed by the ALU.

The ALU is an essential part of each central processing unit ( CPU ). The CPU is also alternately referred to as processor or a microprocessor.

The ALU is also a crucial component of the Graphics Processing Unit ( GPU ) . A GPU is a dedicated processor used for handling the graphics processing which improves the system performance.

Depending upon the microprocessor architecture, the CPU and GPU can contain one or more Arithmetic and logic units. The ALU for the GPU is optimized for rapid graphics processing.

The ALU is a fundamental building block of all microprocessor. From simple to highly advanced microprocessor, all the processor chips, the ALU is a essential component.

In this article, you will learn what is arithmetic logic unit, how ALU works, functions of the ALU, logic gates and other important topics related to the central processing unit ( CPU ) and ALU.

## Arithmetic Logic Unit ( ALU ) In Computer Architecture

## Arithmetic Logic Unit In Computer Architecture

## Table Of Contents

## ALU And CPU Architecture

The ALU is a crucial component of all the microprocessor chips. And therefore, The ALU operations can be best understood in the context of how CPU works.

The CPU stands for the central processing unit and it functions as a brain of the computer system. The CPU is an integrated circuit chip and crucial component of the computer system.

It is CPU is responsible to process the data as per the program instructions. The CPU provides the processing power to the computer by performing complex calculations.

The processor internally consists of three functional units. These functional units are control unit ( CU ), arithmetic and logic unit ( ALU ) and the memory unit ( MU ).

The control unit ( CU ) decodes the operation code ( Opcode ) part of the machine instruction. The CU then directs the arithmetic logic unit ( ALU ) to perform a specific operation as per the operation code.

The ALU operates on the data ( Operand ) part of the machine instruction and processed data is stored into the memory unit ( MU ).

During the program execution, the CPU stores the program instructions and data into the internal high speed memory unit of the CPU. The memory unit consists of CPU registers.

## What Are Arithmetic And Logic Operations ?

The ALU is a part of the processor and the number of operations supported by the processor ( operations performed by the ALU ) depends upon the instruction set architecture of the processor.

The modern processor contains highly advanced ALU circuit that is capable of performing complex arithmetic and logic operations.

The ALU is said to be a combinational circuit because the ALU circuit internally consists of combination of both arithmetic Unit and the logic unit.

### Arithmetic Operations

The ALU performs both arithmetic and logic operations. The arithmetic operations of the ALU include all the basic mathematical operations.

For example, the ALU arithmetic operations includes addition, subtraction, division multiplication and raise to the power.

### Logic Operations

All the decision making operations based on the conditional logic are said to be the logical operations.

The ALU logical operations include the grater than ( â‰¥ ) less than ( â‰¤ ) , comparison, equal toÂ shifting operations, Boolean operations comparisons ( XOR, OR, AND, and NOT operations ).

The ALU supports only binary operations. The arithmetic and logic unit internally consists of AU ( arithmetic unit ) and the LU ( logic unit ).

ALU Arithmetic Operations | ALU Logic Operations |

+ Addition | = Equal To , ≠ Not Equal To |

- Subtracition | > Greater Than |

÷ Division | < Less Than |

× Multiplication | ≥ Greater Than Or Equal To |

Raise By A Power | ≤ Less Than Or Equal To |

## Arithmetic Logic Unit And Boolean Algebra

The arithmetic logic unit ( ALU ) handles three types of operations performed by the CPU. These three basic operations of the ALU include arithmetic, logical and shift operations.

The ALU circuits consists of different types of logic gates that allows the ALU to perform the logical operations. The logic gates are digital circuits and fundamental building block of all the digital circuits.

The computer system is a digital electronic machine. Since all the electronic components of the computer system works on the principles of digital electronic.

And therefore, the computer can execute the machine instructions in the binary format. The machine instructions are represented in binary that contains only two digits that is either zero or one.

The ALU performs the logical operations with the help of logic gates. The ALU makes use of different types of logic gates to execute different logic operations.

A logic gate is an electronic device that works as a building block for all the digital electronic circuits. The logic gates perform basic logical functions that are essential for the digital circuits.

In a digital circuit, the logic gates will make decisions based on a combination of digital signals received from its inputs. Most logic gates have two inputs and one output.

Logic gates are based on the principles of the Boolean algebra.Â In mathematics, the Boolean algebra is the branch of algebra in which the values of the variables are the truth values.

The Boolean algebra is based on the binary number system. The truth value is either true and false and it is denoted 1 and 0, respectively in the binary.

The logic gates take binary inputs and provide one single binary output. There are seven basic logic gates represented by specific symbol. There seven basic logic gates are AND, OR, XOR, NOT, NAND, NOR, and XNOR.

## What Are Logic Gates ?

The arithmetic logic unit internally consists of two sub functional units which includes the arithmetic unit and the logic unit.

The arithmetic unit performs the arithmetic operations. Whereas, the logic unit performs the logic operations such as decision making.

When the program instruction contains the conditional logic, the CPU has to first evaluate the condition. The CPU further operation depends upon the result of the conditional expression.

The arithmetic logic unit executes the conditional statements with the help of the logic gates.

The logic gates are used in the ALU to make decisions during the program execution. The logic gates allow the electrical outputs are only Â â€˜turn onâ€™ when the correct logic sequence has been applied.

The logic gate has a specific name that helps to describe how different inputs will determine the possible outputs.

In order to understand how a logic gate works, the table of logic possibilities needs to be studied. In Boolean algebra , this table is called a â€˜truth tableâ€™ .

In digital electronics, truth tables are used for planning and designing the logic gates.

## ALU Functions

### What Are The Functions Of ALU ?

The ALU is that functional part of the processor that operates on the data. The Opcode part of the instruction format defines the operation to be performed.

Whereas, the data is represented by Operand into the instruction format. The addressing mode part directs the control unit regarding the manner in which data is represented into the instruction format.

The arithmetic logic unit performs three types of functions.

- To operate on data as per the program instruction decoded by control unit.
- ALU performs arithmetic operations such as ; addition, subtraction, increment, multiplication etc.
- ALU performs logical operations such as ; AND , OR , X-OR , NOT etc.
- ALU accepts operands from accumulator and temporary register.
- ALU after performing operation, it stores the result in accumulator or temporary register.
- It performs Bitwise Logical and Bit Shift operations
- It provides states of result to the flag register.
- ALU also handles the branching decisions.

### Bitwise Logic Operations

The bitwise logic operations include all the basic decision making operations such as AND , OR , Exclusive-ORÂ Â bitwiseÂ XOR,Â

### Bit Shift Operations

The bit shift operations are used to move the bits to either the left or right in an instruction word.

There are three types of bit shift operations performed by the ALU. These bit shift operations are logical shift, arithmetic shift and rotate. A logical bit shift operation moves bits to the left or right.

The bits which ‘fall off’ the end of the instruction word are discarded. The falling bit in the instruction word is replaced by 0’s from the opposite end.

## How ALU Works ?

The arithmetic logic unit ALU plays an important role in the program execution. The ALU is part of the processor which performs the mathematical calculations and decision-making logical operations.

The program execution starts when operating system loads the program into the main memory RAM. The microprocessor is responsible to execute the program.

The CPU initiates the program execution by its internal execution mechanism called an instruction cycle. The instruction cycle is the basic CPU operation which consists of four steps.

The instruction cycle is a four stage CPU operation and it is also called as fetch, decode and execute cycle.

The CPU initiates the program execution by fetching the program instructions one by one. The program instruction is also referred as machine instruction or instruction word.

Each time the instruction is fetched, the program counter ( PC ) register is incremented so that it points to the address of the next instruction.

Each processor has three functional units which includes control unit, arithmetic logic unit and the memory unit.

The control unit ( CU ) inside the processor controls the entire execution cycle performed by the processor and generates the necessary control signals.

The control unit is also responsible to decode the program instruction stored into the instruction register. The decoding part of the instruction takes place in the control unit as per the instruction format.

The operation code ( Opcode ) part of the instruction format is decoded by the control unit CU to decode which operation is to be performed. The CU also decodes the Operand to fetch the data.

After the decode operation is completed, the control unit generates the necessary control signals and directs the ALU to perform the desired operation as specified in the Opcode.

The arithmetic logic unit ( ALU ) then performs the necessary mathematical and logical operations on the data. The processed data is stored into the output register and then transferred to the main memory.

The operating system regains the control of the processed data stored into the main memory RAM for further action.

## ALU Configurations

Arithmetic logic unit (ALU) is one functional unit of the CPU architecture. During the program execution, ALU interacts with other functional units of the CPU and performs various operations as per the program instructions.

Depending upon the CPU architecture, Each arithmetic logic unit (ALU) can include the following configurations.

Based on the internal storage of operands, the ISA can be classified as: Stack, Accumulator and General Purpose Register Architecture.

- Â Instruction Set Architecture.
- Â Accumulator.
- Â Stack.
- Â Register to Register.
- Â Register Stack.
- Â Register Memory.

### Instruction Set Architecture

The instruction set architecture (ISA) is a part of the processor architecture. The ISA define set of commands supported by the processor and implemented into the processorâ€™s microarchitecture.

Each microprocessor supports a group of commands that are hardwired into the processor circuitry. The ISA defines the set of commands that the processor can perform to execute the program instructions.

In other words, the instruction set architecture is group of commands and operations used by the software to communicate and direct the processor. These commands are implemented into the processor circuitry that is microarchitecture.

### Accumulator

In computing, an accumulator is a type of register used by the processor to store the short-term and intermediate data related to mathematical and logical operations during the program execution.

The CPU makes use of number of high-speed internal memory called registers. In modern CPUs, accumulators are replaced by general-purpose registers because they offer more flexibility. However, accumulator may still be in some special-purpose processors.

### Stack Architecture

In computing, the computers that are based on the Stack-based CPU Organization use data structure called a stack. The stack is a list of data words. A word is a unit of data in bits of a defined bit length that can be addressed and moved between various memory storage devices and the processor.

Stack system uses the Last In First Out (LIFO) access method which is the most commonly used data access method in most of the processor. A CPU register is used to store the address of the topmost element of the stack which is known as Stack pointer (SP) register.

In stack-based CPU organization, ALU operations are performed on stack data. It means both the operands are always required on the stack. After manipulation, the result is placed in the stack.

The two main operations that are performed on the operators of the stack are Push and Pop. These two operations are performed from one end only.

### Register To Register Architecture

In this type of register-based CPU organization, the processor makes use of multiple general-purpose registers, instead of a single accumulator register.

This CPU Organization is also known as General register-based CPU Organization. In this type of CPU organization, the computer uses two or three address fields in their instruction format.

Each address field points to a general register or a memory word. The CPU will make use of available registers for heavily used variables and intermediate results. The register being the fastest memory results increased CPU execution speed.

### Register Memory Architecture

In this type of register and memory based CPU organization, the processor makes use of both multiple general-purpose registers as well as memory referencing instead of a single accumulator register.

This CPU Organization is also known as register memory CPU Organization. In this type of CPU organization, the processor uses one or two register address fields and memory referencing in their instruction format.

Each address field in the instruction format might point to either a general register or a memory word. The CPU will make use of either available registers or memory address for storing variables and intermediate results for optimal CPU performance.

### Register Stack Architecture

The register-stack architecture is the combination of register and accumulator operations. In the register-stack architecture, all the ALU operations that must be done are pushed to the top of the stack. Whereas the output of the ALU operation is kept at the top of the stack.

More difficult mathematical operations can be simplified using the reverse polish method. Another approach is to utilize the concept of a binary tree to represent operands. This means that the reverse polish process may be simple for these programmers but challenging for others. To carry out push-and-pop operations, new hardware must be developed.

## ALU FAQ

## Arithmetic Logic Unit FAQ

### What Is Arithmetic Logic Unit ?

In computer architecture, the arithmetic logic unit ( ALU ) is an combinational electronic circuit which handles arithmetic and logical operations of the processor. The ALU is a fundamental building block of all the microprocessor chips.

The ALU essentially works as a mathematical brain for the central processing unit ( processor chip ) that performs the arithmetic and logical operations performed by the processor.

### What Are the Components Of ALU ?

The ALU components depending upon its architecture can consists of arithmetic unit and logic unit. The arithmetic unit performs all arithmetic operations.

The logic unit handles all decision making logical operations of the CPU. For example, logic functions are AND , OR , Exclusive-ORÂ Â bitwiseÂ XOR.

### What Is CPU ?

A processor ( CPU ) is an integrated circuit ( IC ). The processor consist of millions of IC chips and each IC chip consist of millions of tiny component called transistor. The Transistor is madeup of silicon which is a semiconductor material .

The processor ( CPU ) controls all the activities of the computer system. And therefore it is referred as brain of the computer system. There are two main computer processor manufacturers Â Intel and Advanced Micro Devices ( AMD ). These two companies produce most of the processors used in desktop,Â laptops Â andÂ notebooks.

AÂ Central Processing Unit ( CPU )Â performs millionsÂ tasks per secondÂ to execute aÂ computer program by performing the basic arithmetic, logical, control and inputÂ /Â output ( I / O ) operationsÂ asÂ specifiedÂ by theÂ programÂ instructions.Â

AÂ Â CPU Â isÂ placed Â onÂ theÂ motherboardÂ inÂ aÂ processorÂ socket Â withÂ lockingÂ liver mechanism Â Â inÂ orderÂ toÂ fixÂ theÂ processorÂ chipÂ properlyÂ into theÂ processorÂ socket . The processor socket contains a IC socket in which the processorÂ chip is firmly mounted . A heatsinkÂ is mounted on the top of the processor chip which Â protects Â the processorÂ fromÂ excessiveÂ heat generated.

### What are Functions Of Arithmetic Logic Unit?

The arithmetic logic unit performs three important functions to execute the program instructions and operate on the data.

The control unit decodes the machine instructions and directs the ALU to perform specific operation.

- To perform The Arithmetical Operations.
- To perform The Bitwise Logic Operations.
- To perform The Bit Shift Operations.

### What are Logic Gates ?

The Logic gates are electronic components used in the digital electronics to handle logical functionality.

The logic gate is an electronic circuit used in the ALU to compute a function on a two valued signal. Logic gates are the basic building block of digital circuits.

The logic gates accept two inputs and produce one output. Some logic gates like NOT gate has only one input and one output.

The logic gate being a digital electronic component, Â can handle inputs only in the binary format (only low 0, or high 1) by receiving the input voltage.

Join The Best Seller

## Computer Science Online Course

This is the most comprehensiveÂ and uniqueÂ C**omputer ScienceÂ And Programming Fundamentals **course Online which will give you in depth understanding of most important fundamental concepts in computer science And Programming .