-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathALU.sv
More file actions
28 lines (25 loc) · 677 Bytes
/
Copy pathALU.sv
File metadata and controls
28 lines (25 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module ALU(
input signed [31:0] Input1,
input signed [31:0] Input2,
output logic[31:0] Output,
input logic[3:0] OpCode,
output logic Zero,
output logic Negative);
assign Zero = Output==0;
assign Negative = Output[31];
always_comb
begin
case(OpCode)
4'b0000: Output = Input1 + Input2;
4'b0001: Output = Input1 - Input2;
4'b0010: Output = Input1 & Input2;
4'b0011: Output = Input1 | Input2;
4'b0100: Output = Input1 ^ Input2;
4'b0101: Output = Input1 * Input2;
4'b0110: Output = Input1 >>> Input2[4:0];
4'b0111: Output = Input1 >> Input2[4:0];
4'b1000: Output = Input1 << Input2[4:0];
default: Output = 0;
endcase
end
endmodule