LIBRARYIEEE;
USE IEEEStd_logic_1164ALL;
ENTITYls49 IS
PORT(bl: IN Std_logic;
bi: IN Std_logic_vector(3 DOWNTO 0);
a,b,c,d,e,f,g: OUT Std_logic);
ENDls49;
ARCHITECTURE behavl_49 OF ls49 IS
SIGNAL s: Std_logic_vector(6 DOWNTO 0);
BEGIN
PROCESS (bi,bl)
BEGIN
IF (bl/='1') AND (bl/='H') THEN
s<=(OTHERS => '0');
ELSE
CASE bi IS
WHEN "0000"=>s<="0111111";
WHEN "0001"=>s<="0000110";
WHEN "0010"=>s<="1011011";
WHEN "0011"=>s<="1001111";
WHEN "0100"=>s<="1100110";
WHEN "0101"=>s<="1101101";
WHEN "0110"=>s<="1111101";
WHEN "0111"=>s<="0100111";
WHEN "1000"=>s<="1111111";
WHEN "1001"=>s<="1101111";
WHEN "1010"=>s<="1110111";
WHEN "1011"=>s<="1111100";
WHEN "1100"=>s<="0111001";
WHEN "1101"=>s<="1011110";
WHEN "1110"=>s<="1111001";
WHEN "1111"=>s<="1110001";
WHEN OTHERS=>s<="0000000";
END CASE;
END IF;
END PROCESS;
a <= s(0);
b <= s(1);
c <= s(2);
d <= s(3);
e <= s(4);
f <= s(5);
g <= s(6);
END behavl49;用case语句就可以,当然也可以由with select,when。。。等语句。输出和数码管的接法有关,下面这个是我用case语句写的,是共阴的接法,共阳的话把q按位取反就是。我综合通过了。
library ieee;
use ieeestd_logic_1164all;
entity smg_16 is
port( a:in std_logic_vector(3 downto 0);
q:out std_logic_vector(6 downto 0)
);
end smg_16;
architecture bhv of smg_16 is
begin
process(a)
begin
case a is
when "0000"=> q<="0111111";
when "0001"=> q<="0000110";
when "0010"=> q<="1011011";
when "0011"=> q<="1001111";
when "0100"=> q<="1100110";
when "0101"=> q<="1101101";
when "0110"=> q<="1111101";
when "0111"=> q<="0100111";
when "1000"=> q<="1111111";
when "1001"=> q<="1101111";
when "1010"=> q<="1110111";
when "1011"=> q<="1111100";
when "1100"=> q<="0111001";
when "1101"=> q<="1011110";
when "1110"=> q<="1111001";
when others=> q<="1110001";
end case;
end process;
end bhv;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)