computer science 210 computer organization introduction to boolean algebra

32
Computer Science 210 Computer Organization Introduction to Boolean Algebra

Upload: gertrude-sparks

Post on 01-Jan-2016

222 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Computer Science 210Computer Organization

Introduction to

Boolean Algebra

Page 2: Computer Science 210 Computer Organization Introduction to Boolean Algebra

George Boole

• English mathematician (1815-1864)

• Boolean algebra– Logic– Set Theory– Digital circuits– Programming: Conditions in while and if

statements

Page 3: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Constants

In Boolean algebra, there are only two constants, true and false

Boolean constant

Binary digit

State of a switch

Voltage level

true 1 On +5V

false 0 Off 0V

Page 4: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Variables

Boolean variables are variables that store values that are Boolean constants.

Let A be true

Let B be false

Etc.

Page 5: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Operator AND

If A and B are Boolean variables (or expressions) then

A AND B

is true if and only if both A and B are true.

Page 6: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Operator AND

If A and B are Boolean variables (or expressions) then

A AND B

is false if and only if either A or B are false or they’re both false.

Page 7: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Operator AND

We denote the AND operation like multiplication in ordinary algebra:

AB or A.B

Page 8: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Operator OR

If A and B are Boolean variables (or expressions) then

A OR B

is true if and only if at least one of A and B is true.

Page 9: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Operator OR

If A and B are Boolean variables (or expressions) then

A OR B

is false if and only if both A and B are false.

Page 10: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Operator OR

We denote the OR operation like addition in ordinary algebra:

A+B

Page 11: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Operator NOT

If A is a Boolean variable (or expression) then

NOT A

has the opposite value from A.

Page 12: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Operator NOT

We denote the NOT operation by putting a bar over the variable (or expression)

_A

Page 13: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Expressions

• As with ordinary algebra, a Boolean expression is a well-formed expression made from– Boolean constants

– Boolean variables

– Operators AND, OR and NOT

– Parentheses

• Example: __ ____ AB + (A+C)B

Page 14: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Evaluating a Boolean expression

At any time, the value of a BE can be computed using the current values of the variables.

__AB + (CD)

Let A = trueLet B = falseLet C = trueLet D = false

Then the resulting value is true

Page 15: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Operator precedence

NOT comes first, then AND, and finally OR

(Like arithmetic negation, product, and addition)

A + BC is not the same as

(A + B)C

Page 16: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Evaluating a Boolean expressionUnlike ordinary algebra, for a BE, there are only finitely many possible assignments of values to the variables; so, theoretically, we can make a table, called a truth table, that shows the value of the BE for every possible set of values of the variables.

For convenience, use 0 = false 1 = true

Page 17: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Truth Table for AND

A B AB

0 0 0

0 1 0

1 0 0

1 1 1

Page 18: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Truth Table for OR

A B A+B

0 0 0

0 1 1

1 0 1

1 1 1

Page 19: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Truth Table for NOT

A

_

A

0 1

1 0

Page 20: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Filling in a Truth Table

• If there are N variables, there are 2N possible combinations of values

• Thus, there are 2N rows in the truth table

• Fill in the values by counting up from 0 in binary

Page 21: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Construct a truth table for _ ___ E = AB + (A+C)B

Example

Page 22: Computer Science 210 Computer Organization Introduction to Boolean Algebra

A B C

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

_ ___ E = AB + (A+C)B

Assign the values of the variables first

Page 23: Computer Science 210 Computer Organization Introduction to Boolean Algebra

A B C

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

_

B

1

1

0

0

1

1

0

0

_ ___ E = AB + (A+C)B

Then add columns for each operation

Page 24: Computer Science 210 Computer Organization Introduction to Boolean Algebra

A B C

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

_

B

1

1

0

0

1

1

0

0

_ ___ E = AB + (A+C)B _

AB

0

0

0

0

1

1

0

0

Page 25: Computer Science 210 Computer Organization Introduction to Boolean Algebra

A B C

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

_

B

1

1

0

0

1

1

0

0

_ ___ E = AB + (A+C)B _

AB

0

0

0

0

1

1

0

0

A+C

0

1

0

1

1

1

1

1

Page 26: Computer Science 210 Computer Organization Introduction to Boolean Algebra

A B C

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

_

B

1

1

0

0

1

1

0

0

_ ___ E = AB + (A+C)B _

AB

0

0

0

0

1

1

0

0

A+C

0

1

0

1

1

1

1

1

___

(A+C)

1

0

1

0

0

0

0

0

Page 27: Computer Science 210 Computer Organization Introduction to Boolean Algebra

A B C

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

_

B

1

1

0

0

1

1

0

0

_ ___ E = AB + (A+C)B _

AB

0

0

0

0

1

1

0

0

A+C

0

1

0

1

1

1

1

1

___

(A+C)

1

0

1

0

0

0

0

0

___

(A+C)B

0

0

1

0

0

0

0

0

Page 28: Computer Science 210 Computer Organization Introduction to Boolean Algebra

A B C

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

_

B

1

1

0

0

1

1

0

0

_ ___ E = AB + (A+C)B _

AB

0

0

0

0

1

1

0

0

A+C

0

1

0

1

1

1

1

1

___

(A+C)

1

0

1

0

0

0

0

0

___

(A+C)B

0

0

1

0

0

0

0

0

E

0

0

1

0

1

1

0

0

Page 29: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Laws of Boolean Algebra

Identity Zero ElementA+0=A, A.1=A A.0=0, A+1=1

Idempotent CommutativeA+A=A, AA=A A+B=B+A, AB=BA

Associative Distributive(A+B)+C=A+(B+C) A(B+C)=AB+AC(AB)C=A(BC) A+BC=(A+B)(A+C)

Page 30: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Laws of Boolean Algebra

Absorption DeMorganA+AB=A, A+B

____ = A

_ B_

,A(A+B)=A AB

___ = A

_ +B

_

Complement Double ComplementA+A

_ =1, AA

_ =0 A

__ = A

Page 31: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Expression Simplification

(A+B_

)C + AC_

+ (B+C____

)= (A+B

_ )C + AC

_ + B

_ C_

(DeMorgan)= (A+B

_ )C + (A+B

_ )C

_ (Distributive)

= (A+B_

)(C+C_

) (Distributive)= (A+B

_ )1 (Complement)

= A+B_

(Identity)

Page 32: Computer Science 210 Computer Organization Introduction to Boolean Algebra

Boolean Expression Simplification

A_

B_

+ AB_

+ AB= A

_ B_

+ AB_

+ AB_

+ AB (Idempotent)= B

_ (A

_ +A) + A(B

_ +B) (Distributive)

= B_

1 + A 1 (Complement)= B

_ + A (Identity)