Advertisement
Vedro

duupaduppa

Mar 25th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.37 KB | None | 0 0
  1. entity led_display is
  2.     Port ( clk_d : in  STD_LOGIC;
  3.            rst_i : in  STD_LOGIC;
  4.   btn_i : in  STD_LOGIC_VECTOR (3 downto 0);
  5.   sw_i  : in  STD_LOGIC_VECTOR (7 downto 0);
  6.            led7_an_o : out  STD_LOGIC_VECTOR (3 downto 0) := "1111";
  7.            led7_seg_o : out  STD_LOGIC_VECTOR (7 downto 0) := "11111111");
  8. end led_display;
  9.  
  10. architecture Behavioral of led_display is
  11. signal digit_i : STD_LOGIC_VECTOR (31 downto 0) := (others => '1');
  12. signal display_no : integer range 0 to 3 := 3;
  13. type t_digits is array (15 downto 0) of STD_LOGIC_VECTOR (6 downto 0);
  14. signal digits : t_digits;
  15. signal sw_i_dec : integer range 0 to 15;
  16.  
  17. begin
  18. digits(0)(6 downto 0) <= "0000001";
  19. digits(1)(6 downto 0) <= "1001111";
  20. digits(2)(6 downto 0) <= "0010010";
  21. digits(3)(6 downto 0) <= "0000110";
  22. digits(4)(6 downto 0) <= "1001100";
  23. digits(5)(6 downto 0) <= "0100100";
  24. digits(6)(6 downto 0) <= "0100000";
  25. digits(7)(6 downto 0) <= "0001111";
  26. digits(8)(6 downto 0) <= "0000000";
  27. digits(9)(6 downto 0) <= "0000100";
  28. digits(10)(6 downto 0) <= "0000010";
  29. digits(11)(6 downto 0) <= "1100000";
  30. digits(12)(6 downto 0) <= "0110001";
  31. digits(13)(6 downto 0) <= "1000010";
  32. digits(14)(6 downto 0) <= "0110000";
  33. digits(15)(6 downto 0) <= "0111000";
  34.  
  35. sw_i_dec <= to_integer(unsigned(sw_i(3 downto 0)));
  36.  
  37. ZAD: process(btn_i)
  38. begin
  39. if(btn_i(3) = '1') then digit_i(31 downto 25) <= digits(sw_i_dec)(6 downto 0);
  40. end if;
  41. if(btn_i(2) = '1') then digit_i(23 downto 17) <= digits(sw_i_dec)(6 downto 0);
  42. end if;
  43. if(btn_i(1) = '1') then digit_i(15 downto 9) <= digits(sw_i_dec)(6 downto 0);
  44. end if;
  45. if(btn_i(0) = '1') then digit_i(7 downto 1) <= digits(sw_i_dec)(6 downto 0);
  46. end if;
  47.  
  48. end process;
  49.  
  50. digit_i(24) <= not sw_i(7);
  51. digit_i(16) <= not sw_i(6);
  52. digit_i(8) <= not sw_i(5);
  53. digit_i(0) <= not sw_i(4);
  54.  
  55. DISPLAY: process(clk_d, rst_i)
  56. begin
  57. if(rst_i = '1') then
  58. display_no <= 3;
  59. led7_an_o <= (others => '1');
  60. led7_seg_o <= (others => '1');
  61. elsif(rising_edge(clk_d)) then
  62. if(digit_i( ((display_no + 1)*8 - 1) downto (display_no + 1)*8 - 8) /= "11111111") then -- jezeli cos jest wpisane na wyswietlacz
  63. led7_an_o(display_no) <= '0';
  64. led7_seg_o <= digit_i( ((display_no + 1)*8 - 1) downto (display_no + 1)*8 - 8);
  65. else led7_an_o(display_no) <= '1';
  66. end if;
  67. if(display_no /= 0) then
  68. display_no <= display_no - 1;
  69. else display_no <= 3;
  70. end if;
  71. end if;
  72. end process;
  73.  
  74. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement