library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity hexcount is
Port ( clk_50MHz : in STD_LOGIC;
anode : out STD_LOGIC_VECTOR (3 downto 0);
seg : out STD_LOGIC_VECTOR (6 downto 0));
end hexcount;
architecture Behavioral of hexcount is
component counter is
Port ( clk : in STD_LOGIC;
count : out STD_LOGIC_VECTOR (15 downto 0);
mpx: out STD_LOGIC_VECTOR (1 downto 0)); -- 2 bit to drive leds
end component;
component leddec is
Port ( dig : in STD_LOGIC_VECTOR (1 downto 0);
data : in STD_LOGIC_VECTOR (3 downto 0);
anode: out STD_LOGIC_VECTOR (3 downto 0);
seg : out STD_LOGIC_VECTOR (6 downto 0));
end component;
signal Sin: STD_LOGIC_VECTOR (15 downto 0);
signal Sout: STD_LOGIC_VECTOR (3 downto 0);
signal sel: STD_LOGIC_VECTOR (1 downto 0);
begin
C1: counter port map (clk=>clk_50MHz, count=>Sin, mpx=>sel);
L1: leddec port map (dig=>sel, data=>Sout, anode=>anode, seg=>seg);
with sel SELECT
Sout <= Sin(3 downto 0) after 0 ns when "00",
Sout <= Sin(7 downto 4) after 0 ns when "01",
Sout <= Sin(11 downto 8) after 0 ns when "10",
Sout <= Sin(15 downto 12) after 0 ns when "11";
end Behavioral;