Logic Gates (Word Problems)
Logic Gates (Word Problems)
Syllabus Content:
1.3.3 Logic gates and logic circuits
use the following logic gate symbols
understand and defi ne the functions of NOT, AND, OR, NAND, NOR and XOR
(EOR) gates including the binary output produced from all the possible binary
inputs (all gates, except the NOT gate, will have two inputs only)
construct the truth table for each of the logic gates above
construct a logic circuit from either:
o – a problem statement
o – a logic expression
o -- a truth table
construct a truth table from either:
o – a logic circuit
o – a problem statement
o – a logic expression
Construct a logic expression from:
o – a logic circuit
o – a problem statement
o – a truth table
Several logic gates combined together form a LOGIC CIRCUIT and these circuits are
designed to carry out a specific function. The checking of the output from a logic gate or
logic circuit is done using a TRUTH TABLE.
1
3.2 Logic gates & Logic circuits
This chapter will consider the function and role of logic gates, logic circuits and truth
tables. Also a number of possible applications of logic circuits will be considered.
A reference to BOOLEAN ALGEBRA will be made throughout the chapter.
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.
When constructing truth tables, all possible combinations of 1s and 0s which can be
input are considered. For the NOT gate (one input) there are only 21 (2) possible binary
combinations.
For all other gates (two inputs), there are 22 (4) possible binary combinations.
2
3.2 Logic gates & Logic circuits
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.
3
3.2 Logic gates & Logic circuits
• Boolean Algebra
A Boolean Variable takes the value of either 0 (False) or 1 (True).
Symbols are used to represent Boolean variables e.g. A, B, C, X, Y, Z
There are three basic logic operations AND, OR, NOT
The Boolean Operators are • + ‾
▪ A + B means A OR B
▪ A • B means A AND B
▪ A means NOT A
Nodes in a circuit are represented by Boolean Variables
4
3.2 Logic gates & Logic circuits
NOT gate
A X
X = NOT A
X=A
AND gate
X
NAND gate
X
5
3.2 Logic gates & Logic circuits
OR gate
X
X = A OR B (logic notation)
X = A + B (Boolean algebra)
NOR gate
X
Input A Input B Output X
0 0 1
0 1 0
1 0 0
1 1 0
X = A + B (Boolean algebra)
XOR gate
X
Input A Input B Output X
0 0 0
0 1 1
1 0 1
1 1 0
X = A XOR B (logic notation)
6
3.2 Logic gates & Logic circuits
X = A . B + A . B (Boolean algebra)
Logic circuits:
When logic gates are combined together to carry out a particular function, such as
controlling a robot, they form a logic circuit. The output from the logic circuit is checked
using a truth table.
There now follows three examples which show:
how to produce a truth table
how to design a logic circuit from a given logic statement/Boolean algebra
how to design a logic circuit to carry out an actual safety function.
Example 1
Produce a truth table for the following logic circuit (note the use of • at junctions):
There are three inputs to this logic circuit, therefore there will be eight possible binary
values which can be input.
To show step-wise how the truth table is produced, the logic circuit has been split up
into three parts and intermediate values are shown as P, Q and R.
7
3.2 Logic gates & Logic circuits
The truth table for the logic circuit will look like this:
Example 2:
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 which 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 statement:
The logic circuit is made up of three parts as shown in the logic statement.
8
3.2 Logic gates & Logic circuits
We will produce the logic gate for the first part and the third part. Then join both parts
together with the OR gate.
9
3.2 Logic gates & Logic circuits
Example 3:
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.
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
any of the three conditions above occur.
This is a different type of problem to those covered in Examples 1 and 2. This time a
real situation is given and it is necessary to convert the information into a logic
statement and then produce the logic circuit and truth table.
Stage 1:
The first thing to do is to convert each of the three statements into logic statements. 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 statements:
10
3.2 Logic gates & Logic circuits
1. turbine speed <= 1000 rpm and bearing temperature > 80°C
logic statement: (S = NOT 1 AND T = 1)
2. turbine speed > 1000 rpm and wind velocity > 120 kph
logic statement: (S = 1 AND W = 1)
3. bearing temperature <= 80°C and wind velocity > 120 kph
logic statement: (T = NOT 1 AND W = 1)
11
3.2 Logic gates & Logic circuits
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 to see whether or not it is correct.
It is possible, however, to produce the truth table straight from the logic circuit. There
were three parts to the problem, so the truth table will first evaluate each part.
We find the outputs from parts (i) and (ii) and then OR these two outputs together to
obtain a new intermediate, which we will label part (iv). We then OR parts (iii) and (iv)
together to get the value of X.
NOTE: S=NOT 1 AND T=1 is the same as NOT S AND T i.e. ¬S٠T
T=NOT 1 AND W=1 is the same as ¬T٠W
12
3.2 Logic gates & Logic circuits
For example, the AND, OR, NOT and XOR gates can be built from these gates as
shown below:
13
3.2 Logic gates & Logic circuits
CLASSWORK:
Q.1 A system is monitored using sensors. The sensors output binary values corresponding to
physical conditions, as shown in the table:
The outputs of the sensors form the inputs to a logic circuit. The output
from the circuit, X, is 1 if any of the following three conditions occur:
either oil pressure >= 3 bar and
temperature >= 200°C
or oil pressure < 3 bar and rotation > 1000
rpm
or temperature >= 200°C and rotation >
1000 rpm
14
3.2 Logic gates & Logic circuits
15
3.2 Logic gates & Logic circuits
Q.2 (a) A student needs to design a logic circuit to model the requirements for membership of a
snooker club. Membership (X) depends on four criteria, as shown in the table:
16
3.2 Logic gates & Logic circuits
Q3. (a) An alarm system (X) is enabled and disabled using either a switch (A) or
a remote control (B). There are two infra-red sensors (C, D) and one door
pressure sensor (E).
The alarm sounds (X = 1) if the alarm is enabled and any one or more of
the sensors is activated.
Draw a logic circuit to represent the alarm system.
17
3.2 Logic gates & Logic circuits
References:
IGCSE Computer Science by Hodder Education.
Past papers.
http://electronics-course.com/logic-gates
18