1 | -- LED bewegung durch Tasten
|
2 |
|
3 | library ieee;
|
4 | use ieee.std_logic_1164.all;
|
5 | use ieee.numeric_std.all;
|
6 | use ieee.std_logic_arith.all;
|
7 |
|
8 | entity bewegung_led is
|
9 |
|
10 | port
|
11 | (
|
12 | clk50 : in std_logic;
|
13 | reset : in std_logic;
|
14 | ausgangszustand_in : in std_logic;
|
15 | led_in : in std_logic_vector(7 downto 0);
|
16 | taste_rechts_in : in std_logic;
|
17 | taste_rechts_preller_in : in std_logic;
|
18 | taste_rechts_entprellt_in : in std_logic;
|
19 | taste_links_in : in std_logic;
|
20 | taste_links_preller_in : in std_logic;
|
21 | taste_links_entprellt_in : in std_logic;
|
22 |
|
23 | led_out : out std_logic_vector(7 downto 0);
|
24 | -- led0 : out std_logic; -- low oder high
|
25 | -- led1 : out std_logic;
|
26 | -- led2 : out std_logic;
|
27 | -- led3 : out std_logic;
|
28 | -- led4 : out std_logic;
|
29 | -- led5 : out std_logic;
|
30 | -- led6 : out std_logic;
|
31 | -- led7 : out std_logic;
|
32 | taste_links_preller_out : out std_logic;
|
33 | taste_links_entprellt_out : out std_logic;
|
34 | taste_rechts_preller_out : out std_logic;
|
35 | taste_rechts_entprellt_out : out std_logic;
|
36 | ausgangszustand_out : out std_logic
|
37 | );
|
38 |
|
39 | end entity;
|
40 |
|
41 | architecture rtl of bewegung_led is
|
42 | begin
|
43 |
|
44 | process (clk50, reset)
|
45 | variable cnt : integer;
|
46 | begin
|
47 | ---------------------------------------------------------------
|
48 | -- reset
|
49 | if reset = '0' then
|
50 | cnt := 0;
|
51 | led_out <= "00000000";
|
52 | -- led0 <= '0';
|
53 | -- led1 <= '0';
|
54 | -- led2 <= '0';
|
55 | -- led3 <= '0';
|
56 | -- led4 <= '0';
|
57 | -- led5 <= '0';
|
58 | -- led6 <= '0';
|
59 | -- led7 <= '0';
|
60 | ausgangszustand_out <= '0';
|
61 | ---------------------------------------------------------------
|
62 | elsif (rising_edge(clk50)) then
|
63 |
|
64 | if ausgangszustand_in = '0' then
|
65 | led_out <= "00001000";
|
66 | cnt := 4;
|
67 | -- led0 <= '1';
|
68 | -- led1 <= '1';
|
69 | -- led2 <= '1';
|
70 | -- led3 <= '0';
|
71 | -- led4 <= '1';
|
72 | -- led5 <= '1';
|
73 | -- led6 <= '1';
|
74 | -- led7 <= '1';
|
75 | ausgangszustand_out <= '1';
|
76 | end if;
|
77 | --------------------------------------------------------------
|
78 | if taste_rechts_in = '0' then
|
79 | if taste_rechts_preller_in = '0' then
|
80 | taste_rechts_entprellt_out <= '1';
|
81 | taste_rechts_preller_out <= '1';
|
82 | end if;
|
83 | end if;
|
84 |
|
85 | if taste_rechts_in = '1' then
|
86 | taste_rechts_preller_out <= '0';
|
87 | end if;
|
88 | --------------------------------
|
89 | if taste_links_in = '0' then
|
90 | if taste_links_preller_in = '0' then
|
91 | taste_links_entprellt_out <= '1';
|
92 | taste_links_preller_out <= '1';
|
93 | end if;
|
94 | end if;
|
95 |
|
96 | if taste_links_in = '1' then
|
97 | taste_links_preller_out <= '0';
|
98 | end if;
|
99 | --------------------------------------------------------------
|
100 | if taste_rechts_entprellt_in = '1' then
|
101 | if cnt >= 0 then
|
102 | cnt := cnt -1;
|
103 | end if;
|
104 |
|
105 | -- case led_in is
|
106 | -- when "00000001" => led_out <= "11111110";
|
107 | -- when "00000010" => led_out <= "00000001";
|
108 | -- when "00000100" => led_out <= "00000010";
|
109 | -- when "00001000" => led_out <= "00000100";
|
110 | -- when "00010000" => led_out <= "00001000";
|
111 | -- when "00100000" => led_out <= "00010000";
|
112 | -- when "01000000" => led_out <= "00100000";
|
113 | -- when "10000000" => led_out <= "01000000";
|
114 | -- when "01111111" => led_out <= "10000000";
|
115 | -- end case;
|
116 | end if;
|
117 |
|
118 | if taste_links_entprellt_in = '1' then
|
119 | if cnt < 10 then
|
120 | cnt := cnt +1;
|
121 | end if;
|
122 |
|
123 |
|
124 | -- case led_in is
|
125 | -- when "00000001" => led_out <= "00000010";
|
126 | -- when "00000010" => led_out <= "00000100";
|
127 | -- when "00000100" => led_out <= "00001000";
|
128 | -- when "00001000" => led_out <= "00010000";
|
129 | -- when "00010000" => led_out <= "00100000";
|
130 | -- when "00100000" => led_out <= "01000000";
|
131 | -- when "01000000" => led_out <= "10000000";
|
132 | -- when "10000000" => led_out <= "01111111";
|
133 | -- end case;
|
134 | end if;
|
135 |
|
136 |
|
137 | case cnt is
|
138 | when 0 => led_out <= "11111110";
|
139 | when 1 => led_out <= "00000001";
|
140 | when 2 => led_out <= "00000010";
|
141 | when 3 => led_out <= "00000100";
|
142 | when 4 => led_out <= "00001000";
|
143 | when 5 => led_out <= "00010000";
|
144 | when 6 => led_out <= "00100000";
|
145 | when 7 => led_out <= "01000000";
|
146 | when 8 => led_out <= "10000000";
|
147 | when 9 => led_out <= "01111111";
|
148 | end case;
|
149 |
|
150 | ----------------------------------------------------
|
151 | if taste_rechts_preller_in <= '1' then
|
152 | taste_rechts_entprellt_out <= '0';
|
153 | end if;
|
154 |
|
155 | if taste_links_preller_in <= '1' then
|
156 | taste_links_entprellt_out <= '0';
|
157 | end if;
|
158 | ---------------------------------------------------
|
159 |
|
160 | end if; -- elsif
|
161 | end process;
|
162 |
|
163 | end rtl;
|