library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity xiaoba10 is
port(
clk:in std_logic;
-- co :out std_logic;--蜂鸣器
led7s1 : out std_logic_vector(7 downto 0);
led7s2 : out std_logic_vector(7 downto 0);
led7s3 : out std_logic_vector(7 downto 0)
);
end xiaoba10;
architecture a of xiaoba10 is
signal m : std_logic_vector(3 downto 0);
signal n : std_logic_vector(3 downto 0);
signal b : std_logic_vector(24 downto 0);
--signal led:std_logic_vector(15 downto 0);
begin
process(clk)
begin
if clk' event and clk='1' then
b<=b+1;
if b>="1001100010010110100000000" then
b<="0000000000000000000000000";
m<=m-1;
-- co<='0';
--elsif clk'event and clk='1' then
-- co<='1';
if m<="0000" then
m<="1001";
n<=n+1;
-- co<='1';
end if;
end if;
end if;
end process;process(m)
begin
case m is
when "0000"=>led7s3<="00000000";
when "0001"=>led7s3<="00000110";
when "0010"=>led7s3<="01011011";
when "0011"=>led7s3<="01001111";
when "0100"=>led7s3<="01100110";
when "0101"=>led7s3<="01101101";
when "0110"=>led7s3<="01111101";
when "0111"=>led7s3<="00000111";
when "1000"=>led7s3<="01111111";
when "1001"=>led7s3<="01101111";when others=>null;
end case;
end process;
process(n)
begin
case n is
when "0000"=>led7s1<="00000110";led7s2<="00000110";
when "0001"=>led7s1<="00110000";led7s2<="00110000";
when "0010"=>led7s1<="00001000";led7s2<="00001000";
when "0011"=>led7s1<="01000000";led7s2<="01000000";
when "0100"=>led7s1<="00000001";led7s2<="00000001";
when "0101"=>led7s1<="01011100";led7s2<="01011100";
when "0110"=>led7s1<="01100011";led7s2<="01100011";--
when "0111"=>led7s1<="00000110";led7s2<="00000110";
when "1000"=>led7s1<="00110000";led7s2<="00110000";
when "1001"=>led7s1<="00001000";led7s2<="00001000";
when "1010"=>led7s1<="01000000";led7s2<="01000000";
when "1011"=>led7s1<="00000001";led7s2<="00000001";
when "1100"=>led7s1<="01011100";led7s2<="01011100";
when "1101"=>led7s1<="01100011";led7s2<="01100011";
when "1110"=>led7s1<="01111111";led7s2<="01111111";
when "1111"=>led7s1<="01100011";led7s2<="00000000";when others=>null;
end case;
end process;
end a;
此帖出自
小平头技术问答
一周热门 更多>