-
Notifications
You must be signed in to change notification settings - Fork 0
/
collisionASTEROIDandGROUND.v
68 lines (45 loc) · 1.07 KB
/
collisionASTEROIDandGROUND.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
57
58
59
60
61
62
63
64
65
66
67
68
module collisionASTEROIDandGROUND(
start,
clock,
reset,
asteroid_move_done,
gameover);
input start;
input clock;
input reset;
input asteroid_move_done;
output reg gameover;
reg [3:0] current_state, next_state;
localparam S_wait= 3'd0, S_check= 3'd1;
always @(posedge clock) begin
case(current_state)
S_wait:
begin
if (start)
begin
next_state=S_check;
end
else
begin
next_state=S_wait;
end
end
S_check:
begin
gameover=asteroid_move_done;
//state only checks if the rocket and the asteroid collides
begin
next_state=S_wait; //should it go to splay state or swait state?
end
end
endcase
end
//datapath control signals
always@(posedge clock)
begin
if(reset)
current_state <= S_wait;
else
current_state <= next_state;
end // state_FFS
endmodule