We start with our last figure, which shows the data path and then add the missing mux and show how the instruction is broken down.
We need to set the muxes.
We need to generate the three ALU cntl lines: 1-bit Bnegate and 2-bit OP
And 0 00 Or 0 01 Add 0 10 Sub 1 10 Set-LT 1 11Homework: What happens if we use 1 00? if we use 1 01? Ignore the funny business in the HOB. The funny business ``ruins'' these ops.
What information can we use to decide on the muxes and alu cntl lines?
The instruction!
So no problem, just do a truth table.
We will let the main control (to be done later) ``summarize'' the opcode for us. It will generate a 2-bit field ALUop
ALUop Action needed by ALU 00 Addition (for load and store) 01 Subtraction (for beq) 10 Determined by funct field (R-type instruction) 11 Not used
How many entries do we have now in the truth table
opcode | ALUop | operation | funct field | ALU action | ALU cntl |
---|---|---|---|---|---|
LW | 00 | load word | xxxxxx | add | 010 |
SW | 00 | store word | xxxxxx | add | 010 |
BEQ | 01 | branch equal | xxxxxx | subtract | 110 |
R-type | 10 | add | 100000 | add | 010 |
R-type | 10 | subtract | 100010 | subtract | 110 |
R-type | 10 | AND | 100100 | and | 000 |
R-type | 10 | OR | 100101 | or | 001 |
R-type | 10 | SLT | 101010 | set on less than | 111 |
ALUop | Funct || Bnegate:OP 1 0 | 5 4 3 2 1 0 || B OP ------+--------------++------------ 0 0 | x x x x x x || 0 10 x 1 | x x x x x x || 1 10 1 x | x x 0 0 0 0 || 0 10 1 x | x x 0 0 1 0 || 1 10 1 x | x x 0 1 0 0 || 0 00 1 x | x x 0 1 0 1 || 0 01 1 x | x x 1 0 1 0 || 1 11
ALUop | Funct 1 0 | 5 4 3 2 1 0 ------+------------ x 1 | x x x x x x 1 x | x x 0 0 1 0 1 x | x x 1 0 1 0
ALUop | Funct 1 0 | 5 4 3 2 1 0 ------+------------- x 1 | x x x x x x 1 x | x x x x 1 x
ALUop | Funct 1 0 | 5 4 3 2 1 0 ------+------------ 0 0 | x x x x x x x 1 | x x x x x x 1 x | x x 0 0 0 0 1 x | x x 0 0 1 0 1 x | x x 1 0 1 0
ALUop | Funct 1 0 | 5 4 3 2 1 0 ------+------------ 0 0 | x x x x x x x 1 | x x x x x x 1 x | x x x 0 x x
ALUop | Funct 1 0 | 5 4 3 2 1 0 ------+------------ 0 x | x x x x x x 1 x | x x x 0 x x
ALUop | Funct 1 0 | 5 4 3 2 1 0 ------+------------ 0 x | x x x x x x x x | x x x 0 x x
ALUop | Funct 1 0 | 5 4 3 2 1 0 ------+------------ 1 x | x x 0 1 0 1 1 x | x x 1 0 1 0
ALUop | Funct 1 0 | 5 4 3 2 1 0 ------+------------ 1 x | x x x x x 1 1 x | x x 1 x x x
The circuit is then easy.