Commit d74ec46b authored by Synthron's avatar Synthron 💬
Browse files

update code

parent b39cd37f
......@@ -12,7 +12,7 @@ end entity Debounce_Switch;
architecture RTL of Debounce_Switch is
-- Set for 250,000 clock ticks of 25 MHz clock (10 ms)
-- 10ms Delay bei 25MHz (250.000)
constant c_DEBOUNCE_LIMIT : integer := 250000;
signal r_Count : integer range 0 to c_DEBOUNCE_LIMIT := 0;
......@@ -23,18 +23,16 @@ begin
p_Debounce : process (i_clk) is
begin
if rising_edge(i_clk) then
-- Switch input is different than internal switch value, so an input is
-- changing. Increase counter until it is stable for c_DEBOUNCE_LIMIT.
-- nach State-Change suchen
if (i_Switch /= r_State and r_Count < c_DEBOUNCE_LIMIT) then
r_Count <= r_Count + 1;
-- End of counter reached, switch is stable, register it, reset counter
-- Zeit verstrichen, Button stabil
elsif r_Count = c_DEBOUNCE_LIMIT then
r_State <= i_Switch;
r_Count <= 0;
-- Switches are the same state, reset the counter
-- Reset
else
r_Count <= 0;
......@@ -42,7 +40,7 @@ begin
end if;
end process p_Debounce;
-- Assign internal register to output (debounced!)
-- Weiterreichen zum Output
o_Switch <= r_State;
end architecture RTL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment