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.
We can also express our logic gates using boolean algebra.
In this lesson, we’ll learn about:
Truth tables are used to show the outputs of logic gates and logic circuits (where more than one logic gate is combined).
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), you can have the following combinations: 00, 01, 10 & 11.
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.
We have seen how a NOT gate is represented as a logic diagram.
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 X | Output Q |
---|---|
1 | 0 |
0 | 1 |
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 want to write this as a Boolean expression, we can write it as:
Q = NOT X
We have seen that an AND circuit is two switches one after the other. Only if BOTH switches are shut will the light go on.
If the light is ON, we have an output of 1.
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.
To build a truth table, you need to write down all of the input combinations 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 X | Input Y | Output Q |
---|---|---|
1 | 1 | |
1 | 0 | |
0 | 1 | |
0 | 0 |
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, the output is 0.
Input X | Input Y | Output Q |
---|---|---|
1 | 1 | 1 |
1 | 0 | 0 |
0 | 1 | 0 |
0 | 0 | 0 |
If we want to write this as a Boolean expression, we can write it as:
Q = X AND Y
We have seen that an OR circuit is two switches in parallel.
If ONE of the switches is closed, the light will go on.
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 X | Input Y | Output Q |
---|---|---|
1 | 1 | |
1 | 0 | |
0 | 1 | |
0 | 0 |
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, the output is 0.
Input X | Input Y | Output Q |
---|---|---|
1 | 1 | 1 |
1 | 0 | 1 |
0 | 1 | 1 |
0 | 0 | 0 |
If we want to write this as a Boolean expression, we can write it as:
Q = X OR Y
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.
The output of an XOR truth table is 1 when one, but not both, inputs are 1, otherwise it is 0.