OpenCores
URL https://opencores.org/ocsvn/signed_unsigned_multiplier_and_divider/signed_unsigned_multiplier_and_divider/trunk

Subversion Repositories signed_unsigned_multiplier_and_divider

[/] [signed_unsigned_multiplier_and_divider/] [trunk/] [debouncer.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 zpekic
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    22:58:22 10/22/2016 
6
-- Design Name: 
7
-- Module Name:    debouncer - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
 
23
-- Uncomment the following library declaration if using
24
-- arithmetic functions with Signed or Unsigned values
25
--use IEEE.NUMERIC_STD.ALL;
26
 
27
-- Uncomment the following library declaration if instantiating
28
-- any Xilinx primitives in this code.
29
--library UNISIM;
30
--use UNISIM.VComponents.all;
31
 
32
entity debouncer is
33
    Port ( clock : in  STD_LOGIC;
34
           reset : in  STD_LOGIC;
35
           signal_in : in  STD_LOGIC;
36
           signal_out : out  STD_LOGIC);
37
end debouncer;
38
 
39
architecture Behavioral of debouncer is
40
 
41
signal debounced: std_logic;
42
signal shifter: std_logic_vector(7 downto 0);
43
signal all0, all1: std_logic;
44
 
45
begin
46
 
47
all0 <= '1' when shifter = "00000000" else '0';
48
all1 <= '1' when shifter = "11111111" else '0';
49
 
50
-- all 1 or all 0 in shift register surely mean 1 or 0, but anything else keeps last state
51
--debounced <= (not all1 and not all0 and debounced) or 
52
--                               (not all1 and all0 and '0') or 
53
--                               (all1 and not all0 and '1') or 
54
--                               (all1 and all1 and debounced);
55
signal_out <= debounced;
56
 
57
debounce: process(clock, debounced)
58
begin
59
    if (rising_edge(clock)) then
60
        if (all1 = '1') then
61
            debounced <= '1';
62
        else
63
            if (all0 = '1') then
64
                debounced <= '0';
65
            else
66
                debounced <= debounced;
67
            end if;
68
        end if;
69
    end if;
70
end process;
71
 
72
sample: process(clock, reset, signal_in)
73
begin
74
        if (reset = '1') then
75
                shifter <= "11111111";
76
        else
77
                if (clock'event and clock = '1') then
78
                        shifter <= shifter(6 downto 0) & signal_in;
79
                end if;
80
        end if;
81
end process;
82
 
83
end;
84
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.