-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.v
More file actions
69 lines (65 loc) · 2.2 KB
/
Copy pathcontroller.v
File metadata and controls
69 lines (65 loc) · 2.2 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
69
module ControllerSequencer (
input wire clk,
input wire reset,
input wire [3:0] opcode,
output reg [1:0] OpSelect, //op. ALU
output reg ALUOut,
output reg [7:0] control_signals
);
typedef enum reg [1:0] {
FETCH,
DECODE,
EXECUTE,
STORE
} state_type;
state_type state;
always @(posedge clk or posedge reset) begin
if (reset) begin
state <= FETCH;
control_signals <= 8'b00000000;
OpSelect <= 2'b00;//implicit alu o sa faca adunare
ALUOut <= 0; Dezactivează ieșirea ALU
end else begin
case (state)
FETCH: begin
control_signals <= 8'b00000001; //fetch
state <= DECODE;
end
DECODE: begin
control_signals <= 8'b00000010; //decode
state <= EXECUTE;
end
EXECUTE: begin
case (opcode)
4'b0001: begin
OpSelect <= 2'b00;//add
ALUOut <= 1;
end
4'b0010: begin
OpSelect <= 2'b01;//sub
ALUOut <= 1;
end
4'b0011: begin
OpSelect <= 2'b10;//or
ALUOut <= 1;
end
4'b0100: begin
OpSelect <= 2'b11;//and
ALUOut <= 1;
end
default: begin
OpSelect <= 2'b00;
ALUOut <= 0;
end
endcase
state <= STORE;
end
STORE: begin
control_signals <= 8'b00010000;//store
ALUOut <= 0;
state <= FETCH;
end
endcase
end
end
endmodule