Truth Tables

We have looked at how logic circuits can be drawn as diagrams with inputs and outputs. Another way of representing these is to draw a circuit as a truth table.

A truth table is a simple grid that shows each input and every possible output. We can use these to understand what our circuit is doing and they can be especially useful when we start combining logic gates.

We can also express our logic gates using boolean algebra, where we write down the logic of our gate as a boolean expression.

In this lesson, we’ll learn about:

  1. What truth tables are
  2. The truth table for a NOT gate
  3. The truth table for an AND gate
  4. The truth table for an OR gate
Media Attachments: Presentation

1. What Truth Tables Are

Truth tables are used to show the outputs of a logic gate and of logic circuits (where we combine more than one logic gate together).

We create them by drawing out a table with columns for each of the inputs and outputs in our logic circuit. The table also needs to have enough rows to represent every single possible combination of inputs.

For example, if you have two inputs (which are always binary numbers), then we can have the following combinations:

  • 0 0
  • 0 1
  • 1 0
  • 1 1

So we would need four rows in our truth table.

Truth tables become extremely important as we start designing larger circuits to help us be able to identify exactly what outputs are produced from these combinations of gates.

Further Thought

We often express boolean logic circuits using boolean algebra. Research what this is.

2. The Truth Table For a NOT Gate

We have seen how a NOT gate is represented as a logic diagram. This looks like figure 1 below.

a NOT Logic Gate
Figure 1 – a NOT Gate.

There is only ONE possible input – which can either be a 1 or a 0.

The way we draw this as a truth table is as follows:

Input XOutput Q
10
01

That’s all there is to it. If you input a 1, the output is a 0. If you input a 0, the output is a 1.

The truth table has ONE input that can have TWO POSSIBLE COMBINATIONS, so there are TWO rows in the truth table.

If we wanted to write this as a boolean expression, we can write this as Q = NOT X.

Further Thought

What would happen if you combined a NOT gate with an AND or OR gate?

3. The Truth Table For an AND Gate

We have seen that an AND circuit is two switches one after the other.

Only if  X AND Y are shut will the light go on.

a circuit with both switches closed.
Figure 2 – an AND circuit with both switches closed.

If the light is ON that means we have an output of 1.

We drew this as an AND gate in a logic diagram as shown in figure 3.

An AND Logic Gate
Figure 3 – an AND Logic Gate

For this truth table, we can see that we have two inputs, with two possible combinations, so we have FOUR rows in the truth table.

The way to build a truth table you need to write down all of the number of combinations of inputs that we can have. As we have two inputs of binary numbers, each of these can be a 1 or 0. So all of the combinations are as follows:

Input XInput YOutput Q
11
10
01
00

Once we’ve set up our truth table with our inputs, we can then write out our outputs. Remember, with an AND gate, we only get an output of 1 if BOTH inputs are 1. Otherwise, it outputs 0.

Input XInput YOutput Q
111
100
010
000

If we wanted to write this as a boolean expression, we can write this as Q = X AND Y.

Further Thought

How many rows would you have if you had 3 inputs?

4. The Truth Table For an OR Gate

We have seen that an OR circuit is two switches in parallel.

If X OR Y OR BOTH are closed, the light will go on.

an OR circuit with one switch closed and one switch open.
Figure 4 – an OR circuit with one switch closed and one switch open.

We drew this as an OR gate in a logic diagram as shown in figure 5.

An OR Logic Gate
Figure 5 – an OR Logic Gate

For this truth table we again need to write down all of the number of combinations of inputs that we can have. As it has two inputs it has the same combinations as we had for the AND gate.

Input XInput YOutput Q
11
10
01
00

Once we’ve set up our truth table with our inputs, we can then write out our outputs. Remember, with an OR gate, we get an output of 1 if ONE OR BOTH inputs are 1. Otherwise, it outputs 0.

Input XInput YOutput Q
111
101
011
000

If we wanted to write this as a boolean expression, we can write this as Q = X OR Y.

Further Thought

There is such a thing as an Exclusive OR gate. How does this differ to a standard OR gate?

Lesson Summary

So to summarise what we’ve learnt in this lesson:

  • Truth tables are ways of summarising the output of any input to a logic circuit.
  • When completing a truth table we should first identify all possible combinations of inputs.
  • The output of a NOT truth table is the opposite of the input.
  • The output of an AND truth table is 1 when both inputs are 1, otherwise it is 0.
  • The output of an OR truth table is 0 when both inputs are 0, otherwise it is 1.