Text: Section 5.3
(review assignments 2 and 3)
These data paths require various control signals: register numbers, read/write control for memories and registers, function for ALU, select lines for registers. The values of these control signals must be determined based on the instruction being executed.
The instructions we are considering (lw, sw, beq, add, sub, and, or, slt) are stored in three instruction formats (Fig. 5.19). The opcode of the instruction is stored in the high 6 bits (bits 26 to 31). However, the R-type instructions all are assigned opcode 0, and are differentiated by the "function" field, bits 0 to 5 of the instruction.
The register numbers are stored in the same place in all these instructions, and so we can connect the instruction fields (the output of the instruction memory) directly to the register number inputs on the register file. We need one multiplexer, however, since the number of the register to write sometimes appears in the rd field, bits 11 to 15 (for R-type instructions) and sometimes in the rt field, bits 16 to 20 (for load instructions). This produces the circuit shown in Fig. 5.20.
We must construct logic to control the ALU functions plus the following control lines (see Fig. 5.21): MemRead, MemWrite, ALUSrc, RegDst, RegWrite, PCSrc, and MemtoReg.
We construct a truth table in which the inputs are the instruction --- specifically, the opcode and function fields --- and the outputs are the control signals and ALU function. P&H do this in two steps: The control signals (exclusive of ALU function) are determined by the opcode alone. The dependence is shown in Figure 5.23. D&H then define a two-bit signal called ALUOp, which is a function of the opcode. The ALU control signal truth table is then based on two inputs: ALUOp and the function field (Figure 5.15).