Logic Gate
Logic Gate
356
10.1 Standard logic gate symbols
Truth tables
Truth tables are used to trace the output from a logic gate or logic circuit. The
NOT gate is the only logic gate with one input; the other five gates have two
inputs (see Figure 10.1).
Although each logic gate can only have one or two inputs, the number of
inputs to a logic circuit can be more than 2; for example, three inputs give a
possible 23 (=8) binary combinations. And for four inputs, the number of possible
binary combinations is 24 (=16). It is clear that the number of possible binary
combinations is a multiple of the number 2 in every case. The possible inputs in
a truth table can be summarised as shown in Table 10.1.
W Table 10.1 All possible inputs for truth tables with two, three and four inputs
357
10 BOOLEAN LOGIC
As we can see, a truth table will also list the output for every possible
combination of inputs.
V Figure 10.2 The output, X, is 1 if: Input Output X = NOT A (logic notation)
A X —
the input, A, is 0 X = A (Boolean algebra)
0 1
1 0
0 0 0
both inputs, A and B, are 1 X = A . B (Boolean algebra)
0 1 0
1 0 0
1 1 1
10.2.3 OR gate
Description: Truth table: How to write this:
A
X
B W Table 10.4
either input, A or B, or 0 0 0
both, are 1 0 1 1 X = A + B (Boolean algebra)
1 0 1
1 1 1
358
10.2 The function of the six logic gates
Activity 10.1
Show why X = (A AND NOT B) OR (NOT A AND B)
and
Y = (A OR B) AND (NOT (A AND B)) both represent the same logic gate.
359
10 BOOLEAN LOGIC
You will notice in the Boolean algebra, three new symbols; these have the
following meaning:
» . represents the AND operation
» + represents the OR operation
» a bar (above the letter or letters, e.g. a) represents the NOT operation.
Example 1
Produce a truth table for the following logic circuit (note the use of black circles at the
junctions between wires):
A
B P
Q X
V Figure 10.8
There are three inputs to this logic circuit, therefore, there will be eight possible
binary values that can be input.
To show stepwise how the truth table is produced, the logic circuit has been split up
into three parts, as shown by the dotted lines, and intermediate values are shown as
P, Q and R.
360
10.3 Logic circuits, logic expressions, truth tables and problem statements
A
Part 1
P This is the first part of the logic circuit; the first task is to find the intermediate values
B
P and Q.
The value of P is found from the AND gate where the inputs are A and B. The value
of Q is found from the NOR gate where the inputs are B and C. An intermediate truth
table is produced using the logic function descriptions in Section 10.2.
W Table 10.8
Q
C
input values Output values
V Figure 10.9 A B C P Q
0 0 0 0 1
0 0 1 0 0
0 1 0 0 0
0 1 1 0 0
1 0 0 0 1
1 0 1 0 0
1 1 0 1 0
1 1 1 1 0
Part 2
The second part of the logic circuit has P and Q as inputs and the intermediate
P output, R:
R
Q
This produces the following intermediate truth table. (Note: even though there are
V Figure 10.10 only two inputs to the logic gate, we have generated eight binary values in part 1 and
these must all be used in this second truth table).
W Table 10.9
Inputs Output
P Q R
0 1 1
0 0 0
0 0 0
0 0 0
0 1 1
0 0 0
1 0 1
1 0 1
361
10 BOOLEAN LOGIC
Part 3
The final part of the logic circuit has R and C as inputs and the final
R output, X:
X
C This gives the third intermediate truth table:
V Figure 10.11 W Table 10.10
Inputs Output
R C X
1 0 1
0 1 1
0 0 0
0 1 1
1 0 1
0 1 1
1 0 1
1 1 0
Putting all three intermediate truth tables together produces the final truth table,
which represents the original logic circuit:
W Table 10.11
The intermediate values can be left out of the final truth table, but it is good practice
to leave them in until you become confident about producing the truth tables. The final
truth table would then look like this:
W Table 10.12
362
10.3 Logic circuits, logic expressions, truth tables and problem statements
Example 2
Write logic expressions from the following logic circuits:
a Logic gate 1
A
Logic gate 3
X
B
C Logic gate 2
V Figure 10.12
The first action is to look at the gates connected to the inputs A, B and C:
logic gate 1: (A AND B)
logic gate 2: (B OR C)
We then join these together using logic gate 3:
[(A AND B)] XOR [(B OR C)] which gives us the required logic expression.
(Note: the square brackets “[ ]” in the expression are not necessary and are used here
just for clarity.)
This would be written as: (A AND B) XOR (B OR C)
b
A
Logic gate 3
Logic gate 1
Logic gate 4
B
X
Logic gate 2
V Figure 10.13
363
10 BOOLEAN LOGIC
Again, we will do this in the order of logic gates 1 and 2 first (connected to the three
inputs):
logic gate 1: (A NAND C)
logic gate 2: (B AND C)
However, logic gate 3 is also connected to one of the inputs so that should be done next:
logic gate 3: (logic gate 1) NOR A
If we replace (logic gate 1) by the logic expression above, we get:
((A NAND C) NOR A)
Finally, we can join all these together using:
logic gate 4: ((A NAND C) NOR A) OR (B AND C)
Activity 10.2
1 Produce truth tables from the following logic circuits:
a A
V Figure 10.14
b A
V Figure 10.15
c A
B
V Figure 10.16
364
10.3 Logic circuits, logic expressions, truth tables and problem statements
d A
B
V Figure 10.17
e A
B
V Figure 10.18
2 Write logic expressions for the following logic circuits:
a A
X
B
C
V Figure 10.19
365
10 BOOLEAN LOGIC
B
C
V Figure 10.20
Example 3
A logic circuit can be represented by the following logic expression: (A XOR C) OR
(NOT C NAND B)
Produce a logic circuit and a truth table from the above statement.
In this example we have a connecting logic gate which is OR.
So, if we produce one half of the circuit from (A XOR C) we get:
C
V Figure 10.21
The other half of the circuit is found from (NOT C NAND B):
B
V Figure 10.22
366
10.3 Logic circuits, logic expressions, truth tables and problem statements
Output (X)
B Stage ‘R’
Stage ‘Q’
C
V Figure 10.23
The truth table is shown:
W Table 10.13
Input values Values at stages: Output
A B C ‘P’ ‘Q’ ‘R’ X
0 0 0 0 1 1 1
0 0 1 1 0 1 1
0 1 0 0 1 0 0
0 1 1 1 0 1 1
1 0 0 1 1 1 1
1 0 1 0 0 1 1
1 1 0 1 1 0 1
1 1 1 0 0 1 1
Example 4
Look at the two truth tables below; in each case produce a logic expression and the
corresponding logic circuit:
a
W Table 10.14
V Figure 10.24
367
10 BOOLEAN LOGIC
b
This time we have two rows where the output is 1;
W Table 10.15
this gives the following logical expressions:
Inputs Output (NOT A AND B)
A B X
0 0 0
(A AND B)
0 1 1 We now join these together using an OR gate to give:
1 0 0
(NOT A AND B) OR (A AND B)
1 1 1
V Figure 10.25
Example 5
a Which Boolean expression is represented by the following truth table?
W Table 10.16
If we now join the four expressions with an OR gate we end up with the
following logic expression:
369
10 BOOLEAN LOGIC
Activity 10.3
1 Produce:
i a truth table
ii a logic circuit
from the following logic expression:
(NOT A AND B) AND (NOT B OR C)
2 Produce:
i a truth table
ii a logic circuit
from the following logic expression:
(A XOR B) OR ((B NOR C) AND B) A B X
0 0 1
3 Produce:
0 1 0
i a logic expression
1 0 0
ii a logic circuit
1 1 1
from the following truth table:
4 Write down a logic expression for each of the following truth tables:
a b
A B C X A B C X
0 0 0 1 0 0 0 0
0 0 1 0 0 0 1 1
0 1 0 0 0 1 0 1
0 1 1 0 0 1 1 0
1 0 0 1 1 0 0 1
1 0 1 1 1 0 1 1
1 1 0 0 1 1 0 0
1 1 1 0 1 1 1 0
b Show that the following logic expression produces the same output as your
answer to part a above:
(NOT A AND NOT B) OR (A AND NOT B)
370
10.3 Logic circuits, logic expressions, truth tables and problem statements
Example 6
A safety system uses three inputs to a logic circuit. An alarm, X, sounds if input A
represents ON and input B represents OFF; or if input B represents ON and input C
represents OFF.
Produce a logic circuit and truth table to show the conditions that cause the output X to be 1.
The first thing to do is to write down the logic statement representing the scenario
in this example. To do this, it is necessary to recall that ON = 1 and OFF = 0 and also
that 0 is usually considered to be NOT 1.
So we get the following logic expression:
(A AND NOT B) OR (B AND NOT C)
(A . — —)
B ) + (B . C
The logic circuit is made up of two parts as shown in the logic expression. We will produce
the logic gate for the first second part. Then join both parts together with the OR gate.
A B
B C
Part 1 Part 2
V Figure 10.26
Now combining both parts with the OR gate gives us:
A
Part 1
B X
Part 2
V Figure 10.27
In order to produce the truth table, there are two ways to do this:
» trace through the logic circuit using the method described in example 1 (Section 10.3)
» produce the truth table using the original logic expression; this second method
has the advantage that it allows you to check that your logic circuit is correct.
371
10 BOOLEAN LOGIC
(Note: it is optional whether to leave in the intermediate values or simply remove them
giving a 4-column truth table with headings: A, B, C, X)
Example 7
A wind turbine has a safety system which uses three inputs to a logic circuit. A certain
combination of conditions results in an output, X, from the logic circuit being equal to 1.
When the value of X = 1 then the wind turbine is shut down.
The following table shows which parameters are being monitored and form the three
inputs to the logic circuit.
W Table 10.20
The output, X, will have a value of 1 if any of the following combination of conditions occur:
Either turbine speed <= 1000 rpm and bearing temperature > 80°C
Or turbine speed > 1000 rpm and wind velocity > 120 kph
Or bearing temperature <= 80°C and wind velocity > 120 kph
Design the logic circuit and complete the truth table to produce a value of X = 1 when
either of the three conditions above occur.
In this example, a real situation is given and it is necessary to convert the information
into a logic expression and then produce the logic circuit and truth table. It is
advisable in problems as complex as this to produce the logic circuit and truth table
separately (based on the conditions given) and then check them against each other to
see if there are any errors.
372
10.3 Logic circuits, logic expressions, truth tables and problem statements
Stage 1
The first thing to do is to convert each of the three statements into logic expressions.
Use the information given in the table and the three condition statements to find how
the three parameters S, T and W are linked. We usually look for the key words AND,
OR and NOT when converting actual statements into logic.
We end up with the following three logic expressions:
i turbine speed <= 1000 rpm and bearing temperature > 80°C
logic expression: (NOT S AND T)
ii turbine speed > 1000 rpm and wind velocity > 120 kph
logic expression: (S AND W)
iii bearing temperature <= 80°C and wind velocity > 120 kph
logic expression: (NOT T AND W)
Stage 2
This now produces three intermediate logic circuits:
i
S
V Figure 10.28
ii S
W
V Figure 10.29
iii
T
V Figure 10.30
Each of the three original statements were joined together by the word ‘OR’. Thus,
we need to join all of the three intermediate logic circuits by two OR gates to get the
final logic circuit.
We will start by joining i and ii together using an OR gate:
V Figure 10.31
373
10 BOOLEAN LOGIC
Finally, we connect the logic circuit in Figure 10.31 to Figure 10.30 to obtain the
answer:
V Figure 10.32
The final part is to produce the truth table. We will do this using the original logic
statement. This method has the bonus of allowing an extra check to be made on the
logic circuit in Figure 10.32 to see whether or not it is correct. It is possible, however,
to produce the truth table straight from the logic circuit in Figure 10.32.
There were three parts to the problem, so the truth table will first evaluate each part.
Then, by applying OR gates, as shown below, the final value, X, is obtained:
i (NOT S AND T)
ii (S AND W)
iii (NOT T AND W)
We find the outputs from parts (i) and (ii) and then OR these two outputs together to
obtain a new intermediate, which we will now label part (iv).
We then OR parts (iii) and (iv) together to get the value of X.
374
10.3 Logic circuits, logic expressions, truth tables and problem statements
Example 8
Consider the logic statement:
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Output Q
X
B
Output P
Output R
C
V Figure 10.33
375
10 BOOLEAN LOGIC
We can then fill out the truth table in stages, starting with P, Q and then R, followed
finally by X:
Input Values Working Space
Output
Q = (A OR R = (P AND C)
A B C P = (A NOR B) X
NOT B)
0 0 0 1 1 0 1
0 0 1 1 1 1 0
0 1 0 0 0 0 1
0 1 1 0 0 0 1
1 0 0 0 1 0 1
1 0 1 0 1 0 1
1 1 0 0 1 0 1
1 1 1 0 1 0 1
376
10.3 Logic circuits, logic expressions, truth tables and problem statements
3 Produce the logic circuit and complete a truth table to represent the following
scenario.
A power station has a safety system controlled by a logic circuit. Three inputs
to the logic circuit determine whether the output, S, is 1. When S = 1 the power
station shuts down.
The following table describes the conditions being monitored.
377