-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalu_control.v
41 lines (37 loc) · 875 Bytes
/
alu_control.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
`timescale 1ns / 1ps
// in EX stage
module alu_control(
input [1:0] ALUOp,
input [5:0] instru,
output reg [3:0] ALUcontrol
);
always @(*) begin
// $display("** ALUOp: 0x%H | instruCode: 0x%H ",ALUOp,instru);
case (ALUOp)
2'b00:
ALUcontrol = 4'b0010;
2'b01:
ALUcontrol = 4'b0110;
2'b10: begin
case (instru)
6'b100000: // add
ALUcontrol = 4'b0010;
6'b100010: // sub
ALUcontrol = 4'b0110;
6'b100100: // and
ALUcontrol = 4'b0000;
6'b100101: // or
ALUcontrol = 4'b0001;
6'b101010: // slt
ALUcontrol = 4'b0111;
default:
;
endcase
end
2'b11:
ALUcontrol = 4'b0000;
default:
;
endcase
end
endmodule