combinational logichtseng/classes/ee120a... · • nand and nor are “universal gates” — you...

41
Combinational Logic Prof. Usagi

Upload: others

Post on 25-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Combinational LogicProf. Usagi

Page 2: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Recap: Logic Design?

2

https://www.britannica.com/technology/logic-design

Page 3: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

sampling cycle

Recap: Analog v.s. digital signals

3

Infinite possible values!1

0

0.5? 0.4? 0.45? 0.445? 0.4445? or

0.4444444444459?Anything within this wide range is considered as “1”

Page 4: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• Please identify how many of the following statements explains why digital computers are now more popular than analog computers. ! The cost of building systems with the same functionality is lower by using

digital computers. " Digital computers can express more values than analog computers. # Digital signals are less fragile to noise and defective/low-quality components. $ Digital data are easier to store. A. 0 B. 1 C. 2 D. 3 E. 4

4

Recap: Why are digital computers more popular now?

Page 5: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• Each position represents a quantity; symbol in position means how many of that quantity • Decimal (base 10)

• Ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 • More than 9: next position • Each position is incremented by power of 10

• Binary (base 2) • Two symbols: 0, 1 • More than 1: next position • Each position is incremented by power of 2

5

Recap: The basic idea of a number system

100101102

123! ! !

+ + =300+20+1 =321

20212223

1001! ! !!

+ + =1 23+1 20 =1 8+1 1 =9

+ !!

!!

Page 6: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• Two types of logics • The theory behind combinational logics • The building blocks of combinational logics

6

Outline

Page 7: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Types of circuits

7

Page 8: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• Combinational logic • The output is a pure function of its current inputs • The output doesn’t change regardless how many times the logic is

triggered — Idempotent • Sequential logic

• The output depends on current inputs, previous inputs, their history

8

Combinational v.s. sequential logic

Page 9: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• A Combinational logic is the implementation of aBoolean Algebra function with only Boolean Variables as their inputs

• A Sequential logic is the implementation of aFinite-State Machine

11

Theory behind each

Page 10: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Boolean Algebra

12

Page 11: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• Boolean algebra — George Boole, 1815—1864 • Introduced binary variables • Introduced the three fundamental logic operations: AND, OR, and NOT • Extended to abstract algebra with set operations: intersect, union,

complement • Switching algebra — Claude Shannon, 1916—2001

• Wrote his thesis demonstrating that electrical applications of Boolean algebra could construct any logical numerical relationship

• Disposal of the abstract mathematical apparatus, casting switching algebra as the two-element Boolean algebra.

• We now use switching algebra and boolean algebra interchangeably in EE, but not doing that if you’re interacting with a mathematician.

13

Boolean algebra (disambiguation)

Page 12: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• {0, 1}: The only two possible values in inputs/outputs • Basic operators

• AND (•) — a • b • returns 1 only if both a and b are 1s • otherwise returns 0

• OR (+) — a + b • returns 1 if a or b is 1 • returns 0 if none of them are 1s

• NOT (‘) — a’ • returns 0 if a is 1 • returns 1 if a is 0

14

Basic Boolean Algebra Concepts

Page 13: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• A table sets out the functional values of logical expressions on each of their functional arguments, that is, for each combination of values taken by their logical variables

15

Truth tables

Input OutputA B0 0 00 1 01 0 01 1 1

ANDInput OutputA B

0 0 00 1 11 0 11 1 1

ORInput OutputA

0 10 11 01 0

NOT

Page 14: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• NAND — (a • b)’ • NOR — (a + b)’ • XOR — (a + b) • (a’ + b’) or ab’ + a’b • XNOR — (a + b’) • (a’ + b) or ab + a’b’

18

Derived Boolean operators

Input OutputA B0 0 10 1 11 0 11 1 0

NANDInput OutputA B

0 0 10 1 01 0 01 1 0

NORInput OutputA B

0 0 00 1 11 0 11 1 0

XORInput OutputA B

0 0 10 1 01 0 01 1 1

XNOR

Page 15: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Express Boolean Operators/Functions in Circuit “Gates”

19

Page 16: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Boolean operators their circuit “gate” symbols

20

AND

OR

NOT

NAND

NOR

XOR

NXORrepresents where we take a compliment value on an input represents where we take a compliment value on an output

Page 17: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

How to express y = e(ab+cd)

21

ye

AND

OR

NOT

NAND

NOR

XOR

NXOR

abcd

# gates : 4# signal nets : 9# pins: 12

# inputs : 5# outputs : 1

Page 18: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

We can make everything NAND!

22

Original NAND

AND

OR

NOT

ab

ab

a

ab

a

b

a

Page 19: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

We can also make everything NOR!

23

Original NAND

AND

OR

NOT

ab

ab

a

ab

a

b

a

Page 20: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

How to express y = e(ab+cd)

24

ye

abcd

Page 21: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

How to express y = e(ab+cd)

25

e

abcd y

Page 22: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

How gates are implemented?

26

Page 23: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• nMOS • Turns on when G = 1 • When it’s on, passes 0s, but not 1s • Connect S to ground (0) • Pulldown network

• pMOS • Turns on when G = 0 • When it’s on, passes 1s, but not 0s • Connect S to Vdd (1) • Pullup network

27

Two type of CMOSs

G

S

D

G

S

D

Page 24: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

NOT Gate (Inverter)

28

Input NMOS(passes 0 when on

G=1)

PMOS(passes 1 when on

G=0)Output

A0 OFF ON 11 ON OFF 0

GND

Vdd

OutputA

Page 25: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

AND Gate

29GND

Vdd

Output

A B

A

B GND

Vdd

Page 26: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

OR Gate

30GND

Vdd

Output

A

B

A B

GND

Vdd

Page 27: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

NAND Gate

31GND

Input NMOS1(passes 0 when

on G=1)

PMOS1(passes 1 when

on G=0)

NMOS2(passes 0 when

on G=1)

PMOS2(passes 1 when

on G=0)OutputA B

0 0 OFF ON OFF ON 10 1 OFF ON ON OFF 11 0 ON OFF OFF ON 11 1 ON OFF ON OFF 0

Vdd

A

A

B

B

Output

Page 28: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR

• Simplifies the design as you only need one type of gate • NAND only needs 4 transistors — gate delay is smaller than

OR/AND that needs 6 transistors • NAND is slightly faster than NOR due to the physics nature

32

Why use NAND?

Page 29: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

How about total number of transistors?

33

4 gates, each 6 transistors : total 24 transistors

9 gates, each 4 transistors : total 36 transistors

Page 30: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

However …

34

e

abcd y

Inverter Inverter

Inverter Inverter

Now, only 5 gates and 4 transistors each — 20 transistors!

Page 31: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Can We Get the Boolean Equation from a Truth Table?

37

Page 32: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• Complement: variable with a bar over it or a ‘ — A’, B’, C’ • Literal: variable or its complement — A, A’, B, B’, C, C’ • Implicant: product of literals — ABC, AC, BC • Implicate: sum of literals — (A+B+C), (A+C), (B+C) • Minterm: AND that includes all input variables — ABC, A’BC,

AB’C • Maxterm: OR that includes all input variables — (A+B+C),

(A’+B+C), (A’+B’+C)

38

Definitions of Boolean Function Expressions

Page 33: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Canonical form — Sum of “Minterms”

39

Input OutputX Y0 0 00 1 01 0 11 1 1

f(X,Y) = XY’ + XY

Input OutputA B0 0 10 1 01 0 01 1 1

XNORf(A,B) = A’B’ + AB

A minterm

Sum (OR) of “product” terms

Page 34: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Canonical form — Product of “Maxterms”

10

Input OutputX Y0 0 00 1 01 0 11 1 1

f(X,Y) = (X+Y) (X + Y’)

Input OutputA B0 0 10 1 01 0 01 1 1

XNOR

f(A,B) = (A+B’) (A’+B)

A “maxterm

Product of maxterms

Page 35: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Let’s design a circuit!

41

Page 36: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Binary addition

42

3 + 2 = 50 0 1 1

+ 0 0 1 010

1 carry

10

3 + 3 = 60 0 1 1

+ 0 0 1 101

1

10

1

half adder — adder without a carry as an inputfull adder — adder with

a carry as an inputInput Output

A B Cin Out Cout0 0 0 0 00 1 0 1 01 0 0 1 01 1 0 0 10 0 1 1 00 1 1 0 11 0 1 0 11 1 1 1 1

Input OutputA B Out Cout0 0 0 00 1 1 01 0 1 01 1 0 1

Page 37: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Half adder

43

Input OutputA B Out Cout0 0 0 00 1 1 01 0 1 01 1 0 1

Out = A’B + AB’Cout = AB

A

B

Cout

Out

Page 38: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

• They can be used interchangeably • Depends on if the truth table has more 0s or 1s in the result • Neither forms give you the “optimized” equation. By optimized,

we mean — minimize the number of operations

46

sum-of-products/product-of-sums

Page 39: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Can we simplify these functions?

47

Page 40: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Laws in Boolean Algebra

10

OR AND

Associative laws (a+b)+c=a+(b+c) (a·b) ·c=a·(b·c)

Commutative laws a+b=b+a a·b=b·a

Distributive laws a+(b·c)=(a+b)·(a+c) a·(b+c)=a·b+a·c

Identity laws a+0=a a·1=a

Complement laws a+a’=1 a·a’=0

Duality: We swap all operators between (+,.) and interchange all elements between (0,1). For a theorem if the statement can be proven with the laws of Boolean algebra, then the duality of the statement is also true.

Page 41: Combinational Logichtseng/classes/ee120a... · • NAND and NOR are “universal gates” — you can build any circuit with everything NAND or NOR • Simplifies the design as you

Some more tools

11

OR AND

DeMorgan’s Theorem (a + b)’ = a’b’ a’b’ = (a + b)’

Covering Theorem a(a+b) = a+ab = a ab + ab’ = (a+b)(a+b’) = a

Consensus Theorem ab+ac+b’c = ab+b’c (a+b)(a+c)(b’+c) = (a+b)(b’+c)

Uniting Theorem a (b + b’) = a (a+b)·(a+b’)=a

Shannon’s Expansion f(a,b,c) = a’b’ + bc + ab’c f(a,b,c) = a f(1, b, c) + a’ f(0,b,c)