Ever wonder how a mobile phone as small as a credit card does many things? Seeing technology around us getting smaller and more powerful is amazing.
Making devices more compact has been made possible due to improvements in contemporary hardware technology. Today, home devices are incredibly powerful, reaching levels of performance we could only even imagine decades ago. In parallel to the growing speed of computers is the growth of the Arithmetic Logic Unit (ALU), a digital circuit within all computer processors.
In this article, we take a look at what an ALU is, how it works, and what are its primary uses in the world of computer science. Without further ado, let’s begin!
What is an ALU?
The Arithmetic Logic Unit (ALU) is one of the fundamental blocks of a computer’s Central Processing Unit (CPU). The CPU is responsible for managing all software and hardware resources of a computer, and the ALU helps facilitate this process.
The CPU consists of three main units:
- ALU (Arithmetic Control Unit). The module that handles all calculations and processing.
- CU (Control Unit). The module handling how resources communicate with each other.
- MU (Memory Unit). The module offering immediate memory, as well as managing the external memory devices attached to the system.
The ALU acts as the brain in this setup, as the CU and the MU help store and move data and commands to the ALU, where the actual calculations and other operations happen.
What is an ALU Made of?
An ALU is a combinatorial circuit, and is capable of performing basic operations like addition, subtraction, and bitwise, which is an action “directly supported by the CPU”. A combinatorial circuit refers to a circuit that is built by combining one or more components. ALUs cannot execute multiplication sums, as multiplying is not carried out via a combinatorial circuit.
An ALU is essentially a complex chipset that takes in some inputs and selections, and returns an output based on the data supplied and operation selected. The exact functionalities supported by an ALU depends upon the requirements of the system and the circuits involved. Usually, the ALU of a personal computer supports a variety of operations, from basic mathematical operations to complex logical and relational functions.
For a clearer understanding, here’s the representation of an ALU circuit that houses an adder, and all basic logical operations like AND, OR, and NOT. The presence of an arithmetic unit (Full Adder) and a logical unit (all logical components) makes the system complete in terms of an Arithmetic Logic Unit.
The main components of the above 1-bit ALU design are:
- Adder circuit. To support mathematical operations like addition, subtraction, multiplication, and division.
- Logical AND circuit. To perform the logical AND operation on two bits.
- Logical NOT circuit. To perform the logical NOT operation on two bits.
- Logical XOR circuit. To perform the logical XOR operation on two bits.
- Multiplexer (MUX). To control the operations performed by the ALU.
When a calculation has to be done, the ALU is provided with the operands via the terminals A0 and B0, and the operator via the selection input at M1 and M0.
The selection lines M0 and M1 select the operation that the ALU will perform. When combined with the input lines A0 and B0, they constitute the Instruction Set. The Instruction Set is a list of operations that are supported by a computer processor.
The reason why we are calling it a 1-bit ALU is that it can carry out an operation only on a single bit. The numbers 0 and 1 can be operated on, with another 0 or 1, to return a 1-bit result.
Combining more of such 1-bit ALUs in parallel creates a powerful unit that can easily run complex calculations. Common combination setups include the 4-bit ALU and the 8-bit ALU, which parallelly support four and eight unit operations.
What is an ALU Used for?
ALU is one of the building blocks of a CPU in a computer. It is used for carrying out all calculations in a computer system. The ALU resides in the heart of the CPU and executes tasks requiring any processing or calculation.
Additional CPU components, such as the Data Bus, the MU and the CU, help make the work easier for the ALU by efficiently providing it with input and data.
Here are some of the top functions that ALUs can do:
- Processing calculations. All bit-level calculations are done on the ALU. Larger calculations are broken down into smaller, singular, bit-based operations to process faster.
- Running processes. Every process or software in a computer system runs by carrying out calculations and memory manipulation. The ALU allows them to do so.
- Accessing Memory. While the memory may not seem like an area where calculations can help, but complex tasks require fast traversal through memory, and address calculations are carried out by the ALU to help read distinct parts of the memory together faster.
This article covered what an ALU is, and its significance in a computer system. We also took a moment to understand how circuits and architectures work on a computer chip. Then, we moved on to understanding the primary use-case of ALU — processing all calculations and operations.
Like the CU and MU, ALU is an inseparable component of the CPU. Understanding how the process works can help people write code that can run faster. If you are looking to build a career in hardware technologies, understanding the fundamentals of the CPU is a must, and the best place to begin with is the ALU!
About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.