-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathcontrol.v
More file actions
65 lines (61 loc) · 1.23 KB
/
Copy pathcontrol.v
File metadata and controls
65 lines (61 loc) · 1.23 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
`ifndef _control
`define _control
module control(
input wire [5:0] opcode,
output reg branch_eq, branch_ne,
output reg [1:0] aluop,
output reg memread, memwrite, memtoreg,
output reg regdst, regwrite, alusrc,
output reg jump);
always @(*) begin
/* defaults */
aluop[1:0] <= 2'b10;
alusrc <= 1'b0;
branch_eq <= 1'b0;
branch_ne <= 1'b0;
memread <= 1'b0;
memtoreg <= 1'b0;
memwrite <= 1'b0;
regdst <= 1'b1;
regwrite <= 1'b1;
jump <= 1'b0;
case (opcode)
6'b100011: begin /* lw */
memread <= 1'b1;
regdst <= 1'b0;
memtoreg <= 1'b1;
aluop[1] <= 1'b0;
alusrc <= 1'b1;
end
6'b001000: begin /* addi */
regdst <= 1'b0;
aluop[1] <= 1'b0;
alusrc <= 1'b1;
end
6'b000100: begin /* beq */
aluop[0] <= 1'b1;
aluop[1] <= 1'b0;
branch_eq <= 1'b1;
regwrite <= 1'b0;
end
6'b101011: begin /* sw */
memwrite <= 1'b1;
aluop[1] <= 1'b0;
alusrc <= 1'b1;
regwrite <= 1'b0;
end
6'b000101: begin /* bne */
aluop[0] <= 1'b1;
aluop[1] <= 1'b0;
branch_ne <= 1'b1;
regwrite <= 1'b0;
end
6'b000000: begin /* add */
end
6'b000010: begin /* j jump */
jump <= 1'b1;
end
endcase
end
endmodule
`endif