-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathALU decoder.v
37 lines (37 loc) · 897 Bytes
/
ALU decoder.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
module ALU_decoder(
input [2:0] funct3,
input funct7,op5,
input [1:0] ALUOp,
output reg [2:0] ALUControl
);
always@(*)begin
case(ALUOp)
2'b00:ALUControl=3'b000;
2'b01:begin
case(funct3)
3'b000:ALUControl=3'b010;
3'b001:ALUControl=3'b010;
3'b100:ALUControl=3'b010;
default:ALUControl=3'b000;
endcase
end
2'b10:begin
case(funct3)
3'b000:begin
if({op5,funct7}==2'b11)
ALUControl=3'b010;
else
ALUControl=3'b000;
end
3'b001:ALUControl=3'b001;
3'b100:ALUControl=3'b100;
3'b101:ALUControl=3'b101;
3'b110:ALUControl=3'b110;
3'b111:ALUControl=3'b111;
default:ALUControl=3'b000;
endcase
end
default:ALUControl=3'b000;
endcase
end
endmodule