plugins: plugin loader redesign
[geany-mirror.git] / tests / ctags / state_machine.v
blob0fb930f041f4ac288cab9eb68e07f1ecc5516d7e
1 // Taken from http://www.europa.com/~celiac/fsm_samp.html
3 // These are the symbolic names for states
4 parameter [1:0] //synopsys enum state_info
5 S0 = 2'h0,
6 S1 = 2'h1,
7 S2 = 2'h2,
8 S3 = 2'h3;
10 // These are the current state and next state variables
11 reg [1:0] /* synopsys enum state_info */ state;
12 reg [1:0] /* synopsys enum state_info */ next_state;
15 // synopsys state_vector state
17 always @ (state or y or x)
18 begin
19 next_state = state;
20 case (state) // synopsys full_case parallel_case
21 S0: begin
22 if (x) begin
23 next_state = S1;
24 end
25 else begin
27 next_state = S2;
28 end
29 end
30 S1: begin
31 if (y) begin
32 next_state = S2;
33 end
34 else begin
35 next_state = S0;
36 end
37 end
38 S2: begin
39 if (x & y) begin
40 next_state = S3;
41 end
42 else begin
43 next_state = S0;
44 end
45 end
46 S3: begin
47 next_state = S0;
48 end
49 endcase
50 end
53 always @ (posedge clk or posedge reset)
54 begin
55 if (reset) begin
56 state <= S0;
57 end
58 else begin
59 state <= next_state;
60 end
61 end