lecture 4: boolean algebra, circuits, canonical forms...converting to a truth table! weekday...

37
CSE 311: Foundations of Computing Lecture 4: Boolean Algebra, Circuits, Canonical Forms

Upload: others

Post on 20-Apr-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

CSE 311: Foundations of Computing

Lecture 4: Boolean Algebra, Circuits, Canonical Forms

Page 2: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Last Class

• More combinational logic gates – NAND, NOR, XOR, XNOR

• Proofs of Logical Equivalence

– e.g.

Page 3: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Boolean Logic: Circuits

Combinational Logic– output = F(input)

Sequential Logic– outputt = F(outputt-1, inputt)

• output dependent on history

• concept of a time step (clock, t)

Boolean Algebra: Another notation for logic consisting of…– a set of elements B = {0, 1}

– binary operations { + , • } (OR, AND)

– and a unary operation { ’ } (NOT )

Page 4: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Boolean Algebra

• Usual notation used in circuit design

• Boolean algebra – a set of elements B containing {0, 1}

– binary operations { + , • }

– and a unary operation { ’ }

– such that the following axioms hold:

For any a, b, c in B:1. closure: a + b is in B a • b is in B2. commutativity: a + b = b + a a • b = b • a3. associativity: a + (b + c) = (a + b) + c a • (b • c) = (a • b) • c4. distributivity: a + (b • c) = (a + b) • (a + c) a • (b + c) = (a • b) + (a • c)5. identity: a + 0 = a a • 1 = a6. complementarity: a + a’ = 1 a • a’ = 07. null: a + 1 = 1 a • 0 = 08. idempotency: a + a = a a • a = a9. involution: (a’)’ = a

Page 5: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

A Combinational Logic Example

Sessions of Class:

We would like to compute the number of lectures or

quiz sections remaining at the start of a given day of

the week.

– Inputs: Day of the Week, Lecture/Section flag

– Output: Number of sessions left

Examples: Input: (Wednesday, Lecture) Output: 2

Input: (Monday, Section) Output: 1

Page 6: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Implementation in Software

public int classesLeftInMorning(weekday, lecture_flag) {

switch (weekday) {

case SUNDAY:

case MONDAY:

return lecture_flag ? 3 : 1;

case TUESDAY:

case WEDNESDAY:

return lecture_flag ? 2 : 1;

case THURSDAY:

return lecture_flag ? 1 : 1;

case FRIDAY:

return lecture_flag ? 1 : 0;

case SATURDAY:

return lecture_flag ? 0 : 0;

}

}

Page 7: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Implementation with Combinational Logic

Encoding:

– How many bits for each input/output?

– Binary number for weekday

– One bit for each possible output (called “1-hot” encoding)

Lecture?Weekday

0 1 2 3

Page 8: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Defining Our Inputs!

Weekday Number Binary

Sunday 0 (000)2

Monday 1 (001)2

Tuesday 2 (010)2

Wednesday 3 (011)2

Thursday 4 (100)2

Friday 5 (101)2

Saturday 6 (110)2

Weekday Input:

– Binary number for weekday

– Sunday = 0, Monday = 1, …

– We care about these in binary:

Page 9: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Converting to a Truth Table!

Weekday Lecture? c0 c1 c2 c3

SUN 000 0

SUN 000 1

MON 001 0

MON 001 1

TUE 010 0

TUE 010 1

WED 011 0

WED 011 1

THU 100 -

FRI 101 0

FRI 101 1

SAT 110 -

- 111 -

case SUNDAY or MONDAY:

return lecture_flag ? 3 : 1;

case TUESDAY or WEDNESDAY:

return lecture_flag ? 2 : 1;

case THURSDAY:

return lecture_flag ? 1 : 1;

case FRIDAY:

return lecture_flag ? 1 : 0;

case SATURDAY:

return lecture_flag ? 0 : 0;

Page 10: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Converting to a Truth Table!

Weekday Lecture? c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

case SUNDAY or MONDAY:

return lecture_flag ? 3 : 1;

case TUESDAY or WEDNESDAY:

return lecture_flag ? 2 : 1;

case THURSDAY:

return lecture_flag ? 1 : 1;

case FRIDAY:

return lecture_flag ? 1 : 0;

case SATURDAY:

return lecture_flag ? 0 : 0;

Page 11: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 1)

Let’s begin by finding an expression

for c3. To do this, we look at the rows

where c3 = 1 (true).

Page 12: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 1)

DAY == SUN && L == 1

DAY == MON && L == 1

Page 13: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 1)

d2d1d0 == 000 && L == 1

d2d1d0 == 001 && L == 1

Substituting DAY with the

binary representation.

Page 14: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 1)

d2 == 0 && d1 == 0 && d0 == 0 && L == 1

d2 == 0 && d1 == 0 && d0 == 1 && L == 1

Splitting up the bits of the day;

so, we can write a formula.

Page 15: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 1)

d2’•d1’•d0’•L

d2’•d1’•d0•L

Replacing with

Boolean Algebra…

Page 16: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 1)

d2’•d1’•d0’•L

d2’•d1’•d0•L

Either situation causes c3 to be

true. So, we “or” them.

c3 = d2’•d1’•d0’•L + d2’•d1’•d0•L

Page 17: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 2)

Now, we do c2.

c3 = d2’•d1’•d0’•L + d2’•d1’•d0•L

Page 18: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 3)

Now, we do c1:

c3 = d2’•d1’•d0’•L + d2’•d1’•d0•L

c2 = d2’•d1•d0’•L + d2’•d1•d0•L

Page 19: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 3)

Now, we do c1:

c3 = d2’•d1’•d0’•L + d2’•d1’•d0•L

d2’•d1’•d0’•L’

d2’•d1’•d0•L’

c2 = d2’•d1•d0’•L + d2’•d1•d0•L

d2’•d1•d0’•L’

d2’•d1•d0•L’

d2•d1’•d0•L

???

Page 20: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 3)

Now, we do c1:

c3 = d2’•d1’•d0’•L + d2’•d1’•d0•L

d2’•d1’•d0’•L’

d2’•d1’•d0•L’

c2 = d2’•d1•d0’•L + d2’•d1•d0•L

d2’•d1•d0’•L’

d2’•d1•d0•L’

d2•d1’•d0•L

d2•d1’•d0’

No matter what L is,

we always say it’s 1.

So, we don’t need L

in the expression.

Page 21: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 3)

Now, we do c1:

c3 = d2’•d1’•d0’•L + d2’•d1’•d0•L

d2’•d1’•d0’•L’

d2’•d1’•d0•L’

c2 = d2’•d1•d0’•L + d2’•d1•d0•L

d2’•d1•d0’•L’

d2’•d1•d0•L’

d2•d1’•d0•L

d2•d1’•d0’

No matter what L is,

we always say it’s 1.

So, we don’t need L

in the expression.

c1 = d2’•d1’•d0’•L’ + d2’•d1’•d0•L’ + d2’•d1•d0’•L’ + d2’•d1•d0•L’ + d2•d1’•d0’ + d2•d1’•d0•L

Page 22: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

d2d1d0 L c0 c1 c2 c3

SUN 000 0 0 1 0 0

SUN 000 1 0 0 0 1

MON 001 0 0 1 0 0

MON 001 1 0 0 0 1

TUE 010 0 0 1 0 0

TUE 010 1 0 0 1 0

WED 011 0 0 1 0 0

WED 011 1 0 0 1 0

THU 100 - 0 1 0 0

FRI 101 0 1 0 0 0

FRI 101 1 0 1 0 0

SAT 110 - 1 0 0 0

- 111 - 1 0 0 0

Truth Table to Logic (Part 4)

Finally, we do c0:

c3 = d2’•d1’•d0’•L + d2’•d1’•d0•L

c2 = d2’•d1•d0’•L + d2’•d1•d0•L

d2•d1’•d0•L’

d2•d1•d0

d2•d1•d0’

c1 = d2’•d1’•d0’•L’ + d2’•d1’•d0•L’ +

d2’•d1•d0’•L’ + d2’•d1•d0•L’ +

d2•d1’•d0’ + d2•d1’•d0•L

Page 23: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Truth Table to Logic (Part 4)

c3 = d2’•d1’•d0’•L + d2’•d1’•d0•L

c2 = d2’•d1•d0’•L + d2’•d1•d0•L

c1 = d2’•d1’•d0’•L’ + d2’•d1’•d0•L’ + d2’•d1•d0’•L’ + d2’•d1•d0•L’ + d2•d1’•d0’ + d2•d1’•d0•L

c0 = d2•d1’•d0•L’ + d2•d1•d0’ + d2•d1•d0

d2

d1

d0

L

NOT

NOT

NOT

OR

AND

AND

Here’s c3 as a circuit:

Page 24: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Boolean Algebra

• Usual notation used in circuit design

• Boolean algebra – a set of elements B containing {0, 1}

– binary operations { + , • }

– and a unary operation { ’ }

– such that the following axioms hold:

For any a, b, c in B:1. closure: a + b is in B a • b is in B2. commutativity: a + b = b + a a • b = b • a3. associativity: a + (b + c) = (a + b) + c a • (b • c) = (a • b) • c4. distributivity: a + (b • c) = (a + b) • (a + c) a • (b + c) = (a • b) + (a • c)5. identity: a + 0 = a a • 1 = a6. complementarity: a + a’ = 1 a • a’ = 07. null: a + 1 = 1 a • 0 = 08. idempotency: a + a = a a • a = a9. involution: (a’)’ = a

Page 25: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

uniting:

10. a • b + a • b’ = a 10D. (a + b) • (a + b’) = a

absorption:

11. a + a • b = a 11D. a • (a + b) = a

12. (a + b’) • b = a • b 12D. (a • b’) + b = a + b

factoring:

13. (a + b) • (a’ + c) = 13D. a • b + a’ • c =

a • c + a’ • b (a + c) • (a’ + b)

consensus:

14. (a • b) + (b • c) + (a’ • c) = 14D. (a + b) • (b + c) • (a’ + c) =

a • b + a’ • c (a + b) • (a’ + c)

de Morgan’s:

15. (a + b + ...)’ = a’ • b’ • ... 15D. (a • b • ...)’ = a’ + b’ + ...

Simplification using Boolean Algebra

Page 26: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

prove the Uniting theorem: X • Y + X • Y’ = X

prove the Absorption theorem: X + X • Y = X

Proving Theorems

Using the laws of Boolean Algebra:

X • Y + X • Y’ =

X + X • Y =

Page 27: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

prove the Uniting theorem: X • Y + X • Y’ = X

prove the theorem: X + X • Y = X

Proving Theorems

Using the laws of Boolean Algebra:

distributivitycomplementarity identity

identity distributivitycommutativity null identity

X • Y + X • Y’ = X • (Y + Y’)= X • 1= X

X + X • Y = X • 1 + X • Y= X • (1 + Y)= X • (Y + 1)= X • 1= X

Page 28: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Proving Theorems

Using truth table:

(X + Y)’ = X’ • Y’

NOR is equivalent to AND

with inputs complemented

(X • Y)’ = X’ + Y’

NAND is equivalent to OR

with inputs complemented

X Y X’ Y’ (X + Y)’ X’ • Y’

X Y X’ Y’ (X • Y)’ X’ + Y’

0 0 1 1 1 1 0 1 1 0 1 11 0 0 1 1 11 1 0 0 0 0

0 0 1 1 1 1 0 1 1 0 0 01 0 0 1 0 01 1 0 0 0 0

For example, de Morgan’s Law:

Page 29: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

c3 = d2’•d1’•d0’•L + d2’•d1’•d0•L

= d2’•d1’•(d0’ + d0)•L

= d2’•d1’•1•L

= d2’•d1’•L

Simplifying using Boolean Algebra

AND

d2

d1

L

NOT

NOT

Page 30: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

1-bit Binary Adder

A

+ B

S

(COUT)

0 + 0 = 0 (with COUT = 0)

0 + 1 = 1 (with COUT = 0)

1 + 0 = 1 (with COUT = 0)

1 + 1 = 0 (with COUT = 1)

Page 31: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

1-bit Binary Adder

A

+ B

S

(COUT)

0 + 0 = 0 (with COUT = 0)

0 + 1 = 1 (with COUT = 0)

1 + 0 = 1 (with COUT = 0)

1 + 1 = 0 (with COUT = 1)

Idea: To chain these together, let’s add a carry-in

Page 32: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

1-bit Binary Adder

A

+ B

S

(COUT)

0 + 0 = 0 (with COUT = 0)

0 + 1 = 1 (with COUT = 0)

1 + 0 = 1 (with COUT = 0)

1 + 1 = 0 (with COUT = 1)

Idea: To chain these together, let’s add a carry-in

A A A A A

B B B B B

S S S S S

CINCOUT(CIN)

A

+ B

S

(COUT)

0 1 1 1 0

0 1 1 0 1

1 1 0 1 1

CINCOUT

1 1 0 0

Page 33: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

1-bit Binary Adder

• Inputs: A, B, Carry-in

• Outputs: Sum, Carry-out

A

B

CIN

COUT

S

A A A A A

B B B B B

S S S S S

CINCOUT

A B CIN COUT S

0 0 0 0 0

0 0 1 0 1

0 1 0 0 1

0 1 1 1 0

1 0 0 0 1

1 0 1 1 0

1 1 0 1 0

1 1 1 1 1

Page 34: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

1-bit Binary Adder

• Inputs: A, B, Carry-in

• Outputs: Sum, Carry-out A A A A A

B B B B B

S S S S S

CINCOUT

A B CIN COUT S

0 0 0 0 0

0 0 1 0 1

0 1 0 0 1

0 1 1 1 0

1 0 0 0 1

1 0 1 1 0

1 1 0 1 0

1 1 1 1 1

A’•B’•CIN

A’•B•CIN’

A•B’•CIN’

A•B•CIN

S = A’•B’•CIN + A’•B•CIN’ +

A•B’•CIN’ + A•B•CIN

Derive an expression for S

Page 35: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

1-bit Binary Adder

• Inputs: A, B, Carry-in

• Outputs: Sum, Carry-out A A A A A

B B B B B

S S S S S

CINCOUT

A•B’•CIN

A•B•CIN’

A’•B•CIN

A•B•CIN

A B CIN COUT S

0 0 0 0 0

0 0 1 0 1

0 1 0 0 1

0 1 1 1 0

1 0 0 0 1

1 0 1 1 0

1 1 0 1 0

1 1 1 1 1

S = 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

Derive an expression for COUT

Page 36: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

1-bit Binary Adder

• Inputs: A, B, Carry-in

• Outputs: Sum, Carry-out A A A A A

B B B B B

S S S S S

CINCOUT

COUT = A’•B•CIN + A•B’•CIN + A•B•CIN’ + A•B•CIN

A B CIN COUT S

0 0 0 0 0

0 0 1 0 1

0 1 0 0 1

0 1 1 1 0

1 0 0 0 1

1 0 1 1 0

1 1 0 1 0

1 1 1 1 1

S = A’•B’•CIN + A’•B•CIN’ + A•B’•CIN’ + A•B•CIN

Page 37: Lecture 4: Boolean Algebra, Circuits, Canonical Forms...Converting to a Truth Table! Weekday Lecture? c0 c1 c2 c3 SUN 000 0 0 1 0 0 SUN 000 1 0 0 0 1 MON 001 0 0 1 0 0 MON 001 1 0

Apply Theorems to Simplify Expressions

The theorems of Boolean algebra can simplify expressions

– e.g., full adder’s carry-out function

Cout = A’ B Cin + A B’ Cin + A B Cin’ + A B Cin= A’ B Cin + A B’ Cin + A B Cin’ + A B Cin + A B Cin= A’ B Cin + A B Cin + A B’ Cin + A B Cin’ + A B Cin= (A’ + A) B Cin + A B’ Cin + A B Cin’ + A B Cin= (1) B Cin + A B’ Cin + A B Cin’ + A B Cin= B Cin + A B’ Cin + A B Cin’ + A B Cin + A B Cin= B Cin + A B’ Cin + A B Cin + A B Cin’ + A B Cin= B Cin + A (B’ + B) Cin + A B Cin’ + A B Cin= B Cin + A (1) Cin + A B Cin’ + A B Cin= B Cin + A Cin + A B (Cin’ + Cin)= B Cin + A Cin + A B (1)= B Cin + A Cin + A B adding extra terms

creates new factoring opportunities