CPS 104 Computer Organization and Programming Lecture-15: Boolean Algebra, Gates & Circuits

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

CPS 104 Computer Organization and Programming Lecture- 15: Boolean Algebra, Gates & Circuits.

Feb 13, 2004 Gershon Kedem http://kedem.duke.edu/cps104/Lectures

CPS104 Lec15.1

GK Spring 2004

Admin.

Homework-3 Due Feb. 23rd 11:59 pm. C++ version is posted. Start NOW!

CPS104 Lec15.2

GK Spring 2004

What Weve Done, Where Were Going

Application Top Down Compiler CPU Operating System Firmware

Software
Interface Between HW and SW Instruction Set Architecture, Memory, I/O

Memory I/O system

Digital Design
Circuit Design

Hardware

Bottom UP to CPU
CPS104 Lec15.3

GK Spring 2004

Overview of Todays Lecture:


Introduction to Boolean Algebra. Boolean Functions, Gates and Circuits

Reading Assignment: Chapter 4, Appendix B.

CPS104 Lec15.4

GK Spring 2004

Introduction to Boolean Algebra:


Truth tables, Boolean functions, Gates and Circuits

Read Appendix B

CPS104 Lec15.5

GK Spring 2004

Boolean Functions and Gates

Boolean functions have arguments that take two values ({T,F} or {0,1}) and they return a single or a set of ({T,F} or {0,1}) value(s). Boolean functions can always be represented by a table called: Truth Table Example:

F: {0,1}3 -> {0,1}2


a 0 0 0 0 1 1 1 1 b 0 0 1 1 0 0 1 1 c 0 1 0 1 0 1 0 1 f1f2 0 1 1 1 1 0 0 0 1 0 0 1 0 1 1 1
GK Spring 2004

CPS104 Lec15.6

Boolean Functions and Gates (Cont.)

Examples: Boolean functions: NOT, AND, OR, XOR, . . .


a 0 1 NOT(a) 1 0 a 0 0 1 1 b 0 1 0 1 a 0 0 1 1 AND(a,b) 0 0 0 1 b 0 1 0 1 a 0 0 1 1 b 0 1 0 1 a 0 0 1 1 OR(a,b) 0 1 1 1 b 0 1 0 1 NOR(a,b) 1 0 0 0
GK Spring 2004

a 0 0 1 1

b 0 1 0 1

XOR(a,b) 0 1 1 0

XNOR(a,b) 1 0 0 1

CPS104 Lec15.7

Boolean Functions and Gates


(Cont.)

a b

Gates are electronics devices that implements simple Boolean functions: Examples:
AND(a,b) a b OR(a,b)

NOT(a)

a b

XOR(a,b)

a b

NAND(a,b)

a b

NOR(a,b)

a b

XNOR(a,b)

CPS104 Lec15.8

GK Spring 2004

Boolean Expressions

Boolean algebra notation: Use: * for AND, + for OR, ~ for NOT. Using the above notation one could write boolean expressions for functions: Example:

F(A, B, C) = (A * B) + ( ~A*C)

CPS104 Lec15.9

GK Spring 2004

Boolean Functions and Expressions

One can evaluate the Boolean expression with all possible argument values to construct a truth table. Example:

F(A, B, C) = (A * B) + ( ~A*C)
A
0 0 0 0 1 1 1 1
CPS104 Lec15.10

B
0 0 1 1 0 0 1 1

C
0 1 0 1 0 1 0 1

F
0 1 0 1 0 0 1 1
GK Spring 2004

Boolean functions simplification

Boolean expressions could be simplified by using the following rules: u A*A = A u A* 0 = 0 u A*1 = A u A*~A = 0
u u u u

A+A = A A+0 = A A+1 = 1 A+~A = 1 A*B = B*A A*(B+C) = (B+C)*A = A*B + A*C

u u

CPS104 Lec15.11

GK Spring 2004

Boolean Functions simplification

Example: b 0 0 1 1 0 0 1 1 c 0 1 0 1 0 1 0 1 f1f2 0 1 1 1 0 0 1 0 0 0 1 0 0 1 1 1

a 0 0 0 0 1 1 1 1

f1 = ~a*~b*c + ~a*b*c + a*~b*c + a*b*c f2 = ~a*~b*~c + ~a*~b*c + a*b*~c + a*b*c

CPS104 Lec15.12

GK Spring 2004

Boolean Functions Simplification f1 = ~a*~b*c + ~a*b*c + a*~b*c + a*b*c = ~a*(~b*c +b*c) +a*(~b*c+b*c) = ~a*c*(~b+b) ~a*c*(~b+b) = ~a*c + a*c = c*(~a+a) =c f2 = ~a*~b*~c + ~a*~b*c + a*b*~c + a*b*c = ~a*(~b*~c + ~b*c) + a*(b*~c + b*c) = ~a*~b(c+~c) * a*b*(~c+c) = ~a*~b + a*b

CPS104 Lec15.13

GK Spring 2004

Boolean Functions and Expressions


The Fundamental Theorem of Boolean Algebra: Every Boolean function can be written in disjunctive normal form as an OR of ANDs (Sumof products) of its arguments or their complements. Proof: Write the truth table, construct sum-ofproduct from the table. Example:
a 0 0 1 1 b 0 1 0 1 XNOR(a,b) 1 0 0 1

XNOR = (~a * ~b) + (a * b)

CPS104 Lec15.14

GK Spring 2004

Boolean Functions and Boolean Expressions

Example-2: b 0 0 1 1 0 1 1 c 0 1 0 1 0 0 1 f1f2 0 1 1 1 1 0 0 0 1 0 0 1 1 1

a 0 0 0 0 1 1 1

f1 = ~a*~b*c + ~a*b*~c + a*~b*~c + a*b*c f2 = ~a*~b*~c + ~a*~b*c + a*b*~c + a*b*c

CPS104 Lec15.15

GK Spring 2004

Boolean Functions, Gates and Circuits


Circuits are made from a network of gates. (function compositions). a b XOR(a,b) Example: 0 0 0 0 1 1 1 0 1 1 1 0

F = ~a*b + ~b*a
b F

CPS104 Lec15.16

GK Spring 2004

Circuit Example: 2x1 MUX


a b
1 0

s
B Gate 1 Y = (A * S) + (B * ~S) Gate 3 A S Gate 2

CPS104 Lec15.17

GK Spring 2004

Example 4x1 MUX


A
1

0 1

a b c d

3 2

y
C
1 0

1 0

S S0 S1

CPS104 Lec15.18

GK Spring 2004

Circuit Example: Selector


Q3

I1 I0 Q0 Q1 Q2 Q3
Q2

0 0 0 1

1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

Q1

1 0 1 1

Q0

CPS104 Lec15.19 I1

I0

GK Spring 2004

Full Adder
Cin a b Sum

01101100 01101101 +00101100 10011001

Cout

a 0 0 0 0 1 1 1 1

b 0 0 1 1 0 0 1 1

Cin 0 1 0 1 0 1 0 1

Sum 0 1 1 0 1 0 0 1

Cout 0 0 0 1 0 1 1 1
GK Spring 2004

CPS104 Lec15.20

Example: 4-bit adder

S3 Cout
Full Adder

S2
Full Adder

S1
Full Adder

S0
Full Adder

b3 a3

b2 a2

b1

a1

b0

a0

CPS104 Lec15.21

GK Spring 2004

You might also like