-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrop.vhd
More file actions
54 lines (48 loc) · 1.37 KB
/
drop.vhd
File metadata and controls
54 lines (48 loc) · 1.37 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
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity drop is Port (
clk : in STD_LOGIC;
spawn : in STD_LOGIC;
dropin : in STD_LOGIC;
dropout : out STD_LOGIC);
end drop;
architecture Behavioral of drop is
signal count : integer := 0;
signal limit : integer := 80222222;
signal crtlbit: STD_LOGIC := '0';
begin
process(clk) begin
if rising_edge(clk) then
if count >= limit then
count <= 0;
dropout <= '1';
else
dropout <= '0';
count <= count + 1;
end if;
if dropin = '1' then
crtlbit <= '1';
count <= 0;
if count >= 3333333 and crtlbit = '1' then
count <= 0;
dropout <= '1';
else
dropout <= '0';
count <= count + 1;
end if;
end if;
if spawn = '1'then
count <= 0;
if limit > 13555555 then
limit <= limit - 222222; -- decrease delay each time piece is placed
else
limit <= 13333333; -- down to the minimum limit
end if;
end if;
end if;
end process;
end Behavioral;
--When receiving no inputs, a drop (due to gravity) is output every (initially) 0.8 sec
--Gravity delay decreases with each piece placed, down to a minimum 0.13 sec
--While holding down, a drop is instead output every 0.033 sec