Fetch the MIPS instruction at the program counter, and compute . The opcode selects an MIPS R-type instruction; register-file read addresses and select the two operands. The function field selects ALU addition. The result returns through write-back multiplexer input zero to destination , and the next program counter is .
Using the diagram's actual selector encodings, the control signals areHere means decode the function field; means add and means subtract. The source's is a two-bit control: the branch-taken output is . With , is immaterial; zero is a convenient concrete setting. No data-memory access occurs.
Fetch and decode the MIPS I-type instruction, read and , and subtract their values in the arithmetic logic unit. The zero flag is one exactly when they are equal. The branch target isThe branch selector chooses that target when and make the diagram's condition equal to . Otherwise it chooses . Neither registers nor data memory are written. The control signals areDashes are don't-care conditions because register write enable is zero. The immediate goes to the branch-target adder, while the main ALU's second input remains the value in .
For the semantics stipulated by the question, write to register 31 and load the next from register . Read through register-file output . Select input two of the next-PC multiplexer, which is already wired from . Select destination input two, already the constant register number 31, and write-back input two, already .
Thus the printed diagram already contains the necessary three-way multiplexers and wires. Extend the controller's opcode/function decoding to generateThe displayed and settings are arbitrary safe choices for an unused result. No additional datapath hardware or control field is required beyond decoding this instruction into the existing values. This uses the question's explicitly specified link convention.
Use the stipulated MIPS I-type instruction encoding, whose unused field is zero, so register-file output supplies the hardwired zero register. With and subtraction selected, the arithmetic logic unit computes . Its zero flag detects , while bit 31 of is the sign in two's complement. Therefore the required signed test isIntroduce one new control bit , and replace the zero-flag input to the existing branch XOR byThis needs an AND gate, an OR gate and a tap of the sign bit. With , existing branch behavior is unchanged. With and , the existing branch-taken circuit gives , exactly the positive test. Its output still selects between and the usual sign-extended branch target. The complete control row isSet for each instruction in parts (a)–(c). Registers and data memory remain unchanged. The available signed
slt operation could support a different design; the sign-and-zero design above avoids adding an ALU-input swap and explicitly distinguishes zero from positive values. Articles by others on the same topic
There are currently no matching articles.