-
Notifications
You must be signed in to change notification settings - Fork 6
/
gameDelegate.v
43 lines (37 loc) · 862 Bytes
/
gameDelegate.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
module GameDelegate(
input wire clk,
input wire rst,
input wire jump,
input wire restart,
input wire collided,
output reg [1:0] state); // what if we use wire ??
localparam InitState = 2'b00; // init
localparam InGameState = 2'b10; // wait for collidie
localparam DeadState = 2'b01; // after collide
always @(posedge clk) begin
case (state)
InitState: begin
if (jump) /// input
state <= InGameState;
else
state <= state;
end
InGameState: begin
if (collided)
state <= DeadState;
else if (rst)
state <= InitState;
else
state <= InGameState;
end
DeadState: begin
if (restart || rst)
state <= InitState;
else
state <= DeadState;
end
default:
state <= InitState;
endcase
end
endmodule // gameDelegate