⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 countwatch.vhd

📁 many application on kit SP-3: VGA, digital clock, counter, interface PS2....
💻 VHD
字号:
----------------------------------------------------------------------------------library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity DongHo is    Port ( clk,SW7,SW6,SW5,SW4 : in  std_logic;				sccode  : in  std_logic_VECTOR (7 downto 0);	        BCD0,BCD1,BCD2,BCD3,BCD4,BCD5:out std_logic_VECTOR (3 downto 0));end DongHo;architecture Behavior of DongHo is	signal count0,count1,count2,count3,count4,count5 : std_logic_vector (3 downto 0);	signal cnt0,cnt1,cnt2,cnt3,cnt4,cnt5 : std_logic_vector (3 downto 0);	begin	process(clk)	begin	if clk'event and clk='1' then 		if SW4='0' then			if (sccode="01110110") then	--esc				count0<="0000";count1<="0000";count2<="0000";					count3<="0000";count4<="0000";count5<="0000";				cnt0<="0000";cnt1<="0000";cnt2<="0000";					cnt3<="0000";cnt4<="0000";cnt5<="0000";								elsif (sccode="00100100") then-- e				if count5="0010" and count4="0011" and count3="0101"					and count2="1001" and count1="0101" and count0="1001"then						count0<="0000";count1<="0000";count2<="0000";						count3<="0000";count4<="0000";count5<="0000";					else					if count0="1001" then						count0<="0000";						if count1="0101" then							count1<="0000";							if count2="1001" then								count2<="0000";								if count3="0101" then									count3<="0000";									if count4="1001" then										count4<="0000";										count5<=count5 + '1';									else											count4<=count4 + '1';																	end if;								else	count3<=count3 + '1';								end if;							else	count2<=count2 + '1';							end if;						else		count1<=count1 + '1';						end if;					else	count0 <= count0 + '1';					end if;								end if;			elsif sccode= "00011011" then--s					count0<=count0 ;				count1<=count1;				count2<=count2 ;				count3<=count3 ;				count4<=count4 ;				count5<=count5 ;--			else--				null;			end if;		else			if SW7='0' and SW6='0' and SW5='0' then							if sccode= "00010110" then --1						cnt0 <= "0001";					elsif	sccode= "00011110" then --2						cnt0 <= "0010";					elsif sccode= "00100110" then --3						cnt0 <= "0011";					elsif	sccode= "00100101" then --4						cnt0 <= "0100";					elsif	sccode= "00101110" then --5						cnt0 <= "0101";					elsif sccode= "00110110" then --6						cnt0 <= "0110";					elsif	sccode= "00111101" then --7						cnt0 <= "0111";					elsif sccode= "00111110" then --8						cnt0 <= "1000";					elsif	sccode= "01000110" then --9						cnt0 <= "1001";					elsif	sccode= "01000101" then --0							cnt0 <= "0000";					end if;							elsif	SW7='0' and SW6='0' and SW5='1' then					if sccode= "00010110" then --1						cnt1 <= "0001";					elsif	sccode= "00011110" then --2						cnt1 <= "0010";					elsif sccode= "00100110" then --3						count1 <= "0011";					elsif	sccode= "00100101" then --4						cnt1 <= "0100";					elsif	sccode= "00101110" then --5						cnt1 <= "0101";					elsif sccode= "00110110" then --6						cnt1 <= "0110";					elsif	sccode= "00111101" then --7						cnt1 <= "0111";					elsif sccode= "00111110" then --8						cnt1 <= "1000";					elsif	sccode= "01000110" then --9						cnt1 <= "1001";					elsif	sccode= "01000101" then --0							cnt1 <= "0000";					end if;				elsif SW7='0' and SW6='1' and SW5='1' then					if sccode= "00010110" then --1						cnt2 <= "0001";					elsif	sccode= "00011110" then --2						cnt2 <= "0010";					elsif sccode= "00100110" then --3						cnt2 <= "0011";					elsif	sccode= "00100101" then --4						cnt2 <= "0100";					elsif	sccode= "00101110" then --5						count2 <= "0101";					elsif sccode= "00110110" then --6						cnt2 <= "0110";					elsif	sccode= "00111101" then --7						cnt2 <= "0111";					elsif sccode= "00111110" then --8						cnt2 <= "1000";					elsif	sccode= "01000110" then --9						cnt2 <= "1001";					elsif	sccode= "01000101" then --0							cnt2 <= "0000";					end if;				elsif	SW7='0' and SW6='1' and SW5='0' then					if sccode= "00010110" then --1						cnt3 <= "0001";					elsif	sccode= "00011110" then --2						cnt3 <= "0010";					elsif sccode= "00100110" then --3						cnt3 <= "0011";					elsif	sccode= "00100101" then --4						cnt3 <= "0100";					elsif	sccode= "00101110" then --5						cnt3 <= "0101";					elsif sccode= "00110110" then --6						cnt3 <= "0110";					elsif	sccode= "00111101" then --7						cnt3 <= "0111";					elsif sccode= "00111110" then --8						cnt3 <= "1000";					elsif	sccode= "01000110" then --9						cnt3 <= "1001";					elsif	sccode= "01000101" then --0							cnt3 <= "0000";					end if;				elsif	SW7='1' and SW6='1' and SW5='0' then					if sccode= "00010110" then --1						cnt4 <= "0001";					elsif	sccode= "00011110" then --2						cnt4 <= "0010";					elsif sccode= "00100110" then --3						cnt4 <= "0011";					elsif	sccode= "00100101" then --4						cnt4 <= "0100";					elsif	sccode= "00101110" then --5						cnt4 <= "0101";					elsif sccode= "00110110" then --6						cnt4 <= "0110";					elsif	sccode= "00111101" then --7						cnt4 <= "0111";					elsif sccode= "00111110" then --8						cnt4 <= "1000";					elsif	sccode= "01000110" then --9						cnt4 <= "1001";					elsif	sccode= "01000101" then --0							cnt4 <= "0000";					end if;				elsif SW7='1' and SW6='0' and SW5='0' then					if sccode= "00010110" then --1						cnt5 <= "0001";					elsif	sccode= "00011110" then --2						cnt5 <= "0010";					elsif sccode= "00100110" then --3						cnt5 <= "0011";					elsif	sccode= "00100101" then --4						cnt5 <= "0100";					elsif	sccode= "00101110" then --5						cnt5 <= "0101";					elsif sccode= "00110110" then --6						cnt5 <= "0110";					elsif	sccode= "00111101" then --7						cnt5 <= "0111";					elsif sccode= "00111110" then --8						cnt5 <= "1000";					elsif	sccode= "01000110" then --9						cnt5 <= "1001";					elsif	sccode= "01000101" then --0							cnt5 <= "0000";					end if;				elsif	SW7='1' and SW6='0' and SW5='1' then					count0<=cnt0 ;					count1<=cnt1;					count2<=cnt2 ;					count3<=cnt3 ;					count4<=cnt4 ;					count5<=cnt5 ;			end if;   ---SW7, SW6, SW5.			end if;   ---- SW7	end if;   ----CLOCK 1hz.	end process;	bcd0<=count0;	bcd1<=count1;	bcd2<=count2;	bcd3<=count3;	bcd4<=count4;	bcd5<=count5;end Behavior;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -