我这段程序实现的是脉冲输入然后在三个数码管,一个显示百位,一个十位,一个个位。想要实现的是当脉冲计数到256的时候能够归0,也就是说最大显示到255.可是不知道为什么,试验台上测试的时候,他却能一直走到999.到了255之后根本没能归0.跟同学商量了商量也没有发现问题所在。大家帮我瞅瞅怎么回事。
library ieee;use ieee.std_logic_1164.all;en
tity counter is port(a,reset:in std_logic; digit1,digit2,digit3:out std_logic_vector(6 downto 0));end counter;architecture counter of counter isbegin 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;
一周热门 更多>