Datapath for R-Type Instructions


There are three types (R, I, and J) of MIPS instructions. An arithmetic-logical (or R-type) instruction has three operands as shown in the figure below. For example, one R-type instruction is add:

   add  $t1, $t2, $t3
   # $t1 = $t2 + $t3
   #  rd =  rs +  rt

R-format instructions all have an opcode of 0. These instructions have three register operands: rs, rt, and rd. Fields rs and rt are sources, and rd is the destination. The ALU function is in the funct field and is decoded by the ALU control design. The R-type instructions implemented include add, sub, AND, OR, and slt. The shamt field is used only for shifts.

The figure shows a datapath for R-type instructions which includes two control signals:
The above instruction operates in the following four steps in one clock cycle:
  1. The instruction is fetched and the PC is incremented.

  2. Registers, $t2 (or rs) and $t3 (or rt), are read from the register file.

  3. The ALU operates on the data read from the register file, using the function code (bits 5:0, which is the funct field, of the instruction) to generate the ALU functions.

  4. The result from the ALU is written into the register file using bits 15:11 of the instruction to select the destination register ($t1 or rd).



      β€œRe-examine all you have been told. Dismiss what insults your soul.”    
      ― Walt Whitman