Gates and Logic: From Transistorsto Logic Gates and Logic ... · PDF fileGates and Logic: From...

34
Gates and Logic: From Transistors to Logic Gates and Logic Circuits Prof. Anne Bracy CS 3410 Computer Science Cornell University The slides are the product of many rounds of teaching CS 3410 by Professors Weatherspoon, Bala, Bracy, and Sirer.

Transcript of Gates and Logic: From Transistorsto Logic Gates and Logic ... · PDF fileGates and Logic: From...

GatesandLogic:FromTransistors toLogicGatesand

LogicCircuits

Prof.AnneBracyCS3410

ComputerScienceCornellUniversity

The slides are the product of many rounds of teaching CS 3410 by Professors Weatherspoon, Bala, Bracy, and Sirer.

GoalsforToday• FromSwitchestoLogicGatestoLogicCircuits• Transistors,LogicGates,TruthTables• LogicCircuits

§ IdentityLaws§ FromTruthTablestoCircuits(SumofProducts)

• LogicCircuitMinimization§ AlgebraicManipulations§ Karnaugh Maps

2

SiliconValley&theSemiconductorIndustry

• Transistors:• Youtube video“Howdoesatransistorwork”

https://www.youtube.com/watch?v=IcrBqCFLHIY• Break:showsomeTransistor,Fab,Waferphotos

3

Transistors101

N-TypeSilicon:negativefree-carriers(electrons)P-TypeSilicon:positivefree-carriers(holes)P-Transistor:negativechargeongategenerateselectricfieldthat

createsa(+charged)p-channelconnectingsource&drainN-Transistor:workstheoppositewayMetal-OxideSemiconductor(Gate-Insulator-Silicon)• ComplementaryMOS=CMOStechnologyusesbothp- &n-type

transistors

4

N-type

Off

Insulator

P-type P-type

Gate DrainSource

+++++++++

++

----- ------ --

- --

-

--

-

--

- --

--

+++N-type

On

Insulator

P-type P-type

Gate DrainSource

++++++++

----- ------ --

- --

-

--

-

--

- --

--

+ +P-typechannelcreated+ ++ ++

CMOSNotationN-type

P-type

Gate input controls whether current can flow between the other two terminals or not.

Hint: the “o” bubble of the p-type tells you that this gate wants a 0 to be turned on

5

gate

Off/Open

0

On/Closed

1

Off/Open

1

On/Closed

0gate

Whichofthefollowingstatementsisfalse?

(A) P- andN-typetransistorsarebothusedinCMOSdesigns.

(B) Astransistorsgetsmaller,thefrequencyofyourprocessorwillkeepgettingfaster.

(C) Astransistorsgetsmaller,youcanfitmoreandmoreofthemonasinglechip.

(D) Puresiliconisasemiconductor.(E) ExpertsbelievethatMoore’sLawwillsoonend.

6

iClicker Question

2-TransistorCombination:NOT• Logicgatesareconstructedbycombiningtransistorsincomplementaryarrangements

• Combinep&n transistorstomakeaNOTgate:

7

p-gatecloses

n-gate stays open

p-gatestays open

n-gate closes

CMOS Inverter :

ground (0)

power source (1)

input output

p-gate

n-gate

power source (1)

ground (0) ground (0)

power source (1)

1 00

+

+

1

Inverter

In Out0 11 0

8

Function: NOTSymbol:

Truth Table:

in outin out

Vsupply (akalogic1)

(groundislogic0)

LogicGates• Digitalcircuitthateitherallows

signaltopassthroughitornot• Usedtobuildlogicfunctions• Sevenbasiclogicgates:

AND,OR,NOT,NAND (notAND),NOR (notOR),XORXNOR (notXOR)

9

Didyouknow?GeorgeBooleInventoroftheideaoflogicgates.HewasborninLincoln,Englandandhewasthesonofashoemaker.

George Boole,(1815-1864)

NOT:

AND:

OR:

XOR:.

LogicGates:Names,Symbols,TruthTables

A B Out0 0 00 1 11 0 11 1 1

A B Out0 0 00 1 01 0 01 1 1

A Out0 11 0

AB

AB

A

A B Out0 0 00 1 11 0 11 1 0

AB

A B Out0 0 10 1 01 0 01 1 0

A B Out0 0 10 1 11 0 11 1 0

AB

AB

NAND:

NOR:

A B Out0 0 10 1 01 0 01 1 1

AB

XNOR:

NORGate

A B out0 0 10 1 01 0 01 1 0

Function: NORSymbol:

Truth Table:

ba out

A

out

Vsupply

B

BA

11

WhichGateisthis?

A B out0 00 11 01 1

12

Function:Symbol:

Truth Table:

A

out

Vsupply

B

BA

Vsupply

iClicker Question

(A) NOT(B) OR(C) XOR(D) AND(E) NAND

Abstraction• Hidecomplexitythroughsimpleabstractions

§ Simplicity• Boxdiagramrepresentsinputsandoutputs

§ Complexity• HidesunderlyingNMOS- andPMOS-transistorsandatomicinteractions

13

in out

Vdd

Vss

in out outadb

a

b

d out

WhichGateisthis?

A B out0 00 11 01 1

14

Function:Symbol:

Truth Table:

iClicker Question

(A) NOT(B) OR(C) XOR(D) AND(E) NAND

ab

Out

UniversalGates• NANDandNOR:

§ Canimplementany functionwithNANDorjustNORgates§ usefulformanufacturing

• NOT:

• AND:

• OR:

15

ba

ba

a

Whatdoesthislogiccircuitdo?

16

Function:Symbol:Truth Table:

a

b

dOut

a b d Out

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

Multiplexing Like a Boss

GoalsforToday• FromSwitchestoLogicGatestoLogicCircuits• Transistors,LogicGates,TruthTables• LogicCircuits

§ FromTruthTablestoCircuits(SumofProducts)§ IdentityLaws

• LogicCircuitMinimization§ AlgebraicManipulations§ Karnaugh Maps

17

LogicImplementationHowtoimplementadesiredlogicfunction?

18

a b c out0 0 0 00 0 1 10 1 0 00 1 1 11 0 0 01 0 1 11 1 0 01 1 1 0

1) Writeminterms2) Writesumofproducts:

ORofallmintermswhereout=1

out=abc +abc +abc

mintermabcabcabcabcabcabcabcabc

c

out

ba

Any combinationalcircuitcanbeimplementedintwolevelsoflogic(ignoringinverters)

LogicEquationsNOT: =ā =!a=¬a

AND: =a·b=a&b=aÙ b

OR: =a+b=a|b=aÚ b

XOR: =aÅ b=ab+āb

LogicEquations§ Constants:true=1,false=0§ Variables:a,b,out,…§ Operators(above):AND,OR,NOT,etc.

19

NAND:(a⚫b)=!(a&b)=¬ (aÙ b)

NOR:(a+b) =!(a|b)=¬ (aÚ b)

XNOR:(a⨁ b) =ab+ab

Identities

20

Identitiesusefulformanipulatinglogicequations• Foroptimization&easeofimplementation

a+0=a+1=a+ā=

a·0=a·1=a·ā=

a11

0a0

Identitiesusefulformanipulatinglogicequations• Foroptimization&easeofimplementation

Identities

21

A

B

A

B↔

A

B

A

B↔

a+ab=a

a(b+c)=ab +ac

(a+ b) = a • b

(ab) = a+ b

a(b+ c) = a+ b • c

GoalsforToday• FromSwitchestoLogicGatestoLogicCircuits• Transistors,LogicGates,TruthTables• LogicCircuits

§ IdentityLaws§ FromTruthTablestoCircuits(SumofProducts)

• LogicCircuitMinimization–why?§ AlgebraicManipulations§ Karnaugh Maps

22

23

(a+b)a+(a+b)c=aa+ba +ac+bc=a+a(b+c) +bc=a +bc

Minimizethislogicequation:

(a+b)(a+c) =

a+0=aa+1=1a+ā =1a·0=0a·1=aa·ā =0

a+ab=aa(b+c)=ab +ac

(a+ b) = a • b(ab) = a+ ba(b+ c) = a+ b • c

MinimizationExample

24

a+0=aa+1=1a+ā =1a·0=0a·1=aa·ā =0

a+ab=aa(b+c)=ab +ac

(a+b)(a+c) à a +bc

How many gates were required before and after?

(a+ b) = a • b(ab) = a+ ba(b+ c) = a+ b • c

iClicker Question

BEFORE AFTER(A) 2OR 1OR(B) 2OR,1AND 2OR(C) 2OR,1AND 1OR,1AND(D) 2OR,2AND 2OR(E) 2OR,2AND 2OR,1AND

CheckingEqualityw/TruthTablescircuits↔truthtables↔equations

Example:(a+b)(a+c)=a+bc

25

a b c (a+b) LHS (a+c) RHS bc

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

CheckingEqualityw/TruthTablescircuits↔truthtables↔equations

Example:(a+b)(a+c)=a+bc

26

a b c (a+b) LHS (a+c) RHS bc

0 0 0 0 0 0 0 0

0 0 1 0 0 1 0 0

0 1 0 1 0 0 0 0

0 1 1 1 1 1 1 1

1 0 0 1 1 1 1 0

1 0 1 1 1 1 1 0

1 1 0 1 1 1 1 0

1 1 1 1 1 1 1 1

MinimizationinPracticeHowdoesonefindthemostefficientequation?• Manipulatealgebraicallyuntil…?• UseKarnaughMaps(optimizevisually)• Useasoftwareoptimizer

Forlargecircuits• Decomposition&reuseofbuildingblocks

27

BuildingaKarnaugh Map

a b c out0 0 0 00 0 1 10 1 0 00 1 1 11 0 0 11 0 1 11 1 0 01 1 1 0

28

Sum of minterms yieldsout =

K-maps identify which inputs are relevant to the output0 0 0 1

1 1 0 1

00 0111100

1

cab

abc+ abc+ abc+ abc

0 0 0 11 1 0 1

MinimizationwithK-Maps

29

(1) Circle the 1’s (see below)(2) Each circle is a logical component of the final equation

= ab" + a"c

00 0111100

1

cab

Rules:• Usefewestcirclesnecessarytocoverall1’s• Circlesmustcoveronly1’s• Circlesspanrectanglesofsizepowerof2(1,2,4,8…)• Circlesshouldbeaslargeaspossible(allcirclesof1?)• CirclesmaywraparoundedgesofK-Map• 1maybecircledmultipletimesifthatmeansfewer

circles

Karnaugh MinimizationTricks(1)

30

Minterms can overlapout = bc" + ac" + ab

Minterms can span 2, 4, 8 or more cells

out = c" + ab

0 1 1 10 0 1 0

00 01 1110

0

1

cab

1 1 1 10 0 1 0

00 01 1110

0

1

cab

KarnaughMinimizationTricks(2)

• Themapwrapsaroundout=b"d

out=b" d"

31

1 0 0 10 0 0 00 0 0 01 0 0 1

00 011110

00

01

ab

cd

11

10

0 0 0 01 0 0 11 0 0 10 0 0 0

00 01 1110

00

01

ab

cd

11

10

Don’tCares“Don’tcare”valuescanbeinterpretedindividuallyinwhateverwayisconvenient

• assumeallx’s=1à out=d

• assumemiddlex’s=0(ignorethem)

• assume4th columnx=1à out=b" d"

32

1 0 0 x0 x x 00 x x 01 0 0 1

00 011110

00

01

ab

cd

11

10

0 0 0 01 x x x1 x x 10 0 0 0

00 011110

00

01

ab

cd

11

10

Takeaway

• Binary—twosymbols:true andfalse—isthebasisofLogicDesign

• MorethanoneLogicCircuitcanimplementsameLogicfunction.UseAlgebra(Identities)orTruthTablestoshowequivalence.

• Anylogicfunctioncanbeimplementedas“sumofproducts”.Karnaugh Mapsminimizenumberofgates.

33

Summary• Mostmoderndevicesmadeofbillionsoftransistors

§ Youwillbuildaprocessorinthiscourse!§ Moderntransistorsmadefromsemiconductormaterials

§ Transistorsusedtomakelogicgatesandlogiccircuits• Wecannowimplementanylogiccircuit

§ UseP- &N-transistorstoimplementNAND/NORgates

§ UseNANDorNORgatestoimplementthelogiccircuit

§ Efficiently: useK-mapstofindrequiredminimalterms34