cs 61c: great ideas in computer architecture sequential ...cs61c/sp16/lec/14/... · program (e.g.,...

29
CS 61C: Great Ideas in Computer Architecture Sequential Elements, Synchronous Digital Systems 1 Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.Berkeley.edu/~cs61c/sp16

Upload: others

Post on 28-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

CS61C:GreatIdeasinComputerArchitectureSequentialElements,Synchronous

DigitalSystems

1

Instructors:VladimirStojanovic&NicholasWeaver

http://inst.eecs.Berkeley.edu/~cs61c/sp16

Page 2: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

LevelsofRepresentation/Interpretation

lw $t0,0($2)lw $t1,4($2)sw $t1,0($2)sw $t0,4($2)

HighLevelLanguageProgram(e.g.,C)

AssemblyLanguageProgram(e.g.,MIPS)

MachineLanguageProgram(MIPS)

HardwareArchitectureDescription(e.g.,blockdiagrams)

Compiler

Assembler

MachineInterpretation

temp=v[k];v[k]=v[k+1];v[k+1]=temp;

0000 1001 1100 0110 1010 1111 0101 10001010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111

LogicCircuitDescription(CircuitSchematicDiagrams)

ArchitectureImplementation

Anythingcanberepresentedasanumber,

i.e.,dataorinstructions

2

Page 3: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

BooleanAlgebra:Circuit&AlgebraicSimplification

3

Page 4: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

LawsofBooleanAlgebra

4

XX=0X0=0X1=XXX=XXY=YX

(XY)Z=Z(YZ)X(Y+Z)=XY+XZ

XY+X=XXY+X=X+YXY=X+Y

X+X=1X+1=1X+0=XX+X=X

X+Y=Y+X(X+Y)+Z=Z+(Y+Z)X+YZ=(X+Y)(X+Z)

(X+Y)X=X(X+Y)X=XYX+Y=XY

ComplementarityLawsof0’sand1’s

IdentitiesIdempotentLawsCommutativityAssociativityDistribution

UnitingTheoremUnitingTheoremv.2DeMorgan’s Law

Page 5: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

BooleanAlgebraicSimplificationExample

5

Page 6: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

BooleanAlgebraicSimplificationExample

6

ab c y00000011010001111001101111011111

Page 7: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

SignalsandWaveforms:Grouping

Page 8: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

SignalsandWaveforms:CircuitDelay

2

3

3 4 5

10 0 1

5 13 4 6

Page 9: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

SampleDebuggingWaveform

Page 10: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

Clickers/PeerInstruction

• SimplifyZ=A+BC+A(BC)

• A: Z=0• B: Z=A(1+BC)• C:Z=(A+BC)• D:Z=BC• E:Z=1

10

Page 11: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

TypeofCircuits• SynchronousDigitalSystemsconsistoftwobasictypesofcircuits:• CombinationalLogic(CL)circuits

–Outputisafunctionoftheinputsonly,notthehistoryofitsexecution– E.g.,circuitstoaddA,B(ALUs)

• SequentialLogic(SL)• Circuitsthat“remember”orstoreinformation• aka“StateElements”• E.g.,memoriesandregisters(Registers)

11

Page 12: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

UsesforStateElements

• Placetostorevaluesforlaterre-use:– Registerfiles(like$1-$31inMIPS)– Memory(cachesandmainmemory)

• Helpcontrolflowofinformationbetweencombinational logicblocks– Stateelementsholdupthemovementofinformationatinputtocombinationallogicblockstoallowfororderlypassage

12

Page 13: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

AccumulatorExample

Want: S=0; for (i=0;i<n;i++)

S = S + Xi

Whydoweneedtocontroltheflowofinformation?

Assume:• EachXvalueisappliedinsuccession,onepercycle• AfterncyclesthesumispresentonS

13

SUMXi S

Page 14: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

FirstTry:Doesthiswork?

14

No!Reason#1:Howtocontrolthenextiterationofthe‘for’loop?Reason#2:Howdowesay:‘S=0’?

Feedback

Page 15: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

RegisterInternals

• n instancesofa“Flip-Flop”

• Flip-flopnamebecausetheoutputflipsandflopsbetween0and1

• Dis“datainput”,Qis“dataoutput”

• Alsocalled“D-typeFlip-Flop”15

Page 16: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

Flip-FlopOperation• Edge-triggeredd-typeflip-flop– Thisoneis“positiveedge-triggered”

• “Ontherisingedgeoftheclock,theinputdissampledandtransferredtotheoutput.Atallothertimes,theinputdisignored.”

• Examplewaveforms:

Page 17: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

Flip-FlopTiming• Edge-triggeredd-typeflip-flop– Thisoneis“positiveedge-triggered”

• “Ontherisingedgeoftheclock,theinputdissampledandtransferredtotheoutput.Atallothertimes,theinputdisignored.”

• Examplewaveforms(moredetail):

Page 18: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

CameraAnalogyTimingTerms

• Wanttotakeaportrait– timingrightbeforeandaftertakingpicture

• Setuptime– don’tmovesinceabouttotakepicture(opencamerashutter)

• Holdtime– needtoholdstillaftershutteropensuntilcamerashuttercloses

• Timeclicktodata– timefromopenshutteruntilcanseeimageonoutput(viewscreen)

18

Page 19: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

HardwareTimingTerms

• SetupTime:whentheinputmustbestablebeforethe edgeoftheCLK

• HoldTime:whentheinputmustbestableafterthe edgeoftheCLK

• “CLK-to-Q”Delay:howlongittakestheoutputtochange,measuredfromthe edgeoftheCLK

19

Page 20: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

AccumulatorTiming1/2• Resetinputtoregisteris

usedtoforceittoallzeros(takespriorityoverDinput).

• Si-1 holdstheresultoftheith-1iteration.

• Analyzecircuittimingstartingattheoutputoftheregister.

Page 21: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

AccumulatorTiming2/2• resetsignalshown.

• Also,inpracticeXmightnotarrivetotheadderatthesametimeasSi-1

• Si temporarilyiswrong,butregisteralwayscapturescorrectvalue.

• Ingoodcircuits,instabilityneverhappensaroundrisingedgeofclk.

Page 22: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

ModelforSynchronousSystems

22

• Collectionof CombinationalLogicblocksseparatedbyregisters• Feedbackisoptional• Clocksignal(s)connectsonlytoclockinputofregisters• Clock(CLK):steadysquarewavethatsynchronizesthesystem• Register:severalbitsofstatethatsamplesonrisingedgeofCLK(positiveedge-triggered)orfallingedge(negativeedge-triggered)

Page 23: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

MaximumClockFrequency

• Whatisthemaximumfrequencyofthiscircuit?

23

Period=MaxDelay=CLK-to-QDelay+CLDelay+SetupTime

Hint:Frequency=1/Period

Page 24: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

CriticalPaths

Timing…

Note: delay of 1 clock cycle from input to output.Clock period limited by propagation delay of adder/shifter.

Page 25: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

PipeliningtoimproveperformanceTiming…

• Insertion of register allows higher clock frequency• More outputs per second (higher bandwidth)• But each individual result takes longer (greater latency)

Page 26: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

RecapofTimingTerms• Clock(CLK)- steadysquarewavethatsynchronizessystem• SetupTime - whentheinputmustbestablebefore the

risingedgeoftheCLK• HoldTime - whentheinputmustbestableafter therising

edgeoftheCLK• “CLK-to-Q” Delay- howlongittakestheoutputtochange,

measuredfromtherisingedgeoftheCLK

• Flip-flop - onebitofstatethatsampleseveryrisingedgeoftheCLK(positiveedge-triggered)

• Register - severalbitsofstatethatsamplesonrisingedgeofCLKoronLOAD(positiveedge-triggered)

Page 27: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

Clickers/PeerInstruction

Whatismaximumclockfrequency?(assumeallunconnectedinputscomefromsomeregister)• A:5GHz• B:200MHz• C:500MHz• D:1/7GHz• E:1/6GHz

Clock->Q1nsSetup1nsHold1nsANDdelay1ns

Page 28: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

Administrivia• NolectureonWed– studyformidterm• Midterm1isonThu2/25– Time6-8pm– Location

• 2050VLSB(aa-lz)• 1Pimentel(ma-zz)

– Coversuptoandincluding02/17lecture(CALL2)– 1handwritten,doublesided,8.5”x11”cheatsheet– We’llgiveyouMIPSgreensheet

• Emailssent-outtostudentsrequiringspecialaccommodationfortheexam– pleaserespond

28

Page 29: CS 61C: Great Ideas in Computer Architecture Sequential ...cs61c/sp16/lec/14/... · Program (e.g., C) Assembly Language Program (e.g., MIPS) Machine Language Program (MIPS) Hardware

StudyAdvice

1. Reviewslides,book,worksheets,etc.andaddtoyourcheatsheet asyoudosoa. Thisstepisnottheend

2. Takeamockexamintheallottedtime,usingonlyyourcheatsheet

3. Gooversolutions,lookatwhytheanswersarewhattheyare(especiallyforquestionsyouansweredincorrectly)

4. Updatecheatsheet asnecessary5. if(!perfect)goto 2;

29