EDA数字秒表的设计程序
程序说明:1。此程序包括分频,计数控制,显示控制部分。
2。开机显示00。00。00,用户课随时计时,暂停,清零,最大计时可到59 分59。99秒。
3。技术时钟为100HZ
4。采用时分复用的方法控制4个数码管的显示,可节省资源。
程序如下:
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_arith.all;
Use ieee.std_logic_unsigned.all;
Entity watch is
Port ;
seg:out std_logic_vector;
Beginstop:in std_logic;
Reset:in std_logic;☁
Cp2:in std_logic);
End watch;
Architecture behave of watch is
Signal num1: std_logic_vector;
Signal num2: std_logic_vector;
Signal num3: std_logic_vector;
Signal num4: std_logic_vector;
Signal num5: std_logic_vector;
Signal num6: std_logic_vector;
Signal num: std_logic_vector;
Signal numlet: std_logic_vector;
Signal count: std_logic_vector;
Signal selsig: std_logic_vector;
Signal segsig: std_logic_vector;
Signal cp1: std_logic;
Signal cp3: std_logic;
Begin
Process ---- 分频。
Begin
If then
if then
count<="00000ป00000น0000000"; cp1<=not cp1;
else count<=count 1;
end if;
end if;
cp3<=count
;
end process;
process
begin
if reset ='1' then num1 <="0000";
num2 <="0000";
num3 <="0000";
num4 <="0000";
num5 <="0000";
num6 <="0000";
else if cp1' event and cp1='1' then
if beginstop='1' then num1<=num1 1;
if num1 ="1001" then if num2 ="1001" then
num2 <="0000"; num3<= num3 1;
if num3 ="1001" then
num3 <="0000"; num4<= num4 1;
if num4 ="0101" then
num4 <="0000"; num5<= num5 1;
if num5 ="1001" then
num5 <="0000"; num6<= num6 1;
if num6 ="0101" t⌛hen
num6<="0000";
end if; end if; end if; end if; end if; end if; end if;
end if; end if;
end process;
process
begin
if then
if="000") then
num<=num1;selsig<="111110"; end if;
if="001") then
num<=num2;selsig<="111101"; end if;
if="010") then
num<=num3;selsig<="111011"; end if;
if="011") then
num<=num4;selsig<="110111"; end if;
if="100") then
num<=num5;selsig<="101111"; end if;
numlet<=numlet 1;
if="101") then
numlet<="011111"; end if;
end if;
if ="0000")then
segsig<="01111111"; end if;
if ="0001")then
segsig<="00001101"; end if;
if ="0010")then
segsig<="10110111"; end if;
if ="0011")then
segsig<="10011111"; end if;
if ="0100")then
segsig<="11001101"; end if;
if ="0101")then
segsig<="11011011"; end if;
if ="0110")then
segsig<="11111011"; ッ end if;
if ="0111")then
segsig<="00001111"; end if;
if ="1000")then
segsig<="11111111"; end if;
if ="1001")then
segsig<="11011111"; end if;
end process;
sel<=selsig;
seg<=segsig;
end behave;