In our previous lessons, we looked at how individual gates like NAND and XOR work. We also learned how to count in binary. Now, we are going to combine those two ideas.
Think of logic gates as the building blocks of a brain. On their own, they just respond to high or low voltages. But when we wire them together in specific ways, they can perform math just like a calculator. In this lesson, we will build a circuit that can add numbers together. This is the first step toward building a central processing unit (CPU).
Before we build the circuit, we need to remember the four basic rules of adding single bits. In binary, addition looks very similar to the math you learned in school, but it is much simpler because there are only two digits: 0 and 1.
To turn these rules into a circuit, we need two outputs. Let's look at the Sum () column in the table above. The Sum is 1 only when the inputs are different ( or ). This is exactly how an XOR gate behaves!
Now look at the Carry () column. The is only when both inputs are . This is the behavior of an gate.
In real computers, we add long strings of numbers. When you add the second column of a math problem, you often have to include a carry from the first column.
A Full Adder handles three inputs instead of two:
Input A: The first bit.Input B: The second bit.Carry In(): The carry bit from the previous addition.
By adding this third input, we can chain many adders together to add very large numbers. The logic gets slightly more complex, but the goal is the same: produce one Sum output and one Carry Out () output.
To build a Full Adder, we combine two stages of logic. Let's look at how the circuit you will work with is organized:
1. Finding the Sum ()
The Sum is calculated by checking if the total number of 1 inputs is odd. We use two XOR gates for this.
- The first
XORgate comparesAandB. - The second
XORgate compares that result with .
In this lesson, we moved from simple logic gates to a functional math circuit. You learned that:
Binaryaddition follows four simple rules.- An
XORgate is the primary tool for calculating aSum. - A
Full Adderuses aCarry In() to allow for multi-bit addition.
Now it is time to put this into practice. In the next section, you will go into the CodeSignal Logic simulator to wire these gates together. You will follow a provided design to create a working 1-bit Full Adder that takes three inputs and produces the correct Sum and Carry bits. Pay close attention to how the signals flow from the inputs through the and gates to reach the final outputs!


