forked from keanneeee/EE2026
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSoccer Field
More file actions
73 lines (57 loc) · 3.07 KB
/
Soccer Field
File metadata and controls
73 lines (57 loc) · 3.07 KB
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
module soccer_field(input basys_clock, input reset, input [12:0] pixel_index,
output reg [15:0] oled_data);
//coordinates
wire [6:0] x;
wire [5:0] y;
assign x = pixel_index % 96;
assign y = pixel_index / 96;
//circle formula
wire [12:0] circle_formula;
assign circle_formula = (x - 48)*(x - 48) + (y - 32)*(y - 32);
wire [12:0] circle_formula_semi_left;
assign circle_formula_semi_left = (x - 9)*(x - 9) + (y - 32)*(y - 32);
wire [12:0] circle_formula_semi_right;
assign circle_formula_semi_right = (x - 86)*(x - 86) + (y - 32)*(y - 32);
always @ (posedge basys_clock)begin
if (reset) oled_data <= 16'b00000_000000_00000;
else begin
//field border lines
if ((x == 0 || x == 95) && (y >= 0 && y <= 63) ||
(y == 0 || y == 63) && (x >= 0 && x <= 95))
oled_data <= 16'b11111_111111_11111;
else if ((y == 63) && (x >= 0 && x <= 95))
oled_data <= 16'b11111_111111_11111;
//goal post line small
else if (((x == 0 || x == 5) && (y >= 20 && y <= 44)) || //left vertical
((y == 20 || y == 44) && (x >= 0 && x <= 5)) || //left horizontal
((x == 90 || x == 95) && (y >= 20 && y <= 44)) || //right vertical
((y == 20 || y == 44) && (x >= 90 && x <= 95))) //right horizontal
oled_data <= 16'b11111_111111_11111;
//goal post line big
else if (((x == 0 || x == 15) && (y >= 10 && y <= 54)) || //left vertical
((y == 10 || y == 54) && (x >= 0 && x <= 15)) || //left horizontal
((x == 80 || x == 95) && (y >= 10 && y <= 54)) || //right vertical
((y == 10 || y == 54) && (x >= 80 && x <= 95))) //right horizontal
oled_data <= 16'b11111_111111_11111;
//center line
else if (x == 48 && y >= 0 && y <= 63)
oled_data <= 16'b11111_111111_11111;
//center circle
else if (circle_formula <= 196 && circle_formula >= 169)
oled_data <= 16'b11111_111111_11111;
//semi circles
else if ((circle_formula_semi_left <= 196 && circle_formula_semi_left >= 169) && (x >= 15)) //left semi circle
oled_data <= 16'b11111_111111_11111;
else if ((circle_formula_semi_right <= 196 && circle_formula_semi_right >= 169) && (x <= 80)) //right semi circle
oled_data <= 16'b11111_111111_11111;
//soccer field green
else
oled_data <= 16'b00000_111111_00000;
// 16'b01111_111111_01111; //lighter green colour
end
//test for player on top of soccer field(outside the whole soccer field code block)
// if (circle_formula <= 49) begin
// oled_data <= 16'b11111_011111_00111;
// end
end //always @ end
endmodule