-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfsm.sv
74 lines (62 loc) · 1.63 KB
/
fsm.sv
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
70
71
72
73
`timescale 1 ns / 1 ps
`default_nettype none
`include "svlogger.sv"
module fsm
#(
parameter NAME = "FSMExample"
)(
input logic aclk,
input logic aresetn
);
typedef enum logic[3:0] {
IDLE = 0,
ONE = 1,
TWO = 2,
THREE = 3,
FOUR = 4,
FIVE = 5,
SIX = 6
} ex_fsm;
ex_fsm fsm;
svlogger mylog;
initial begin
mylog = new("MyFSM", `SVL_VERBOSE_DEBUG, `SVL_ROUTE_ALL);
end
always @ (posedge aclk or negedge aresetn) begin
if (aresetn == 1'b0) begin
fsm <= IDLE;
end else begin
case (fsm)
default: begin
mylog.debug("Start in IDLE state");
fsm <= ONE;
end
ONE: begin
mylog.info("Moving in ONE state");
fsm <= TWO;
end
TWO: begin
mylog.warning("Moving in TWO state");
fsm <= THREE;
end
THREE: begin
mylog.critical("Moving in THREE state");
fsm <= FOUR;
end
FOUR: begin
mylog.error("Moving in FOUR state");
fsm <= FIVE;
end
FIVE: begin
mylog.info("Moving in FIVE state");
fsm <= SIX;
end
SIX: begin
mylog.info("End of simulation");
$finish();
end
endcase
end
end
endmodule
`resetall