-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkicker.vhd
132 lines (96 loc) · 3.13 KB
/
kicker.vhd
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 09/14/2021 03:07:51 PM
-- Design Name:
-- Module Name: Object1 - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity kicker is
Port (
clk25: in std_logic;
HC: in integer;
VC: in integer;
resetn:in std_logic;
FC: in integer;
strobe: in std_logic;
btnU: in std_logic;
btnD: in std_logic;
kkCol: out std_logic_vector(11 downto 0);
posout: out integer;
colswitcher: in std_logic;
Exist: out std_logic
);
end kicker;
architecture Behavioral of kicker is
constant Black: std_logic_vector (11 downto 0) := X"000";
constant Red: std_logic_vector (11 downto 0) := X"F00";
constant yellow: std_logic_vector (11 downto 0) := X"FF0";
constant white: std_logic_vector (11 downto 0) := X"FFF";
--signalPosition
constant StartH: integer :=600;
constant StartV: integer := 0;
constant maxrad : integer := 10;
begin
process(clk25, resetn)
variable rad: integer range 0 to maxrad;
variable newPos: integer range 50 to 430;
begin
if resetn ='0' then
newPos := 230;
elsif rising_edge(clk25) then
if strobe ='1' then
if FC mod 1 = 0 then
if btnU ='1' and newPos > 90 then
newPos :=newPos-3 ;
elsif newPos < 90 then
newPos := 93;
end if;
if btnD = '1' and newPos <390 then
newPos :=newPos+3 ;
elsif newPos >390 then
newPos := 387;
end if;
end if;
end if;
-- if ((HC - (StartH+90))**2 + (VC-StartV- newPos)**2) <= (maxrad/3)**2 then
-- Exist <= '1';
-- kkCol<= white;
-- end if;
if ((HC - StartH)**2 + (VC-StartV- newPos)**2) <= (maxrad+3)**2 then
Exist <= '1';
kkCol<= Black;
elsif (((HC -StartH)*2)**2 + ((VC-newPos)**2) <= (maxrad*3)**2) then
Exist <= '1';
if colswitcher='1' then
kkCol<= yellow;
else
kkCol<= red;
end if;
else
Exist <= '0';
end if;
posout <= newPos;
end if;
end process;
end Behavioral;