Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given this processor hardware design (MIPS), add control states to the following

ID: 1716012 • Letter: G

Question

Given this processor hardware design (MIPS), add control states to the following to implement a multiply-by-4 instruction (as decoded by the when below), such that mul4 rd makes rd=4*rd;. Note that there is no multiplier per se in the ALU. You should add initial values and test your design using the simulator before submitting it here.

~~~~~~

when op() op(1) Mul4

Start:
PCout, MARin, MEMread, Yin
CONST(4), ALUadd, Zin, UNTILmfc
MDRout, IRin
Zout, PCin, JUMPonop
HALT /* Should end here on undecoded op */

Mul4:
/* YOUR CODE GOES HERE! */

Explanation / Answer

when op() op(2) Clr

Start:
PCout, MARin, MEMread, Yin
CONST(4), ALUadd, Zin, UNTILmfc
MDRout, IRin
Zout, PCin, JUMPonop
HALT /* Should end here on undecoded op */

Clr:
SELrs, REGout, Yin
IRimmedout, ALUadd, Zin
Zout, MARin
CONST(0), MDRin, MEMwrite, JUMP(Start)

You can test your code with:

Enter/edit your control and initialization here:

/* This is a demo of how the simulator works....
   Comments are done as they are in C, i.e., like this.
*/

/* Now a simple delay specification... */
delay 5 IN OUT SEL
delay 20 ALU
delay 15 ALUand ALUor ALUxor /* a little faster */
delay 36 MEM /* just a tad over one clock */

/* In order for JUMPonop to work, you need to define how
   opcodes are decoded; that's what "when" does.
   For each different type of instruction, you define a
   mask and match value; if ((ir & mask) == match), then
   the next state after JUMPonop will be the labeled one.
   Note the functions available for formatting fields....
*/
when (op(0x3f)+funct(0x3f)) funct(32) Add
when 0xfc000000 0x20000000 Addi

/* Just like the EE380 reference description... */
Start:
PCout, MARin, MEMread, Yin
CONST(4), ALUadd, Zin, UNTILmfc
MDRout, IRin
Zout, PCin, JUMPonop

HALT /* Should end here on undecoded op */

Add:
SELrs, REGout, Yin
SELrt, REGout, ALUadd, Zin
Zout, SELrd, REGin, JUMP(Start)

Addi:
SELrs, REGout, Yin
IRimmedout, ALUadd, Zin
Zout, SELrt, REGin, JUMP(Start)

/* Initial values... all others are 0 */
$9=0x10000000
/* MEM[0]= MIPS "addi $10,$9,0x50" instruction */
MEM[0]=0x20000000+rs(9)+rt(10)+immed(0x50)
/* MEM[4]= MIPS "add $11,$10,$9" instruction */
MEM[4]=funct(32)+rs(9)+rt(10)+rd(11)
/* MEM[8]= an instruction with no when, to cause HALT */
MEM[8]=0

/* A few final value tests... */
PC#12 10 /* only if sim enough cycles */
$10#0x10000050 5
MEM#2 /* 2 points off per memory error */
MEM[0]#0x20000000+rs(9)+rt(10)+immed(0x50)
MEM[4]#0x012a5820
MEM[8]#23 /* like this one */

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote