Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 11 of 9361. Foundations of Digital Logic and Computer ArchitectureFree lesson

Arithmetic Logic with Adders and Subtractors

You will construct half and full adders to perform binary arithmetic and cascade them to create multi-bit ripple carry adders.

In this lesson, you will learn how to harness basic logic gates to perform binary addition, the fundamental operation behind all computer calculations.

The Half Adder: Adding Two Bits

When we add two single binary digits (bits), we encounter two possible outcomes: the sum and a carry-out. For example, 1 + 1 equals 0 with a carry of 1.

A Half Adder takes two inputs, A and B, and produces two outputs: Sum (S) and Carry (C). Using the logic gates we’ve mastered:

  • Sum is an XOR operation: S = A ⊕ B
  • Carry is an AND operation: C = A · B

This works for the first column of an addition, but what about columns further to the left that need to include a carry from a previous step?

The Full Adder: Incorporating the Carry

To handle three inputs (bit A, bit B, and an incoming carry Cin), we use a Full Adder. This is essentially two Half Adders joined together. It calculates the sum of three bits, resulting in:

  • Sum = A ⊕ B ⊕ Cin
  • CarryOut = (A · B) + (Cin · (A ⊕ B))

The Ripple Carry Adder

To add multi-bit numbers—like two 4-bit integers—we "cascade" these adders. We connect the CarryOut of one Full Adder to the CarryIn of the next.

       C3      C2      C1      C0 (Cin)
       |       |       |       |
[FA3]--[FA2]--[FA1]--[FA0]

This is called a Ripple Carry Adder. It is intuitive but has a physical limitation: the carry signal must "ripple" through every stage before the final sum is accurate. If you want to subtract, we use a trick: by inverting the bits of the second number (using NOT gates) and setting the initial CarryIn to 1, we can turn our adder into a subtractor using two's complement arithmetic!

Key Takeaway: By cascading Full Adders, we create a Ripple Carry Adder that can process multi-bit numbers, forming the arithmetic backbone of your computer's processor.