COMP4009 - 2019-20-W04 - Computing - Logic PDF
COMP4009 - 2019-20-W04 - Computing - Logic PDF
Dr Shumao Ou
[email protected]
E202, x4508
Learning Outcome for this lecture
• Reading Material
• CS illuminated, Chapter 4
• Lipschutz, Essential Computer Mathematics, Chapters 7
and 8
• Code’s book, Chapters 10 and 11
Layers of a Computing System
Logic Level
• Stored
• Moved
• Modified
Gates and Circuits
Gate
• A device performs a basic
operation on electrical signals
• Gates are electronic devices
used to operate with bits
• Basic gate operations are
boolean logical operation
• And
• Or
• Not
• …
Circuits
• Gates combined to perform
more complicated tasks
• E.g. Add two numbers
Logic Description
• Boolean expressions
• Uses Boolean algebra, a mathematical notation for expressing two-
valued logic
• Logic diagrams
• Truth tables
• A table showing all possible input value and the associated output
values
Gates
X A B
X = A and B
X = AB
OR Gate
X A B
X= A or B
NOT Gate
XA
X = not A X = ~A
XOR Gate
• Note the difference between the XOR gate and the OR gate; they
differ only in one input situation
• When both input signals are 1, the OR gate produces a 1 while the
XOR produces a 0
OR XOR
NAND Gate
X A B
X AB
NOR Gate
X A B
X A B
Review of Gate Processing
• Combinational circuit
• The input values explicitly determine the output
• Sequential circuit
• The output is a function of the input values and the existing state of
the circuit (sequential circuits are not covered in this module)
X=AB +AC
D=AB
E=AC
X=D+E
Combinational Circuits
X=AB +AC
INPUT OUTPUT
A B X
0 0 0 A
Q: How can we read 0 1 1 Truth
this to build a circuit? 1 0 1 table
1 1 0
A circuit to add
A B AB
INPUT OUTPUT
A B X
0 0 0 A
0 1 1 Truth
1 0 1 table
1 1 0
Logic functions
NOT OR
Truth Tables
•Given a circuit we can construct
a truth table by listing all possible
combinations of input and all the
intermediate results of the gates,
finally showing the output
A B B (A+B) A B ( A B) ( A B )
Truth Tables
•Given a circuit we can construct
a truth table by listing all possible
combinations of input and all the
intermediate results of the gates,
finally showing the output
A B B (A+B) A B ( A B) ( A B )
0 0 1 0 1 0
0 1 0 1 0 0
1 0 1 1 1 1
1 1 0 1 1 1
Truth Tables
• (A+B) C
A B C A+B (A+B)C
0 0 0 0 0
0 0 1 0 0
0 1 0 1 0
0 1 1 1 1
1 0 0 1 0
1 0 1 1 1
1 1 0 1 0
1 1 1 1 1
Derive Boolean Expression
Rules to derive Boolean expression from Truth Tables
• Given the truth table with its inputs and outputs:
1. Consider the rows of the truth table where output is 1
2. For each output 1 row, write a Boolean expression
containing the input variables connected with AND operators
(.) If the value of the input is 0, the input will appear inverted.
3. Combine all the expressions by using OR operators (+)
A B X
0 0 0
0 1 1 A’.B
1 0 1 A.B’
1 1 0
So X = A’.B + A.B’
To analyse a truth table we use
Boolean Algebra
At Brookes:
• Download Logisim from the link on
Moodle to your H drive and run
At Home:
• You may need to install Java first
• Excellent tutorial at:
http://www.cburch.com/logisim/docs/2.7/en/html/g
uide/tutorial/index.html
• And
https://www.youtube.com/watch?v=cMz7wyY_Px
E
Conclusion
30