Advertisement
krowka

kostka1

Jan 23rd, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.28 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.all;
  3.  
  4. entity kostka is
  5.     port(
  6.     clk:        in std_logic;
  7.     button:     in std_logic;
  8.     display:    out std_logic_vector(6 downto 0)
  9.     );
  10. end kostka;
  11.  
  12. architecture behave of kostka is
  13.     signal display_digit: natural range 0 to 7;
  14.     signal digit: natural range 0 to 7;
  15.     signal interval: natural range 0 to 25000000 := 0;
  16. begin
  17.     process(clk)
  18.     begin
  19.         if rising_edge(clk) then
  20.             if(digit < 6) then
  21.                 digit <= digit + 1;
  22.             else
  23.                 digit <= 1;
  24.             end if;
  25.            
  26.             if(interval > 0) then
  27.                 interval <= interval - 1;
  28.             end if;
  29.            
  30.             if(button = '0' and interval = 0) then
  31.                 display_digit <= digit;
  32.                 interval <= 25000000;
  33.             end if;
  34.            
  35.             --if(button = '0') then
  36.                 --if(interval = 0) then
  37.                     --display_digit <= digit;
  38.                     --interval <= 25000000;
  39.                 --end if;
  40.             --end if;
  41.         end if;
  42.     end process;
  43.    
  44.     process(display_digit)
  45.     begin
  46.         case display_digit is
  47.         --when 0 => display <= "0000000";
  48.         when 1 => display <= "1001111"; -- "1"
  49.         when 2 => display <= "0010010"; -- "2"
  50.         when 3 => display <= "0000110"; -- "3"
  51.         when 4 => display <= "1001100"; -- "4"
  52.         when 5 => display <= "0100100"; -- "5"
  53.         when 6 => display <= "0100000"; -- "6"
  54.         when others => display <= "0000000";
  55.         end case;
  56.     end process;
  57. end behave;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement