完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
我这段程序实现的是脉冲输入然后在三个数码管,一个显示百位,一个十位,一个个位。想要实现的是当脉冲计数到256的时候能够归0,也就是说最大显示到255.可是不知道为什么,试验台上测试的时候,他却能一直走到999.到了255之后根本没能归0.跟同学商量了商量也没有发现问题所在。大家帮我瞅瞅怎么回事。 library ieee;use ieee.std_logic_1164.all;entity counter is port(a,reset:in std_logic; digit1,digit2,digit3:out std_logic_vector(6 downto 0));end counter;architecture counter of counter i***egin process(a,reset) variable temp1: integer range 0 to 10; variable temp2: integer range 0 to 10; variable temp3: integer range 0 to 10;begin if(reset='1') then temp1 :=0; temp2 :=0; temp3 :=0; elsif(a'event and a='1') then temp1:=temp1+1; if(temp1=10) then temp1:=0; temp2:=temp2+1; if(temp2=10) then temp1:=0; temp2:=0; temp3:=temp3+1; if(temp3=2 and temp2=5 andtemp1=6) then temp1:=0; temp2:=0; temp3:=0; end if; end if; end if; end if; case temp1 is when 0=>digit1<="1111110"; when 1=>digit1<="0110000"; when 2=>digit1<="1101101"; when 3=>digit1<="1111001"; when 4=>digit1<="0110011"; when 5=>digit1<="1011011"; when 6=>digit1<="1011111"; when 7=>digit1<="1110000"; when 8=>digit1<="1111111"; when 9=>digit1<="1111011"; when others => NULL; end case; case temp2 is when 0=>digit2<="1111110"; when 1=>digit2<="0110000"; when 2=>digit2<="1101101"; when 3=>digit2<="1111001"; when 4=>digit2<="0110011"; when 5=>digit2<="1011011"; when 6=>digit2<="1011111"; when 7=>digit2<="1110000"; when 8=>digit2<="1111111"; when 9=>digit2<="1111011"; when others => NULL; end case; case temp3 is when 0=>digit3<="1111110"; when 1=>digit3<="0110000"; when 2=>digit3<="1101101"; when others => NULL; end case; end process; end counter; |
|
相关推荐
4个回答
|
|
temp1,temp2,temp3,怎么会计数到10呢,建议先将计数部分独立出来写个模块,做个仿真,看仿真结果,这比较容易找到错误
|
|
|
|
没看出来程序有什么问题 求楼主给出问题所在!
|
|
|
|
library ieee;
use ieee.std_logic_1164.all; entity counter is port( a,reset:in std_logic; digit1,digit2,digit3:out std_logic_vector(6 downto 0) ); end counter; architecture counter of counter is begin process(a,reset) variable temp1: integer range 0 to 10; variable temp2: integer range 0 to 10; variable temp3: integer range 0 to 10; begin if(reset='1') then temp1 :=0; temp2 :=0; temp3 :=0; elsif(a'event and a='1') then temp1:=temp1+1; if(temp1=10) then temp1:=0; temp2:=temp2+1; if(temp2=10) then temp1:=0; temp2:=0; temp3:=temp3+1; end if; end if; if(temp3=2 and temp2=5 andt emp1=6) then temp1:=0; temp2:=0; temp3:=0; end if; end if; case temp1 is when 0=>digit1<="1111110"; when 1=>digit1<="0110000"; when 2=>digit1<="1101101"; when 3=>digit1<="1111001"; when 4=>digit1<="0110011"; when 5=>digit1<="1011011"; when 6=>digit1<="1011111"; when 7=>digit1<="1110000"; when 8=>digit1<="1111111"; when 9=>digit1<="1111011"; when others => NULL; end case; case temp2 is when 0=>digit2<="1111110"; when 1=>digit2<="0110000"; when 2=>digit2<="1101101"; when 3=>digit2<="1111001"; when 4=>digit2<="0110011"; when 5=>digit2<="1011011"; when 6=>digit2<="1011111"; when 7=>digit2<="1110000"; when 8=>digit2<="1111111"; when 9=>digit2<="1111011"; when others => NULL; end case; case temp3 is when 0=>digit3<="1111110"; when 1=>digit3<="0110000"; when 2=>digit3<="1101101"; when others => NULL; end case; end process; end counter; |
|
|
|
elsif(a'event and a='1') then
temp1:=temp1+1; if(temp1=10) then temp1:=0; temp2:=temp2+1; if(temp2=10) then temp1:=0; temp2:=0; temp3:=temp3+1; end if; end if; if(temp3=2 and temp2=5 andt emp1=6) then temp1:=0; temp2:=0; temp3:=0; end if; end if; 你这样就没问题了 |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1673 浏览 1 评论
1428 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
1644 浏览 0 评论
941 浏览 0 评论
2433 浏览 0 评论
1498 浏览 38 评论
5698 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-29 01:16 , Processed in 0.636275 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号