用VHDL编程实现4位LED数码管动态显示
4个LED数码管的a、b、c、d、e、f、g是并联的,利用com1、com2、com3、com4实现循环选通进行循环显示,如果可以的话请发到邮箱hb_beyond@qq....
4个LED数码管的a、b、c、d、e、f、g是并联的,利用com1、com2、com3、com4实现循环选通进行循环显示,如果可以的话请发到邮箱hb_beyond@qq.com,谢谢
展开
1个回答
展开全部
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity shownum is
port(clock,en : in std_logic;
dp2,dp1 : in std_logic; ---dp2:百位小数点 dp1:个位小数点
numina,numinb,numinc : in std_logic_vector(3 downto 0);
display : out std_logic_vector(6 downto 0);
enout : out std_logic_vector(2 downto 0); 控制使能段
dpout : out std_logic); --小数点输出
end;
architecture decoder of shownum is
signal counter : integer range 0 to 2;
signal counter1 : integer range 0 to 1;
signal num1 : std_logic;
begin
a: process(clock,en)
variable num : std_logic_vector(3 downto 0);
begin
if en='1' then --如果en为高电平时,允许七段数码管显示数字
if rising_edge(clock) then
if counter=2 then
counter<=0;
else
counter<=counter+1;
end if;
case counter is
when 0=>
enout<="110";
num:= numina;
when 1=>
enout<="101";
num:= numinb;
when 2=>
enout<="011";
num:= numinc;
when others=>
enout<="111";
num:= "0000";
end case;
case num is
when"0000"=>display<="1111110";
when"0001"=>display<="0110000";
when"0010"=>display<="1101101";
when"0011"=>display<="1111001";
when"0100"=>display<="0110011";
when"0101"=>display<="1011011";
when"0110"=>display<="1011111";
when"0111"=>display<="1110000";
when"1000"=>display<="1111111";
when"1001"=>display<="1111011";
when others=>display<="0000000";
end case;
end if;
else --en='0'不显示
display<="0000000";
end if;
end process;
b: process(num1) --从这开始是我不能实现的地方,不能将小数点也动态显示
begin
if counter1=1 then
counter1<=0;
else
counter1<=counter1+1;
end if;
case counter is
when 0=>
if dp2='0' and dp1='0' then
enout<="111";num1<=dp2 or dp1;
elsif dp2='0' and dp1='1' then
enout<="101";num1<=dp2 or dp1;
elsif dp2='1' and dp1='0' then
enout<="011" ;num1<=dp2 or dp1;
else
enout<="111";
end if;
when 1=>
if dp2='0' and dp1='0' then
enout<="111";num1<=dp2 or dp1;
elsif dp2='0' and dp1='1' then
enout<="101";num1<=dp2 or dp1;
elsif dp2='1' and dp1='0' then
enout<="011" ;num1<=dp2 or dp1;
else
dpout<='0';
end if;
when others=>null;
end case;
dpout<=num1;
end process;
end;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity shownum is
port(clock,en : in std_logic;
dp2,dp1 : in std_logic; ---dp2:百位小数点 dp1:个位小数点
numina,numinb,numinc : in std_logic_vector(3 downto 0);
display : out std_logic_vector(6 downto 0);
enout : out std_logic_vector(2 downto 0); 控制使能段
dpout : out std_logic); --小数点输出
end;
architecture decoder of shownum is
signal counter : integer range 0 to 2;
signal counter1 : integer range 0 to 1;
signal num1 : std_logic;
begin
a: process(clock,en)
variable num : std_logic_vector(3 downto 0);
begin
if en='1' then --如果en为高电平时,允许七段数码管显示数字
if rising_edge(clock) then
if counter=2 then
counter<=0;
else
counter<=counter+1;
end if;
case counter is
when 0=>
enout<="110";
num:= numina;
when 1=>
enout<="101";
num:= numinb;
when 2=>
enout<="011";
num:= numinc;
when others=>
enout<="111";
num:= "0000";
end case;
case num is
when"0000"=>display<="1111110";
when"0001"=>display<="0110000";
when"0010"=>display<="1101101";
when"0011"=>display<="1111001";
when"0100"=>display<="0110011";
when"0101"=>display<="1011011";
when"0110"=>display<="1011111";
when"0111"=>display<="1110000";
when"1000"=>display<="1111111";
when"1001"=>display<="1111011";
when others=>display<="0000000";
end case;
end if;
else --en='0'不显示
display<="0000000";
end if;
end process;
b: process(num1) --从这开始是我不能实现的地方,不能将小数点也动态显示
begin
if counter1=1 then
counter1<=0;
else
counter1<=counter1+1;
end if;
case counter is
when 0=>
if dp2='0' and dp1='0' then
enout<="111";num1<=dp2 or dp1;
elsif dp2='0' and dp1='1' then
enout<="101";num1<=dp2 or dp1;
elsif dp2='1' and dp1='0' then
enout<="011" ;num1<=dp2 or dp1;
else
enout<="111";
end if;
when 1=>
if dp2='0' and dp1='0' then
enout<="111";num1<=dp2 or dp1;
elsif dp2='0' and dp1='1' then
enout<="101";num1<=dp2 or dp1;
elsif dp2='1' and dp1='0' then
enout<="011" ;num1<=dp2 or dp1;
else
dpout<='0';
end if;
when others=>null;
end case;
dpout<=num1;
end process;
end;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询