Log in Sign up
Back to Discover
💻

Arithmetic logic unit

technology Maturity 7-9

A computer has a tiny brain part.

ALU block.svg
ALU block.svg
It does math. It can add or take away. This helps the computer work. It is very fast. Do you like math?

31 words

A computer has a special part for math.

ALU block.svg
ALU block.svg
This part is called an ALU. It takes in two numbers. It also gets a code. This code tells it what to do. It can add numbers together. It can also take numbers away. The part then gives back an answer. It can also say if a number is zero. It can even say if a number is negative. This helps the computer do its work.
AluStatusRegister.svg
AluStatusRegister.svg
It is a very important part.

83 words

An ALU is a key part of a computer. It stands for an arithmetic logic unit.

ALU block.svg
ALU block.svg
This unit does math and logic tasks. It works with binary numbers. These are numbers made of bits.
ALU data paths.svg
ALU data paths.svg

To work, the ALU needs three things. First, it needs two numbers called operands. Second, it needs an opcode. An opcode is a code that tells the ALU what task to do. For example, it might say "add these numbers." The ALU then gives back a result.

AluStatusRegister.svg
AluStatusRegister.svg

The ALU also sends out status signals. These signals give extra info about the result. A "carry-out" signal shows if a number was carried over during math. A "zero" signal shows if the answer is zero. It can also show if a number is negative or too big.

Some ALUs can do more tasks. They can shift bits left or right. This is called a shift operation. They can also do logic tasks like AND or OR. This helps the computer make quick choices. The ALU is a building block for CPUs and GPUs.

181 words

An arithmetic logic unit, or ALU, is a vital part of a computer.

ALU block.svg
ALU block.svg
It is a digital circuit that does math and logic tasks. This unit works with integer binary numbers. It is different from a floating-point unit, which handles different types of numbers. You can find an ALU inside many computing circuits. It is a building block for a central processing unit (CPU). It is also found in graphics processing units (GPUs).
ALU data paths.svg
ALU data paths.svg

How does an ALU work? It needs a few things to start a task. First, it needs two numbers called operands. Second, it needs an opcode. An opcode is a code that tells the ALU which operation to perform. For example, the opcode might tell the ALU to add two numbers. The ALU then sends the result to an output.

74181aluschematic.svg
74181aluschematic.svg
This process happens when electrical signals move through the circuit. There is a tiny wait called a propagation delay. This is the time it takes for signals to move through the parts. The computer uses a clock signal to keep everything timed correctly.

An ALU can do many different jobs. It can perform basic math like adding or subtracting. It can also increment a number by one. Another job is decrementing a number by one. The ALU can also do bitwise logic operations. These include tasks like AND, OR, and XOR.

Rotate left logically.svg
Rotate left logically.svg
It can even shift bits left or right. Some complex ALUs use something called a barrel shifter. This lets them shift many bits all at once. This variety makes the ALU very useful for all kinds of math.

Sometimes, the ALU gives extra information about its work. These are called status outputs. A carry-out signal shows if a number was carried over. A zero signal shows if the result is zero. The ALU can also show if a number is negative. It can show if a result is too big, which is called an overflow.

AluStatusRegister.svg
AluStatusRegister.svg
It can also show parity, which tells if there is an even or odd number of bits. These signals help the computer make decisions. They are often stored in a status register for later use.

An ALU can also help work with very large numbers. This is called multiple-precision arithmetic. An ALU might only be 8 bits wide. To handle a 24-bit number, it breaks it into three smaller pieces. The ALU works on one piece at a time. It uses the carry-out bit from one piece to help with the next piece. This allows a small circuit to solve very large math problems. It is a clever way to use simple parts for big jobs.

445 words

An arithmetic logic unit, or ALU, is a fundamental digital circuit in modern computing.

ALU block.svg
ALU block.svg
It is a combinational circuit designed to perform arithmetic and bitwise operations on integer binary numbers. This makes it a primary building block for many types of processors. You will find ALUs inside central processing units (CPUs) and graphics processing units (GPUs). While an ALU handles integers, other units called floating-point units (FPUs) are used for different types of numbers. The ALU is essentially the mathematical engine of the computer.

To function, the ALU requires specific inputs to determine its task. These inputs include operands, which are the actual data values being processed. The ALU also receives an opcode, or operation code. The opcode is an enumerated value that tells the ALU which specific operation to perform. The size of the opcode bus determines how many different operations the unit can handle. For example, a four-bit opcode allows for up to sixteen distinct operations.

74181aluschematic.svg
74181aluschematic.svg
The final result of the operation is then sent to an output bus.

ALU data paths.svg
ALU data paths.svg
The physical movement of data happens through electrical conductors called nets. These nets form data buses, which are groups of signals that carry binary integers. A standard ALU typically uses three parallel data buses: two for the input operands, known as A and B, and one for the result, known as Y. Usually, the width of these buses matches the native word size of the processor. The ALU is a combinational logic circuit, meaning its outputs change in response to input changes. There is a brief period called propagation delay, which is the time required for signals to move through the circuitry. To manage this, external circuitry uses a clock signal to ensure signals are stable before they are sampled.

An ALU supports a wide variety of arithmetic functions. It can perform basic addition of two operands, A and B. It can also perform "add with carry," where a carry-in bit from a previous operation is included in the sum. Subtraction is another core function, which can also act as a way to compare the magnitude of two numbers. The ALU can also perform two's complement to find the negative of a number. Other arithmetic tasks include incrementing a value by one or decrementing it by one. These operations allow the processor to handle almost any basic mathematical requirement.

Beyond math, the ALU performs bitwise logical operations. These include AND, OR, and exclusive-OR (XOR) operations. These functions allow the computer to test specific bits within a number. The ALU can also perform bit shift operations. In a shift, the bits in an operand move left or right. Simple ALUs shift by only one bit at a time. However, more complex units use a barrel shifter to move an arbitrary number of bits in a single operation.

Rotate left logically.svg
Rotate left logically.svg
Different types of shifts exist, such as arithmetic shifts, logical shifts, and rotations. In a rotation, the bits are treated like a circular buffer where the ends meet.

AluStatusRegister.svg
AluStatusRegister.svg
When an operation finishes, the ALU provides supplemental information through status outputs. These signals describe the nature of the result. A carry-out signal indicates a carry from addition or a borrow from subtraction. A zero signal indicates the result is entirely composed of logic zeros. The negative signal shows if a result is negative, while the overflow signal indicates a result has exceeded the numeric range of the output bus. Parity signals indicate if there is an even or odd number of bits set to one. These status bits are often stored in a status register, also called a condition code register, to help the computer make decisions during conditional branching.

One of the most important uses of these status signals is in multiple-precision arithmetic. This is an algorithm used when a number is larger than the ALU's word size. For instance, an 8-bit ALU can process a 24-bit integer by breaking it into three 8-bit fragments. The ALU operates on the least-significant fragments first. It then uses the carry-out bit from that operation as a carry-in for the next fragment. By repeating this process for every piece, the ALU can successfully calculate much larger numbers than its physical size would normally allow. This connection between small circuits and large-scale math is a key part of how computers function.

724 words
🖼️ Images & Media (11)
File:ALU block.svg
ALU block.svg
File:74181aluschematic.svg
74181aluschematic.svg
File:Rotate left logically.svg
Rotate left logically.svg
File:Rotate right logically.svg
Rotate right logically.svg
File:Rotate right through carry.svg
Rotate right through carry.svg
File:Rotate left through carry.svg
Rotate left through carry.svg
File:Rotate left.svg
Rotate left.svg
File:Rotate right.svg
Rotate right.svg
File:Rotate right arithmetically.svg
Rotate right arithmetically.svg
File:AluStatusRegister.svg
AluStatusRegister.svg
File:ALU data paths.svg
ALU data paths.svg
Up Next
💻
Processor (computing)
Technology
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.