-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTorwand.vhd
127 lines (87 loc) · 2.96 KB
/
Torwand.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
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 09/17/2021 10:55:59 AM
-- Design Name:
-- Module Name: Torwand - 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;
USE ieee.numeric_std.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 Torwand is
Port (
clk25: in std_logic;
HC: in integer;
VC: in integer;
FC: in integer;
strobe: in std_logic;
resetn:in std_logic;
mouseypos: in std_logic_vector(9 downto 0);
TorwandCol: out std_logic_vector(11 downto 0);
colswitcher: in std_logic;
poswitch: in std_logic;
Exist: out std_logic
);
end Torwand;
architecture Behavioral of Torwand is
-- constant StartHo: integer := 280;
-- constant StartHu: integer := 280;
-- constant StartVu: integer := 0;
constant torwPos: integer := 75;
constant maxrad : integer := 10;
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";
begin
process(clk25, poswitch)
variable torypos : integer range 50 to 430;
begin
if poswitch ='1' then
torypos := 230;
elsif rising_edge(clk25) then
-- outside area
if to_integer(unsigned(mouseypos)) > 50 and to_integer(unsigned(mouseypos)) < 430 then
torypos := to_integer(unsigned(mouseypos));
elsif to_integer(unsigned(mouseypos)) > 430 then
torypos := 430;
elsif to_integer(unsigned(mouseypos)) <50 then
torypos := 50;
end if;
-- if vc > 50 and Vc < 430 then
-- Normal area
if ((HC - torwPos)**2 + ((VC - torypos)**2 ) <= (maxrad+3)**2 ) then
Exist <= '1';
TorwandCol <= Black;
elsif (((HC - torwPos)*2)**2 + ((VC -torypos)**2) <= (maxrad*3)**2) then
Exist <= '1';
if colswitcher='1' then
TorwandCol <= red;
else
TorwandCol <= yellow;
end if;
else
Exist <= '0';
end if;
-- end if;
end if;
end process;
end Behavioral;