Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- entity led_display is
- Port ( clk_d : in STD_LOGIC;
- rst_i : in STD_LOGIC;
- btn_i : in STD_LOGIC_VECTOR (3 downto 0);
- sw_i : in STD_LOGIC_VECTOR (7 downto 0);
- led7_an_o : out STD_LOGIC_VECTOR (3 downto 0) := "1111";
- led7_seg_o : out STD_LOGIC_VECTOR (7 downto 0) := "11111111");
- end led_display;
- architecture Behavioral of led_display is
- signal digit_i : STD_LOGIC_VECTOR (31 downto 0) := (others => '1');
- signal display_no : integer range 0 to 3 := 3;
- type t_digits is array (15 downto 0) of STD_LOGIC_VECTOR (6 downto 0);
- signal digits : t_digits;
- signal sw_i_dec : integer range 0 to 15;
- begin
- digits(0)(6 downto 0) <= "0000001";
- digits(1)(6 downto 0) <= "1001111";
- digits(2)(6 downto 0) <= "0010010";
- digits(3)(6 downto 0) <= "0000110";
- digits(4)(6 downto 0) <= "1001100";
- digits(5)(6 downto 0) <= "0100100";
- digits(6)(6 downto 0) <= "0100000";
- digits(7)(6 downto 0) <= "0001111";
- digits(8)(6 downto 0) <= "0000000";
- digits(9)(6 downto 0) <= "0000100";
- digits(10)(6 downto 0) <= "0000010";
- digits(11)(6 downto 0) <= "1100000";
- digits(12)(6 downto 0) <= "0110001";
- digits(13)(6 downto 0) <= "1000010";
- digits(14)(6 downto 0) <= "0110000";
- digits(15)(6 downto 0) <= "0111000";
- sw_i_dec <= to_integer(unsigned(sw_i(3 downto 0)));
- ZAD: process(btn_i)
- begin
- if(btn_i(3) = '1') then digit_i(31 downto 25) <= digits(sw_i_dec)(6 downto 0);
- end if;
- if(btn_i(2) = '1') then digit_i(23 downto 17) <= digits(sw_i_dec)(6 downto 0);
- end if;
- if(btn_i(1) = '1') then digit_i(15 downto 9) <= digits(sw_i_dec)(6 downto 0);
- end if;
- if(btn_i(0) = '1') then digit_i(7 downto 1) <= digits(sw_i_dec)(6 downto 0);
- end if;
- end process;
- digit_i(24) <= not sw_i(7);
- digit_i(16) <= not sw_i(6);
- digit_i(8) <= not sw_i(5);
- digit_i(0) <= not sw_i(4);
- DISPLAY: process(clk_d, rst_i)
- begin
- if(rst_i = '1') then
- display_no <= 3;
- led7_an_o <= (others => '1');
- led7_seg_o <= (others => '1');
- elsif(rising_edge(clk_d)) then
- if(digit_i( ((display_no + 1)*8 - 1) downto (display_no + 1)*8 - 8) /= "11111111") then -- jezeli cos jest wpisane na wyswietlacz
- led7_an_o(display_no) <= '0';
- led7_seg_o <= digit_i( ((display_no + 1)*8 - 1) downto (display_no + 1)*8 - 8);
- else led7_an_o(display_no) <= '1';
- end if;
- if(display_no /= 0) then
- display_no <= display_no - 1;
- else display_no <= 3;
- end if;
- end if;
- end process;
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement