Sindh Madressatul Islam University,
Karachi
Department of Computer Science
BS Computer Science 3rd Semester
Section E
Course: Discrete Structure
Topic: Logics in Discrete Structure
Applications of Logic
3
To days Lecture outline
 Basic Logic gates
 Circuits using logic gates
 Boolean Algebra
 Adders
 Reductions of circuits
4
Basic Logic Gates
where x = ¬x
where xy = x ∧ y
where
where x+y = x ∨ y
¬(xy)= xy
• Not
• And
• Or
• Nand
• Nor
• Xor
x
x
x
y
xy
x
x
y
x
y
xy
x
x
y
x⊕y
x
y
5
Constructing Circuits
Here is the circuit of the statement
(p ∧ q) ∨ (~p ∧ q) ∨ (p ∧ ~q)
6
is the circuit output of the following
Cont...
Following
statement
(x + y) ∧ ¬ y
x
y
7
Designing a circuitt for a given input/output
Here is the out put
we can write it as following
8
Designing a circuitt for a given input/output
Here is the circuit of the previous input/output
9
Boolean Algebra
• Just like Boolean logic, variables can only be 1 or 0,
instead of true/false
• Not
~0 = 1
~1 = 0
• Or is used as a plus
0+0 = 0
0+1=1
1+0=1
1+1= ?
And is used as a multiplication
0 * 0 = 0
0 * 1 = 0
1 * 0 = 0
1 * 1 = 1
10
Half Adder
• Consider adding two 1-bit binary numbers x and y
0+0 = 0
0+1 = 1
1+0 = 1
1+1 = 10
• Carry is x AND y
• Sum is x XOR y
• The circuit to compute this is called a half-adder.
11
Circuit of Half Adder
• Sum = x XOR y
• Carry = x AND y
x
y Sum
Carry
12
Using Half adders
•We can then use a half-adder to compute the
sum of two Boolean numbers
1 0 0
1 1 0 0
+ 1 1 1 0
? 0 1 0
13
How to fix that
• We need to create an adder that can take a carry bit as an
additional input
Inputs: x, y, carry in
Outputs: sum, carry out
• This is called a full adder
Will add x and y with a half-adder
Will add the sum of that to the
carry in
• What about the carry out?
It’s 1 if either (or both):
x+y = 10
x+y = 01 and carry in = 1
14
The Full adder
The “HA” boxes are
half-adders
X
Y
S
HA
C
X
Y
S
HA
C
c
x
y c
s
15
The Full adder
x
y
s
c
The full circuitry of the full adder
c
16
Logical Expression
Following is the circuit representations of the
statement
17
Cont…….
The above statement is the logical equivalent to
the statement
Reasons
: Distributive Law
: Negation Law
: Identity law
: Distributive Law
: Negation Law
: Identity Law
: Commutative Law
Accordingly the two circuits are equivalent
Statement
(P ∧Q) ∨ (~ P ∧Q) ∧ (P∧ ~ Q)
≡ (P∧ ~ P) ∧Q ∧ (P∧ ~ Q)
≡ t ∧Q ∧ (P∧ ~ Q)
≡ Q ∧ (P∧ ~ Q)
≡ (Q ∧ P) ∧ (Q∧ ~ Q)
≡ (Q ∧ P) ∧t
≡ Q ∧ P
≡
T
h
P
u
∧
s
Q
18
Lecture summary
• Basic Logic gates
to Logical
• Circuits using logic gates
• Circuits corresponding
Expressions
• Reductions of circuits
19

SMIU Discrete Structure Lecture 3 Section 3E.pdf

  • 1.
    Sindh Madressatul IslamUniversity, Karachi Department of Computer Science BS Computer Science 3rd Semester Section E
  • 2.
    Course: Discrete Structure Topic:Logics in Discrete Structure
  • 3.
  • 4.
    To days Lectureoutline  Basic Logic gates  Circuits using logic gates  Boolean Algebra  Adders  Reductions of circuits 4
  • 5.
    Basic Logic Gates wherex = ¬x where xy = x ∧ y where where x+y = x ∨ y ¬(xy)= xy • Not • And • Or • Nand • Nor • Xor x x x y xy x x y x y xy x x y x⊕y x y 5
  • 6.
    Constructing Circuits Here isthe circuit of the statement (p ∧ q) ∨ (~p ∧ q) ∨ (p ∧ ~q) 6
  • 7.
    is the circuitoutput of the following Cont... Following statement (x + y) ∧ ¬ y x y 7
  • 8.
    Designing a circuittfor a given input/output Here is the out put we can write it as following 8
  • 9.
    Designing a circuittfor a given input/output Here is the circuit of the previous input/output 9
  • 10.
    Boolean Algebra • Justlike Boolean logic, variables can only be 1 or 0, instead of true/false • Not ~0 = 1 ~1 = 0 • Or is used as a plus 0+0 = 0 0+1=1 1+0=1 1+1= ? And is used as a multiplication 0 * 0 = 0 0 * 1 = 0 1 * 0 = 0 1 * 1 = 1 10
  • 11.
    Half Adder • Consideradding two 1-bit binary numbers x and y 0+0 = 0 0+1 = 1 1+0 = 1 1+1 = 10 • Carry is x AND y • Sum is x XOR y • The circuit to compute this is called a half-adder. 11
  • 12.
    Circuit of HalfAdder • Sum = x XOR y • Carry = x AND y x y Sum Carry 12
  • 13.
    Using Half adders •Wecan then use a half-adder to compute the sum of two Boolean numbers 1 0 0 1 1 0 0 + 1 1 1 0 ? 0 1 0 13
  • 14.
    How to fixthat • We need to create an adder that can take a carry bit as an additional input Inputs: x, y, carry in Outputs: sum, carry out • This is called a full adder Will add x and y with a half-adder Will add the sum of that to the carry in • What about the carry out? It’s 1 if either (or both): x+y = 10 x+y = 01 and carry in = 1 14
  • 15.
    The Full adder The“HA” boxes are half-adders X Y S HA C X Y S HA C c x y c s 15
  • 16.
    The Full adder x y s c Thefull circuitry of the full adder c 16
  • 17.
    Logical Expression Following isthe circuit representations of the statement 17
  • 18.
    Cont……. The above statementis the logical equivalent to the statement Reasons : Distributive Law : Negation Law : Identity law : Distributive Law : Negation Law : Identity Law : Commutative Law Accordingly the two circuits are equivalent Statement (P ∧Q) ∨ (~ P ∧Q) ∧ (P∧ ~ Q) ≡ (P∧ ~ P) ∧Q ∧ (P∧ ~ Q) ≡ t ∧Q ∧ (P∧ ~ Q) ≡ Q ∧ (P∧ ~ Q) ≡ (Q ∧ P) ∧ (Q∧ ~ Q) ≡ (Q ∧ P) ∧t ≡ Q ∧ P ≡ T h P u ∧ s Q 18
  • 19.
    Lecture summary • BasicLogic gates to Logical • Circuits using logic gates • Circuits corresponding Expressions • Reductions of circuits 19