-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_states.sv.bak
61 lines (52 loc) · 1.32 KB
/
game_states.sv.bak
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
module game_states(input logic CLK, RESET,
input logic hit, maze_ready,
input logic [31:0] keycode,
output logic title,
output logic[1:0] game_end);
enum logic [2:0] { title, in_game, new_round } State, Next_state;
logic[7:0] key;
always_ff @ (posedge CLK)
begin
if(RESET)
State <= title;
else
State <= Next_state;
end
always_comb
begin
Next_state = State;
game_end = 2'b00;
title = 1'b0;
if ((keycode[31:24] ==8'h28 )||(keycode[23:16]==8'h28)||(keycode[15:8] ==8'h28)||(keycode[7:0]==8'h28))
key = 8'h28;
Next_state = State;
unique case(State)
title:
if(key == 8'h28)
Next_state = new_round;
new_round:
if(maze_ready)
Next_state = in_game;
else
Next_state = new_round;
in_game:
if(hit)
Next_state = new_round;
else
Next_state = in_game;
endcase
case(State)
title:
begin
title = 1'b1;
end
new_round:
begin
game_end = 2'b01;
end
in_game:
begin
game_end = 2'b00;
end
endcase
end