martaczaska

Untitled

Apr 1st, 2019
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.STD_LOGIC_ARITH.ALL;
  4. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  5.  
  6. ---- Uncomment the following library declaration if instantiating
  7. ---- any Xilinx primitives in this code.
  8. --library UNISIM;
  9. --use UNISIM.VComponents.all;
  10.  
  11. entity display is
  12. Port ( clk_i : in STD_LOGIC;
  13. rst_i : in STD_LOGIC;
  14. digit_i : in STD_LOGIC_VECTOR (31 downto 0);
  15. led7_an_o : out STD_LOGIC_VECTOR (3 downto 0);
  16. led7_seg_o : out STD_LOGIC_VECTOR (7 downto 0));
  17. end display;
  18.  
  19. architecture Behavioral of display is
  20. signal active_led7_an: std_logic_vector (3 downto 0) := "1111";
  21. --signal active_led7_seg: std_logic_vector (3 downto 0); --abcdefg dp
  22. begin
  23. process (clk_i, rst_i, digit_i, active_led7_an)
  24. begin
  25. if (rst_i='1') then
  26. led7_an_o<="0000";
  27. led7_seg_o<="00000000";
  28. elsif (rising_edge(clk_i)) then
  29. case active_led7_an is
  30. when "0000" => active_led7_an <= "0111";
  31. when "0111" => active_led7_an <= "1011";
  32. when "1011" => active_led7_an <= "1101";
  33. when "1101" => active_led7_an <= "1110";
  34. when "1110" => active_led7_an <= "0111";
  35. when others => active_led7_an <= "0111";
  36. end case;
  37.  
  38. case active_led7_an is
  39. when "0111" => led7_seg_o <= digit_i (31 downto 24);
  40. when "1011" => led7_seg_o <= digit_i (23 downto 16);
  41. when "1101" => led7_seg_o <= digit_i (15 downto 8);
  42. when "1110" => led7_seg_o <= digit_i (7 downto 0);
  43. when others => led7_seg_o <= "00000000";
  44. end case;
  45. end if;
  46. led7_an_o <= active_led7_an;
  47. end process;
  48.  
  49. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment