📄 shuzizhong.txt
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity shuzizhong is
port(clk,set,s1,s2,s3:in std_logic;
second1,second2,minite1,minite2,hour1,hour2:out std_logic_vector(3 downto 0);
cout:out std_logic);
end entity;
architecture one of shuzizhong is
begin
pro1:process(clk,set,s1,s2,s3)
variable msecond1,msecond2,mminite1,mminite2,mhour1,mhour2:std_logic_vector(3 downto 0);
begin
if clk'event and clk='1' then
if set='1' then -----启动校验
if s1='1'
then msecond1:=msecond1+1;
if msecond1="1010"
then msecond1:="0000";
msecond2:=msecond2+1;
if msecond2="0110"
then msecond2:="0000";
end if;
end if;
end if; --------秒校验
if s2='1'
then
mminite1:=mminite1+1;
if mminite1="1010"
then mminite1:="0000";
mminite2:=mminite2+1;
if mminite2="0110"
then mminite2:="0000";
end if;
end if;
end if; ---------分校验
if s3='1' then
mhour1:=mhour1+1;
if mhour1="1010" then mhour1:="0000";
mhour2:=mhour2+1;
end if;
if mhour1="0100"and mhour2="0010"
then mhour1:="0000";mhour2:="0000";
end if;
end if;-------时校验
else msecond1:=msecond1+1;-----正常计时工作
if msecond1="1010"
then msecond1:="0000";
msecond2:=msecond2+1;
if msecond2="0110"
then msecond2:="0000";
mminite1:=mminite1+1;
if mminite1="1010"
then mminite1:="0000";
mminite2:=mminite2+1;
if mminite2="0110"
then mminite2:="0000";
mhour1:=mhour1+1;
if mhour1="1010" then mhour1:="0000";
mhour2:=mhour2+1;
end if;
if mhour1="0100"and mhour2="0010"
then mhour1:="0000";mhour2:="0000";
end if;----------24小时制
end if;
end if;
end if;
end if;
if (msecond1="0000") and (msecond2="0000") and (mminite1="0000") and (mminite2="0000")
then cout<='1';
else cout<='0';
end if;-----------整点报时
end if;
end if;
second1<=msecond1;
second2<=msecond2;
minite1<=mminite1;
minite2<=mminite2;
hour1<=mhour1;hour2<=mhour2;
end process;
end architecture one;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -