Basic Arithmetic Logic Unit (ALU) Circuitry

One of the primary functions performed by a computer is mathematics. Even functions like graphics and sorting data are mathematics - because everything on a computer is represented by digital data. This article describes the digital logic circuits used to perform binary addition and subtraction.

Half adder circuit


The circuit shown above and its accompanying logic diagram performs the function of adding two one-bit binary numbers. The output of the circuit provides the sum along with a possible carry. When adding higher-bit binary numbers however, provisions for a carry-in from a previous stage must be provided. For this reason, this circuit is called a "half-adder".

Full adder circuit

In the circuit shown above, a second stage has been added to accept a carry-in from a previous stage. The carry-out of this circuit is created by ORing the carry bits of both stages. This circuit is called a "full-adder".


Logic diagram of the full adder.

Adder circuit

To simplify circuit diagrams we could indicate a full adder using a simple box labeled with the circuit's function and with its inputs and outputs labeled.

Eight-bit binary adder

By connecting eight full-adder circuits together, each circuit's carry-out output to the carry-in input of the next circuit, we can construct an eight-bit binary adder.

Exclusive OR gate


Shown above is an exclusive OR (XOR) gate and it's logic table, except this time we labeled one of its inputs Control. Note that when the control input is low (binary 0), the output is the same as the binary value on the A input. When the control input is high (binary 1), the output is the inverted value of the A input. What we have here is a controllable inverter. In other words with 0 on control, the input passes though unchanged, with 1 on control, we have an inverter.

Arithmetic Logic Unit

As previously described, in binary mathematics, subtracting a number is accomplished by instead adding the two's complement of the number. In the circuit shown above we run every bit of the second number of a binary math operation through a controllable inverter. If we wish to add the two numbers, we put 0 on the control line. If we wish to subtract the second number we put 1 on the control line. (In actual operation we would need to add 1 to the inverted number before adding).

This article describes some of the logic circuits used to create the Arithmetic Logic Unit (ALU) of a microprocessor.

More Computer Architecture Articles:
• Data Structures - Linked List, Stack, Queue, and Tree
• The AMD Athlon 64 Processor
• Microcontrollers
• How Computer Chips are Made
• Round-Robin CPU Scheduling Algorithm
• Microprocessor Counter, Clock, Timer Circuits
• The Fetch, Decode, Execute Cycle
• The Evolution of Hard Disk Bit Recording
• Introduction to Boolean Algebra
• Dynamic Loading of Program Routines and Dynamically linked libraries (DLLs)