Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 03.12.2017 14:20:21
  6. -- Design Name:
  7. -- Module Name: top - 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_unsigned.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 top is
  36. Port ( clk : in STD_LOGIC;
  37. btnU : in STD_LOGIC;
  38. btnD : in STD_LOGIC;
  39. an : out STD_LOGIC_VECTOR (3 downto 0);
  40. led : out STD_LOGIC_VECTOR (2 downto 0);
  41. seg : out STD_LOGIC_VECTOR (6 downto 0));
  42. end top;
  43.  
  44. architecture Behavioral of top is
  45.  
  46. component up_down_select is
  47. Port ( clk : in STD_LOGIC;
  48. up : in STD_LOGIC;
  49. down : in STD_LOGIC;
  50. clk_out : out STD_LOGIC:='0';
  51. stan: out STD_LOGIC_VECTOR (1 downto 0);
  52. dir : out STD_LOGIC:='0');
  53. end component;
  54.  
  55. component pwm2 is
  56. Port ( clk : in STD_LOGIC;
  57. wyp : in STD_LOGIC_VECTOR (3 downto 0);
  58. wyj : out std_logic);
  59. end component;
  60.  
  61. component seg7_disp
  62. Port ( clk : in STD_LOGIC;
  63. data : in STD_LOGIC_VECTOR (15 downto 0);
  64. an : out STD_LOGIC_VECTOR (3 downto 0);
  65. seg : out STD_LOGIC_VECTOR (6 downto 0));
  66. end component;
  67.  
  68. component dzielnikc
  69. Generic (Fwy:integer:=10);
  70. Port ( clk : in STD_LOGIC;
  71. clk_div : out STD_LOGIC);
  72. end component;
  73.  
  74.  
  75. component licznik_rew
  76. Port ( clk : in STD_LOGIC;
  77. kier : in STD_LOGIC;
  78. wyj : out STD_LOGIC_VECTOR (3 downto 0));
  79. end component;
  80.  
  81. component debouncer
  82. port (
  83. pb, clock_100hz : in std_logic;
  84. pb_debounced : out std_logic
  85. );
  86. end component;
  87.  
  88. signal clk_100Hz:STD_LOGIC:='0';
  89. signal clk_1000Hz:STD_LOGIC:='0';
  90. signal clk_licz:STD_LOGIC:='0';
  91.  
  92. signal pb_Up:STD_LOGIC:='0';
  93. signal pb_Down:STD_LOGIC:='0';
  94. signal kier:STD_LOGIC:='0';
  95. signal licz:STD_LOGIC_VECTOR (3 downto 0):=(others=>'0');
  96. signal data:STD_LOGIC_VECTOR (15 downto 0):=(others=>'0');
  97.  
  98.  
  99.  
  100.  
  101.  
  102. begin
  103.  
  104. data<="0000000000010000" when licz="1010" else "000000000000"&licz;
  105.  
  106. DZ1:dzielnikc
  107. generic map (Fwy=>100)
  108. port map(clk=>clk,clk_div=>clk_100Hz);
  109.  
  110. DZ2:dzielnikc
  111. generic map (Fwy=>1000)
  112. port map(clk=>clk,clk_div=>clk_1000Hz);
  113.  
  114. DB1:debouncer
  115. port map(pb=>btnU,pb_debounced=>pb_Up,clock_100hz=>clk_100Hz);
  116. DB2:debouncer
  117. port map(pb=>btnD,pb_debounced=>pb_Down,clock_100hz=>clk_100Hz);
  118.  
  119. UDS1:up_down_select
  120. Port map( clk =>clk_100Hz,up=>pb_Up,down=>pb_Down,clk_out=>clk_licz,stan=>led(1 downto 0), dir=>kier);
  121.  
  122. L1:licznik_rew
  123. port map(clk=>clk_licz,kier=>kier,wyj=>licz);
  124.  
  125. Disp1:seg7_disp
  126. port map(clk=>clk,data=>data,an=>an,seg=>seg);
  127. PWM1:pwm2
  128. port map ( clk=>clk_1000Hz,wyp=>licz,wyj=>led(2));
  129.  
  130. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement