Advertisement
domints

7Segment iterator

Nov 18th, 2019
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.35 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.NUMERIC_STD.ALL;
  4.  
  5. entity Main is
  6.     Port(
  7.         Clk : in STD_LOGIC;
  8.         SevenSegment : out STD_LOGIC_VECTOR(7 downto 0);
  9.         SevenSegmentEnable : out STD_LOGIC_VECTOR(2 downto 0);
  10.         SevenSegmentDot : out STD_LOGIC;
  11.         LED : out STD_LOGIC
  12.     );
  13. end Main;
  14.  
  15. architecture Behavioral of Main is
  16.     --                                  268435456
  17.     constant LICZNIK_LIMIT : integer := 100000000;
  18.     signal licznik : unsigned(27 downto 0);
  19.    
  20.     signal eCnt : unsigned(2 downto 0);
  21.     signal ses : STD_LOGIC_VECTOR(0 to 7) := "00000000";
  22.     signal dot : STD_LOGIC;
  23. begin
  24. process(Clk)
  25. begin
  26.     if rising_edge(Clk) then
  27.         if licznik = LICZNIK_LIMIT then
  28.             licznik <= b"0000000000000000000000000000";
  29.             eCnt <= eCnt + 1;
  30.         else
  31.             licznik <= licznik + 1;
  32.         end if;
  33.     end if;
  34.    
  35.     case eCnt is
  36.         when "000" => ses <= "01111111"; dot <= '1';
  37.         when "001" => ses <= "10111111"; dot <= '0';
  38.         when "010" => ses <= "11011111"; dot <= '0';
  39.         when "011" => ses <= "11101111"; dot <= '0';
  40.         when "100" => ses <= "11110111"; dot <= '0';
  41.         when "101" => ses <= "11111011"; dot <= '0';
  42.         when "110" => ses <= "11111101"; dot <= '0';
  43.         when "111" => ses <= "11111110"; dot <= '0';
  44.         when others => ses <= "11111111"; dot <= '1';
  45.     end case;
  46. end process;
  47.  
  48. SevenSegment <= ses;
  49. LED <= dot;
  50. SevenSegmentEnable <= "000";
  51. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement