coms 361 computer organization

56
1 COMS 361 Computer Organization Title: Boolean Algebra Date: 11/02/2004 Lecture Number: 17

Upload: shubha

Post on 10-Feb-2016

38 views

Category:

Documents


1 download

DESCRIPTION

COMS 361 Computer Organization. Title: Boolean Algebra Date: 11/02/2004 Lecture Number: 17. Announcements. Homework 8 Due Thursday, 11/11/04. Review. Representing numbers in binary Problems Unsigned (magnitude) Sign-magnitude One’s complement Two’s complement. Outline. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: COMS 361 Computer Organization

1

COMS 361Computer Organization

Title: Boolean AlgebraDate: 11/02/2004Lecture Number: 17

Page 2: COMS 361 Computer Organization

2

Announcements

• Homework 8– Due Thursday, 11/11/04

Page 3: COMS 361 Computer Organization

3

Review

• Representing numbers in binary– Problems

• Unsigned (magnitude)• Sign-magnitude

– One’s complement– Two’s complement

Page 4: COMS 361 Computer Organization

4

Outline

• Representing numbers in binary– Finish overflow

• Boolean Algebra• Boolean Logic

Page 5: COMS 361 Computer Organization

5

Truth Table

• Provides a listing of every possible combination of inputs and corresponding outputs

• Example (2 inputs, 2 outputs):

INPUTS OUTPUTS… …… …

x y x . y x + y0 0 0 00 1 0 11 0 0 11 1 1 1

Page 6: COMS 361 Computer Organization

6

Truth Table

• Example (3 inputs, 2 outputs):

x y z y + z x.(y + z)0 0 0 0 00 0 1 1 00 1 0 1 00 1 1 1 01 0 0 0 01 0 1 1 11 1 0 1 11 1 1 1 1

Page 7: COMS 361 Computer Organization

7

Proof using Truth Table

• Can use truth table to prove a Boolean expression• Prove that: x . (y + z) = (x . y) + (x . z)

(i) Construct truth table for LHS & RHS of above equality

x y z y + z x.(y + z) x.y x.z (x.y)+(x.z)0 0 0 0 0 0 0 00 0 1 1 0 0 0 00 1 0 1 0 0 0 00 1 1 1 0 0 0 01 0 0 0 0 0 0 01 0 1 1 1 0 1 11 1 0 1 1 1 0 11 1 1 1 1 1 1 1

Page 8: COMS 361 Computer Organization

8

Proof using Truth Table

(ii) Check that LHS = RHS– Postulate is SATISFIED because output column 2

& 5 (for LHS & RHS expressions) are equal for all cases

Page 9: COMS 361 Computer Organization

9

Duality

• Duality Principle – every valid Boolean expression (equality) remains valid if the operators and identity elements are interchanged, as follows:

+ .1 0

• Example: Given the expressiona + (b.c) = (a+b).(a+c)

then its dual expression is

a . (b+c) = (a.b) + (a.c)

Page 10: COMS 361 Computer Organization

10

Duality

• Duality gives free theorems– “two for the price of one”– You prove one theorem and the other comes for free!

• If (x+y+z)' = x'.y.'z' is valid, then its dual is also valid:(x.y.z)' = x'+y'+z’

• If x + 1 = 1 is valid, then its dual is also valid:x . 0 = 0

Page 11: COMS 361 Computer Organization

11

Basic Theorems of Boolean Algebra

• Apart from the axioms/postulates, there are other useful theorems.

Idempotency(a) x + x = x (b) x . x = x

Proof of (a): x + x = (x + x).1 (identity)

= (x + x).(x + x') (complementarity)= x + x.x' (distributivity)= x + 0 (complementarity)= x (identity)

Page 12: COMS 361 Computer Organization

12

Basic Theorems of Boolean Algebra

• Theorems can be proved using the truth table method.

• They can also be proved by algebraic manipulation using axioms/postulates or other basic theorems.

Page 13: COMS 361 Computer Organization

13

Basic Theorems of Boolean Algebra

• absorption can be proved by: x + x.y = x.1 + x.y (identity) = x.(1 + y) (distributivity) = x.(y + 1) (commutativity) = x.1 (Theorem 2a) = x (identity)

• By duality: x.(x+y) = x

• Try to prove other theorems by algebraic manipulation.

Page 14: COMS 361 Computer Organization

14

Boolean Functions

• Boolean function is an expression formed with binary variables, the two binary operators, OR and AND, and the unary operator, NOT, parenthesis and the equal sign.

• Its result is also a binary value.• We usually use . for AND, + for OR, and ' or ¬ for

NOT. Sometimes, we may omit the . if there is no ambiguity.

Page 15: COMS 361 Computer Organization

15

Boolean Functions

• Examples: F1= xyz' F2= x + y'z F3=(x'y'z)+(x'yz)+(xy') F4=xy'+x'z

• From the truth table, F3=F4.• Can you also prove by algebraic

manipulation that F3=F4?

x y z F1 F2 F3 F40 0 0 0 0 0 00 0 1 0 1 1 10 1 0 0 0 0 00 1 1 0 0 1 11 0 0 0 1 1 11 0 1 0 1 1 11 1 0 1 1 0 01 1 1 0 1 0 0

Page 16: COMS 361 Computer Organization

16

Complement of Functions

• Given a function, F, the complement of this function, F', is obtained by interchanging 1 with 0 in the function’s output values.

x y z F1 F1'0 0 0 0 10 0 1 0 10 1 0 0 10 1 1 0 11 0 0 0 11 0 1 0 11 1 0 1 01 1 1 0 1

Example: F1 = xyz' Complement: F1' = (xyz')' = x' + y' + (z')' DeMorgan = x' + y' + z Involution

Page 17: COMS 361 Computer Organization

17

Complement of Functions

• More general DeMorgan’s theorems useful for obtaining complement functions:

(A + B + C + ... + Z)' = A' . B' . C' … . Z' (A . B . C ... . Z)' = A' + B' + C' + … + Z'

Page 18: COMS 361 Computer Organization

18

Standard Forms

• Certain types of Boolean expressions lead to gating networks which are desirable from implementation viewpoint

• Two Standard Forms: Sum-of-Products and Product-of-Sums

• Literals: a variable on its own or in its complemented form. Examples: x, x' , y, y'

• Product Term: a single literal or a logical product (AND) of several literals.

Examples: x, xyz', A'B, AB

Page 19: COMS 361 Computer Organization

19

Standard Forms

• Sum Term: a single literal or a logical sum (OR) of several literals.

Examples: x, x+y+z', A'+B, A+B

• Sum-of-Products (SOP) Expression: a product term or a logical sum (OR) of several product terms.

Examples: x, x+yz', xy'+x'yz, AB+A'B'

• Product-of-Sums (POS) Expression: a sum term or a logical product (AND) of several sum terms.

Exampes: x, x(y+z'), (x+y')(x'+y+z), (A+B)(A'+B')

Page 20: COMS 361 Computer Organization

20

Standard Forms

• Every boolean expression can either be expressed as sum-of-products or product-of-sums expression

Page 21: COMS 361 Computer Organization

21

Summary

Boolean algebra is required for constructing digital circuits

AND, OR and NOT constitute connectives

Boolean laws can be proved with either the help of truth table or with the basic postulates

There are certain postulates and theorems in Boolean algebra which helps in manipulation of boolean expression

SOP and POS are two generic way of expressing any boolean function

Page 22: COMS 361 Computer Organization

22

Example: Half Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

Page 23: COMS 361 Computer Organization

23

Example: Half Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

Page 24: COMS 361 Computer Organization

24

Example: Half Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

Page 25: COMS 361 Computer Organization

25

Example: Half Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

Page 26: COMS 361 Computer Organization

26

Example: Full Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

Example: full adder adds two binary digits and Carry in to form Sum and Carry Out

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C in 0 1 0 1 0 1 0 1

S um 0 1 1 0 1 0 0 1

C out 0 0 0 1 0 1 1 1

Page 27: COMS 361 Computer Organization

27

Example: Full Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

Example: full adder adds two binary digits and Carry in to form Sum and Carry Out

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C in 0 1 0 1 0 1 0 1

S um 0 1 1 0 1 0 0 1

C out 0 0 0 1 0 1 1 1

Page 28: COMS 361 Computer Organization

28

Example: Full Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

Example: full adder adds two binary digits and Carry in to form Sum and Carry Out

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C in 0 1 0 1 0 1 0 1

S um 0 1 1 0 1 0 0 1

C out 0 0 0 1 0 1 1 1

Page 29: COMS 361 Computer Organization

29

Example: Full Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

Example: full adder adds two binary digits and Carry in to form Sum and Carry Out

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C in 0 1 0 1 0 1 0 1

S um 0 1 1 0 1 0 0 1

C out 0 0 0 1 0 1 1 1

Page 30: COMS 361 Computer Organization

30

Example: Full Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

Example: full adder adds two binary digits and Carry in to form Sum and Carry Out

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C in 0 1 0 1 0 1 0 1

S um 0 1 1 0 1 0 0 1

C out 0 0 0 1 0 1 1 1

Page 31: COMS 361 Computer Organization

31

Example: Full Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

Example: full adder adds two binary digits and Carry in to form Sum and Carry Out

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C in 0 1 0 1 0 1 0 1

S um 0 1 1 0 1 0 0 1

C out 0 0 0 1 0 1 1 1

Page 32: COMS 361 Computer Organization

32

Example: Full Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

Example: full adder adds two binary digits and Carry in to form Sum and Carry Out

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C in 0 1 0 1 0 1 0 1

S um 0 1 1 0 1 0 0 1

C out 0 0 0 1 0 1 1 1

Page 33: COMS 361 Computer Organization

33

Example: Full Adder

• Truth Tables– Tabulate all possible input combinations and their

associated output values

Example: half adder adds two binary digits to form Sum and Carry

Example: full adder adds two binary digits and Carry in to form Sum and Carry Out

A B 0 0 1 1

0 1 0 1

Sum Carry 0 1 1 0

0 0 0 1

A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

C in 0 1 0 1 0 1 0 1

S um 0 1 1 0 1 0 0 1

C out 0 0 0 1 0 1 1 1

Page 34: COMS 361 Computer Organization

34

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

Sum = A B Cin

Page 35: COMS 361 Computer Organization

35

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

Sum = A B Cin + A B Cin

Page 36: COMS 361 Computer Organization

36

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

Sum = A B Cin + A B Cin + A B Cin

Page 37: COMS 361 Computer Organization

37

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

Sum = A B Cin + A B Cin + A B Cin + A B Cin

Page 38: COMS 361 Computer Organization

38

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

Sum = A B Cin + A B Cin + A B Cin + A B Cin

Cout = A B Cin

Page 39: COMS 361 Computer Organization

39

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

Sum = A B Cin + A B Cin + A B Cin + A B Cin

Cout = A B Cin + A B Cin

Page 40: COMS 361 Computer Organization

40

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

Sum = A B Cin + A B Cin + A B Cin + A B Cin

Cout = A B Cin + A B Cin + A B Cin

Page 41: COMS 361 Computer Organization

41

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

Sum = A B Cin + A B Cin + A B Cin + A B Cin

Cout = A B Cin + A B Cin + A B Cin + A B Cin

Page 42: COMS 361 Computer Organization

42

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

Sum = A B Cin + A B Cin + A B Cin + A B Cin

Cout = A B Cin + A B Cin + A B Cin + A B Cin

Page 43: COMS 361 Computer Organization

43

Example

• Circuit to drive a digital display

• Need 4 bits to represent 10 numbers (0-9)

L1

L6

L2

L3

L7

L4

L5

Page 44: COMS 361 Computer Organization

44

Example

• Determine which segments are on for each number

L1L

6L2

L3

L

7

L4

L5

B3 B2 B1 B0 Val L1 L2 L3 L4 L5 L6 L7

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

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

0 0 1 0 2 1 1 1 0 1 1 0

0 0 1 1 3 1 1 1 0 0 1 1

0 1 0 0 4 0 1 0 1 0 1 1

0 1 0 1 5 1 1 1 1 0 0 1

0 1 1 0 6 1 1 1 1 1 0 1

0 1 1 1 7 1 0 0 0 0 1 1

1 0 0 0 8 1 1 1 1 1 1 1

1 0 0 1 9 1 1 1 1 0 1 1

Page 45: COMS 361 Computer Organization

45

Example

• Determine which segments are on for each number

L1L

6L2

L3

L

7

L4

L5

B3 B2 B1 B0 Val L1 L2 L3 L4 L5 L6 L7

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

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

0 0 1 0 2 1 1 1 0 1 1 0

0 0 1 1 3 1 1 1 0 0 1 1

0 1 0 0 4 0 1 0 1 0 1 1

0 1 0 1 5 1 1 1 1 0 0 1

0 1 1 0 6 1 1 1 1 1 0 1

0 1 1 1 7 1 0 0 0 0 1 1

1 0 0 0 8 1 1 1 1 1 1 1

1 0 0 1 9 1 1 1 1 0 1 1

Page 46: COMS 361 Computer Organization

46

Example

• Determine which segments are on for each number

L1L

6L2

L3

L

7

L4

L5

B3 B2 B1 B0 Val L1 L2 L3 L4 L5 L6 L7

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

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

0 0 1 0 2 1 1 1 0 1 1 0

0 0 1 1 3 1 1 1 0 0 1 1

0 1 0 0 4 0 1 0 1 0 1 1

0 1 0 1 5 1 1 1 1 0 0 1

0 1 1 0 6 1 1 1 1 1 0 1

0 1 1 1 7 1 0 0 0 0 1 1

1 0 0 0 8 1 1 1 1 1 1 1

1 0 0 1 9 1 1 1 1 0 1 1

Page 47: COMS 361 Computer Organization

47

Example

• Determine which segments are on for each number

L1L

6L2

L3

L

7

L4

L5

B3 B2 B1 B0 Val L1 L2 L3 L4 L5 L6 L7

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

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

0 0 1 0 2 1 1 1 0 1 1 0

0 0 1 1 3 1 1 1 0 0 1 1

0 1 0 0 4 0 1 0 1 0 1 1

0 1 0 1 5 1 1 1 1 0 0 1

0 1 1 0 6 1 1 1 1 1 0 1

0 1 1 1 7 1 0 0 0 0 1 1

1 0 0 0 8 1 1 1 1 1 1 1

1 0 0 1 9 1 1 1 1 0 1 1

Page 48: COMS 361 Computer Organization

48

Example

• Determine which segments are on for each number

L1L

6L2

L3

L

7

L4

L5

B3 B2 B1 B0 Val L1 L2 L3 L4 L5 L6 L7

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

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

0 0 1 0 2 1 1 1 0 1 1 0

0 0 1 1 3 1 1 1 0 0 1 1

0 1 0 0 4 0 1 0 1 0 1 1

0 1 0 1 5 1 1 1 1 0 0 1

0 1 1 0 6 1 1 1 1 1 0 1

0 1 1 1 7 1 0 0 0 0 1 1

1 0 0 0 8 1 1 1 1 1 1 1

1 0 0 1 9 1 1 1 1 0 1 1

Page 49: COMS 361 Computer Organization

49

Example

• Determine which segments are on for each number

L1L

6L2

L3

L

7

L4

L5

B3 B2 B1 B0 Val L1 L2 L3 L4 L5 L6 L7

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

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

0 0 1 0 2 1 1 1 0 1 1 0

0 0 1 1 3 1 1 1 0 0 1 1

0 1 0 0 4 0 1 0 1 0 1 1

0 1 0 1 5 1 1 1 1 0 0 1

0 1 1 0 6 1 1 1 1 1 0 1

0 1 1 1 7 1 0 0 0 0 1 1

1 0 0 0 8 1 1 1 1 1 1 1

1 0 0 1 9 1 1 1 1 0 1 1

Page 50: COMS 361 Computer Organization

50

Example

• Determine which segments are on for each number

L1L

6L2

L3

L

7

L4

L5

B3 B2 B1 B0 Val L1 L2 L3 L4 L5 L6 L7

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

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

0 0 1 0 2 1 1 1 0 1 1 0

0 0 1 1 3 1 1 1 0 0 1 1

0 1 0 0 4 0 1 0 1 0 1 1

0 1 0 1 5 1 1 1 1 0 0 1

0 1 1 0 6 1 1 1 1 1 0 1

0 1 1 1 7 1 0 0 0 0 1 1

1 0 0 0 8 1 1 1 1 1 1 1

1 0 0 1 9 1 1 1 1 0 1 1

Page 51: COMS 361 Computer Organization

51

Example

• Determine which segments are on for each number

L1L

6L2

L3

L

7

L4

L5

B3 B2 B1 B0 Val L1 L2 L3 L4 L5 L6 L7

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

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

0 0 1 0 2 1 1 1 0 1 1 0

0 0 1 1 3 1 1 1 0 0 1 1

0 1 0 0 4 0 1 0 1 0 1 1

0 1 0 1 5 1 1 1 1 0 0 1

0 1 1 0 6 1 1 1 1 1 0 1

0 1 1 1 7 1 0 0 0 0 1 1

1 0 0 0 8 1 1 1 1 1 1 1

1 0 0 1 9 1 1 1 1 0 1 1

Page 52: COMS 361 Computer Organization

52

Example

• Determine which segments are on for each number

L1L

6L2

L3

L

7

L4

L5

B3 B2 B1 B0 Val L1 L2 L3 L4 L5 L6 L7

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

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

0 0 1 0 2 1 1 1 0 1 1 0

0 0 1 1 3 1 1 1 0 0 1 1

0 1 0 0 4 0 1 0 1 0 1 1

0 1 0 1 5 1 1 1 1 0 0 1

0 1 1 0 6 1 1 1 1 1 0 1

0 1 1 1 7 1 0 0 0 0 1 1

1 0 0 0 8 1 1 1 1 1 1 1

1 0 0 1 9 1 1 1 1 0 1 1

Page 53: COMS 361 Computer Organization

53

Example

• Determine which segments are on for each number

L1L

6L2

L3

L

7

L4

L5

B3 B2 B1 B0 Val L1 L2 L3 L4 L5 L6 L7

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

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

0 0 1 0 2 1 1 1 0 1 1 0

0 0 1 1 3 1 1 1 0 0 1 1

0 1 0 0 4 0 1 0 1 0 1 1

0 1 0 1 5 1 1 1 1 0 0 1

0 1 1 0 6 1 1 1 1 1 0 1

0 1 1 1 7 1 0 0 0 0 1 1

1 0 0 0 8 1 1 1 1 1 1 1

1 0 0 1 9 1 1 1 1 0 1 1

Page 54: COMS 361 Computer Organization

54

Example

• Circuit to drive segment L4

3210 3210

3210 3210

3210 3210 L4

BBBBBBBB

BBBBBBBB

BBBBBBBB

L1L

6L2

L3

L

7

L4

L5

Page 55: COMS 361 Computer Organization

55

Reducing Complexity

• Laws of Boolean algebra can be applied to full adder's carry out

• Function to derive the following simplified expression

Cout = A Cin + B Cin + A B

A 0 0 0 0 1 1 1 1

C in 0 1 0 1 0 1 0 1

B 0 0 1 1 0 0 1 1

C out 0 0 0 1 0 1 1 1

B C in

A C in

A B

Page 56: COMS 361 Computer Organization

56

• Some standard gates and their symbols and truth tables