Question: Given this processor hardware design, add control states to the following to implement an average instruction (as decoded by the when below), such that avg
Given this processor hardware design, add control states to the following to implement an average instruction (as decoded by the when below), such that avg $rd,$rs,$rt gives rd the average of the other two values. You're probably used to averaging by adding and then dividing by 2, but that actually doesn't work -- because the add can go out of range. Instead, use the algorithm that rd=((rs&rt)+((rs^rt)>>1))
when op() op(1) Avg
Start: PCout, MARin, MEMread, Yin CONST(4), ALUadd, Zin, UNTILmfc MDRout, IRin Zout, PCin, JUMPonop HALT /* Should end here on undecoded op */
Avg: /* YOUR STATES GO HERE! */
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
