基于vhdl_的_数字钟的设计内容摘要:

: out std_logic_vector(3 downto 0)。 mo0,mo1 : out std_logic_vector(3 downto 0)。 ya0,ya1 : out std_logic_vector(3 downto 0)。 en : in std_logic。 en 接上一个模块小时的进位 lock : in std_logic_vector(2 downto 0) )。 end daymony1。 architecture Behavioral of daymony1 is signal dat0 : std_logic_vector(3 downto 0):=0110。 signal dat1 : std_logic_vector(3 downto 0):=0001。 signal mon0 : std_logic_vector(3 downto 0):=0001。 signal mon1 : std_logic_vector(3 downto 0):=0000。 signal yea0 : std_logic_vector(3 downto 0):=0100。 signal yea1 : std_logic_vector(3 downto 0):=0001。 signal day_out,month_out:std_logic。 程序内部天和月的进位,也可放于前面设为 buffer begin da0=dat0。 da1=dat1。 mo0=mon0。 mo1=mon1。 ya0=yea0。 ya1=yea1。 年月日赋初值 P1:process (clk0,en,lock)天的输出,分大月和小月,以及二月 begin if en=39。 139。 then 时分秒模块有进位使能年月日 if lock=001then if clk039。 event AND clk0=39。 139。 then if (mon0=0001and mon1=0000)or(mon0=0011and mon1=0000) or(mon0=0101and mon1=0000)or(mon0=0111and mon1=0000) or(mon0=1000and mon1=0000)or(mon0=0000and mon1=0001) or(mon0=0010and mon1=0001)then 1 3 5 7 8 10 12 月为 31 天 if dat0=0001 and dat1=0011then dat0=0001。 dat1=0000。 day_out=39。 139。 elsif dat0=1001then dat0=0000。 dat1=dat1+1。 day_out=39。 039。 else dat0=dat0+39。 139。 dat1=dat1。 day_out=39。 039。 end if。 elsif(mon0=0100and mon1=0000)or(mon0=0110and mon1=0000) or(mon0=1001and mon1=0000)or(mon0=0001and mon1=0001)then 4 6 9 11 月份 30 天 if dat0=0000 and dat1=0011then dat0=0001。 dat1=0000。 day_out=39。 139。 elsif dat0=1001then dat0=0000。 dat1=dat1+1。 day_out=39。 039。 else dat0=dat0+39。 139。 dat1=dat1。 day_out=39。 039。 end if。 Else 对闰年的判断 2 月 29 数码管只显示年后两位 前两位默认为 20 故只要后两位能被 4 整除即使闰年 if((yea1=0000OR yea1=0010OR yea1=0100OR yea1=0110 OR yea1=01000)AND(yea0=0000 OR yea0=0100OR yea0=01000))OR ((yea1=0001 OR yea1=0011 OR yea1=0101OR yea1=0111 OR yea1=1001)AND(yea0=0010OR yea0=0110)) THEN if dat0=1001 and dat1=0010then dat0=0001。 dat1=0000。 day_out=39。 139。 elsif dat0=1001then dat0=0000。 dat1=dat1+39。 139。 day_out=39。 039。 else dat0=dat0+39。 139。 dat1=dat1。 day_out=39。 039。 end if。 else 不是闰年,二月份 28 天 if dat0=1000 and dat1=0010then dat0=0001。 dat1=0000。 day_out=39。 139。 elsif dat0=1001then dat0=0000。 dat1=dat1+39。 139。 day_out=39。 039。 else dat0=dat0+39。 139。 dat1=dat1。 day_out=39。 039。 end if。 end if。 判断闰年的语句 end if。 判断月份的语句 end if。 对应 clk0 end if。 对应 lock end if。 对应使能 end process P1。 P2:process (day_out,lock)对月的输出 begin if lock=001then if day_out39。 event AND day_out=39。 139。 then 天数产生进位使月份加一 if mon0=0010 and mon1=0001then mon0=0001。 mon1=0000。 month_out=39。 139。 到十二月份后重新回到一月份产生月进位给年 elsif mon0=1001then mon0=0000。 mon1=mon1+39。 139。 month_out=39。 039。 else mon0=mon0+39。 139。 mon1=mon1。 month_out=39。 039。 end if。 end if。 end if。 end process P2。 P3:process (month_out,lock)对年的设制 begin if lock=001then if month_out39。 event AND month_out=39。 139。 then 月份产生进位使年加一 if yea0=1001and yea1=1001then yea0=0000。 yea1=0000。 elsif yea0=1001then yea0=0000。 yea1=yea1+39。 139。 else yea0=yea0+39。 139。 yea1=yea1。 end if。 end if。 end if。 end process P3。 end Behavioral。 分频 library IEEE。 use。 use。 use。 Unment the following lines to use the declarations that are provided for instantiating Xilinx primitive ponents. library UNISIM。 use。 entity fenpin is port(upd0 : in std_logic。 clk : in std_logic。 f_clk : out std_logic。 lock : out std_logic_vector(2 downto 0) )。 end fenpin。 architecture Behavioral of fenpin is signal tem : std_logic_vector(2 downto 0):=000。 signal cout : std_logic_vector(8 downto 0):=000000000。 signal clk_o : std_logic。 begin lock=tem。 f_clk=clk_o。 process(upd0,clk ,cout) begin if clk 39。 event and clk =39。 139。 then if cout=111110011then cout=000000000。 clk_o=not clk_o。 else cout=cout+39。 139。 end if。 end if。 if upd039。 event and upd0=39。 139。 then tem=tem+39。 139。 end if。 end process。 end Behavioral。 时分秒 library IEEE。 use。 use。 use。 Unment the following lines to use the declarations that are provided for instantiating Xilinx primitive ponents. library UNISIM。 use。 entity s_m_hour is port( clk0: in std_logic。 clk0 工作时钟, clk1 预置脉冲 lock : in std_logic_vector(2 downto 0)。 工作模式选择 s0,s1 : out std_logic_vector(3 downto 0)。 m0,m1 : out std_logic_vector(3 downto 0)。 h0,h1 : out std_logic_vector(3 downto 0)。 co : out std_logic。 _vector(2 downto 0)。 hour 产生进位 en : in std_logic )。 end s_m_hour。 architecture Behavioral of s_m_hour is signal ts0 : std_logic_vector(3 downto 0):=0100。 signal ts1 : std_logic_vector(3 downto 0):=0101。 signal tm0 : std_logic_vector(3 downto 0):=1001。 signal tm1 : std_logic_vector(3 downto 0):=0101。 signal th0 : std_logic_vector(3 down。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。