欢迎来到天天文库
浏览记录
ID:41701287
大小:53.67 KB
页数:7页
时间:2019-08-30
《时钟——倒计时实验报告》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实验报告实验已实验功能:有时钟计时,秒钟清零端,时钟,分钟加一按键,用了一个拨码,当拨码电平为0时倒计时,从99开始到00再回到99,当拨码电平为1时,任意按下时钟或分钟加一的按键,即可回到时钟状态。源程序代码:libraryieee;useieee-std_logic_1164.all;useieee・stdlogicQrith.all;entityexpl5isport(ClkRstS1,S2,S3SPKDisplayuseieee.std_logic_imsignod.all;instd_logic;--时钟输入instd_logic;--复位输
2、入instdlogic;--时间调节输入outstd_logic;--扬声器输出outstd_logic_vector(7downto0);—段码管显示输111SEG_SEL,SEG_SEL1:bufferstd_logic_vector(2downto0)-七段码管扫描驱动);endexpl5;architecturebehaveofexpl5issignalDisp_Temp,Disp_Templ:integerrange0to15;signalDisp_Decode,Disp_Decodel:std_logic_vector(7downto0);
3、signalSEC1,SEC1OsignalMINI,MINI0signalHOUR1,HOUR10signaldjsl,djslOsignalClkCountl数器signalClklHzsignalMusic_Countsignalflagbeginprocess(Clk)integerrange0integortango0integerrange0integerrange0to9-秒钟个位、十位to9;--分钟个位、to9;--小时个位、to9;十位十位stdlogicvector(13downto0);--产生1Hz时钟的分频计std_logi
4、c;std_]ogic_vector(2downto0);std_logic;—标识符beginif(Clk,eventandClk=,1")thenif(Clk_Countl<10000)thenClkCountl〈二ClkCountl+1;elseClk_Countl<='00000000000001〃;endif;endif;endprocess;ClklHz<=Clk_Countl(13);一产生一秒时钟process(ClklHz,Rst)beginif(Rst二'O')then--系统复位djsl<=9;djsl0<=9;SEC1<=O;S
5、EC1O<=O;MINIVO;MIN1O<=O;HOUR1〈二0;H0UR10<=0;-正常运行elsif(ClklHz,eventandClklHz二'1')thenif(S3二'0,)then一倒计时状态flag<=0,;if(djsl=OanddjslO=O)thendjsl<=9;djsl0<=9;elsif(djsl=O)thendjsl〈=9;if(djslO=O)thendjsl0<=9;elsedjslO〈二djslOT;endif;elsedjsl<=djsl-l;endif;elsif(SI二'0’)then―调节小时flag〈二'
6、r;if(HOURl二9)thenH0UR1〈二0;HOUR10UH0UR10+1;elsif(HOUR10=2andHOUR1=3)thenI10URl<=0;HOUR10<=0;elseHOUR1<=HOUR1+1;endif;elsif(S2二'O')then--调节分钟flag〈二'],;if(MIN1=9)thenMTNl<=0;辻(MINIO二5)thenMIN10<=0;elseMIN1O<=MIN1O+1;endif;elseMIN1<=MIN1+1;endif;elsif(SECl=9)then—时钟自动计时过程SECl<=0;辻(S
7、EC10=5)thenSEC10<=0;if(MIN1=9)thenMINl<=0;if(MIN10=5)thenMIN10<=0;if(HOUR1=9)thenH0URl<=0;HOUR10〈二HOUR10+1;elsif(H0UR10=2andHOUR1=3)thenH0URl<=0;H0UR10<=0;elseHOUR1<=HOUR1+1;endif;elseMIN10<=MIN10+l;endif;elseMINI〈二MIN1+1;endif;elseSEC10〈二SEC10+1;endif;elseSEC1<=SEC1+1;endif;end
8、if;endprocess;process(Clk)beginif(Clk'eventandC
此文档下载收益归作者所有