-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbullet.v
78 lines (66 loc) · 1.56 KB
/
bullet.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
69
70
71
72
73
74
75
76
77
78
module bullet(
input clk,
input resetn,
input fire,
input [7:0] ss_x,
input [7:0] ast1_x,
input [7:0] ast2_x,
input [7:0] ast3_x,
input [7:0] ast4_x,
input [7:0] ast5_x,
input [7:0] ast6_x,
input [7:0] ast7_x,
input [7:0] ast8_x,
output reg [3:0] which);
wire hit1, hit2, hit3, hit4, hit5, hit6, hit7, hit8;
assign hit1 = (ast1_x < ss_x + 2'd3) & (ast1_x >= ss_x - 2'd3);
assign hit2 = (ast2_x < ss_x + 2'd3) & (ast2_x >= ss_x - 2'd3);
assign hit3 = (ast3_x < ss_x + 2'd3) & (ast3_x >= ss_x - 2'd3);
assign hit4 = (ast4_x < ss_x + 2'd3) & (ast4_x >= ss_x - 2'd3);
assign hit5 = (ast5_x < ss_x + 2'd3) & (ast5_x >= ss_x - 2'd3);
assign hit6 = (ast6_x < ss_x + 2'd3) & (ast6_x >= ss_x - 2'd3);
assign hit7 = (ast7_x < ss_x + 2'd3) & (ast7_x >= ss_x - 2'd3);
assign hit8 = (ast8_x < ss_x + 2'd3) & (ast8_x >= ss_x - 2'd3);
always@(posedge clk)
begin: bullet_table
if(!resetn | !fire)
begin
which <= 4'd0;
end
else if (fire)
begin
if (hit1)
begin
which <= 4'd1;
end
else if (hit2)
begin
which <= 4'd2;
end
else if (hit3)
begin
which <= 4'd3;
end
else if (hit4)
begin
which <= 4'd4;
end
else if (hit5)
begin
which <= 4'd5;
end
else if (hit6)
begin
which <= 4'd6;
end
else if (hit7)
begin
which <= 4'd7;
end
else if (hit8)
begin
which <= 4'd8;
end
end
end // Bullet table
endmodule