Given this processor hardware design, add control states to the following to imp
ID: 1715979 • Letter: G
Question
Given this processor hardware design, add control states to the following to implement an exchange-with-memory instruction (as decoded by the when below), such that swap $rt,immed($rs) swaps the values in register rt and memory[rs+immed]. Hint: swaps are usually done using a temporary register -- Y is a good choice. Another hint: you only need to compute rs+immed once, because reading from memory doesn't change the value in the MAR.
when (op()) op(1) Swap
Start:
PCout, MARin, MEMread, Yin
CONST(4), ALUadd, Zin, UNTILmfc
MDRout, IRin
Zout, PCin, JUMPonop
HALT /* Should end here on undecoded op */
Swap:
/* YOUR STATES GO HERE! */
Explanation / Answer
when (op()) op(1) Swap
Start:
PCout, MARin, MEMread, Yin
CONST(4), ALUadd, Zin, UNTILmfc
MDRout, IRin
Zout, PCin, JUMPonop
HALT /* Should end here on undecoded op */
Swap:
SELrs, REGout, Yin
IRimmedout, ALUadd, Zin
Zout, MARin, MEMread
SELrt, REGout, Yin, UNTILmfc
MDRout, SELrt, REGin
Yout, MDRin, MEMwrite, JUMP(Start) /* MAR still has rs+immed */
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.