CH 2 - Digital Logic
CH 2 - Digital Logic
Omar El Safty
Introduction
Why data is stored as binary in computers?
• Computers use logic gates
• Logic gates use one of two values: 0 or 1
The behavior of each logic gate can be presented by constructing a truth table.
KEY TERM
Truth table – A table is used to trace the output from a logic gate or a logic circuit considering all
possible combinations of 0s and 1s that can be input.
22
Ch.2: Digital Logic Eng. Omar El Safty
Input Output
A X
0 1
1 0
How to write it:
X = NOT A
Explanation:
• It has one input
• Output will be 1 if the input is 0
• Output will be 0 if the input is 1
A B X
0 0 0
How to write it: 0 1 0
X = A AND B
1 0 0
Explanation: 1 1 1
• It has two inputs
• Output will be 1 if both inputs are 1
• Output will be 0 if either input is 0
23
Ch.2: Digital Logic Eng. Omar El Safty
2.3 OR gate
How to draw it: Truth table:
A B X
0 0 0
How to write it:
0 1 1
X = A OR B
1 0 1
Explanation:
1 1 1
• It has two inputs
• Output will be 1 if either input is 1
• Output will be 0 if both inputs are 0
A B X
0 0 0
How to write it:
0 1 1
X = A XOR B
1 0 1
Explanation: 1 1 0
• It has two inputs
• Output will be 1 if both inputs are different
• Output will be 0 if both inputs are 1
• Output will be 0 if both inputs are 0
24
Ch.2: Digital Logic Eng. Omar El Safty
A B X
0 0 1
How to write it:
X = A NAND B 0 1 1
1 0 1
Explanation:
• It has two inputs 1 1 0
A B X
0 0 1
How to write it:
X = A NOR B 0 1 0
1 0 0
Explanation:
1 1 0
• It has two inputs
• Output will be 1 if both inputs are 0
• Output will be 0 if either input is 1
25
Ch.2: Digital Logic Eng. Omar El Safty
2. Logic circuits
Definition:
A combination of logic gates to carry out a particular function.
Solution:
R
Q
26
Ch.2: Digital Logic Eng. Omar El Safty
2 Write down the logic statements for all intermediate gates in addition to the output:
P = A OR B
Q= B NAND C
R = P XOR Q
X (Output) = R OR C
3 Draw the truth table (this logic circuit has 3 inputs which means that there are 23 = 8
possibilities):
A B C X
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
27
Ch.2: Digital Logic Eng. Omar El Safty
4 Insert the logic statements of the intermediate gates in the truth table:
P Q R
A B C X
= (A OR B) = (B NAND C) = (P XOR Q)
0 0 0 0 1 1
0 0 1 0 1 1
0 1 0 1 1 0
0 1 1 1 0 1
1 0 0 1 1 0
1 0 1 1 1 0
1 1 0 1 1 0
1 1 1 1 0 1
P Q R X
A B C
= (A OR B) = (B NAND C) = (P XOR Q) = (R OR C)
0 0 0 0 1 1 1
0 0 1 0 1 1 1
0 1 0 1 1 0 0
0 1 1 1 0 1 1
1 0 0 1 1 0 0
1 0 1 1 1 0 1
1 1 0 1 1 0 0
1 1 1 1 0 1 1
28
Ch.2: Digital Logic Eng. Omar El Safty
P = A OR B
Q= B NAND C
R = P XOR Q
X (Output) = R OR C
2 Write the output (X) in terms of the input values (A, B and C):
− Expand R to P XOR Q
X = (P XOR Q) OR C
− Expand both P and Q
X = ( (A OR B) XOR (B NAND C) ) OR C
Solution:
Scan the following QR code to watch an elaborative video of the answer:
29
Ch.2: Digital Logic Eng. Omar El Safty
Example:
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 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 the value of 1 if any of the following combination of conditions occur:
• either turbine speed <=1000 rpm and bearing temperature > 80oC
• or turbine speed > 1000 rpm and wind velocity > 120 kph
• or bearing temperature <=80oC 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.
Solution:
Scan the following QR code to watch an elaborative video of the answer:
30
Ch.2: Digital Logic Eng. Omar El Safty
IMPORTANT
Logic circuits can behave the same as a single logic gate. This can be identified if both the
logic circuit truth table output and a logic gate truth table output are the same.
31