2023-10-20 09:48:18 +00:00
|
|
|
module alu (input [31:0] input_a, input_b,
|
2023-10-21 13:57:58 +00:00
|
|
|
input [3:0] op_code,
|
2023-10-20 09:48:18 +00:00
|
|
|
output reg [31:0] out);
|
|
|
|
|
|
|
|
always@ (*) begin
|
|
|
|
case (op_code)
|
2023-10-21 13:57:58 +00:00
|
|
|
4'b0000 : out <= input_a + input_b;
|
|
|
|
4'b0001 : out <= input_a - input_b;
|
|
|
|
4'b0010 : out <= input_a << input_b;
|
|
|
|
4'b0011 : out <= (input_a < input_b) ? 1 : 0;
|
|
|
|
4'b0100 : out <= input_a ^ input_b;
|
|
|
|
4'b0101 : out <= input_a >> input_b;
|
|
|
|
4'b0111 : out <= input_a >>> input_b;
|
|
|
|
4'b1000 : out <= input_a | input_b;
|
|
|
|
4'b1001 : out <= input_a & input_b;
|
2023-10-20 09:48:18 +00:00
|
|
|
default : out <= 32'b0;
|
|
|
|
endcase
|
|
|
|
end
|
2023-10-11 08:43:36 +00:00
|
|
|
|
2023-10-20 09:48:18 +00:00
|
|
|
endmodule
|