Back

Logic gate diagrams and truth tables

Introduction
We have seen how logic gates work and how to represent them on paper. Now we can start to putting the logic gates together, to build complex logic diagrams. We can also see how truth tables are an invaluable tool when trying to understand what a logic diagram does. When presented with any logic diagram, you should always construct a truth table, that spells out exactly what the output is after every gate. That way, you will be able to work out what the final output will be for all the different permutations of inputs.

Example 1
Consider this logic diagram:

ANDNOT

What is the output? The output from the AND gate is true when both A and B are true. Otherwise, the output is false. This then feeds into the NOT gate. If the input into the NOT gate is false, the output C is true. If the input to the NOT gate is true, the output C is false.

Now this is starting to get complicated and we only have two logic gates! Imaging if we had hundreds connected together. This is where truth tables become invaluable. Rather than trying to work out what is going on in a logic diagram in one go, and trying to keep track of what is happening in our heads, we can use truth tables to help, working out the logic at each stage in the diagram.

ANDNOTTT

First of all, we work out the output for the AND gate from the combinations of inputs. We create a column for the results. We feed these results into our NOT gate, producing yet another column for these results. We now have a complete truth table, which we can use to predict the output for any combination of inputs.

Example 2
Consider this logic diagram:

NOTNOTAND

What is the final output, C? We could try to work it out in our heads, although it is easy to get quickly confused. It would be better to produce a truth table of the diagram. That way, we can consider each part of the diagram in steps.

NOTNOTANDTT

We can look at Input A and then do NOT A. We can then look at Input B and do NOT B. We can then use the columns for NOT A and NOT B to do the AND gate. This is the final output for this logic diagram.

Example 3
Consider this more complex logic diagram:

AONA

Trying to work out what will happen for all of the different permutations without using a truth table will be difficult. When you do use a truth table, however, it all becomes much easier. Notice this time, however, that both Input A and Input B are fed into two different logic gates at the start of the diagram on the left. It doesn't make any difference to producing the truth table. We just do the logic for each gate in turn as before.

AONATT

Example 4
Consider this even more complex logic diagram:

XOR

By using truth tables, we can see what the output is for every permutation of inputs:

XORTT

You may have noticed that in Example 3 and Example 4, the outputs were the same for whatever combination of inputs was fed in. The difference here is what logic gates were used to create the logic diagram. It is entirely possible to create the same outputs for the given inputs by using different combinations of logic gates.

Example 5
Suppose we have a diagram with three inputs. With three inputs, there are a possible eight different combinations of ones and zeros that could be entered into the logic diagram. Here is diagram that we need to produce a truth table for:

3inputs

The procedure is exactly the same. Firstly, we will work out the number of possible combinations of inputs of A, B and C, which we have already said is eight. Then we will work out the logic after each gate, and build up our truth table until we get to the final output. Our final truth table will look like this:

3inputstruth

Back