Arithmetic Logic Unit (ALU)

What is Arithmetic Logic Unit (ALU?

Just as the name indicates, the ALU or Arithmetic Logic Unit of the CPU executes the different arithmetic and logic operations that the CPU has to perform on different operands in specific instruction words.

In a few specific processors the Arithmetic Logic Unit may be divided into two separate units namely the Arithmetic Unit or the AU and the Logic Unit or LU.

Understanding Arithmetic Logic Unit (ALU)

What is Arithmetic Logic Unit (ALU)

Typically, in a computer system, or in the CPU to be more precise, the Arithmetic Logic Unit or ALU, which is also known as the Integer Unit or IU, happens to be the main component.

Technically speaking, the ALU or IU is an integrated circuit in the CPU or even in a GPU that is actually an important element that does all the calculation in the processor.

The ALU has the ability to do a lot of things such as add and subtract numbers apart from performing other arithmetic operations as well as logic and shifting operations. This includes Boolean comparisons such as:

Apart from that, mathematical and bitwise operations can also be made on the binary numbers.

The codes and the operands used by the ALU determine which particular operations need to perform on the basis of the input data.

When the processing of the data input is completed by the ALU, the result is then sent to the memory of the computer system.

History

The concept of ALU is nothing new.

In fact, it was proposed way back in 1945 by the famous mathematician, John von Neumann, in a report on the foundation of the Electronic Discrete Variable Automatic Computer or EDVAC, the new computer then.

The ALU back then was very simple and typically could handle only one data bit at one time.

However, the ALUs presented a much wider word size typically to the programmers.

Also, in 1967, Fairchild 3800 was introduced by Fairchild which was the first ALU put into operation as an Integrated Circuit or IC.

This had an 8-bit ALU with an accumulator.

This was the beginning of the surge of other ALUs with Integrated Circuits including the 4-bit Arithmetic Logic Units namely the Am2901 and 74181. These devices were designed specifically to make the ‘bit slice’ capable.

This design facilitated the ‘carry look ahead’ signals by utilizing the numerous interconnected ALU chips.

This allowed creating an ALU that came with a much wider word size.

This design became popular pretty quickly and soon it was extensively used in the bit-slice minicomputers.

When the microprocessors appeared in the early 1970s, the transistors became much smaller in size and there was not enough space left in the die to install a full size ALU on it.

However, a narrower ALU was used but that needed numerous cycles for each Machine Language instruction.

For example, the popular Zilog Z80 microprocessor came with a 4-bit ALU but could perform 8-bit additions.

However, the geometries of the transistors became smaller over time, according to Moore’s law, and therefore it was reasonable and possible to build bigger ALUs on the microprocessors.

Now, in the age of the modern Integrated Circuit transistors, these are even smaller than the early microprocessors.

This means that these now need highly sophisticated ALUs to be fixed on the ICs.

These complex ALUs of today come with wider word widths, better and more architectural enhancements and useful features such as binary multipliers, barrel shifters and more.

These enhanced designs allow the ALUs to perform in a shorter clock cycle, often in a single one, and complete even those operations in quick time that would have required multiple operations on the traditional ALUs.

With continuous technological developments, the ALUs, which were and are still considered to be mechanical, electronic or electro-mechanical circuits usually are now being attempted to make biological ALUs.

However, as of now, research on these is still being carried out.

Design

The design of the ALU is a vital part of the CPU.

It has changed significantly over time, as said earlier, and newer and better approaches are now being followed in order to speed up instruction handling.

Typically, the engineers design the ALU in such a way that it can perform any given kind of operation.

Still, it becomes costlier as and when the operations become more complicated.

This is because the ALU uses up more space and destroys more heat in the CPU.

That is why the engineers make the CPUs more powerful because it ensures that the CPU itself will be more powerful and faster.

On the contrary, if the Central Processing unit is made more powerful than the ALU, it will consume more energy or power which will produce more heat in turn.

There is no universal standard of the ALU design which is why it may vary from one processor to another in spite of being the main component of every processor.

This eventually offers variable functionality.

For example, some ALUs may be designed to execute integer calculations only while others may carry out floating-point operations only.

Working Process

As for the working process of the ALU, it involves input and output access directly to the different parts of the computer such as:

Here, the input comprises the instruction word, which is also called the machine instruction word more often. This instruction word consists of:

Each of these has specific functions to perform. For example:

The operation code indicates the type of operation to be performed by the ALU and the operands are used while executing the operations.

For example, it might tell the ALU that the two operands are to be compared logically or simply to be added together.

The format, on the other hand, is typically combined with the operation code.

This usually determines whether it is a fixed-point instruction or a floating-point instruction.

The output, as always, is the result of the operation which is normally transferred and held in the storage register and settings.

This actually shows whether or not the operation was performed properly.

If, however, the operation is not successful, a machine status word, which is a kind of status, will be stored in a permanent location.

Read Also:  What is Base Address? (Explained)

However, generally speaking, the ALU comes with its own storage units for storing different items such as:

Usually, there are gated circuits in the ALU that control the operations performed on the bits as well as the bit flow in the subunits of it.

These gates are usually managed by a sequence logic unit. This specific unit uses a specific sequence or algorithm for controlling every operation code.

Apart from handling addition and subtraction calculations, multiplications and divisions are also done in the Arithmetic Unit by using a set of adding or subtracting as well as shifting operations.

The negative numbers are characterized in different ways.

However, it is good to note that the multiplication operation of two integers is done by the ALU since it is designed that way. The result in such cases is therefore also an integer.

On the other hand, the division operations may not be performed by the ALU in some cases.

This is because the results of a division may be a floating-point number.

Therefore, it is commonly handled by the Floating Point Unit. However, the FPU can also handle other non-integer calculations equally well.

As in the logic unit, one of the 16 probable logic operations is performed such as comparing two given operands in order to find out where the bits do not match.

Functions of the Algorithm

The ALU is responsible for multiple-precision arithmetic which is an algorithm that uses integers to operate.

These integers are however much larger than the word size of the ALU.

In such situations, the algorithm considers every operand as an ordered collection that is in fragments corresponding to the ALU size.

These are arranged in order from the most significant ones to the least significant ones or vice versa.

The algorithm also utilizes the ALU to operate directly on a specific fragment of operand.

This produces a simultaneous fragment, called a ‘partial,’ of the multi-precision outcome.

Each of these partials, when produced, is usually written in a related region of storage.

This region is typically designated for multi-precision results. This procedure is repeated for every operand fragment.

However, while performing an arithmetic operation like addition or subtraction the algorithm begins by summoning an ALU operation on the least significant fragments of the operand.

This helps in generating both a carry-out bit as well as a least significant partial.

This partial is then written by the algorithm to the selected storage but the carry-out bit is stored by the state machine of the processor typically on the ALU status register.

Next, the algorithm proceeds to the next fragment of the operand collection and repeats the process to produce more significant carry-out bits and partials till every operand fragment is processed.

This eventually produces an entire collection of partials in the designated storage which is actually the multi-precision arithmetic result.

However, during the multiple-precision shift operations it is the shift direction that determines the order of operand fragment processing.

For example, in the case of a left-shift operation, the least significant fragments are processed first.

This is due to the fact that the least significant bit of every partial, which is conveyed through the stored carry bit, is needed to be acquired from the most significant bit of the earlier less significant operand that has shifted to the left.

In contrast, in the case of right-shift operations, the most significant fragments of the operands are processed first due to the fact that the most significant bit of every partial is to be obtained from the least significant bit of the previous more significant right-shifted operand.

And, in the case of bitwise logical operations, the operand fragments are processed in any random order.

This is due to the fact that every partial depends on the parallel operand fragments only and the carry bit stored from the earlier ALU operation is disregarded.

ALU Signals

The ALU contains a wide range of input and output electrical connections that helps in sending the digital signals to and from the external electronics.

This means that the ALU receives the input signals from the external circuits and responds to it by sending output signals to the external electronics.

There are three parallel buses in the ALU. Out of these two are input operands and one is an output operand.

All these buses in combination handle the number of signals, which are however the same.

Status Input and Output Signals

The status input signals allow accessing further information once the ALU performs an operation in order to complete the task successfully.

In this case, the carry-out stored from the previous ALU operation is called the single ‘carry-in’ bit.

On the other hand, the status output signals provide the results of the operations performed by the ALU.

These are provided as supplemental data as if these were multiple signals.

Typically, and in general, the ALU contains different status signals such as:

The external registers contain the status output signals after every operation is completed by the ALU and are made available as and when required for ALU operations in the future.

Architecture Configurations

Typically, every ALU comes with the following architecture configurations:

Here is a brief description of each of them.

Advantages

The Arithmetic Logic Unit offers several advantages such as:

Disadvantages

On the other hand, the disadvantages of ALU are:

Read Also:  Direct Memory Access vs Memory Mapped I/O: 13 Differences

Function of Arithmetic Logic Unit

The ALU actually supports a wide range of basic arithmetic calculations as well as bitwise logic functions as explained below.

The arithmetic functions performed by the ALU include:

The bitwise logical functions performed by the ALU are:

The ALU also performs some bit shift functions to shift the operand A or B to the right or left depending on the operation code.

The operand that is shifted is displayed at Y.

The operand is shifted only by one bit position by the simple ALUs while the complex ones can shift them by any arbitrary number of bits by using the barrel shifters in a single operation.

Typically, in all types of single-bit shift operations, the shifted out bit of the operand is displayed on carry-out and the value of the bit shifted into the operand is based on the kind of shift. These can be:

The ALU however cannot perform complex functions, due to several factors such as:

These functions are usually performed by the external processor circuitry but by coordinating a series of simpler ALU operations.

In such situations, for example, to calculate the square root of a number, there can be several ways implemented depending on the complexity of the ALU. Some of these ways are:

The square root of the number will be calculated in any case but it is all about fastest transition, cost, and time.

Components of ALU

Typically, the Arithmetic Logic Unit comes with three major components or functional parts such as:

However, if you look at it closely there are also several other components in an ALU that helps it in its operations and it is good to know all about them. Here are all of them explained for you.

Logic Gates

These are considered to be the building blocks of the ALU and are typically made up of specific components such as:

In an Integrated Circuit, these gates represent input ON with a binary number 1 and OFF by binary number 0. There are different types of logic gates such as:

Bits

The ALU also uses a wide range of bits which forms a part of its design. These are as follows:

Read Also:  What is ROM (Read only Memory)? Types & Function

Registers

These are crucial components in an Arithmetic Logic Unit which allows storing all instruction, intermediate data, input and output.

The registers are better than RAM, cache or even the hard disk because they allow faster access to the memory.

These registers are typically built on the CPU and are quite small in size.

The main function of the registers in an ALU is to store the intermediate data that is processed.

There are a number of different types of registers used for definite purpose by the Arithmetic Logic Unit out of which four are general purpose registers.

All of these four registers are 16-bit registers which means that these can store up to 16 bit of data.

The different types of registers may have different names. Here they are with a brief description against each:

How Many ALU Does a CPU Have?

Ideally, there is no universal standard or a golden rule for ALU or CPU design which fixates the number of ALUs a CPU can have.

Therefore, it is due to the variable design of the ALU and the CPU that some processors may come with only one single ALU to perform the calculations while a few processors may come with more than one Arithmetic Logic Units for the same.

The number of ALUs a CPU can have can also vary according to the CPU architectures as well as the generation of the processors.

At the minimum, a CPU will come with one ALU for every CPU core.

However, the most widely used superscalar CPU architectures of today typically come with several execution pipelines.

It is highly possible for all or some of these pipelines to have an ALU in them.

Also, there are a few specific CPU architectures that may have SIMD or Single Instruction, Multiple Data ALUs. This is where several ALUs perform a task in parallel on different parts of the data.

And, having multiple ALUs should not be considered to be a modern marvel.

This is because, according to records, historically, the 1948 Whirlwind I was one of the earliest computers to come with several discrete single-bit ALU circuits. This had 16 math units that could handle the operation on 16-bit words.

Typically, the CPUs designed in the 1970s and 1980s, the ALU was actually a unit of the design occupying almost a square piece of silicon die.

However, with the passage of time when more modern CPUs were designed, these were not only more complicated than the older versions but also had more transistors and silicon.

Therefore, these came with up to a dozen circuits each of which acted like an Arithmetic Logic Unit.

Some of these could only perform addition operations while others only shift operations.

Therefore, even if a CPU comes with multiple ALUs you should not think that it will support multiprocessing necessarily and there are several reasons for it.

To start with, an ALU is certainly not a core of a processor.

This is simply a collection of electronic circuitry that includes components such as:

It, therefore, really does not matter what an ALU processes.

It simply performs the arithmetic or logic operations as requested on the operands supplied.

Therefore, CPUs with multiple Arithmetic Logic Units and processing lanes are very common nowadays.

However, the number of such ALUs will typically depend on the number of pipelines in the CPU design.

In spite of that, these do not speed up the overall operation of the CPU.

This is because in most of the cases enough work is not available to the resources of the processors.

Conclusion

So, with all that said and explained this article comes to an end.

You are surely more knowledgeable now about the Arithmetic Logic Unit than you were before you started reading this article.