| Control unit: ALU | |||||||||||||
| ALU operation selection: function depends on type of instruction | |||||||||||||
| R-type: function determined by function field from instruction | |||||||||||||
| Load/store: add to compute memory address | |||||||||||||
| Branch: subtract to compare operands | |||||||||||||
| (Main control) | (Instruction) | ||||||||||||
| Instruction | ALUOp | Function | ALU control | ||||||||||
| lw, sw | 00 | xxxxxx | 010 | add | |||||||||
| beq | 01 | xxxxxx | 110 | subtract | |||||||||
| add | 10 | 100000 | 010 | add | |||||||||
| sub | 10 | 100010 | 110 | subtract | |||||||||
| and | 10 | 100100 | 000 | and | |||||||||
| or | 10 | 100101 | 001 | or | |||||||||
| slt | 10 | 101010 | 111 | set on less than | |||||||||
| Fig. 5.15 shows complete truth table for generating these ALU control bits | |||||||||||||