Advertisement
Guest User

Untitled

a guest
Jan 10th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.66 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    18:37:34 12/07/2011
  6. -- Design Name:
  7. -- Module Name:    led01 - RTL
  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. use IEEE.STD_LOGIC_ARITH.ALL;
  23. use IEEE.STD_LOGIC_SIGNED.ALL;
  24.  
  25. ---- Uncomment the following library declaration if instantiating
  26. ---- any Xilinx primitives in this code.
  27. --library UNISIM;
  28. --use UNISIM.VComponents.all;
  29.  
  30. entity led01 is
  31.     port (  --2. ZADATAK
  32.             clk : in std_logic; -- signal takta
  33.             reset : in std_logic; -- signal reseta
  34.             ld7 : out std_logic; -- signal za upravljanje LED LD7
  35.            
  36.             --3. ZADATAK
  37.             ra : in std_logic;
  38.             rb : in std_logic;
  39.             ld6 : out std_logic
  40.             );
  41. end led01;
  42.  
  43. architecture RTL of led01 is
  44.    
  45.     --2. ZADATAK
  46.     signal brojilo: std_logic_vector(25 downto 0);
  47.    
  48.     --3. ZADATAK
  49.     signal brojilo2: std_logic_vector(25 downto 0);
  50.     signal korak: std_logic_vector(7 downto 0);
  51.     signal dogadjaj: std_logic;
  52.     signal smjer: std_logic;
  53.    
  54.     component encoder01
  55.     port (
  56.             clk               : in std_logic;
  57.          reset             : in std_logic;
  58.          
  59.          rot_a             : in std_logic;
  60.          rot_b             : in std_logic;
  61.          
  62.          rotary_event      : out std_logic;
  63.          rotary_direction  : out std_logic
  64.             );
  65.     end component;
  66.    
  67. begin
  68.    
  69.     --3. ZADATAK
  70.     enc: component encoder01 port map (clk => clk,
  71.                                                 reset => reset,
  72.                                                 rot_a => ra,
  73.                                                 rot_b => rb,
  74.                                                 rotary_event => dogadjaj,
  75.                                                 rotary_direction => smjer);
  76.    
  77.     --2. ZADATAK
  78.     process (clk) is
  79.     begin
  80.         if rising_edge(clk) then
  81.             if reset='1' then
  82.                 brojilo<=(others => '0');
  83.             else
  84.                 brojilo<=brojilo+1;
  85.             end if;
  86.         end if;
  87.     end process;
  88.    
  89.     ld7<=brojilo(25);
  90.    
  91.     --3. ZADATAK
  92.     process (clk) is
  93.     begin
  94.         if rising_edge(clk) then
  95.             if reset='1' then
  96.                 brojilo2<=(others => '0');
  97.             else
  98.                 brojilo2<=brojilo2+korak;
  99.             end if;
  100.         end if;
  101.     end process;
  102.    
  103.     process (clk) is
  104.     begin
  105.         if rising_edge(clk) then
  106.             if reset='1' then
  107.                 korak<="00000001";
  108.             else
  109.                 if dogadjaj='1' then
  110.                     if smjer='1' and korak(7)/='1' then
  111.                         korak<=korak(6 downto 0) & '0';
  112.                     elsif smjer='0' and korak(0)/='1' then
  113.                         korak<='0' & korak(7 downto 1);
  114.                     end if;
  115.                 end if;
  116.             end if;
  117.         end if;
  118.     end process;
  119.    
  120.     ld6<=brojilo2(25);
  121.  
  122. end RTL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement