You are on page 1of 6

Moremicrocode

2/9/2011

TableandSwitches

MemoryRead
CopytheaddresstoreadintotheMemory Add Address Register. R it TellthememorysystemtoREAD.Thisonly startsthereadwhichwilltakeseveralcycles Afollowingmicrocodeinstructionmust WAIT WAIT untilthereadiscomplete complete. CopythedatafromtheMemoryBuffer RegistertothedesiredregisterorALU.

bus IR resu A bus bus PC bus R1 bus R2 bus bus M ALU Mem adr lt L B func func IR bus U opr PC bus R1 bus R2 bus MA M R bus R B nd resu R bus lt X X

MemoryRead
MAR 3
memory
0 1 2 3 4 FFFFFFFF 47 12354 18 72 12214 14

MemoryRead
MBR MAR 3
memory
0 1 2 3 4 FFFFFFFF 47 12354 18 72 12214 14

MBR

COMP375

Moremicrocode

2/9/2011

MemoryRead
MAR 3
memory
0 1 2 3 4 FFFFFFFF 47 12354 18 72 12214 14

MemoryWrite
MBR Copytheaddresstobewrittenintothe M Memory Address Add Register. R it CopythedataintotheMemoryBuffer Register. TellthememorysystemtoWRITE.Thisonly startsthewritewhichwilltakeseveralcycles AfuturemicrocodeinstructionmustWAIT beforedoinganothermemoryfunction.

72

MemoryWrite
MAR 4
memory
0 1 2 3 4 FFFFFFFF 47 12354 18 72 12214 14

MemoryWrite
MBR MAR 4
memory
0 1 2 3 4 FFFFFFFF 47 12354 18 72 91 14

91

91

MBR

COMP375

Moremicrocode

2/9/2011

FollowtheFetch/ExecuteCycle
Thestepsofthefetch/executecycleare reflected fl t din i th themicrocode i d 1. Readtheinstructionfrommemory 2. Incrementtheprogramcounter 3. Gettheoperands 4. Executetheinstruction 5. Savetheresults

FetchandPCIncrement
Thefetch/executecyclealwaysstartswith reading di the th instruction i t ti from f memoryand d incrementingtheprogramcounter. Inoursimplecomputer,thistakesthreelines ofmicrocode. Afterthemicrocodeforoneinstructionthe CPUwillstartthefetchofthenextinstruction.

JumpInstructions
Thelastmicrocodestepofajumpalmost always l copies i avalue l i into t th theprogram counter. Jumpinstructionsrarely accessmemory unlesstheyarepushingorpoppingsomething onthestack.

Arithmetic
Mostarithmeticinstructionshavethesteps

Copysomethingintotheoperandreg. Putavalueonthebusanddoit. Copytheresultregistersomeplace


Inamorerealisticsystem,theALUfunction wouldbedeterminedbytheopcode ofthe instruction.

COMP375

Moremicrocode

2/9/2011

Whatdoesthismicrocodeimplement?
bus IR resu A bus bus PC bus R1 bus R2 bus bus M ALU Mem adr lt L B func func IR bus U opr PC bus R1 bus R2 bus MA M R bus R B nd resu R bus lt X X

StackInstructions
Thestackiskeptinmemory WeassumeR2pointstothetopofthestack

1. 2. 3. 4.

push pop add jump

Currenttopofstack

Stackpointer,R2

PopInstruction
Readthememorylocationwhoseaddressisin th thestack t kpointer i t

PopInstruction
Decrementthestackpointer

Currenttopofstack

Stackpointer,R2
Currenttop pofstack

Stackpointer,R2

COMP375

Moremicrocode

2/9/2011

PushInstruction
Incrementthestackpointer

PushInstruction
Writethevalueatthememorylocationwhose dd t kpointer i t address i isi inth thestack

Stackpointer,R2
Currenttop pofstack

Currenttopofstack

Stackpointer,R2

FunctionCall
Afunctioncallinstructionpushesthereturn address dd onth thestack t kand djumps j to t th thestart t tof f thefunction. ThereturnaddressisintheProgramCounter. WewillassumeregisterR2isthestackpointer

Incrementthestackpointer,R2
Inc

bus IR resu bus bus bus PC bus R1 bus R2 bus bus M B adr lt R IR bus A opr PC bus R1 bus R2 bus MA M bus L nd R B U R bus
X X X X X X X X X

A L U fun

Mem func

inc write wait

COMP375

Moremicrocode

2/9/2011

PutthenewtopofstackaddressbackinR2andset thememoryaddresstothetopofstack

Writethereturnaddress,PC,tothe topofstackinmemory

Write bus IR resu bus bus bus PC bus R1 bus R2 bus bus M B adr lt R IR bus A opr PC bus R1 bus R2 bus MA M bus L nd R B U R bus
X X X X X X X X X write wait X X

A L U fun

Mem func

bus IR resu bus bus bus PC bus R1 bus R2 bus bus M B adr lt R IR bus A opr PC bus R1 bus R2 bus MA M bus L nd R B U R bus
X X X X X X X

A L U fun

Mem func

inc

inc write wait

Jump to the address of the function

TryIt
Writethemicrocodetoimplementareturn i t ti instruction Popthereturnaddressoffthestack 1. Readthetopofstack 2. Decrementthestackpointer 3. PutthevaluereadintheProgramCounter

Wait bus IR resu bus bus bus PC bus R1 bus R2 bus bus M B adr lt R IR bus A opr PC bus R1 bus R2 bus MA M bus L nd R B U R bus
X X X X X X X X X write wait

A L U fun

Mem func

inc

COMP375

You might also like