一天24小时倒计时闹钟.docx

上传人:b****5 文档编号:7419197 上传时间:2023-05-11 格式:DOCX 页数:8 大小:46.58KB
下载 相关 举报
一天24小时倒计时闹钟.docx_第1页
第1页 / 共8页
一天24小时倒计时闹钟.docx_第2页
第2页 / 共8页
一天24小时倒计时闹钟.docx_第3页
第3页 / 共8页
一天24小时倒计时闹钟.docx_第4页
第4页 / 共8页
一天24小时倒计时闹钟.docx_第5页
第5页 / 共8页
一天24小时倒计时闹钟.docx_第6页
第6页 / 共8页
一天24小时倒计时闹钟.docx_第7页
第7页 / 共8页
一天24小时倒计时闹钟.docx_第8页
第8页 / 共8页
亲,该文档总共8页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

一天24小时倒计时闹钟.docx

《一天24小时倒计时闹钟.docx》由会员分享,可在线阅读,更多相关《一天24小时倒计时闹钟.docx(8页珍藏版)》请在冰点文库上搜索。

一天24小时倒计时闹钟.docx

一天24小时倒计时闹钟

 

 

一、电子钟相关功能描述如下:

(1)计时功能:

这是本计时器设计的基本功能,可进行时、分、秒计时,并显示。

(2)闹钟功能:

如果当前时间与设置的闹钟时间相同,则扬声器发出一段声音,并维持一分钟。

二、设计原理:

数字闹钟电路的基本结构由两个60进制计数器和一个24进制计数器组成,分别对秒、分、小时进行计时,当计时到23时59分59秒时,再来一个计数脉冲,则计数器清零,重新开始计时。

秒计数器的计数时钟CLK为1Hz的标准信号。

当数字闹钟处于计时状态时,秒计数器的进位输出信号作为分钟计数器的计数信号,分钟计数器的进位输出信号又作为小时计数器的计数信号时、分、秒的计时结果通过6个数码管来动态显示。

当一天的时间结束了扬声器将会鸣叫,持续1分钟。

三、设计程序

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

 

-----实体---------

entitymiaobiaois

port(en,rst,clk:

instd_logic;----------------暂停,复位,频率------

dian,bell:

outstd_logic;---------------数码管点和蜂鸣器-----------

duan:

outstd_logic_vector(5downto0);------数码管的段显示---

cout:

outstd_logic_vector(6downto0));------数码管的位选-------

end;

 

--------------结构体-----------

architectureoneofmiaobiaois

signalclk_1k:

std_logic;

signalclk_1h:

std_logic;

signalcnt6:

integerrange0to5;

signaldata:

std_logic_vector(5downto0);

signaldout:

std_logic_vector(5downto0);

signals:

std_logic_vector(6downto0);

signalled1,led2,led3,led4,led5,led6:

std_logic_vector(5downto0);

begin

-------------1k分频--------

process(clk)

variablecnt1:

integerrange0to250;

variablecnt2:

integerrange0to100;

begin

ifclk'eventandclk='1'then

ifcnt1=250then

cnt1:

=0;

ifcnt2=100then

cnt2:

=0;

clk_1k<=notclk_1k;

else

cnt2:

=cnt2+1;

endif;

else

cnt1:

=cnt1+1;

endif;

endif;

endprocess;

---------------1h分频-----------

process(clk)

variablecnt1:

integerrange0to4999;

variablecnt2:

integerrange0to4999;

begin

ifclk'eventandclk='1'then

ifcnt1=4999then

cnt1:

=0;

ifcnt2=4999then

cnt2:

=0;

clk_1h<=notclk_1h;

else

cnt2:

=cnt2+1;

endif;

else

cnt1:

=cnt1+1;

endif;

endif;

endprocess;

 

-------------数码管---------

process(clk_1k)

begin

ifclk_1k'eventandclk_1k='1'then

ifcnt6=5then

cnt6<=0;

else

cnt6<=cnt6+1;

endif;

endif;

endprocess;

process(cnt6)

begin

casecnt6is

when0=>dout<="111110";

when1=>dout<="111101";

when2=>dout<="111011";

when3=>dout<="110111";

when4=>dout<="101111";

when5=>dout<="011111";

whenothers=>dout<=null;

endcase;

endprocess;

process(dout)

begin

casedoutis------数码管位地址相对应的输出段码信号--------

when"111110"=>data<=led1;dian<='1';

when"111101"=>data<=led2;dian<='0';

when"111011"=>data<=led3;dian<='1';

when"110111"=>data<=led4;dian<='0';

when"101111"=>data<=led5;dian<='1';

when"011111"=>data<=led6;dian<='0';

whenothers=>data<=null;dian<='0';

endcase;

endprocess;

------------段显示地址--------

process(clk_1h)

begin

ifrst='0'then

led6<="000010";led5<="000011";led4<="000101";led3<="001001";led2<="000101";led1<="001001";

elsifclk_1h'eventandclk_1h='1'then

ifen='1'then

caseled1is

when"000000"=>led1<="001001";

caseled2is

when"000000"=>led2<="000101";

caseled3is

when"000000"=>led3<="001001";

caseled4is

when"000000"=>led3<="000101";

caseled5is

when"000000"=>led3<="001001";

caseled6is

when"000000"=>led6<="000010";

led5<="000011";

led4<="000101";

led3<="001001";

led2<="000101";

led1<="001001";

bell<='1';

whenothers=>led6<=led6-1;

endcase;

whenothers=>led5<=led5-1;

bell<='0';

endcase;

whenothers=>led4<=led4-1;

endcase;

whenothers=>led3<=led3-1;

endcase;

whenothers=>led2<=led2-1;

endcase;

whenothers=>led1<=led1-1;

endcase;

endif;

endif;

endprocess;

 

---------------七段译码-----------

process(data)

begin

casedatais

when"000000"=>s<="0111111";

when"000001"=>s<="0000110";

when"000010"=>s<="1011011";

when"000011"=>s<="1001111";

when"000100"=>s<="1100110";

when"000101"=>s<="1101101";

when"000110"=>s<="1111101";

when"000111"=>s<="0000111";

when"001000"=>s<="1111111";

when"001001"=>s<="1101111";

whenothers=>s<=null;

endcase;

endprocess;

duan<=dout;

cout<=s;

end;

四、管脚分配

体会与收获

通过这个项目给我最大的体会就是不用害怕大项目,其实我们可以通过一个一个小项目完成好后在添加一些新的功能上去,不断的修改,整个项目完成我也是通过一个又一个简单小项目调试先,如先弄好寄存,再弄显示….一步一步加上一些功能上去,如果遇到不懂的和其他同学互相交流,有时候人家就那么几句话就可以让你灵感出现。

要注重团队合作,一个人的力量毕竟是小的,互相学习借鉴人家,从中选择对自己有益的一面。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2