Hallo Harry.
Dies ist ein Ausschnitt aus einem Projekt (Digitaluhr) mit
gemultiplexter Ausgabe von Stunden und Minuten auf der 4-stelligen
7-Segment-Anzeige.
Ich hoffe, das hilft Dir weiter.
-- 7-Segment-Anzeige im Multiplex-Betrieb
-- anz7seg.vhdl
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
library UNISIM;
use UNISIM.VComponents.all;
entity anz7seg is
port(
clock : in std_logic;
reset : in std_logic;
data_in : in std_logic_vector(15 downto 0);
led : out std_logic_vector(6 downto 0);
seg : out std_logic_vector(3 downto 0)
);
end anz7seg;
architecture Behavioral of anz7seg is
signal count : std_logic_vector(15 downto 0);
signal hex : std_logic_vector(3 downto 0);
begin
-- Counter provides delay for 7-segment display
process (clock, reset, count)
begin
if (reset = '1') then
count <= (others => '1');
elsif rising_edge(clock) then
count <= count + 1;
end if;
end process;
-- Basic MUX for the 7-segment display
process (clock, reset, hex, data_in, count)
begin
if (reset = '1') then
led <= (others => '1');
seg(0) <= '1';
seg(1) <= '1';
seg(2) <= '1';
seg(3) <= '1';
elsif rising_edge(clock) then
case count(15) is
when '0' =>
if (count(14) = '0') then
hex <= data_in(3 downto 0);
seg(0) <= '0';
seg(1) <= '1';
seg(2) <= '1';
seg(3) <= '1';
elsif (count(14) = '1') then
hex <= data_in(7 downto 4);
seg(0) <= '1';
seg(1) <= '0';
seg(2) <= '1';
seg(3) <= '1';
end if;
when '1' =>
if (count(14) = '0') then
hex <= data_in(11 downto 8);
seg(0) <= '1';
seg(1) <= '1';
seg(2) <= '0';
seg(3) <= '1';
elsif (count(14) = '1') then
hex <= data_in(15 downto 12);
seg(0) <= '1';
seg(1) <= '1';
seg(2) <= '1';
seg(3) <= '0';
end if;
when others =>
null;
end case;
end if;
case hex is
when "0000" =>
led <= "1000000";
when "0001" =>
led <= "1111001";
when "0010" =>
led <= "0100100";
when "0011" =>
led <= "0110000";
when "0100" =>
led <= "0011001";
when "0101" =>
led <= "0010010";
when "0110" =>
led <= "0000010";
when "0111" =>
led <= "1111000";
when "1000" =>
led <= "0000000";
when "1001" =>
led <= "0010000";
when others =>
led <= "1111111";
end case;
end process;
end Behavioral;