You are on page 1of 42

Chapter 3 – Logic gates and logic circuits

Syllabus Content:
1. Security aspects:
 use logic gates to create electronic circuits
 understand and define 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 2 inputs only)
 draw truth tables and recognize a logic gate from its truth table
 recognize and use the following standard symbols used to represent logic gates:

 produce truth tables for given logic circuits, for example:

 produce a logic circuit to solve a given problem or to implement a given written logic
statement

Page #56
3 Logic gates and logic circuits

Introduction:

The functions and roles of logic gates, logic circuits and truth tables will be considered.
A number of possible applications of logic circuits will also be considered in this chapter.

What is a binary value?

Computer cannot understand or make sense of any alphabet or numerical value.


It only uses and understands two values, either 0 or 1.
The two digits, 0 and 1, are also known as binary values.

Working of logic gate:

Logic gates take binary inputs (0s or 1s only) and produce a binary output (0s or 1s only).

Uses of logic gates:

Electronic circuits in computers, many new memories and controlling devices are made
up of thousands of logic gates.

Logic circuit:

Several logic gates combined together form a logic circuit.

Truth table:

The checking of the output from a logic gate or logic circuit is done using a truth table.

Meanings of binary values:

The binary value 1 also means ON or TRUE or HIGH.


If the logic gate has an input or output of 1 then it means it is ON and working.
The binary value 0 also means OFF or FALSE or LOW.
If the logic gate has an input or output of 0 then it means it is OFF and not working.

Three symbols used in Boolean algebra:

AND can be represented using .

OR can be represented using +


A bar above the letter e.g. a (complement) represents the NOT operation.

57
Inputs of logic gates/logic circuits:

A logic gate can only have either 1 or 2 inputs.


A logic circuit can have more than 2 inputs but according to the syllabus, we will consider
logic circuits with either 2 or 3 inputs only.

Naming of inputs/output:

Starting inputs are usually named/called letters “A”, “B” or “C” (though other alphabets
are used too).
The output is usually named/called the letter “X”.

A single input:

A single input means 21 which is equal to 2.


It shows that a single input can only have 2 possible combinations.

Input
A
0
1
Two inputs:

Two inputs means 22 which is equal to 4.


It shows that two inputs can only have 4 possible combinations.

Input
A B
0 0
0 1
1 0
1 1

58
Three inputs:

Three inputs means 23 which is equal to 8.


It shows that three inputs can only have 8 possible combinations.

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

59
Labeling of diagrams of logic gates/circuits:

Output
Input 1

A X

Input 1

Output
A
X
B

Input 2

60
Consider the following statement:

X = 1 if (A is 1 AND B is NOT 1)

Meaning of statement explained:

X is the output while A and B are inputs.


The output X of the circuit will only be ON (=1) if the following conditions are satisfied:

1. A is 1 which means input A is ON.


2. Logic gate AND is present between the two inputs.
3. B is NOT 1 means input B is 0 and hence OFF.

61
Logic gates:

1) NOT gate:

i) Symbol:

ii) Representation:

Logic notation: X = NOT A


Boolean algebra: X = a

iii) Description:

It is the only logic gate which has one input only.


The output will be 1 if the input is 0.
The output will be 0 if the input is 1.
It simply swaps the input and output, so if you input 1 then the output is 0 and if you
input 0 then the output is 1.

iv) Truth table:

Input Output
A X
0 1
1 0

62
2) AND gate:

i) Symbol:

ii) Representation:

Logic notation: X = A AND B


Boolean algebra: X = a . b

iii) Description:

It has atleast two inputs.


The output will be 1 if both the inputs are 1.
The output will be 0 if both inputs are 0.
The output will be 0 if both inputs have different values.

iv) Truth table:

Inputs Output
A B X
0 0 0
0 1 0
1 0 0
1 1 1

63
3) NAND gate (NOT AND):

i) Symbol:

ii) Representation:

Logic notation: X = A NAND B


Boolean algebra: X = a . b

iii) Description:

It has atleast two inputs.


It is similar to an AND gate.
Its output is complement (opposite) to that of an AND gate.
The output will be 1 if both the inputs are 0.
The output will be 1 if both inputs have different values.
The output will be 0 if both inputs are 1.

iv) Truth table:

Inputs Output
A B X
0 0 1
0 1 1
1 0 1
1 1 0

64
4) OR gate:

i) Symbol:

ii) Representation:

Logic notation: X = A OR B
Boolean algebra: X = a + b

iii) Description:

It has atleast two inputs.


The output will be 1 if both the inputs are 1.
The output will be 1 if both inputs have different values.
The output will be 0 if both inputs are 0.

iv) Truth table:

Inputs Output
A B X
0 0 0
0 1 1
1 0 1
1 1 1

65
5) NOR gate (NOT OR):

i) Symbol:

ii) Representation:

Logic notation: X = A NOR B


Boolean algebra: X = a + b

iii) Description:

It has atleast two inputs.


It is similar to an OR gate.
Its output is complement (opposite) to that of an OR gate.
The output will be 1 if both the inputs are 0.
The output will be 0 if both inputs have different values.
The output will be 0 if both inputs are 1.

iv) Truth table:

Inputs Output
A B X
0 0 1
0 1 0
1 0 0
1 1 0

66
6) XOR gate:

i) Symbol:

ii) Representation:

Logic notation: X = A XOR B


Boolean algebra: X = (a . b) + (a . b)

iii) Description:

It has atleast two inputs.


It is similar to an OR gate.
The output will be 1 if both inputs have different values.
The output will be 0 if both inputs are 0.
The output will be 0 if both inputs are 1.

iv) Truth table:

Inputs Output
A B X
0 0 0
0 1 1
1 0 1
1 1 0

67
A number of different types of examples have been discussed on the following
pages to clear your concepts about:

1. drawing a logic circuit from a given simple logic statement along with its truth table.
2. drawing a logic circuit from a given complex/difficult logic statement along with its truth
table.
3. drawing a logic circuit from a given table about data of inputs, binary values and conditions
along with its truth table.
4. how to deduce either a logic statement or Boolean algebra notation from a given logic
circuit.
5. drawing NOT, AND, OR, NOR and XOR logic gates using NAND gates only and checking
the output through truth table.
6. drawing any logic circuit using NAND gates only and checking the output through truth
table.
7. simplifying a logic circuit and checking the output through truth table.

68
Example 1
X = 1 if (A = 1 AND B = 1) OR (B = NOT 1 AND C = 1)

1 2 33
1 2
(A = 1 AND B = 1) OR (B = NOT 1 AND C = 1)

Logic gate to be used at the end Logic gate to


Logic gate to be used for NOT gate
for output X + joining logic
joining A and B inputs to be used be used for
circuit part (1) and part (2)
for input B joining NOT B
and C inputs
1
1
This is used at junctions
A

1 2
2
B

X X
3
3
2
3
C

If you have to draw a truth table only then label all the logic gates with either
alphabets or numbers (as done above) otherwise if the logic circuit is to be only drawn,
then do not number them at all.

2 Applying AND operation 3 Applying NOT operation on


2 3
1 Truth table for three on values of A and B to values of B to get values of
1
primary inputs: get values of logic gate 1: logic gate 2:

69
44 Applying AND operation 55 Applying OR operation on values of 1
on values of 2 and C to and 3 to get values of logic gate X:
get values of logic gate 3:

When you work the values out and write them together, the truth table will look
something like the following:

Values of primary
inputs
Values of the
output

Values of logic
gates in circuits

70
Example 2

X = 1 if (A is NOT 1 OR B is 1) NOR C is 1) NAND (A is 1 AND C is 1) NOR B is 1)

*This logic circuit is then


joined with*
11
(A = NOT 1 OR B = 1) NOR C = 1 *Both logic circuits
are then joined with*
Logic gate to be used for Logic gate to be joined
joining NOT A and B inputs with logic circuit part (1) 33
NAND

Logic gate to be
used at the end for
*This logic circuit is then
output X + joining
joined with*
22 logic circuit part (1)
(A = 1 AND C = 1) NOR B = 1 and part (2)

Logic gate to be used for Logic gate to be joined


joining A and C inputs with logic circuit part (2)
Instructions:
1. First, draw logic gate as
11
A = NOT 1 OR B = 1 written in 1st bracket.
2. After that, join that logic
A gate with the gate
stated in 2nd bracket
A = NOT 1
along with stated input.
B
(A = NOT 1 OR B = 1) NOR C = 1)

A = 1 AND C = 1
2
2 A
Instructions:
1. Then, draw logic gate as
written in 3rd bracket.
B
2. After that, join that logic
gate with the gate (A = 1 AND C = 1) NOR B = 1)
stated in 4th bracket
along with stated input.
C

71
33
Instructions:

1. Join the logic circuit 1 with logic circuit 2 using the logic gate stated between the
brackets.

11

A 1
2 4 3
3

B
X X

3 5
C

2
2

If you have to draw a truth table only then label all the logic gates with either alphabets
or numbers (as done above) otherwise if the logic circuit is to be only drawn, then do not
number them at all.
33 Applying OR operation on
22 Applying NOT operation on values of logic gate 1 and
1 Truth table for three
1 values of A to get values of B to get values of logic
primary inputs: logic gate 1: gate 2:

72
4 5 6
1Applying AND operation 5 Applying NOR operation on 6 Applying NOR operation on
on values of A and C to values of logic gate 2 and C values of logic gate 3 and B
4
get values of logic gate 3: to get values of logic gate 4: to get values of logic gate 5:

77
Applying NAND When you work the values out and write them together, the
operation on values of truth table will look something like the following:
logic gates 4 and 5 to
get values of logic
gate X:

Values of primary Values of logic Values of the


inputs gates in circuits output

73
Example 3

A factory that manufactures cleaning products has a system that monitors conditions
throughout the manufacturing process.

The inputs to the system are:

(a) The system will sound an alarm (X) when certain conditions are detected.
The alarm (X) will sound (=1) when:

• The pressure >= 80% and the temperature >= 35 C°

or

• The temperature < 35 C° and the pH > 7

Draw a logic circuit to represent the alarm system in the factory. Each logic gate must
have a maximum of two inputs.

T X

[4]

74
Understanding the question:

If pH > 7 then A = 1 If Temperature < 35 C° then T = 1 If Pressure >= 80% then P = 1


If pH <= 7 then A = 0 If Temperature >= 35 C° then T = 0 If Pressure < 80% then P = 0

The alarm X will only activate/sound when the conditions given will be satisfied. For the output X
to be ON and working, it is very important that the binary value of inputs written alongside
conditions must be 1 meaning ON.
However, if you look at the table of ‘inputs, values and conditions’ you will realize that for every
single input one condition produces binary value “1” and the other produces binary value “0”

The inputs with those conditions that have binary value “1” will be used as they are by simply
tracing lines from the input to the logic gate. However for inputs with conditions having binary
value “0”, a NOT gate will be compulsorily drawn and attached to that input to ensure it
complements/swaps the value and hence it becomes “1” instead of “0”.

The word used for joining the first statement and the second statement of the condition is actually
the logic gate that will be used for joining these two inputs.

i ii iii
11 The pressure >= 80% AND the temperature >= 35 C°

2
OR
i ii iii

3
The temperature < 35 C° AND the pH > 7

1 i) The pressure >= 80% (Input P) 3 i) The temperature < 35 C° (Input T)


• has a binary value of 1. • has a binary value of 1.
• hence NOT gate is not required for • hence NOT gate is not required for
input P in this condition. input P in this condition.

ii) AND ii) AND


• the input or NOT gate used in (i) and • the input or NOT gate used in (i) and
the input or NOT gate used in (iii) will be the input or NOT gate used in (iii) will
joined together by AND gate. be joined together by AND gate.

iii) The temperature >= 35 C° (Input T) iii) The pH > 7 (Input P)


• has a binary value of 0. • has a binary value of 1.
• for this condition to work, the binary • hence NOT gate is not required for
value must be 1. input P in this condition.
• hence a NOT gate is required for input P
in this condition.

2 OR gate will be used to join together the logic circuit (1) and (3) and it will be the
output X.

75
Writing a logic statement:

(P = 1 AND T = NOT 1) OR (T = 1 AND A = 1)

11 22 33
(P = 1 AND T = NOT 1) OR (T = 1 AND A = 1)

Logic gate to be NOT gate to be Logic gate to be used at the Logic gate to be
used for joining P used for input T end for output X + joining logic used for joining T
and NOT T inputs circuit part (1) and part (2) and A inputs

1
1
Remember the order T
of arrangement of
P
inputs:

1. A (at top) 3
3
2. T (in middle) A
3. P (at bottom)
T

Drawing the logic circuit:

76
If you have to draw a truth table only then
label all the logic gates with either
alphabets or numbers (as done on right
side) otherwise if the logic circuit is to be
only drawn, then do not number them at
all.

(b) Complete the truth table for the given logic problem.

[4]

22 3
Applying NOT operation on 3 Applying AND operation
1 on values of A and T to
1 Truth table for three values of T to get values of
primary inputs: logic gate 1: get values of logic gate 2:

77
4
4 55
Applying AND operation on Applying OR operation on values of
values of logic gate 1 and P to logic gates 2 and 3 to get values of
get values of logic gate 3: logic gate X:

Completing the truth table:

1 2 3

Values of primary Values of logic Values of the


inputs gates in circuits output

78
How to deduce either a logic statement or Boolean algebra notation from a
given logic circuit:

Since the logic circuits given have 3 inputs only, we will divide the circuit into three portions. Let’s
consider the 3 inputs as A, B and C (going from top to bottom) and the output as X.

We will keenly look at the logic circuit and observe all the logic gates firstly.

The portion 1 will focus on the initial logic gate formed by joining the first input A (topmost) with
either the second B or third C inputs.

The portion 2 will be the logic circuit/logic gates left behind after the identification of portion 1.

The portion 3 will only cover the output logic gate X as it joins the circuits of portion 1 and portion 2.

Then we will simply write down a logic statement or Boolean algebra notation of the logic gates
included in the logic circuit from portion 1. We will bracket this piece of writing.

Then we will write down logic statement or Boolean algebra notation of the logic gates included in
the logic circuit from portion 1. We will bracket this piece of writing.

In the end, we will first write bracket from portion 1, then write the name of output logic gate
included in portion 3, and after that, simply writing the bracket from portion 2.

Q1. Write a logic statement which corresponds to the following logic circuit:

[3]

79
It is the first logic gate formed by It is the output logic gate X as
joining input A (topmost) with the it joins the circuits of portion 1
second input B. Hence it will be and portion 2. Hence it will be
classified as portion 1. classified as portion 3.
1
1

3
3

2
2

It is the logic circuit/the


logic gates left behind
after the identification of
portion 1. Hence it will
be classified as portion 2.

1
• Two inputs A and B are used.
• They are joined together by an OR gate.

Hence the logical statement for this portion becomes: A OR B

In Boolean algebra, it becomes: A + B

2
• NOT gate is used with input C to complement its values.
• Then the NOT gate and input B are used.
• They are joined together by an OR gate.

Hence the logical statement for this portion becomes: B OR NOT C

In Boolean algebra, it becomes: B + C

80
Now we have two different statements that can be put into two different brackets like this:

Logic statement: (A OR B) (B OR NOT C)


Boolean algebra: (A + B) (B + C)

3
The name of output logic gate that is, in this case, ‘AND’ will be placed between both
the brackets (therefore joining them)

Logic statement: (A OR B) AND (B OR NOT C)

Boolean algebra: (A + B) . (B + C)

The logic statement will be finally written like this:

X = 1 if (A is 1 OR B is 1) AND (B is 1 OR C is NOT 1) // OR //

X = 1 if (A = 1 OR B = 1) AND (B = 1 OR C = NOT 1)

Another way to write the statement is like this:

X = (A OR B) AND (B OR NOT C)

These type of questions (asking for logic statement from a given logic circuit) are usually
asked for 3 marks only. The division of marks is following:
st
• 1 mark for the 1 bracket
nd
• 1 mark for the 2 bracket
• 1 mark for writing the name of gate used for joining them between both the brackets

Example:

• (A OR B) (1)
• AND (1)
• (B OR NOT C) (1)

81
Q2. Write a logic statement which corresponds to the following logic circuit:

It is the first logic gate formed by It is the output logic gate X as


joining input A (topmost) with the it joins the circuits of portion
second input B. Hence it will be 1 and portion 2. Hence it will
classified as portion 1. be classified as portion 3.

1
1

33

2
2

It is the logic circuit/the


logic gates left behind
after the identification of
portion 1. Hence it will
be classified as portion 2.

1
• Two inputs A and B are used.
• They are joined together by an AND gate.

Hence the logical statement for this portion becomes: A AND B

In Boolean algebra, it becomes: A . B

2
• NOT gate is used with input B to complement its values.
• Then the NOT gate and input C are used.
• They are joined together by an OR gate.

Hence the logical statement for this portion becomes: C OR NOT B

In Boolean algebra, it becomes: C + B

82
Now we have two different statements that can be put into two different brackets like this:

Logic statement: (A AND B) (C OR NOT B)

Boolean algebra: (A . B) (C + B)

3
The name of output logic gate that is, in this case, ‘AND’ will be placed between both

the brackets (therefore joining them)

Logic statement: (A AND B) AND (C OR NOT B)

Boolean algebra: (A . B) . (C + B)

The logic statement will be finally written like this:

X = 1 if (A is 1 AND B is 1) AND (C is 1 OR B is NOT 1) // OR //

X = 1 if (A = 1 AND B = 1) AND (C = 1 OR B = NOT 1)

Another way to write the statement is like this:

X = (A AND B) AND (C OR NOT B)

83
Q3. Write a logic statement to match the given logic circuit.

It is the output logic gate X as it


It is the first logic gate formed by joining input A joins the circuits of portion 1
(topmost) with the third input C. Hence it will be and portion 2. Hence it will be
classified as portion 1. classified as portion 3.

1
1

3
3

22

It is the logic circuit/the


logic gates left behind
after the identification of
portion 1. Hence it will
be classified as portion 2.

1
• Two inputs A and C are used.
• They are joined together by XOR gate.

Hence the logical statement for this portion becomes: A XOR C

In Boolean algebra, it becomes: (A . C) + (A . C)

2
• NOT gate is used with input C to complement its values.
• Then the NOT gate and input B are used.
• They are joined together by a NAND gate.

Hence the logical statement for this portion becomes: B NAND NOT C

In Boolean algebra, it becomes: B . C

84
Now we have two different statements that can be put into two different brackets like this:

Logic statement: (A XOR C) (B NAND NOT C)

Boolean algebra: ((A . C) + (A . C)) (B . C)

3
The name of output logic gate that is, in this case, ‘OR’ will be placed between both the
brackets (therefore joining them)

Logic statement: (A XOR C) OR (B NAND NOT C)

Boolean algebra: ((A . C) + (A . C)) . (B . C)

The logic statement will be finally written like this:

X = 1 if (A is 1 XOR C is 1) OR (B is 1 NAND C is NOT 1) // OR //


X = 1 if (A = 1 XOR C = 1) OR (B = 1 NAND C = NOT 1)

Another way to write the statement is like this:

X = (A XOR C) OR (B NAND NOT C)

85
There are two possible ways to review logic circuit design:

1. One method is to use logic ‘building blocks’ (NAND gates only). It is possible to build up
any logic gate, and therefore any logic circuit, by simply linking together a number of
NAND gates only.
2. Second method involves simplifying the logic circuit as far as possible. It can be done by
making truth table of the circuit and different logic gates/circuits. The output from the truth
table can be compared with an output from a single logic gate or another circuit with lower
production cost. If both outputs match, then that single logic gate or the other circuit can
be used to replace the whole circuit hence simplifying and saving cost. This can also
improve reliability and make it easier to trace faults if they occur.

These methods allow electronics companies to save the cost of components, make
production/manufacturing easy and save time.

1) Using NAND gates only (logic ‘building blocks’):

Following NAND logic circuits can be drawn and used to replace the mentioned logic gates. This is
proven by truth tables of both the original logic gate and the circuit made up of NAND gates only.

1) NOT gate:

Circuit diagram: Truth tables

A2
X X

NOT gate NAND circuit


This circuit diagram made up of NAND
gate only can be used instead of NOT
gate as both produce the same output. Same values of output X

86
2) AND gate:

Circuit diagram:

This circuit diagram made up of


A NAND gate only can be used
B 1 1b
X X instead of AND gate as both
produce the same output.

Truth tables

AND gate NAND circuit

Same values of output X

87
3) OR gate:

Circuit diagram:

A2
1 This circuit diagram
made up of NAND
gate only can be

B2
X X used instead of OR
gate as both
produce the same

B 2 output.

Truth tables

OR gate NAND circuit

Same values of output X

88
4) NOR gate:

Circuit diagram:

This circuit diagram made up of NAND gate only can


be used instead of NOR gate as both produce the
A same output.

A2
1
3 X X
B2

B 2

Truth tables

NOR gate NAND circuit

Same values of output X

89
5) XOR gate:

Circuit diagram: This circuit diagram made up of NAND gate only can be
used instead of XOR gate as both produce the same output.

A
2
1 X X
1b

B 3

Truth tables

XOR gate NAND circuit

Same values of output X

90
Q1. Show how the following logic circuit could be built using NAND gates only.
Also complete truth tables for both logic circuits to show that they produce identical outputs.

A
B
1

X X

C 2

Explanation:

AND gate which can be replaced using two


NAND gates in a circuit like this:

A OR gate which
B 1 can be replaced
using two NAND
X X gates in a circuit
like this:
C 2

NOT gate which can be


replaced using two NAND
gates in a circuit like this:

91
Drawing of the logic circuit:

A
1 2
B
4
replacement of AND gate

X X

C
3 5 replacement of OR gate

replacement of NOT gate

Truth tables

Original circuit NAND circuit

Same values of output X

92
Q2. Show by drawing a truth table which single logic gate has the same function as the
following logic circuit made up of NAND gates only.

A
1
3 X X

B
2

Truth tables

Same values of output X

NAND circuit OR gate

Hence a single OR gate has the same function as the logic circuit made up of NAND gates
only as they both produce the same output.

93
Q3. Re-draw the following logic circuit using NAND gates only.

Drawing of the logic circuit:

Each dotted area is worth 1 marks.

94
2) Simplifying the logic circuit:

A logic circuit can be replaced with another low cost circuit or a single logic gate if the outputs
match. Logic circuits can be simplified and components/logic gates can be reduced with the help
of simply making truth tables and comparing outputs.

Q1. Show by drawing a truth table which single logic gate has the same function as the logic
circuit drawn below:

2
1 X

Truth tables

Same values of output X

Logic circuit drawn above NOR gate

Hence a single NOR gate has the same function as the logic circuit drawn above as they
both produce the same output.

95
May/June 2020 (12) Questions:

Q1.

96
Answer:

97

You might also like