ALU_Control.v
984 Bytes
module ALUControl(funct, aluop, aluctrl);
input[5:0] funct;
input[1:0] aluop;
output reg[3:0] aluctrl;
always @(*) begin
case(aluop)
2'b00: aluctrl = 4'b0010; // add
2'b01: aluctrl = 4'b0110; // sub
2'b10: case(funct) // R type instruction
6'b100000: aluctrl = 4'b0010; // add
// 6'b100001: aluctrl = 4'b0010; // addu
6'b100010: aluctrl = 4'b0110; // sub
// 6'b100011: aluctrl = 4'b0110; // subu
6'b100100: aluctrl = 4'b0000; // and
6'b100101: aluctrl = 4'b0001; // or
6'b100110: aluctrl = 4'b1101; // xor
6'b011000: aluctrl = 4'b1000; // mult
// 6'b011001: aluctrl = 4'b1000; // multu
6'b011010: aluctrl = 4'b1001; // div
// 6'b011011: aluctrl = 4'b1001; // divu
6'b101010: aluctrl = 4'b0111; // slt
// 6'b101011: aluctrl = 4'b0111; // sltu
6'b010000: aluctrl = 4'b1010; // mfhi
6'b010010: aluctrl = 4'b1011; // mflo
default: aluctrl = 4'b1111;
endcase
default: aluctrl = 4'b1111;
endcase
end
endmodule