COMS 361 Computer Organization

Post on 10-Feb-2016

31 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

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

1

COMS 361Computer Organization

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

2

Announcements

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

3

Review

• Representing numbers in binary– Problems

• Unsigned (magnitude)• Sign-magnitude

– One’s complement– Two’s complement

4

Outline

• Representing numbers in binary– Finish overflow

• Boolean Algebra• Boolean Logic

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

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

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

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

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)

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

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)

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.

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.

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.

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

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

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'

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

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')

20

Standard Forms

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

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

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

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

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

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

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

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

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

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

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

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

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

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

34

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

Sum = A B Cin

35

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

Sum = A B Cin + A B Cin

36

Example: Full Adder

A

00001111

B

00110011

Cin

01010101

Sum

01101001

Cout

00010111

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

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

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

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

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

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

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

43

Example

• Circuit to drive a digital display

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

L1

L6

L2

L3

L7

L4

L5

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

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

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

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

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

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

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

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

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

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

54

Example

• Circuit to drive segment L4

3210 3210

3210 3210

3210 3210 L4

BBBBBBBB

BBBBBBBB

BBBBBBBB

L1L

6L2

L3

L

7

L4

L5

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

56

• Some standard gates and their symbols and truth tables

top related