-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathALUControlUnit.v
More file actions
68 lines (51 loc) · 1.33 KB
/
ALUControlUnit.v
File metadata and controls
68 lines (51 loc) · 1.33 KB
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
61
62
63
64
65
66
67
68
`timescale 10ns/1ns
module alu_control
// IO ports
(
input wire [1:0] aluOP,
input wire [2:0] funct3,
input wire funct7,
output reg [3:0] aluControl
);
// internal signal declaration
assign funct = {funct7, funct3};
// symbolic state representation
// aluOP
localparam [5:0]
LOAD_STORE_OP = 2'b00,
BEQ_OP = 2'b01,
R_OP = 2'b10;
// funct
localparam [3:0]
R_ADD = 4'b0000,
R_SUB = 4'b1000,
R_AND = 4'b0111,
R_OR = 4'b0110;
// body
always @*
begin
case(aluOP)
LOAD_STORE_OP:
aluControl = 4'b0010;
BEQ_OP:
aluControl = 4'b0110;
R_OP:
begin
case(funct)
R_ADD:
aluControl = 4'b0010;
R_SUB:
aluControl = 4'b0110;
R_AND:
aluControl = 4'b0000;
R_OR:
aluControl = 4'b0001;
default:
aluControl = 4'b0010;
endcase
end
default:
aluControl = 4'bx;
endcase
end
endmodule