数字时钟程序

数字时钟程序

ID:34303233

大小:53.69 KB

页数:6页

时间:2019-03-04

数字时钟程序_第1页
数字时钟程序_第2页
数字时钟程序_第3页
数字时钟程序_第4页
数字时钟程序_第5页
资源描述:

《数字时钟程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、-说明:程序为基本的数字时钟并用七段数码管显示的程序,程序有清零的功能,如果想进一步要求有校时与报时的功能,可加相应的置数端与报时信号,这里不做详细说明,另外这里的数码管为共阴极。libraryieee;useieee.std_logic_l164.all;useieee.std_logic_unsigned.all;entitydclockisport(clk,clkl,reset:instd_logic;selloutstd_logic_vector(2downto0);led7s:outstd_lo

2、gic_vector(6downto0));—elk用于计数,clkl用于扫描,sei用于数码管的选择,led7s用于段选信号;enddclock;architecturebhvofdclockissignalsec_l:std_logic_vector(3downto0);-秒钟低位;signalsec_h:std_logic_vector(2downto0);-秒钟高位;signalensec:std_logic;—秒钟进位信号;signalmin_l:std_logic_vector(3downto

3、0);一分辛中低位;signalmin_h:std_logic_vector(2downto0);—分罕中高位;signalenmin:std_logic;—分钟进位信号;signalhour_l:std_logic_vector(3downto0);—时钟低位;signalhour_h:std_logic_vector(1downto0);—时钟高位;signalcount:std_logic_vector(2downto0);—标志位;signaldaout:std_logic_vector(3dow

4、nto0);—输出信号;beginsec:process(clk,reset)一秒钟计数;beginif(reset=!1f)thensec_l<=n0000,,;sec_h<=n000n;elsif(clk'eventandelk二T)thenif(sec_h=nl01"andsec_l二”1001H)thensec_h<=n000H;sec_l<=,,0000n;ensec<='r;elsif(sec_l=H1001H)thensec_l<="0000n;sec_h<=sec_h4-l;elsesec

5、_l<=sec_l+1;ensec<=,0,;endif;endif;endprocesssec;min:process(reset,ensec)一分令中计数;beginif(reset=fr)thenminJ<=,,0000,,;min_h<=n000M;elsifensec-I*thenif(min_h=nl01nandmin_l=n1001n)thenmin_h<=n000n;min_l<=n0000H;enmin<=,V;elsif(min_l二T001n)thenminJ<=n0000n;min

6、_h<=min_h4-l;elsemin_l<=min_l+l;enmin<=,0,;endif;endif;endprocessmin;hour:process(reset,enmin)一时¥中计数;beginif(reset=,1*)thenhour_l<=H0000H;hour_h<=n00n;els讦enmin二Tthenif(hour_h=n10nandhour_l=n001ln)thenhour_h<=n00n;hour_K=n0000n;elsif(hour_l=nl001n)thenhou

7、r_l<=n0000M;hour_h<=hour_h+1;elsehour_l<=hour_l-i-1;endif;endif;endprocesshour;scanO:process(clkl,reset)—设置扫描标志位;beginif(reset=*T)thencount<=,,000M;elsif(clkreventandclkl二T)thenif(count=n101n)thencount<=n000n;elsecount<=count+1;endif;endif;endprocessscanO

8、;scant:process(count,reset)一扫描;beginif(reset=fr)thendaout<=n0000n;sel<=H11ln;elsecasecountiswhen,,000,,=>daout<=sec_l;sel<=,,00r';whenn001,,=>daout(3)<=,0,;daout(2downto0)<=sec_h;sel<=n010";whenH010,,=>daout<=min_l;

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。