15th of March, 2026

Logic Gates

Logical operations can be represented in physical form using logic gates. Logic gates are commonly constructed using transistors (these will be explained in the next chapter) and make up the Central Processing Unit (CPU). Multiple logic gates are combined into a circuit.

Addition

The previous chapter explains how the summing of two binary values works. We can represent this process using a circuit consisting of two types of logic gates. The process of addition requires comparing three bits. The first two bits are the bits of the values we are summing up. The third bit is the ‘carry bit’, which is the value carried by the previous addition. We can represent this operation using the circuit below:

This circuit is called a half-adder circuit and has the following associated truth table:

\(x\) \(y\) \(sum\) \(carry\)
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1

While this circuit works for summing two bits, it does not check for any incoming carry value from a previous addition. The more complex full-adder circuit allows for adding three bits together, one of which is the carry value from a previous addition. The full-adder circuit is constructed as follows:

Which has the following truth table:

\(x\) \(y\) \(carry_{in}\) \(sum\) \(carry\)
0 0 0 0 0
1 0 0 1 0
0 1 0 1 0
1 1 0 0 1
0 0 1 1 0
1 0 1 0 1
0 1 1 0 1
1 1 1 1 1

Try and run through the circuit for two or three input combinations to get a feeling for how this circuit works! The beauty of this circuit is that we can link \(n\) of these circuits after each other to perform the addition of an \(n\) bit binary number. The first circuit in the chain would be a half-adder, as initially there will be no carry value, followed by \(n - 1\) full-adder circuits. These would be linked up as follows:

This circuit can add two four-but numbers. Each circuit gets the input bits at its index, as well as the carry value from the previous addition. The final result is a four-bit number given by \(s_1\) to \(s_4\). An example calculation of this would be the following, where we add the numbers 0110 (6) and 0011 (3):

Which, correctly, results in 1001 (9). A small reminder, in case you forgot as I did while writing this, we add the bits going from right to left (same way we do this with the decimal system), and when retrieving the final sum we set the bits from left to right as well.

In This chapter we started with simple boolean logic, saw how this logic was used in logic gates, how logic gates linked together form circuits, and how these circuits can perform operations like addition. In the next chapter we will look into what parts a computer is made of, including the actual physical pieces which are used to build these logic gates and circuits!