--(本源码不排除包含些许错误,参考者谨慎!)
--主频:40Mhz,0.5s计数一次,六个数码管,动态扫描方式逐次点亮
entity leddisplay is
port(clk,rst:in std_logic;
ledk:out std_logic_vector(5 downto 0);
leda:out std_logic_vector(7 downto 0));
end leddisplay;
architecture a of leddisplay is
signal count:std_logic_vector(25 downto 0);
signal countt:std_logic_vector(15 downto 0);
signal ledat:std_logic_vector(23 downto 0);
signal ledmove:std_logic_vector(2 downto 0);
signal ledaa:std_logic_vector(3 downto 0);
begin
process(clk,rst)
begin
if rst='0' then
count<=(others=>'0');
ledat<=(others=>'0');
countt<=(others=>'0');
ledmove<="000";
elsif rising_edge(clk) then
if count=19999999 then
count<=(others=>'0');
ledat<=ledat+1;
countt<=countt+1;
else
count<=count+1;
countt<=countt+1;
if countt(15)=1 then
countt<=(others=>'0');
ledmove<=ledmove+1;
if ledmove=6 then
ledmove<="000";
end if;
end if;
end if;
end if;
end process;
process(clk,rst)
begin
if rst='0' then
ledk<="111 111";
ledaa<="0000";
elsif rising_edge(clk) then
case ledmove is
when "000"=>
ledk<=not "111 110";
ledaa<=ledat(23 downto 20);
when "001"=>
ledk<=not "111 101";
ledaa<=ledat(19 downto 16);
when "010"=>
ledk<=not "111 011";
ledaa<=ledat(15 downto 12);
when "011"=>
ledk<=not "110 111";
ledaa<=ledat(11 downto 8);
when "100"=>
ledk<=not "101 111";
ledaa<=ledat(7 downto 4);
when "101"=>
ledk<=not "011 111";
ledaa<=ledat(3 downto 0);
when others=>
ledk<="000 000";
end case;
end if;
end process;
process(ledaa)
begin
case ledaa is
when "0000"=>
leda<=x"3f";
when "0001"=>
leda<=x"06";
when "0010"=>
leda<=x"5b";
when "0011"=>
leda<=x"4f";
when "0100"=>
leda<=x"66";
when "0101"=>
leda<=x"6d";
when "0110"=>
leda<=x"7d";
when "0111"=>
leda<=x"07";
when "1000"=>
leda<=x"7f";
when "1001"=>
leda<=x"6f";
when "1010"=>
leda<=x"77";
when "1011"=>
leda<=x"7c";
when "1100"=>
leda<=x"39";
when "1101"=>
leda<=x"5e";
when "1110"=>
leda<=x"79";
when "1111"=>
leda<=x"71";
when others =>
leda<=x"00";
end case;
end process;
end a;
共2条 1/1
1
跳转至
页
数码管计数参考代码
关键词: 代码 计数
共2条 1/1
1
跳转至
页
回复
有奖活动 | |
---|---|
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
【有奖活动】智能可穿戴设备AR/VR如何引领科技新潮流! | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
【有奖活动】震撼来袭!这场直播将直击工程师的心灵! |
打赏帖 | |
---|---|
如何实现基于NXPiMX.RT1021的BH1730采集被打赏5分 | |
玩转“DFRobot盖革计数器模块”准备工作认识模块知识分享被打赏30分 | |
【换取手持数字示波器】AHT10温度检测分享被打赏40分 | |
【换取手持数字示波器】ACM32F070开发板点亮LCD屏和触控按键,串口,ADC被打赏40分 | |
【换取手持数字示波器】ACM32F070LCD屏和触控按键功驱动蜂鸣器分享被打赏40分 | |
【换取手持数字示波器】国民技术PWM功能知识分享被打赏40分 | |
【换取手持数字示波器】放大器运放知识分享被打赏40分 | |
【分享评测,赢取加热台】+开关电源AC输入知识分享被打赏30分 | |
【换取手持数字示波器】N32G430点亮数码管与串口打印、ADC被打赏40分 | |
老胖子聊电路--分析一个反馈电路被打赏50分 |