# MIPS Main Control Logic

In the Patterson & Hennessy book,

This is for these 4 instructions, if I need to implement instructions like andi, addi, ori, j, etc, do I add on to this table? Or do I do something else?

UPDATE

If I do add on, I think the hard part is the ALUOp. There are only 2 bits, I think I need the below operations. And I added what my idea of an implementation. Whats the correct MIPS implementation tho?

instr    ALUOp
--------+------
AND      0000
OR       0001
add      0100
sub      0101
slt      0111
funct    1xxx


Where the MSB (bit 3) is a "see funct" bit (R-Type instructions). bit 2 will be "use ALU" bit. Then the last 2 is the operation bits. I saw various implementations, where there are more instructions like NOR, XOR, shift etc. Is there no standard or most commonly used standard?

• Yet another homework question. – Brian Carlton Oct 25 '11 at 16:42
• @Brian Carlton What's wrong with that? – AndrejaKo Oct 25 '11 at 17:10
• I guess this is not my strong point :) with little useful help in school ... – Jiew Meng Oct 26 '11 at 0:04

## 2 Answers

If the hardware defined in your datapath supports the new instructions without adding any new control signals, then yes, just go ahead and extend the table to the right!

Augmented answer per augmented question:

The answer depends entirely on the datapath and what your control signals mean... I presume the ALUOp bits are each respectively the select signal for a 2x1 MUX, each of which in turn selects the operand inputs to your ALU. In that way they can be used to select either a value from a register or the immediate from the instruction itself. So for immediate instructions, you are probably going to choose the "register" input for operand 1 and the "immediate" inupt for operand 2...

• Ok, now what should the ALUOp bits be for immediate instructions? do I use the unused 11? – Jiew Meng Oct 26 '11 at 0:34
• @jiewmeng, for any question you need to ask exactly what you are needing explained. If you then have further full questions you should ask them as another question. Please take the time to formulate exactly what you are looking for, often that process will answer most questions. – Kortuk Oct 26 '11 at 6:27
• @Kortuk, I'll keep that in mind ... sometimes I rush to ask questions. Updated my qn too – Jiew Meng Oct 26 '11 at 7:17
• @jiewmeng, for this site to garner great answers it needs great questions. Just advice for asking questions here. – Kortuk Oct 26 '11 at 7:26

I avoided this problem by adding 2 more bit line to ALUOp. So now all the I-type instructions that could not be decoded by the ALUContol block, had 2 additional ALUOp bit and I could now decode 24 more instructions.