-
Notifications
You must be signed in to change notification settings - Fork 0
/
ALU_Ctrl.v
60 lines (46 loc) · 1.57 KB
/
ALU_Ctrl.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Alden Rivera 0416329
// Jorge Pineda 0416330
//Subject: CO project 2 - ALU Controller
//--------------------------------------------------------------------------------
//Version: 1
//--------------------------------------------------------------------------------
//Writer:
//----------------------------------------------
//Date:
//----------------------------------------------
//Description:
//--------------------------------------------------------------------------------
module ALU_Ctrl(
funct_i,
ALUOp_i,
ALUCtrl_o
);
//I/O ports
input [6-1:0] funct_i;
input [3-1:0] ALUOp_i;
output [4-1:0] ALUCtrl_o;
//Internal Signals
reg [4-1:0] ALUCtrl_o;
//Parameter
//Select exact operation
always@(*)
begin
case(ALUOp_i)
3'b010:
begin
if(funct_i == 6'b100001) ALUCtrl_o = 4'b0010; //add
else if(funct_i == 6'b100011) ALUCtrl_o = 4'b0110;//sub
else if(funct_i == 6'b100100) ALUCtrl_o = 4'b0000;//AND
else if(funct_i == 6'b100101) ALUCtrl_o = 4'b0001;//OR
else if(funct_i == 6'b101010) ALUCtrl_o = 4'b0111;//SLT
else if(funct_i == 6'b011000) ALUCtrl_o = 4'b1111;//MUL
end
3'b001://beq
ALUCtrl_o = 4'b0110;
3'b011:
ALUCtrl_o = 4'b0010;
3'b100:
ALUCtrl_o = 4'b0111;
endcase
end
endmodule