You are on page 1of 31

CISC 3593

Computer Organization
Fall 2013

Boolean Algebra
and
Digital Logic Gates
1

Boolean algebra
Just like Boolean logic!
Well call propositions variables
Well still use names like p, q, r, s, etc.
But variables can only have values 1 or 0
instead of True / False
2

George Boole, 1815 - 1864


Born to working class parents
Taught himself mathematics and
joined the faculty of Queens
College in Ireland.
Wrote An Investigation of the
Laws of Thought (1854)
Introduced binary variables
Introduced
the
three
fundamental logic operations:
AND, OR, and NOT.

<3>

Boolean algebra
The negation operation is written as a
horizontal bar above the variable name or above
the value

_
0_ = 1
1=0

Boolean algebra
Logical Or is a plus sign +

0+0 = 0
0+1 = 1
1+0 = 1
1+1 = 1

Boolean algebra
Logical And is multiplication sign *

0*0 = 0
0*1 = 0
1*0 = 0
1*1 = 1

Review of Boolean algebra truth tables

AND, OR, NOT


AND

AB Y
0 0 0
0 1 0
1 0 0
1 1 1

OR

AB Y
0 0 0
0 1 1
1 0 1
1 1 1

NOT

A Y
0 1
1 0

Some Laws of
Boolean Algebra
Commutative laws: a+b = b+a, ab = ba =b*a
Distributive laws: a+(bc) = (a+b)(a+c),
a(b+c) = ab+ac
Identity laws: a+0 = a, a*1 = a
Complement laws: a+ = 1, a* = 0
<8>

Boolean algebra
and Boolean Logic
___

Example: translate (x+y+z)(xyz) to a Boolean


logic expression
(xyz)(xyz)

We can define a Boolean function:


F(x,y) = (xy)(xy)

And then write a truth table for it:


x

F(x,y)

Basic logic gates


Not

And

x
y

xy

Or

x
y

x+y

Nand

x
y

xy

Nor

x
y

x+y

Xor

x
y

xy

x
y
z
x
y
z

xyz
x+y+z

10

Converting between circuits and


equations
Find the output of the following circuit

x
y

x+y

(x+y)y

__

Answer: (x+y)y
Or (xy)y

11

Converting between circuits and


equations
Find the output of the following circuit

xy

xy

___
__

Answer: xy

Or (xy) xy

12

Converting between circuits and


equations

Write the circuits for the following


Boolean algebraic expressions
__
a) x+y

x
y

x+y

13

Converting between circuits and


equations

Write the circuits for the following


Boolean
algebraic
expressions
_______
b) (x+y)x

x
y

x+y

x+y

(x+y)x

14

Writing xor using and/or/not


p q (p q) (p q)
____

x y (x + y)(xy)

x
y

x+y
xy

xy

(x+y)(xy)
xy
15

1. Identity

A* 1=A
A* 0= 0

A+1=1
A+0=A

2. Complement

A+ = 1

A*=0

Distributivity Law
A(B+C) = AB + AC

A+BC = (A+B)(A+C)

A
B
C

A
B
A
C

A
B
C

A
B
A
C
16

Associativity
(A+B) + C = A + (B+C)

C
A
B

A
B
C

(AB)C = A(BC)

C
A
B

A
B
C

DeMorgans Law

(A+B) = A B

(AB) = A + B

AC + AB + B C
= AC + BC

17

DeMorgans Law
Y = AB = A + B

Y=A+B=A B

A
B

A
B

A
B

A
B

1-<18>

Bubble Pushing
Pushing bubbles backward (from the
output) or forward (from the inputs)
changes the body of the gate from AND to
OR or vice versa.
Pushing a bubble from the output back to
the inputs puts bubbles on all gate inputs.
A
B

A
B

Pushing bubbles on all gate inputs forward


toward the output puts a bubble on the
output and changes the gate body.
A
B

A
B

Y
<19>

How to add binary numbers


Consider adding two 1-bit binary numbers x and y

0+0 = 0
0+1 = 1
1+0 = 1
1+1 = 10

x
0
0
1
1

y
0
1
0
1

Carry Sum
0
0
0
1
0
1
1
0

Carry is x AND y
Sum is x XOR y
The circuit to compute this is called a half-adder

20

Half Adder
Truth Table
x
Sum
y
Carry

carry

sum

0
0
1
1

0
1
0
1

0
0
0
1

0
1
1
0

21

The half-adder
Sum = x XOR y
Carry = x AND y

x
y

x
y

Sum
Carry

Carry Sum

Sum
Carry
22

Using half adders


We can then use a half-adder to compute
the sum of two Boolean numbers
1
1
+1
?

0
1
1
0

0
0 0
1 0
1 0

23

How to fix this


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?


Its 1 if either (or both):
x+y = 10
x+y = 01 and carry in = 1

x y c carry sum
1 1 1 1
1
1 1 0 1
0
1 0 1
1 0 0
0 1 1

1
0
1

0
1
0

0 1 0
0 0 1
0 0 0

0
0
0

1
1
0
24

x y c s1 c1 carry sum

The full adder


The HA boxes are
half-adders

c
x
y

s1
X

HA

HA

S
S

1
1
1
1
0
0
0
0

1
1
0
0
1
1
0
0

1
0
1
0
1
0
1
0

0
0
1
1
1
1
0
0

1
1
0
0
0
0
0
0

1
1
1
0
1
0
0
0

1
0
0
1
0
1
1
0

C
C

c1

c
25

The full adder


The full circuitry of the full adder
c
s
x
y
c
26

Adding bigger binary numbers


Just chain full adders together
Y

HA

s0

C
C

FA

s1

X
Y

FA

s2

X
Y

FA

X
Y

...

x0
y0
x1
y1
x2
y2
x3
y3

s3
c
27

Adding bigger binary numbers


A half adder has 4 logic gates
A full adder has two half adders plus a OR gate
Total of 9 logic gates

To add n bit binary numbers, you need 1 HA and


n-1 FAs
To add 32 bit binary numbers, you need 1 HA
and 31 FAs
Total of 4+9*31 = 283 logic gates

To add 64 bit binary numbers, you need 1 HA


and 63 FAs
Total of 4+9*63 = 571 logic gates
28

More about logic gates


To implement a logic gate in hardware,
you use a transistor
Transistors are all enclosed in an IC, or
integrated circuit
The current Intel Pentium IV processors
have 55 million transistors!

29

Flip-flops
Consider the following circuit:

What does it do?

30

Memory
A flip-flop holds a single bit of memory
The bit flip-flops between the two NAND
gates

In reality, flip-flops are a bit more


complicated
Have 5 (or so) logic gates (transistors) per flipflop

Consider a 1 Gb memory chip


1 Gb = 8,589,934,592 bits of memory
Thats about 43 million transistors!

In reality, those transistors are split into 9


ICs of about 5 million transistors each
31

You might also like