entity count10 is
port( clr : in STD_LOGIC;
clk : in STD_LOGIC;
co : out STD_LOGIC;
y0 : out STD_LOGIC_VECTOR(3 downto 0));
end count10;
architecture beh1 of count10 is
signal cnt:integer range 0 to 9 :=0;
begin
process(clk,clr)
begin
if(clr='1')then
cnt<=0;
else
if(clk'event and clk='1')then
if cnt=9 then
cnt<=0;
co<='1';
else
cnt<=cnt+1;
co<='0';
end if;
end if;
end if;
end process;
y0<="0000" when cnt=0 else
"0001" when cnt=1 else
"0010" when cnt=2 else
"0011" when cnt=3 else
"0100" when cnt=4 else
"0101" when cnt=5 else
"0110" when cnt=6 else
"0111" when cnt=7 else
"1000" when cnt=8 else
"1001" when cnt=9 else
"0000";
end beh1;