Vous êtes sur la page 1sur 19

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

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

CPS104 Lec16.1

GK Spring 2004

Admin.

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

CPS104 Lec16.2

GK Spring 2004

Review: 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 Lec16.3

GK Spring 2004

Review: 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 Lec16.4

GK Spring 2004

Review: 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 Lec16.5

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 Lec16.6

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 Lec16.7

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 Lec16.8

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 Lec16.9

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 Lec16.10

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 Lec16.11 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 Lec16.12

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 Lec16.13

GK Spring 2004

Example: Adder/Subtractor
S3 Cout
Full Adder

S2
Full Adder

S1
Full Adder

S0
Full Adder

Add/Sub b3 a3 b2 a2 b1 a1 b0 a0

CPS104 Lec16.14

GK Spring 2004

Overflow Example1: 0100000 01101012 (= 5310) +01010102 (= 4210) 10111112 (=-3310) Example3: 1100000 01101012 (= 5310) +11010102 (=-2210) 00111112 (= 3110)
CPS104 Lec16.15

Example2: 1000000 10101012 (=-4310) +10010102 (=-5410) 00111112 (= 3110) Example4: 0000000 00101012 (= 2110) +01010102 (= 4210) 01111112 (= 6310)
GK Spring 2004

Add/Subtract With Overflow detection


Overflow

Sn- 1
Full Adder

Sn- 2
Full Adder

S1

S0

Full Adder

Full Adder

Add/Sub bn- 1 an- 1 bn- 2 an- 2 b1 a1 b0 a0

CPS104 Lec16.16

GK Spring 2004

ALU Slice
Cin 3

a b
2 1

A 0 1 -

F 0 0 1 2 3

Q a+b a-b NOT b a OR b a AND b

Add/sub

0 2

Cout Add/sub
CPS104 Lec16.17

F
GK Spring 2004

The ALU
Overflow
= Zero

Qn-1

Qn-2

Q1

Q0
ALU control

ALU Slice

ALU Slice

ALU Slice

ALU Slice

bn-1 an-1

bn-2 an-2

b1

a1

b0

a0

CPS104 Lec16.18

GK Spring 2004

Shifter
a7 a6 a5 a4 a3 a2 a1 a0

Shift-1

Shift-2

Shift-4

1
Q7
CPS104 Lec16.19

Q6

Q5

Q4

Q3

Q2

Q1

Q0
GK Spring 2004

Vous aimerez peut-être aussi