library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.NUMERIC_STD.ALL; entity seven_segment_display is Port ( clk : in STD_LOGIC; reset : in STD_LOGIC; pause : in STD_LOGIC; Anode_Activate : out STD_LOGIC_VECTOR (3 downto 0); LED_out : out STD_LOGIC_VECTOR (6 downto 0)); end seven_segment_display; architecture Behavioral of seven_segment_display is signal displayed_number: STD_LOGIC_VECTOR (15 downto 0); signal LED_BCD: STD_LOGIC_VECTOR (3 downto 0); signal refresh_counter: integer range 0 to 63 := 0; signal LED_activating_counter: integer range 0 to 3 := 0; signal cntlo : integer range 0 to 5 := 1; -- start with display 80! signal cnthi : integer range 0 to 9 := 0; signal one_second_counter: integer range 0 to 999 := 0; begin process(LED_BCD) begin case LED_BCD is when "0000" => LED_out <= "0000001"; -- "0" when "0001" => LED_out <= "1001111"; -- "1" when "0010" => LED_out <= "0010010"; -- "2" when "0011" => LED_out <= "0000110"; -- "3" when "0100" => LED_out <= "1001100"; -- "4" when "0101" => LED_out <= "0100100"; -- "5" when "0110" => LED_out <= "0100000"; -- "6" when "0111" => LED_out <= "0001111"; -- "7" when "1000" => LED_out <= "0000000"; -- "8" when "1001" => LED_out <= "0000100"; -- "9" when "1010" => LED_out <= "0000010"; -- a when "1011" => LED_out <= "1100000"; -- b when "1100" => LED_out <= "0110001"; -- C when "1101" => LED_out <= "1000010"; -- d when "1110" => LED_out <= "0110000"; -- E when others => LED_out <= "0111000"; -- F end case; end process; process(clk) begin if(rising_edge(clk)) then if refresh_counter<63 then refresh_counter <= refresh_counter + 1; else refresh_counter <= 0; if LED_activating_counter<3 then LED_activating_counter <= LED_activating_counter+1; else LED_activating_counter <= 0; end if; end if; end if; end process; process(LED_activating_counter, displayed_number) begin case LED_activating_counter is when 0 => Anode_Activate <= "0111"; LED_BCD <= displayed_number(15 downto 12); when 1 => Anode_Activate <= "1011"; LED_BCD <= displayed_number(11 downto 8); when 2 => Anode_Activate <= "1101"; LED_BCD <= displayed_number(7 downto 4); when 3 => Anode_Activate <= "1110"; LED_BCD <= displayed_number(3 downto 0); -- when others => Anode_Activate <= "0111"; -- due to use of a proper counter: there is no "others" anymore --> get rid of the latches! end case; end process; process begin -- the prescaler and counter wait until rising_edge(clk); if one_second_counter < 999 then one_second_counter <= one_second_counter + 1; else one_second_counter <= 0; if cntlo<5 then cntlo <= cntlo+1; else cntlo <= 0; if cnthi<9 then cnthi <= cnthi+1; else cnthi <= 0; cntlo <= 0; end if; end if; end if; end process; displayed_number(15 downto 8) <= (others => '0'); displayed_number(7 downto 4) <= std_logic_vector(to_unsigned(cnthi, 4)); displayed_number(3 downto 0) <= x"7" when cntlo = 0 else x"8" when cntlo = 1 else x"7" when cntlo = 2 else x"0" when cntlo = 3 else x"1" when cntlo = 4 else x"0"; end Behavioral;