Beruflich Dokumente
Kultur Dokumente
FinalProject
CST337,CSUMBSummer2016
CreateMIPSSingleCycleDatapathsfor3PseudoInstructions
Formyfinalproject,Icreateddatapathsfor3MIPSpseudoinstructions,MOVE,BLT,and
SGE.
MOVE($d,$s)
TheMOVEinstructionmovesdatafromregister$storegister$d.IimplementedMOVE
asanItypeinstruction.ThiscommandbehavessimilarlytotheRtypeinstructionADD($d,$s,
$zero),where$sand$zeroarethesourceregisters,and$disthedestinationregister.
TheuniqueOpCode101111waschosen.The32bitinstructionforMOVEisinthe
followingformat:
OpCode
101111
$s
XXXXX
$d
XXXXX
immediate
0000000000000000
AlthoughMOVEisimplementedasanItypeinstruction,theControlsettingsfrom
OpCode10111areidenticaltotheControlsettingsthatoriginatefromanRtypeinstruction.
ThereasonisthatthedatapathIcreatedwillactuallybehavelikeADD($d,$s,$zero),anditis
importantforRegDsttobesetto1.TheALUControlissetto0010(add).
Tofacilitatethisflow,Iimplementedtwomultiplexerstoswapthevaluesoftheread
register2andthewriteregisteronlyintheeventthattheOpCodeistheMOVEOpCode.An
ANDgateisusedtodetermineiftheinstructionistheMOVEinstruction.Ifso,thevalue
headedtothereadregister2andthewriteregisterareswapped.Ifnot,theycontinue,
unhindered.AlthoughintheItypeformat,register$zeroisnotspecificallyindicated
anywhere,withtheimmediatedigits[150]settoallzeros,thedatapathisabletointerpret
digits[1511]asregister$zero.
Thiscompletesthecircuit,ensuringthatthevalueinregister$siswrittentoregister$d,
whilenotinterferingwiththelogicbehindanyexistinginstructions.
JenniferDunham
FinalProject
CST337,CSUMBSummer2016
CreateMIPSSingleCycleDatapathsfor3PseudoInstructions
JenniferDunham
FinalProject
CST337,CSUMBSummer2016
CreateMIPSSingleCycleDatapathsfor3PseudoInstructions
BLT($s,$t,offset)
TheBLTinstructionbranchestoaspecifiedaddressifthevalueinregister$sislessthan
thevalueinregister$t.ThiscommandbehavessimilarlytotheBEQinstruction,thoughinstead
ofbranchingwhentwovaluesareequal,itbranchesonlywhenthevalueofregister$sisless
thanthevalueofregister$t.
TheuniqueOpCode001111waschosen.The32bitinstructionforBLTisinthe
followingformat:
OpCode
001111
$s
XXXXX
$t
XXXXX
offset
XXXXXXXXXXXXXXXX
Thecontrolsettingsensurethatthedatapathflowsthroughproperly,withRegDst,
Jump,MemRead,MemWrite,ALUSrc,andRegWritesetto0.MemtoRegisalsosetto0,
thoughitsvaluedoesnotimpactthisdatapath.Branchissetto1,andthisiscritical.ALUOpis
setto01,andtheALUControlissetto0110(subtract).
Toimplementthisflow,IimplementedonemultiplexerandanANDgate.TheANDgate
checkstoseewhethertheOpCodecorrespondstomyBLTinstruction.Ifitdoes,thenittells
themultiplexertopassonthevalueofthedigit[31]inthesubtractionresultintotheexisting
BranchANDgate.Therefore,iftheOpCodeANDgateis1,andthemostsignificantdigitinthe
resultis1,indicatingtheresultisnegative,thecodewillbranchtothespecifiedaddress.Ifthe
OpCodeANDgateis1,butthemostsignificantdigitintheresultis0,thenhecodewillnot
branch(wedonotwantthiscodetobranchif$sisgreaterthan$torifthevaluesareequal).
However,iftheOpCodeANDgateisnot1,thenthedatapathwillallowthevalueofthezero
flagtopassthroughasoriginallydesigned.Thus,theaddedBLTdatapathdoesnotinterfere
withthelogicbehindanyexistinginstructions.
JenniferDunham
FinalProject
CST337,CSUMBSummer2016
CreateMIPSSingleCycleDatapathsfor3PseudoInstructions
JenniferDunham
FinalProject
CST337,CSUMBSummer2016
CreateMIPSSingleCycleDatapathsfor3PseudoInstructions
SGE($d,$s,$t)
TheSGEinstructionsetsthevalueofthedestinationregistertothevalueinregister$sif
itisgreaterthanorequaltothevalueinregister$t,anditsetsthevalueofthedestination
registerto0,otherwise.
Theuniquefunctioncode110000waschosen.The32bitinstructionforSGEisinthe
followingformat:
OpCode
000000
$s
XXXXX
$t
XXXXX
$d
XXXXX
shamt
00000
Function
110000
AsanRtypeinstructionwithanOpCodeof000000,mySGEinstructiondoesnotmake
anychangestotheControlvalues.Thecontrolvaluesareindicatedonmydiagram,andthese
areconsistentwithallRtypeinstructions.TheALUcontrolissetto0110(subtract),inorderto
comparethevaluesinthetworegisters,$sand$t.
Mydiagrammakestwokeydecisions.Thefirst,andthemostimportantinensuringthat
theaddedlogicwillneverinterferewithexistinginstructions,istocheckforwhetherthe
instructionprovidedtotheCPUistheSGEinstructionbycheckingthefunctioncode
(instructions50)toseeiftheyare110000.Tobeextrasafe,sinceanItypecommandmay
coincidentallyhavethesesamelast6digitsinitspositions50,Ialsocheckedtoensurethat
theOpCodewas000000.Ifbothofthesearetrue,thenweknowthattheinstructionistheSGE
instruction,andthevaluewrittentotheregisterisgoingeitherbethevalueinthe$sregisteror
thevalueof0.However,ifthisisfalse,thentheresultoftheALUwillcontinuetothewrite
register($d),unhindered.Thisisdoneviaamultiplexersettofeedtheexistingvaluethroughif
thetestreturnsa0(thereforenottheSGEinstruction),ortouseavaluespecifictotheSGE
instructionifthevalueis1.
TheotherkeydecisionusesthecomparisoninthesubtractionfromtheALU.Ifthe
instructionistheSGEinstruction,thenthevaluewrittento$disdependentontheresultsof
thesubtractionof$tfrom$s.Ifthemostsignificantdigitintheresult(inposition[31])is0,
thentheresultiseitherpositiveor0,sothefirstvalueiswrittentotheregister.Ifthedigitin
JenniferDunham
FinalProject
CST337,CSUMBSummer2016
CreateMIPSSingleCycleDatapathsfor3PseudoInstructions
position[31]is1,thenitindicatesthattheresultisnegative;thus,thesecondvalueisgreater,
and0iswrittentoregister$d.Thisisdonebyanothermultiplexer,withthevalueofthedigitin
position[31]determiningwhichvaluetowritebasedonwhetheritis0or1.
Thiscompletesthecircuit,ensuringthateitherthevalueof$sor0iswrittentoregister
$d,dependingontheoutcomeofthesubtraction,whilenotinterferingwiththelogicbehind
anyexistinginstructions.
JenniferDunham
FinalProject
CST337,CSUMBSummer2016
CreateMIPSSingleCycleDatapathsfor3PseudoInstructions