ALUDecoder.v 748 B

1234567891011121314151617181920212223
  1. module ALUDecoder(
  2. input [1:0] ALUOp,
  3. input [2:0] funct3,
  4. input op5, funct7,
  5. output reg [2:0] ALUControl
  6. );
  7. always@*
  8. case(ALUOp)
  9. 2'b00: ALUControl = 3'b000; //lw, sw requires 000 ADD for Addresses out of Reg File
  10. 2'b01: ALUControl = 3'b001; //beq utilizes 001 SUB to set zero flag
  11. 2'b10: //R-type check funct3, 5th bit of op and funct7 field
  12. begin
  13. case(funct3)
  14. 3'b000: ALUControl = {op5, funct7} == 2'b11 ? 3'b001: 3'b000; //SUB else ADD
  15. 3'b010: ALUControl = 3'b101; //SLT
  16. 3'b110: ALUControl = 3'b010; //OR
  17. 3'b111: ALUControl = 3'b011; //AND
  18. endcase
  19. end
  20. endcase
  21. endmodule