Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
48 views35 pages

G3 Computing Textbook Chapter 03

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views35 pages

G3 Computing Textbook Chapter 03

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

CHAPTER

03 Logic Gates

52
53
54
3.1 Boolean Logic

In Computing, a Boolean value has only two


possible values: True and False. The study
of Boolean values, called Boolean logic, was
developed by the English mathematician
George Boole in 1847.

ER MS
KEY T
Boolean
A data type representing either True or
False

Georgle Boole

Boolean values are often used to determine the status of a system or a


0 1 logical condition such as whether one number is larger than another.
Besides True and False, Boolean values can be represented in other
ways as shown in Table 3.1.1.
False True
Boolean logic is very important as the data in a computer is stored
Off On as bits which have a value of either 0 or 1. From Table 3.1.1, we see
that 0 and 1 also correspond to the Boolean values of False and
True respectively. Hence, the data in a computer can be represented
Low High using Boolean values, and common operations such as addition,
subtraction, multiplication, and division are performed by the
computer’s processor using Boolean logic.
No Yes
The inputs and outputs of simple problems and decisions can each
be represented using a single bit or Boolean value as they are usually
Table 3.1.1 Ways of representing binary in nature. This means that there are only two possible options
the two Boolean values
for each input and output.

3.2 Truth Tables

ER MS
KEY T
We use a truth table to show the resulting
output for every possible combination of
inputs. Tables 3.2.1 to 3.2.3 show the truth
tables for logic gates with one, two and three Truth table
inputs respectively. Notice that there is only A table that shows the resulting output for every
one output column in the truth tables. This possible combination of inputs
is because we will be using these tables for
logic gates that have only one output.

55
Input A Output Input A Input B Input C Output

0 0 0 0

1 0 0 1
Table 3.2.1 Truth table for logic gate with one input
0 1 0

0 1 1
Input A Input B Output
1 0 0
0 0
1 0 1
0 1

1 0 1 1 0

1 1 1 1 1

Table 3.2.2 Truth table for logic gate with two inputs Table 3.2.3 Truth table for logic gate with three inputs

To construct a truth table, we need to:

1 Determine the number of rows in the truth table, which is equal to 2n, where n refers to the number
of inputs.
For example, if there are two inputs, the truth table will have 22 = 4 rows. If there are three inputs,
the truth table will have 23 = 8 rows.

2 Fill in the input columns in ascending order using the binary number system.
For example, in a three-input system, the inputs start from 000 in the first row, followed by 001 in
the second, 010 in the third and so on, up to 111 in the last row.

The output is determined by the type of logic gate, as described in the next section.

3.3 Logic Gates

LEARNING OUTCOMES
1.3.3 Draw symbols and construct truth tables for AND, OR, NOT, NAND, NOR and XOR logic gates.

ER MS
A logic gate is an electrical circuit KEY T
that performs logical operations
Logic gate
based on one or more inputs and
An electrical circuit that performs logical operations based on one
produces a single output.
or more inputs and produces a single output
In this section, you will learn
Logical operation
about the six basic types of logic
An operation that acts on binary inputs to produce an output
gates (AND, OR, NOT, NAND, NOR
according to the laws of Boolean logic
and XOR) as well as their functions
and applications.

56
3.3.1 AND Gate

The AND gate has two inputs and one output. The logic symbol and Boolean statement representing the
AND gate are shown in Table 3.3.1. Boolean statements are also known as logic statements.

Type Symbol Boolean statement

A
AND Q Q=A•B
B

Table 3.3.1 The AND gate

The AND gate performs the AND operation, which We can make use of declarative statements that are
gives an output of 1 only when both inputs are 1. either True (1) or False (0), to help us make sense
The truth table in Table 3.3.2 illustrates this. of Table 3.3.2. For example, to take part in a talent
show competition, applicants may be screened for
their ability to sing, and their ability to dance, as
illustrated in Table 3.3.3.

Input A Input B Output Q Can sing Can dance Can sing AND dance

0 0 0 False False False

0 1 0 False True False

1 0 0 True False False

1 1 1 True True True

Table 3.3.2 Truth table of the AND gate Table 3.3.3 Declarative statements using AND

3.3.2 OR Gate

The OR gate has two inputs and one output. The logic symbol and Boolean statement representing the OR
gate are shown in Table 3.3.4.

Type Symbol Boolean statement

A
OR Q Q=A+B
B

Table 3.3.4 The OR gate

57
The OR gate performs the OR operation, which gives an
output of 1 when at least one of its inputs is 1. The truth
table in Table 3.3.5 illustrates this.

Input A Input B Output Q

0 0 0

0 1 1

1 0 1

1 1 1

Table 3.3.5 Truth table of the OR gate

We can make use of declarative statements that are either True (1) or False (0), to help us make sense of
Table 3.3.5. For example, when installing an anti-burglary alarm, we may expect the alarm to be triggered
when either a window or a door has been forced open without the use of a key, as illustrated in Table 3.3.6.

Window is forced open Door is forced open Window OR door is forced open

False False False

False True True

True False True

True True True

Table 3.3.6 Declarative statements using OR

3.3.3 NOT Gate

The NOT gate has only one input and one output. The logic symbol and Boolean statement representing
the NOT gate are shown in Table 3.3.7.

Type Symbol Boolean statement

NOT A Q Q=A

Table 3.3.7 The NOT gate

The small circle at the output of the NOT gate symbol


represents an inversion. Input A Output Q

The NOT gate performs the NOT operation, which 0 1


inverts the input to its opposite state. Thus, it is also
known as the inverter gate. 1 0

The truth table in Table 3.3.8 illustrates this. Table 3.3.8 Truth table of the NOT gate

58
3.3.4 NAND Gate

The NAND gate has two inputs and one output. The logic symbol and Boolean statement representing the
NAND gate are shown in Table 3.3.9.

Type Symbol Boolean statement

A
NAND Q Q=A•B
B

Table 3.3.9 The NAND gate

The NAND gate performs the NAND operation, which gives an output of 0 only when both inputs are 1. The
truth table in Table 3.3.10 illustrates this.

Input A Input B Output Q

0 0 1

0 1 1

1 0 1

1 1 0

Table 3.3.10 Truth table of the NAND gate

An AND gate followed by a NOT gate is A A


equivalent to a NAND gate. Q Q
B B
Figure 3.1 An AND gate followed by a NOT gate is equivalent to a NAND gate

U
DID YO
?
KNO W Power (GND) Power (5V)
$
"##
$&
'()

Input A !
%&..

Input B
!
Output A• B
!
+,-
% *

Actual logic gates are usually very small and The above chip contains 4 NAND gates as shown in
made using different forms of silicon. The the accompanying diagram.
above photo shows a magnified NAND gate
found on a computer chip.

59
3.3.5 NOR Gate

The NOR gate has two inputs and one output. The logic symbol and Boolean statement representing the
NOR gate are shown in Table 3.3.11.

Type Symbol Boolean statement

A
NOR Q Q=A+B
B

Table 3.3.11 The NOR gate

The NOR gate performs the NOR operation, which gives an output of 0 when at least one of its inputs is 1.
The truth table in Table 3.3.12 illustrates this.

Input A Input B Output Q

0 0 1

0 1 0

1 0 0

1 1 0

Table 3.3.12 Truth table of the NOR gate

An OR gate followed by a NOT gate is A A


equivalent to a NOR gate. Q Q
B B
Figure 3.2 An OR gate followed by a NOT gate is equivalent to a NOR gate

3.3.6 XOR Gate

The XOR gate has two inputs and one output. The logic symbol and Boolean statement representing the
XOR gate are shown in Table 3.3.13.

Type Symbol Boolean statement

A
XOR Q Q=A B
B

Table 3.3.13 The XOR gate

60
The XOR gate performs the XOR operation, which gives
an output of 1 when exactly one of its inputs is 1. The
truth table in Table 3.3.14 illustrates this.

Input A Input B Output Q

0 0 0

0 1 1

1 0 1

1 1 0

Table 3.3.14 Truth table of the XOR gate

We can make use of declarative statements that are either True (1) or False (0), to help us make sense of
Table 3.3.14. For example, when ordering from a set lunch menu, the patron may be required to select
either coffee or tea, but not both, as the preferred choice of beverage. This is illustrated in Table 3.3.15.

Selects coffee Selects tea Selects coffee XOR tea

False False False

False True True

True False True

True True False

Table 3.3.15 Declarative statements using XOR

U
DID YO
?
K NOW
NAND, NOR and XOR mean “not and”, “not or” and “exclusive or” respectively.

Also, the XOR gate can be reconstructed using a combination of only AND,
OR and NOT gates as shown.

A
B A
Q Q
B

Hence, Q=A B=(A • B)+(A • B).

61
QUICK 3
C K 3.
CHE
1. State whether each of the statements below is true or false.
a) An OR gate returns an output of 1 when either input is 1.
b) An AND gate returns an output of 1 only when both its inputs are 1.
c) A NOT gate returns an output of 1 when its input is 1.

2. When using a NOR gate, which of the following conditions will return an output of 1?
a) Both inputs are 0
b) Both inputs are 1
c) One input is 1 and the other is 0
d) None of the above

3. When using a NAND gate, which of the following conditions will return an output of 0?
a) Both inputs are 0
b) Both inputs are 1
c) One input is 1 and the other is 0
d) None of the above

4. When using a XOR gate, which of the following conditions will return an output of 1?
a) Both inputs are 0
b) Both inputs are 1
c) One input is 1 and the other is 0
d) None of the above

5. Identify the logic gate described by each of the following truth tables:

a)
Input A Input B Output Q
0 0 0
0 1 1
1 0 1
1 1 1

b)
Input A Input B Output Q
0 0 0
0 1 1
1 0 1
1 1 0

c)
Input A Input B Output Q
0 0 1
0 1 1
1 0 1
1 1 0

62
3.4 Logic Circuits

LEARNING OUTCOMES
1.3.1 Represent logic circuits using either logic circuit diagrams or Boolean statements and
convert between the two representations.

1.3.2 Construct the truth table for a given logic circuit (maximum 3 inputs) and vice versa.

3.4.1 Logic Circuit Diagrams

ERMS
Logic gates are the basic building blocks of logic
circuits. A logic circuit can consist of only one logic
gate, but we can build more complex and useful logic
KEY T
circuits by connecting two or more logic gates together. Logic circuit
A logic circuit diagram shows how these logic gates A circuit that consists of only one logic
are connected. A logic circuit diagram is formed by gate or multiple connected logic gates
using symbols to represent logic gates and lines to
represent the wires connecting the inputs and outputs Logic circuit diagram
of the different logic gates together. A visual representation using symbols
to show how the component logic gates
In logic circuit diagrams, lines that cross each other are are connected together in a logic circuit
not connected unless the intersection point is marked
by a solid dot.

3.4.1.1 Intermediate Inputs

intermediate input
input
A D Output
B Q
C
Figure 3.3 Logic circuit with an intermediate input

Within a logic circuit, it is common for the output of a logic gate to be also the input of another logic gate.
In Figure 3.3, the output of the first OR gate is also one of the inputs of the second OR gate. In this textbook,
we will call these “intermediate inputs”.

The logic circuit in Figure 3.3 has three inputs (A, B and C), one intermediate input (D) and one output (Q).

63
3.4.1.2 Constructing Truth Tables from Logic Circuit Diagrams

To generate a truth table from a logic circuit diagram, follow these steps:

1 2 3 4
Determine the total number of Draw the Work out the Work out the
columns and rows in the truth table. truth table intermediate final output.
and fill in all inputs.
Number of columns = total number of the input
inputs, intermediate inputs, and output combinations.
Number of rows = 2n, where n is the
number of inputs.

A D Output
Consider the logic circuit in Figure
3.4. Let us use the steps above to B Q
generate its truth table. C

Figure 3.4 A logic circuit diagram

Determine the total number of columns and rows in the truth table.

Since there are three inputs (A, B and C), one output (Q) and one intermediate input
Step 1: (D):

Number of columns = total number of inputs, intermediate inputs, and output = 5


Number of rows = 23 = 8

Draw the truth table and fill in all the input combinations.

Intermediate
Input A Input B Input C Input D Output Q

0 0 0

0 0 1

0 1 0

0 1 1
Step 2:
1 0 0

1 0 1

1 1 0

1 1 1

Table 3.4.1 Filling in all the input combinations in the truth table

64
Work out the intermediate input.

Work out the intermediate input D using A and B

Intermediate
Input A Input B Input C Input D Output Q

0 0 0 0

0 0 1 0

Step 3: 0 1 0 0

0 1 1 0

1 0 0 0

1 0 1 0

1 1 0 1

1 1 1 1

Table 3.4.2 Filling in the column for intermediate input D

Work out the final output.

Work out the final output Q using C and D.

Intermediate
Input A Input B Input C Input D Output Q

0 0 0 0 0

0 0 1 0 1

0 1 0 0 0
Step 4: 0 1 1 0 1

1 0 0 0 0

1 0 1 0 1

1 1 0 1 1

1 1 1 1 1

Table 3.4.3 Filling in the column for the final output Q

65
3.4.2 Boolean Statements

Like a logic gate, a logic circuit can also be represented by a Boolean statement. Boolean statements are
useful in two ways:

1 They can be evaluated using truth tables to determine the output of a logic circuit.

2 They can determine the arrangement of the logic gates in a logic circuit.

3.4.2.1 Order of Operations

To evaluate a Boolean statement, the order of


operations must always be followed. Order Logical operation

In mathematics, you would have learnt about the 1 Parentheses


order of operations in evaluating algebraic equations.
For instance, in 1 + 2 × 3, the multiplication operation 2 NOT
is evaluated before the addition operation to give the
result of 7. A similar order applies when evaluating 3 AND
Boolean statements. The order of operations for
Boolean statements is summarised in Table 3.4.4. 4 OR

There is no standard order of operations for XOR.


Table 3.4.4 Order of operations for Boolean
Whenever there is significant ambiguity, parentheses statements
should be used to clarify the intended order of
operations.

3.4.2.2 Constructing Truth Tables from Boolean Statements

Consider the Boolean statement below:

Q=( A• B) +(A•C)
We can evaluate it by expressing all combinations of its inputs and output using a truth table.

Determine the total number of columns and rows in Order 1 Order 2


the truth table.

Since there are three inputs (A, B and C), one output
Q= ( A• B ) + ( A• C)
(Q) and two intermediate inputs Order 3
(( A•B) and ( A• C)):
Step 1: Figure 3.5 Evaluating a Boolean
Number of columns = total number of inputs, statement following the order of
operations
intermediate inputs, and output = 6
Number of rows = 23 = 8
Using the order of operations, the parts of the Boolean statement in parentheses are to
be evaluated first, followed by the part with the OR operation. This means that “A•B ”
as well as “A •C” are evaluated first, from left to right, since they are contained within
parentheses. They form the two intermediate inputs, D and E.

66
Draw the truth table and fill in all the input combinations.

Intermediate Intermediate
Input A Input B Input C Input D Input E Output Q
(A • B) (A • C)

0 0 0

0 0 1

0 1 0
Step 2:
0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

Table 3.4.5 Filling in the input combinations

Work out the intermediate inputs.

To work out the intermediate input D, use A and B.

To work out the intermediate input E, use A and C.

Intermediate Intermediate
Input A Input B Input C Input D Input E Output Q
(A • B) (A • C)

0 0 0 0 0

0 0 1 0 0
Step 3:
0 1 0 0 0

0 1 1 0 0

1 0 0 0 0

1 0 1 0 1

1 1 0 1 0

1 1 1 1 1

Table 3.4.6 Filling in the intermediate inputs D and E

67
Work out the final output.

To work out the final output Q, use D and E.

Intermediate Intermediate
Input A Input B Input C Input D Input E Output Q
(A • B) (A • C)

0 0 0 0 0 0

0 0 1 0 0 0

Step 4: 0 1 0 0 0 0

0 1 1 0 0 0

1 0 0 0 0 0

1 0 1 0 1 1

1 1 0 1 0 1

1 1 1 1 1 1

Table 3.4.7 Filling in the final output Q

3.4.2.3 Constructing Boolean Statements from Truth Tables

In the previous section, we learnt how to


construct a truth table from a Boolean Input A Input B Input C Output Q
statement. In many situations, it is also
useful to do the reverse, which is to 0 0 0 0
construct a Boolean statement from a truth
table. 0 0 1 0

The Boolean statement can be formed 0 1 0 0


by creating an AND term for each input
combination with a final output of 1, and 0 1 1 1
then ORing all the AND terms together.
1 0 0 0
We will illustrate this using the truth table
in Table 3.4.8. 1 0 1 0

1 1 0 1

1 1 1 0

Table 3.4.8 Truth table used to derive the Boolean statement

68
Determine the combinations which result in an output of 1.

From the truth table in Table 3.4.8, we can see that there are two combinations which
Step 1: result in output Q = 1:

A = 0, B = 1 and C = 1
A = 1, B = 1 and C = 0

Create an AND term for each combination that results in an output of 1.

Step 2: Since these conditions need to be all present for output Q to be 1, we should AND them
together. Note that A is used to represent A = 0. This is because when A = 0, Ā will give 1.

A∙B∙C
A∙B∙C

OR the AND terms together.


ER MS
Since either of these two input combinations will
result in an output of 1, we should join the partial
KEY T
Step 3: Boolean statements together using OR. Thus, we Sum-of-Product (SOP)
obtain the final Boolean statement below: A Boolean statement where the
AND terms are ORed together
Q =A∙B∙C+A∙B∙C

This form of representation where the AND terms


are ORed together is known as Sum-of-Product
(SOP).

3.4.2.4 Constructing Logic Circuit Diagrams from Boolean Statements

To determine how logic circuits look like, we should use the order Let us draw the logic circuit diagram
of operations to evaluate the Boolean statements. represented by this Boolean
statement:
Recall that in Table 3.4.4, the AND operation is evaluated before the
OR operation. This means that the logic gate representing “A∙ B”
should be drawn first. The output of “A∙B ” is then connected as an Q=A•B+C
input to an OR gate with input C.

Draw an AND gate with inputs A and B.

A
Step 1:
B

Figure 3.6 Drawing the AND gate first

Connect the output of “A∙B” as an input to an OR gate.

A A∙B
Step 2: B

Figure 3.7 Connecting the output of the AND gate to the OR gate

69
Connect C to the other input of the OR gate.

A A∙B
Step 3: B Q
C

Figure 3.8 Completed logic circuit diagram of Q = A ∙ B + C

3.4.2.5 Constructing Boolean Statements from Logic Circuit Diagrams

In the previous section, we learnt to draw logic circuit diagrams from Boolean statements. In this section,
we will learn how to do the reverse, which is to derive the Boolean statement from a logic circuit diagram.

Example 1: A D
Let us work out the Boolean statement of the logic
circuit diagram shown in Figure 3.9. B Q
To work out the Boolean statement of a logic C
circuit diagram, we can work backwards from its
final output. Figure 3.9 Deriving the Boolean statement from a
logic circuit diagram

Work out the Boolean statement involving the final output.

An OR gate with inputs D and C is connected to the final output Q.

A D
B Q
Step 1:
C
Figure 3.10 Working backwards from the final output

Hence, the Boolean statement for this OR gate is: Q= D+ C

Note that D is an intermediate input.

Work out the Boolean statement involving the intermediate input.

Notice that the intermediate input D is also the output D of an OR gate with inputs A
and B.

A D
Step 2:
B Q
C
Figure 3.11 Working backwards from the intermediate input D

Hence, the Boolean statement for this OR gate is: D = A+ B

70
Combine the Boolean statements.

Substituting the Boolean statement from Step 2 into the statement from Step 1 will
Step 3: give us the Boolean statement which represents the logic circuit diagram:

Q=(A+B)+C

Example 2: A D
Let us now work out the Boolean statement of the logic
circuit diagram in Figure 3.12. Z
B
Again, we start by working backwards from the final E
output. C
Figure 3.12 Deriving the Boolean statement from a logic
circuit diagram

Work out the Boolean statement involving the final output.

An OR gate with inputs D and E is connected to the final output Z.

Hence, we can work out the Boolean


statement for this OR gate as: A D
Step 1:
Z=D+E Z
B
Note that D and E are intermediate inputs. E
C

Figure 3.13 Working backwards from the final


output Z

Work out the Boolean statements involving the intermediate inputs.

Notice that the intermediate input D is also the output D of a NOT gate with input A.

Hence, the Boolean statement for


this NOT gate is: A D

D=A Z
B
Next, notice that the intermediate E
C
Step 2: input E is also the output E of an
AND gate with inputs B and C.
Figure 3.14 Working backwards from the
intermediate input D

Hence, the Boolean statement for A D


this AND gate is:
Z
E=B• C B
E
C

Figure 3.15 Working backwards from the


intermediate input E

71
Combine the Boolean statements.

Substituting the Boolean statements from Step 2 into the statement from Step 1 will
Step 2: give us the Boolean statement which represents the logic circuit diagram:

Z=A+(B •C)

QUICK
E CK 3.4
CH
1. Consider the logic circuit below.

A D
B Q
E
C
Figure 3.16 A logic circuit

a) State the number of inputs.


b) State the number of outputs.

2. Refer to the Boolean statement below.

Q=(A+B)∙C

a) Draw the truth table by evaluating the statement.


b) Draw the logic circuit diagram that represents the statement.

3.Produce truth tables for the following expressions:


a) A + B
b) A + ( A B)
c) A• B + B• C
d) ( A •B ) C

3.5 Manipulating Boolean Statements

LEARNING OUTCOMES
1.3.4 Manipulate Boolean statements using the associative and distributive properties of certain
logical operators and De Morgan’s theorem.

Like algebraic expressions, Boolean statements can be manipulated using the associative, distributive and
other properties of the AND, OR and XOR operations. Table 3.5.1 lists some common properties of AND, OR
and XOR for manipulating Boolean statements.

72
Property AND OR XOR

Annulment A•0=0 A+1=1

Identity A•1=A A+0=A A 0=A

Idempotent A• A=A A+A=A

Self-Inverting A A= 0

Complement A•A=0 A+A=1 A Ā= 1

Commutative A• B=B •A A+B=B+A A B= B A

Associative A•(B•C)=(A•B)•C A+(B+C)=(A+B)+C A ( B C) = ( A B) C


A•(B+C)=(A•B)+(A•C)
Distributive A+(B•C)=(A+B)•(A+C)
A•(B C)=(A•B) (A•C)
Absorption A•(A+B)=A A+(A•B)=A

De Morgan’s A• B=A+B A+B=A•B


Theorem
Table 3.5.1 Common properties of AND, OR and XOR

Another common property for manipulating Boolean statements is


U
DID YO
the Double Negation property where performing two consecutive

?
NOT operations gives back the original input:

A=A
KNO W
These properties are
also called “laws” (e.g.,
By using these properties, Boolean statements can be simplified distributive law).
to use fewer logic gates or to prove identities that show two logic
circuits are equivalent.
An alternative and more
As an example of how these properties can be used to prove general way to prove an
an identity, let us try to prove the absorption property of AND, identity is to show that
i.e. A•(A+B)=A. To prove an identity, we start from the Boolean the truth tables for both
statement on one side of the equation and perform manipulations sides match. You can also
step-by-step until it matches the Boolean statement on the other prove that two Boolean
side. In this case, we will start from the left-hand side (LHS) as it has statements are not
more terms for manipulation to reach the right-hand side (RHS): equivalent by comparing
their truth tables and
LHS =A• (A+B) confirming that they do
=( A + 0)• (A+B) (Identity property of OR) not match.
=A +(0• B) (Distributive property of OR)
=A +0 (Annulment property of AND)
=A (Identity property of OR)
=RHS

For clarity, we have highlighted the name of the property being


used for each step. This is optional and it is not necessary to
memorise the names of the properties. However, each step should
still be shown clearly and using multiple properties at the same
time should be avoided.

73
QUICK
E C K 3.5
CH
1. Prove the following identities:
a ) A+ A = 0
b ) (A + B )•B = A•B
c ) (A +B )•(B+ B)= B
d) A =(A+B )•(A+ B)
e ) ( A • B ) ( A•B )=B

2. Simplify the following Boolean statements:


a ) A+ B +A• B
b ) A+ B +A• B
c ) A• B + B•A
d) ( A+ B )•(B+ C)

3. By using truth tables, prove that:


a) NAND is not associative, i.e., ( A• B) •C ≠A•( B •C )
b) NOR is not associative, i.e., ( A + B)+C ≠ A+(B +C )

4. a) By using truth tables, prove that AND is distributive,


i.e., A • (B +C )= (A •B )+ (A•C )
b) Hence, or otherwise, prove that OR is distributive,
i.e., A +(B •C )= (A +B) • (A+ C )

3.6 Solving System Problems

LEARNING OUTCOMES
1.3.5 Solve system problems using combinations of logic gates (maximum 3 inputs).

Computing devices and electrical appliances perform logical decisions using logic circuits. This section
introduces three applications of logic circuits that are used to make logical decisions.

3.6.1 Motion-Sensing Lights

In toilets or offices installed with motion-sensing lights, the logic circuit is designed to make a logical
decision of when to switch on the lights depending on the input conditions.

74
One example of a logic circuit used to operate motion-
sensing lights is found in Figure 3.17.

Motion sensor
Motion=1
No motion=0 A
Light bulb
On=1
Light sensor Q Off=0
Bright=1
Dark=0
B C

Figure 3.17 Logic circuit for motion-sensing light

The motion-sensing light is switched The corresponding Boolean statement for this logic circuit
on when both of its input conditions are is Q=A•B.
fulfilled – its surroundings are dark, and
motion is detected within the toilet or
Input A Input B Intermediate Output Q
office area. At all other times, the light is Input C
switched off. This ensures that the light is
not switched on when no one is around, 0 0 1 0
helping to reduce electricity consumption.
0 1 0 0
When the logic circuit is used to control
a motion-sensing light, inputs A and B 1 0 1 1
are provided by a motion sensor and a
light sensor respectively, and output Q 1 1 0 0
is connected to a light bulb. Table 3.6.2
shows how the truth table should be
interpreted for this circuit. Table 3.6.1 Truth table for Q=A•B

Input A Input B intermediate Output Q


Input C
0 (no motion) 0 (dark) 1 0 (light off)

0 (no motion) 1 (bright) 0 0 (light off)

1 (motion) 0 (dark) 1 1 (light on)

1 (motion) 1 (bright) 0 0 (light off)

Table 3.6.2 Truth table for the logic circuit of a motion-sensing light

3.6.2 Car Door Lock

A car door can be unlocked either manually with a key or by receiving an unlock signal via a remote control
sensor. The key switch provides an input of 1 when the key is turned. The remote control switch provides
an input of 1 when the unlock signal is detected.

We can then work out that there are two types of inputs (the key switch and remote control sensor),
resulting in 22 = 4 possible outputs for the lock.

Let us work out the truth table for the car door lock. If we connect inputs A and B to a key switch and remote
control sensor respectively, and the output Q to the lock, we can create the truth table shown in Table 3.6.3.

75
Input A Input B Output Q

0 (key absent) 0 (signal absent) 1 (locked)

0 (key absent) 1 (signal present) 0 (unlocked)

1 (key turned) 0 (signal absent) 0 (unlocked)

1 (key turned) 1 (signal present) 0 (unlocked)

Table 3.6.3 Truth table for the car door lock

The Boolean statement for this car door lock is:

Q=A+B
This is equivalent to using a NOR gate.

Hence, the logic circuit for this car door lock can be
designed as follows:

Key switch
Key absent=0
Key present=1 A Lock
Locked=0
Q Unlocked=1
Remote control sensor
Signal absent=0 B
Signal present=1

Figure 3.18 Logic circuit for car door lock

3.6.3 Two-Way Switches

Figure 3.19 Light Q is controlled by switches A and B, which are


Two-way switches allow a single light placed at both ends of the corridor
to be switched on or off from two
different locations easily. Two-way Q
switches are often used at the opposite
ends of corridors or staircases to A B
control a light that is located between
the switches.

In Figure 3.19, the light Q at the centre


of a long corridor is controlled by
switches A and B at both ends of the
corridor. Each switch has two states:
0 for “off” and 1 for “on”. Light Q also
has two states: 0 for “off” and 1 for Input A Input B Output Q
“on”. Light Q will be on only when
both switches A and B are off or on 0 0 1
concurrently. However, if only one
switch is on and the other is off, light 0 1 0
Q will be off.
1 0 0
If we connect the inputs of the logic
circuit to switches A and B and the 1 1 1
output to light Q, we can create the
truth table shown in Table 3.6.4. Table 3.6.4 Truth table for the two-way switches

76
To derive the Boolean statement from a
truth table, recall the following two steps:

1 Create an AND term for each input A


combination that results in an
B
output of 1.

2 OR the AND terms together.


Q
The Boolean statement for this two-way
switch will be:

Q=A •B+ A •B
Hence, the logic circuit for the two-way
switches can be designed as follows: Figure 3.20 Logic circuit for the two-way switches

QUICK
E C K 3.6
CH
1. A logic circuit is used to determine whether the doors for a shopping mall should be open or closed. The door
should open only during business hours and when it is not raining.

The system has two inputs and one output


• Input A: Whether it is during business hours
(0 = not business hours, 1 = business hours)
• Input B: Whether it is raining
(0 = not raining, 1 = raining)
• Output Q: Whether the doors should be open
(0 = closed, 1 = open)

a) Write down the truth table for A, B and Q.


b) Write down a Boolean statement for Q in terms of A and B.
c) Draw the logic circuit diagram for A, B and Q.

2. A narrow railway crossing is shared by vehicles traveling in two opposite directions, North and South. A warning
light needs to turn on if either a train is approaching or if there is a vehicle waiting to travel North and another
vehicle is waiting to travel South at the same time.

The inputs to the system are:

Input Binary Condition


N 0 No vehicle waiting to travel North
1 Vehicle is waiting to travel North
S 0 No vehicle waiting to travel South
1 Vehicle is waiting to travel South
T 0 No train approaching
1 Train is approaching

77
QUICK
E C K 3.6
CH
The output to the system is Q for the warning light (0 = off, 1 = on).

a) Write down the truth table for N, S, T and Q.


b) Write down a Boolean statement for Q in terms of N, S and T.
c) Draw the logic circuit diagram for N, S, T and Q.

W
REVIE
E ST IO N
QU
1. Draw the truth tables for the following Boolean statements.
a) Q=A+(B•C)
b) X=A•B
c) Y=A•B
d) Q=(A+B)•(C+D)

2. For the statement:

If A is True then Q is True


else if B is False then Q is True
else Q is False

determine its:
a) Boolean statement; and
b) truth table.

3. Use distributive laws to expand the following statements:


a) (A+B)•(C+D)•E
b) (A•B•C)+(D•E)

4. Draw the truth table for the logic circuit shown below.

B Q

Figure 3.21 Logic circuit

78
ANSWER

Pg. 62-Quick Check 3.3


1. a) True b) True c) False

2. A

3. B

4. C

5. a) OR b) XOR c) NAND

Pg. 72-Quick Check 3.4

1. a) 3 (Note: Intermediate inputs are not counted as inputs.)


b) 1

2. a) Truth table:
Input A Input B Input C Intermediate Input (A) Intermediate Input (A+B) Output Q
0 0 0 1 1 0
0 0 1 1 1 1
0 1 0 1 1 0
0 1 1 1 1 1
1 0 0 0 0 0
1 0 1 0 0 0
1 1 0 0 1 0
1 1 1 0 1 1

b) Logic circuit:

A
B Q

3. a)
Input A Input B Intermediate Input (B) Output Q
0 0 1 1
0 1 0 0
1 0 1 1
1 1 0 1

b)
Input A Input B Intermediate Input (A B) Intermediate Input (A B) Output Q
0 0 0 1 1
0 1 1 0 0
1 0 1 0 1
1 1 0 1 1

79
ANSWER

c)
Input Input Input Intermediate Intermediate Intermediate
Output Q
A B C Input (A•B) Input (B) Input (B•C)
0 0 0 0 1 0 0
0 0 1 0 1 1 1
0 1 0 0 0 0 0
0 1 1 0 0 0 0
1 0 0 0 1 0 0
1 0 1 0 1 1 1
1 1 0 1 0 0 1
1 1 1 1 0 0 1

d)
Input Input Input Intermediate Intermediate
Output Q
A B C Input (B) Input (A•B)
0 0 0 1 0 0
0 0 1 1 0 1
0 1 0 0 0 0
0 1 1 0 0 1
1 0 0 1 1 1
1 0 1 1 1 0
1 1 0 0 0 0
1 1 1 0 0 1

Pg. 74-Quick Check 3.5


1. a) LHS =A+A 2. a) A+B+A•B = A+B+A+B (De Morgan’s Theorem)
=1 (Complement property of OR) =1 (Complement property of OR)
=0
=RHS b) A+B+A•B =A•B+A•B (De Morgan’s Theorem)
=A•B+A•B (Double Negation property)
=A•(B+B) (Distributive property of AND)
b) LHS =(A+B)•B
=A•1 (Complement property of OR)
=(A•B)•B (De Morgan’s Theorem) =A (Identity property of AND)
=(A•B)•B (Double Negation property)
=A•(B•B)(Associative property of AND) c) A•B+B•A =A•B+A•B (Commutative property of AND)
=A•B (Idempotent property of AND) =A•(B+B) (Distributive property of AND)
=RHS =A•1 (Complement property of OR)
=A (Identity property of AND)
c) LHS =(A+B)•(B+B)
=(A•B)+B (Distributive property of OR) d) (A+B)•(B+C) =(B+A)•(B+C) (Commutative property of OR)
=B (Absorption property of OR) =B+(A•C) (Distributive property of OR)
=RHS

d) RHS =(A+B)•(A+B)
=A+(B•B) (Distributive property of OR)
=A+0 (Complement property of AND)
=A (Identity property of OR)
=LHS

e) LHS =(A•B) (A•B)


=(A A)•B (Distributive property of AND)
=1∙B (Complement property of XOR)
=B (Identity property of AND)
=RHS

80
ANSWER

3. a) Truth table for LHS (A•B)•C:


Input Input Input Intermediate
Output Q
A B C Input (A•B)
0 0 0 1 1
0 0 1 1 0
0 1 0 1 1
0 1 1 1 0
1 0 0 1 1
1 0 1 1 0
1 1 0 0 1
1 1 1 0 1

Truth table for RHS A•(B•C):


Input Input Input Intermediate
Output Q
A B C Input (B•C)
0 0 0 1 1
0 0 1 1 1
0 1 0 1 1
0 1 1 0 1
1 0 0 1 0
1 0 1 1 0
1 1 0 1 0
1 1 1 0 1

As the two truth tables do not match, (A•B)•C≠A•(B•C)

b) Truth table for LHS (A+B)+C:


Input Input Input Intermediate
Output Q
A B C Input (A+B)
0 0 0 1 0
0 0 1 1 0
0 1 0 0 1
0 1 1 0 0
1 0 0 0 1
1 0 1 0 0
1 1 0 0 1
1 1 1 0 0

81
ANSWER

Truth table for RHS A+(B+C):


Input Input Input Intermediate
Output Q
A B C Input (B+C)
0 0 0 1 0
0 0 1 0 1
0 1 0 0 1
0 1 1 0 1
1 0 0 1 0
1 0 1 0 0
1 1 0 0 0
1 1 1 0 0

As the two truth tables do not match, (A+B)+C≠A+(B+C)

4. a) Truth table for LHS A•(B+C)

Input Input Input Intermediate


Output Q
A B C Input (B+C)
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 1 0
1 0 0 0 0
1 0 1 1 1
1 1 0 1 1
1 1 1 1 1

Truth table for RHS (A•B)+(A•C)

Input Input Input Intermediate Intermediate


Output Q
A B C Input (A•B) Input (A•C)
0 0 0 0 0 0
0 0 1 0 0 0
0 1 0 0 0 0
0 1 1 0 0 0
1 0 0 0 0 0
1 0 1 0 1 1
1 1 0 1 0 1
1 1 1 1 1 1

As the two truth tables match, A•(B+C)=(A•B)+(A•C)

b) RHS =(A+B)•(A+C)
=(A+B)•A+(A+B)•C (Result from part (a))
=A•A+A•B+A•C+B•C (Result from part (a))
=A+A•B+A•C+B•C (Idempotent property of AND)
=A•(1+B+C)+B•C (Distributive property of AND)
=A•1+B•C (Annulment property of OR)
=A+B•C (Identity property of AND)
= LHS

82
ANSWER
Pg. 77-Quick Check 3.6
1. a)
Input A Input B Output Q
0 0 0
0 1 0
1 0 1
1 1 0

b) Q=A•B

c) A
Q
B
2. a)
Input N Input S Input T Output Q
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1

b) Q=N•S+T
Alternatively, using Sum-of-Product (SOP):
Q=N•S•T+N•S•T+N•S•T+N•S•T+N•S•T

c)
N

S Q
T

83
ANSWER

Pg. 78-Review Questions


1. a) Q=A+(B•C)
Input Input Input Intermediate
Output Q
A B C Input (B•C)
0 0 0 0 0
0 0 1 0 0
0 1 0 0 0
0 1 1 1 1
1 0 0 0 1
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1

(Note: Q is 1 when either A is 1, or both B and C are 1.)

b) X=A•B
Intermediate Intermediate Output Q
Input A Input B
Input (A) Input (B)
0 0 1 1 1
0 1 1 0 0
1 0 0 1 0
1 1 0 0 0

(Note: X is 1 only when both A and B are 0.)

c) Y=A•B
Input A Input B Intermediate Input (B) Output Q
0 0 1 0
0 1 0 0
1 0 1 1
1 1 0 0

(Note: Y is 1 only when A is 1 and B is 0.)

84
ANSWER

d) Q=(A+B)•(C+D)

Input Input Input Input Intermediate Intermediate


Output Q
A B C D Input (A+B) Input (C+D)
0 0 0 0 0 0 0
0 0 0 1 0 1 0
0 0 1 0 0 1 0
0 0 1 1 0 1 0
0 1 0 0 1 0 0
0 1 0 1 1 1 1
0 1 1 0 1 1 1
0 1 1 1 1 1 1
1 0 0 0 1 0 0
1 0 0 1 1 1 1
1 0 1 0 1 1 1
1 0 1 1 1 1 1
1 1 0 0 1 0 0
1 1 0 1 1 1 1
1 1 1 0 1 1 1
1 1 1 1 1 1 1

2. a) Boolean statement: Q = A + B
b) Truth table:
Input A Input B Intermediate Input (B) Output Q
0 0 1 1
0 1 0 0
1 0 1 1
1 1 0 1

3. a) A•C•E+A•D•E+B•C•E+B•D•E
b) (A+D)•(A+E)•(B+D)•(B+E)•(C+D)•(C+E)

4. Step 1: Total number of rows in the truth table = 23 = 8 as there are three inputs.

Step 2: Draw the truth table and fill in all the input combinations.

Input Input Input


A B C
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

Step 3: Work out the intermediate inputs D, E, F and G first.

85
ANSWER

A D

B E Q

G
C F

D = A• B
E = B+ C
F =C
G =E • F

Input Input Input Intermediate


Output Q
A B C Input D Input E Input F Input G
0 0 0 0 0 1 0
0 0 1 0 1 0 0
0 1 0 0 1 1 1
0 1 1 0 1 0 0
1 0 0 0 0 1 0
1 0 1 0 1 0 0
1 1 0 1 1 1 1
1 1 1 1 1 0 0

Step 4: Work out the final output, Q

Q=D+G
Input Input Input Intermediate
Output Q
A B C Input D Input E Input F Input G
0 0 0 0 0 1 0 0
0 0 1 0 1 0 0 0
0 1 0 0 1 1 1 1
0 1 1 0 1 0 0 0
1 0 0 0 0 1 0 0
1 0 1 0 1 0 0 0
1 1 0 1 1 1 1 1
1 1 1 1 1 0 0 1

86

You might also like