title: representing the addi $s1, $0, 4 instruction: write down the value of the control signals
body: <p>Im doing a homework where I need to write down the value of the control signals for 5 instructions and am trying to figure out the sample first (code at the bottom). The 5 instructions I need to do are</p>
  
  <pre><code>Address    Code        Basic                 Source
  
  0x00400014  0x12120004  beq $16,$18,0x0004    15    beq $s0, $s2, exit
  0x00400018  0x8e080000  lw $8,0x0000($16)     16    lw  $t0, ($s0)
  0x0040001c  0x02118020  add $16,$16,$17       17    add $s0, $s0, $s1
  0x00400020  0xae08fffc  sw $8,0xfffc($16)     18    sw  $t0, -4($s0)
  0x00400024  0x08100005  j 0x00400014          19    j   loop
  </code></pre>
  
  <p>And the example he did is for addi $s1,$0,4 . Right now I have this for it:</p>
  
  <pre><code>    Address    Code       Basic                 Source
      0x00400028 0x20110004 addi $16,$0,4         20 addi     $s1, $0, 4   
  </code></pre>
  
  <p>where I think the 4 in the basic column is incorrect. What would be the right answer?</p>
  
  <p>Heres the sample he did for that, and below that is the diagram he is referring to with the control signals:</p>
  
  <pre><code>##--------------------------
  # Example
  # addi  $s1, $0, 4
  # Although not supported as in Figure 4.24, the instruction can be easily
  # supported with minor changes in the control circuit.
  
  instruction_address=0x00400028 
  instruction_encoding=0x20110004
  
  OPcode=0b001000
  
  Jump=0
  Branch=0
  Jump_address=0x00440010    # not used in this instruction
  Branch_address=0x0040003C  # not used in this instruction
  
  Read_register_1=0b00000
  Read_register_2=0b10001
  Sign_extend_output=0x00000004 
  
  ALUSrc=1            # pick the value from sign_extend_output
  ALUOp=0b00          # assume the same value as load/store instruction
  ALU_control_input=0b0010    # add operation, as in load/store instruction
  
  MemRead=0
  MemWrite=0
  MemtoReg=0          # select the ALU result 
  
  RegDst=0
  Write_register=0b10001      #register number for $s1
  RegWrite=1
  
  ##--------------------------
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/QKkIA.png" alt="enter image description here"></p>