-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontrol.v
56 lines (53 loc) · 889 Bytes
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* control.v */
module control(
input wire [5:0] opcode,
output reg [3:0] EX,
output reg [2:0] M,
output reg [1:0] WB
);
parameter RTYPE = 6'b000000;
parameter LW = 6'b100011;
parameter SW = 6'b101011;
parameter BEQ = 6'b000100;
parameter NOP = 6'b100000;
initial begin
EX <= 4'b0000;
M <= 3'b000;
WB <= 2'b00;
end
always@* begin
case (opcode)
RTYPE:
begin
EX <= 4'b1100;
M <= 3'b000;
WB <= 2'b10;
end
LW:
begin
EX <= 4'b0001;
M <= 3'b010;
WB <= 2'b11;
end
SW:
begin
EX <= 4'bz001;
M <= 3'b001;
WB <= 2'b0z;
end
BEQ:
begin
EX <= 4'bz010;
M <= 3'b100;
WB <= 2'b0z;
end
NOP:
begin
EX <=4'b1000;
M <=3'b000;
WB <=2'b00;
end
default: $display ("Opcode not recognized.");
endcase
end
endmodule // control