Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 03/16/2019 06:27:39 PM
  6. -- Design Name:
  7. -- Module Name: mpg - 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. use IEEE.STD_LOGIC_SIGNED.ALL;
  25.  
  26. -- Uncomment the following library declaration if using
  27. -- arithmetic functions with Signed or Unsigned values
  28. --use IEEE.NUMERIC_STD.ALL;
  29.  
  30. -- Uncomment the following library declaration if instantiating
  31. -- any Xilinx leaf cells in this code.
  32. --library UNISIM;
  33. --use UNISIM.VComponents.all;
  34.  
  35. entity mpg is
  36. Port( CLK : in std_logic;
  37. BTN : in std_logic;
  38. EN : out std_logic);
  39. end mpg;
  40.  
  41. architecture Behavioral of mpg is
  42.  
  43. signal q1,q2,q3 : std_logic := '0';
  44. signal count : std_logic_vector (15 downto 0) := x"0000";
  45.  
  46. begin
  47.  
  48. en <= Q2 AND (not Q3);
  49.  
  50. process (clk)
  51. begin
  52. if rising_edge(clk) then
  53. count <= count + 1;
  54. end if;
  55. end process;
  56.  
  57.  
  58. process (count, btn, clk)
  59. begin
  60. if rising_edge(clk) then
  61. if count = x"FFFF" then
  62. Q1 <= btn;
  63. end if;
  64. end if;
  65. end process;
  66.  
  67. process (clk)
  68. begin
  69. if rising_edge(clk) then
  70. Q2 <= Q1;
  71. Q3 <= Q2;
  72. end if;
  73. end process;
  74.  
  75. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement