title: How to implement bgtz in a MIPS data path diagram, and find its respective control values?
body: <p>I have a single cycle MIPS data path diagram, which has been designed so that it can easily handle instructions such as <code>lw, sw</code> and <code>add</code>, amongst others. </p>
  
  <p>For example, when we want to determine the control values, we see that <code>lw</code> is an <code>I-Type</code> instruction. </p>
  
  <ol>
  <li>This means that we have an instruction going from the 'Instruction Memory' into the control unit (with the OP code), another instruction going into 'Read Register 1', another one going into 'Read Register 2' and a final one into the 'Sign Extension'. </li>
  <li><code>lw</code> writes from memory into a register, thus 'RegWrite' = 1 and consequently 'RegDst' is also equal to 1. </li>
  <li>MemtoReg is also one, since we are going from memory to register and the ALUOp for <code>lw</code> is <code>00</code>.</li>
  <li>Our ALUSrc value is also 1 because we take the line from the 'Sign Extend' (because of the immediate in <code>I Type</code> instructions). </li>
  <li>No <code>branch</code> or <code>jump</code> is performed thus Branch = Jump = 0. This completes the control values for <code>lw</code>. </li>
  </ol>
  
  <p>However <code>lw</code> is not a complex instruction and can be easily implemented and the control values can be easily worked out. However how does this work for more complex instructions, such as <code>bgtz</code>? From what I understand, <code>bgtz</code> is an I-Type instruction because it has a source register and a target register, along with an immediate value (label where we have to go if the statement is true). The path is shown in red, but I'm not sure it's correct. I'm also certain that I'm missing another piece of hardware that will make bgtz possible. However, for the control values I'm certain that:</p>
  
  <ol>
  <li>ALUOp = </li>
  <li>RegWrite = 0</li>
  <li>MemtoReg = x</li>
  <li>MemWrite = x</li>
  <li>RegDst = x</li>
  <li>ALUSrc = 1</li>
  <li>Branch = 1</li>
  <li>Jump = 0</li>
  </ol>
  
  <p>My data path diagram looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/1cUB5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1cUB5.png" alt="enter image description here"></a></p>
  
  <p>I need to understand how we can implement bgtz here, and what the control values will be. In a more general way, how can we implement different instruction in this data path diagram, such as lui, xor, etc...</p>