0% found this document useful (0 votes)
19 views34 pages

14th October

Uploaded by

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

14th October

Uploaded by

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

Discrete Structures/Mathematics

Daud Khan Khalil


School of Computer Science and Software Engineering
L o g i c Gates
Logic Gates

• Boolean algebra is used to model the circuitry of electronics


devices.
• Each input and each output of such a device can be thought
of as a member of the set [0,1].
• A computer or other electronics devices is made up of a
number of circuits.
• A logic gate is an elementary building block of a digital circuit.
• Most logic gates have two inputs and one output.
• At any given moment, every terminal is in one of the two
binary conditions low (0) or high (1), represented by different
voltage levels.
Continued….

• Logic gates turn ON when a certain condition is true, and OFF


when the condition is false
 They check whether or not the information they get follows
a certain rule.
• They either spit out the answer true (ON) or false (OFF)
• Remember:
– True= ON = 1
– False = OFF=0
Let’s do an example!

• Let’s say a certain logic gate


needs to determine if two
5
numbers are equal ON Logic
(they are

• The rule would be “is equal”


equal)
Gate
5
• If the two input numbers are
equal, it will go into its ON
position, indicating true
5
• If they are not equal, it will
OFF Logic
go into its OFF position, (they are Gate
indicating false.
not equal) 6
Continued…
• But we learned before that computers only think
of things in terms of ON and OFF, which 1
Logic (ON)
to them is 1 and 0
• So a computer wouldn’t take an
1
(ON) Gate 1
input of 5 or 6 – all of the (ON)
information need to be 0s and
1s
• Reminder: Input refers to the
information you give the logic 1
(ON)
gate, and output refers to what
it spits out! 0 Logic
(OFF) Gate 0
(OFF)
Types of Logic Gates!

• Major logic gates: NOT, AND,


OR, and XOR
• There are also other ones,
such as NAND, NOR, and
XNOR that we’re going to cover as
well.
• This is called Boolean logic.
• In a circuit schematic each
logic gate is represented by a
different picture, like the
ones shown below.
NOT Gate

• NOT is the most simple logic gate.


• All it does is take in an input that is either ON or OFF and
spits out the opposite.
• So for a 1 it will give a 0, and for a 0 it will give a 1.
• Another name for a NOT gate is inverter, because it
inverts
(makes opposite) the input.
Continued…

Truth Table for Not gate


Continued…

AND-gate
• An AND-gate is a circuit with two input signals and one output
signal.
• If both input signals are 1, the output signal is 1. Otherwise
the output signal is 0.
• Symbolic representation & Input/output Table is on next slide.
Continued…

Symbolic Representation
Truth Table
Continued…

OR-gate
• An OR-gate is a circuit with two input signals and one output
signal.
• If both input signals are 0, then the output signal is 0.
Otherwise, the output signal is 1.
• Symbolic representation & Input/Output Table is on the next
slide
Continued…
Continued…

XOR
•XOR is the short way to say “Exclusive OR”
•Like OR, XOR also only needs one input to be ON for it to
spit out ON
•But unlike OR, when both inputs are ON, XOR spits out OFF
•It is also OFF when both inputs are OFF
Truth Table

Another way of looking at this circuit is to observe that the output


is 1 if the inputs are different, but 0 if the inputs are the same

Symbolic Representation and Input/output table


Continued…

NAND Gate
• The NAND gate operates as an AND gate followed by a NOT
gate.
• It acts in the manner of the logical operation "and" followed by
negation.
• The output is "false" if both inputs are "true." Otherwise, the
output is "true."
Continued…

NOR Gate
• The NOR gate is a combination OR gate followed by an
inverter. Its output is "true" if both inputs are "false."
Otherwise, the output is "false."
Continued…

XNOR Gate
• The XNOR (exclusive-NOR) gate is a combination XOR gate
followed by an inverter.
• Its output is "true" if the inputs are the same, and "false" if the
inputs are different.
Logic gates representation using the Truth table
Logic gate symbols
Stacking Logic Gates!

• An output of one logic gate can be an input to


another logic gate.
• This creates trees of gates that depend on each
other.
• Also known as combinational circuit
Let’s Do an Example!

1 1
0
Example 2 !

1
AND
1 0
0
Example 3 !

1
1
1 AND

1 1 0

0
Continued…

.
Continued….

• Indicate the output of the circuit below when the input signals
are P = 1, Q = 0 and R = 0
Solution
Continued…

• Construct the input/output table for the following circuit.


Solution.. Label it first
Finding a Boolean expression for a circuit
Solution

• Trace through the circuit from left to right, writing down the
output of each logic gate.
Logic gates actually look like weird
bugs in real life!

However, the diagrams we use are


easier to understand
Exercise

Construct the circuit for


xy+ xy
(x+y) x
(x+y+z) xyz.
xy+xz+zx
xyz+ xyz +xyz +xyz
(p∧q) ∨(~ p∧q) ∨(p∧~q)

You might also like