-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathALU.v
35 lines (33 loc) · 892 Bytes
/
ALU.v
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
29
30
31
32
33
34
35
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2020/10/24 15:17:35
// Design Name:
// Module Name: alu
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module alu(
input [31:0] A,
input [31:0] B,
input [2:0] ALUOp,
output [31:0] C
);
assign C = (ALUOp == 3'b000) ? (A + B) :
(ALUOp == 3'b001) ? (A - B) :
(ALUOp == 3'b010) ? (A & B) :
(ALUOp == 3'b011) ? (A | B) :
(ALUOp == 3'b100) ? (A >> B) :
(ALUOp == 3'b101) ? $signed($signed(A) >>> B) : (A + B);
endmodule