aboutsummaryrefslogtreecommitdiffstats
path: root/ee4363/mp1/MIPSALU.v
blob: 096aff56ba38687afd2f202a92ab13ec244d61e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module MIPSALU (ALUctl, A, B, ALUOut, Zero);
  input [3:0] ALUctl;
  input [31:0] A,B;
  output reg [31:0] ALUOut;
  output Zero;
  assign Zero = (ALUOut==0); 
  always @(ALUctl, A, B)
      case (ALUctl)
         0: ALUOut <= A & B;
         1: ALUOut <= A | B;
         2: ALUOut <= A + B;
         6: ALUOut <= A - B;
         7: ALUOut <= A < B ? 1:0;
         12: ALUOut <= ~(A | B);          
		 default: ALUOut <= 0; 
      endcase
endmodule