Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 03/02/2018 02:54:41 PM
  6. -- Design Name:
  7. -- Module Name: debounce - 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.  
  21.  
  22. library IEEE;
  23. use IEEE.STD_LOGIC_1164.ALL;
  24.  
  25. -- Uncomment the following library declaration if using
  26. -- arithmetic functions with Signed or Unsigned values
  27. --use IEEE.NUMERIC_STD.ALL;
  28.  
  29. -- Uncomment the following library declaration if instantiating
  30. -- any Xilinx leaf cells in this code.
  31. --library UNISIM;
  32. --use UNISIM.VComponents.all;
  33.  
  34.  
  35. entity debounce is
  36. Port ( Clk : in STD_LOGIC;
  37. Rst : in STD_LOGIC;
  38. D_in : in STD_LOGIC;
  39. Q_out : out STD_LOGIC);
  40. end debounce;
  41. architecture Behavioral of debounce is
  42. signal Q1, Q2, Q3 : std_logic;
  43. begin
  44.  
  45. -- Provides a one-shot pulse from a non-clock input, with reset
  46. --**Insert the following between the 'architecture' and
  47. ---'begin' keywords**
  48.  
  49.  
  50. --**Insert the following after the 'begin' keyword**
  51. process(clk)
  52. begin
  53. if (Clk'event and Clk = '1') then
  54. if (rst = '1') then
  55. Q1 <= '0';
  56. Q2 <= '0';
  57. Q3 <= '0';
  58. else
  59. Q1 <= D_IN;
  60. Q2 <= Q1;
  61. Q3 <= Q2;
  62. end if;
  63. end if;
  64. end process;
  65.  
  66. Q_OUT <= Q1 and Q2 and (not Q3);
  67.  
  68.  
  69.  
  70.  
  71.  
  72. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement