mipsalu

Implementing beq instruction to a simple control unit in logisim


so i dont know if im stupid but i have tried to research this for offers and i still cant seem to understand how the beq instruction is built? i get that u first extract the 6 lsb to get the opcode and that beq has the opcode 000100 but i dont get what happens after in this picture, why is there a 2 and 6 input to the decoder and why is the ALUControl 010, shouldnt it be sub operator to see if beq is true logisim beq instruction at bottom

i want to know what happens after the opcode goes into the comparator


Solution

  • Looks to me like the BEQ needs a 6 (subtraction) for ALUControl, so gets this 6 from that MUX.  That MUX will select 2 with a mux selector control input 0, and 6 with a mux selector control input 1.  So, when BEQ, then a 1 goes to that mux selector control input, as well as to the Branch control signal.

    Many other instructions need a 2 and also get it from this MUX, by leaving that mux control selector input at 0 (in that diagram, from "not" BEQ).  The addi, addiu, add, addu, lw, and sw instructions (among others) all want 2 (addition) for the ALUControl.

    The sub, subu, subiu, subi instructions also want 6 (subtract) for the ALUControl, though these are not shown in that limited diagram.  That diagram does not show how the R-Type instructions generate their respective ALUControl values.  It only shows that ALUControl is 6 for BEQ and 2 for other than BEQ.