数字闹钟设计.docx
- 文档编号:29221018
- 上传时间:2023-07-21
- 格式:DOCX
- 页数:13
- 大小:164.29KB
数字闹钟设计.docx
《数字闹钟设计.docx》由会员分享,可在线阅读,更多相关《数字闹钟设计.docx(13页珍藏版)》请在冰豆网上搜索。
数字闹钟设计
课程设计说明书
题目:
数字闹钟
目录
摘要…………………………………………………………………………1
第1章设计方案………………………………………………………2
第2章VHDL源程序设计…………………………………………………3
第3章实验结果波形仿真图心得体会………………………………………7
参考文献………………………………………………………………………11
摘要:
随着EDA技术的发展和应用领域的扩大与深入,EDA技术在电子信息、通信、自动控制及计算机应用领域的重要性日益突出。
EDA技术就是依赖功能强大的计算机,在EDA工具软件平台上,对以硬件描述语言VHDL为系统逻辑描述手段完成的设计文件,自动地完成逻辑优化和仿真测试,直至实现既定的电子线路系统功能。
本文介绍了基于VHDL硬件描述语言设计的多功能数字闹钟的思路和技巧。
在QuartusII开发环境中编译和仿真了所设计的程序,并逐一调试验证程序的运行状况。
仿真和验证的结果表明,该设计方法切实可行,该数字闹钟可以实现调时定时闹钟。
关键字:
闹钟FPGAVHDLQuartusII
Abstract:
alongwiththedevelopmentandapplicationoftechnologyEDAdomainexpansionandin-depth,EDAtechnologyintheelectronicinformation,communication,automaticcontrolandtheimportanceofcomputerapplicationfieldincreasinglyprominent.EDAtechnologyisdependentonpowerfulcomputersintheEDAsoftwareplatform,withVHDLVHDLforsystemlogicdescribingmeanscompletedesigndocuments,automaticallylogicoptimizationandsimulationtestuntilrealizethesetelectroniccircuitsystemfunction.ThispaperintroducesthedesignbasedonVHDLVHDLmulti-functiondigitalalarmclockofthinkingandskills.InQuartusIIdevelopmentenvironmentscompileandsimulationthedesignprocess,andthentheoperationstatusofdebuggingvalidationprocedures.Thesimulationandverificationresultsshowthatthedesignmethodisfeasible,andthedigitalclockcanrealizetonewhentimingalarmclockbeesfunctionhascertainpracticalapplications.
Keyword:
alarmclockFPGAVHDLQuartusII
第1章设计方案
1.电子钟相关功能描述
(1)计时功能:
这是本计时器设计的基本功能,可进行时、分、秒计时,并显示。
(2)闹钟功能:
如果当前时间与设置的闹钟时间相同,则产生蜂鸣。
(3)调时调分调闹钟功能:
当需要校时或者要重新设置闹钟的时间时可控制调整。
2.设计原理
数字闹钟电路的基本结构由两个60进制计数器和一个24进制计数器组成,分别对秒、分、小时进行计时,当计时到23时59分59秒时,再来一个计数脉冲,则计数器清零,重新开始计时。
秒计数器的计数时钟CLK为1Hz的标准信号。
当数字闹钟处于计时状态时,秒计数器的进位输出信号作为分钟计数器的计数信号,分钟计数器的进位输出信号又作为小时计数器的计数信号时、分、秒的计时结果通过6个数码管来动态显示。
数字闹钟除了能够正常计时外,还应能够对时间进行调整。
因此,通过控制数字钟的工作状态,即控制数字钟,使其分别工作于正常计时,调整分、时和设定闹钟分、时5个状态。
当数字闹钟处于计时状态时,3个计数器允许计数,且秒、分、时计数器的计数时钟信号分别为CLK,秒的进位,分的进位;当数字闹钟处于调整时间状态时,被调的分或时会一秒一秒地增加;当数字钟处于闹钟定时状态时,可以设定小时和分;当计时到所设定的时刻时,产生蜂鸣警告。
对于同一功能的电路可以采用多种方案进行实现,但要选择一个最佳方案,如原理图设计法特点为强大的编辑功能;丰富的元件库及库文件的集成化管理;强大的自动化功能;良好的开放性。
而vhdl硬件描述性语言设计方法的特点是功能强大、设计灵活;支持广泛、易于修改;强大的系统硬件描述能力;独立于器件的设计、与工艺无关;很强的移植能力;易于共享和复用。
综合了自己所学的知识和一些实现的问题,我选择了第二种方案。
设计流程图如图1所示
图1设计流程图
第2章VHDL源程序设计
时钟控制模块:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityshizhongis
port(clk:
instd_logic;
md1:
instd_logic;
md2:
instd_logic_vector(1downto0);
clken:
outstd_logic;
h1,h2,m1,m2,s1,s2:
outstd_logic_vector(3downto0));
endshizhong;
architectureoneofshizhongis
signalhou1:
std_logic_vector(3downto0);
signalhou2:
std_logic_vector(3downto0);
signalmin1:
std_logic_vector(3downto0);
signalmin2:
std_logic_vector(3downto0);
signalseth1:
std_logic_vector(3downto0);
signalseth2:
std_logic_vector(3downto0);
signalsetm1:
std_logic_vector(3downto0);
signalsetm2:
std_logic_vector(3downto0);
signalsec1:
std_logic_vector(3downto0);
signalsec2:
std_logic_vector(3downto0);
begin
-----------------------------------------------小时十位
h110:
process(clk,hou2,min1,min2,sec1,sec2,md1,md2)
begin
ifclk'eventandclk='1'then
if(hou1="0010"andhou2="0011")and(min1="0101"andmin2="1001")
and(sec1="0101"andsec2="1001")then
hou1<="0000";
elsifhou1="0010"andhou2="0011"andmd1='0'
andmd2="01"then
hou1<="0000";
elsif(hou2="1001"and(min1="0101"andmin2="1001")
and(sec1="0101"andsec2="1001"))or(hou2="1001"andmd1='0'andmd2="01")
then
hou1<=hou1+1;
endif;
endif;
endprocessh110;
-----------------------------------------------小时个位
h220:
process(clk,min1,min2,sec1,sec2,md1,md2,hou1)
begin
ifclk'eventandclk='1'then
if(hou1="0010"andhou2="0011")and(min1="0101"andmin2="1001")
and(sec1="0101"andsec2="1001")then
hou2<="0000";
elsifhou2="1001"and(min1="0101"andmin2="1001")
and(sec1="0101"andsec2="1001")then
hou2<="0000";
elsif(hou2="1001"andmd1='0'andmd2="01")
or(hou1="0010"andhou2="0011")then
hou2<="0000";--md<='1';--
elsif((min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001"))
or(md1='0'andmd2="01")then
hou2<=hou2+1;--speak<=clk;--
endif;
endif;
endprocessh220;
-----------------------------------------------分钟十位
m110:
process(clk,min2,sec1,sec2,md1,md2)
begin
ifclk'eventandclk='1'then
if(min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001")then
min1<="0000";
elsifmin1="0101"andmin2="1001"and(md1='0'andmd2="00")then
min1<="0000";
elsif(min2="1001"and(sec1="0101"andsec2="1001"))or(min2="1001"andmd1='0'andmd2="00")then
min1<=min1+1;
endif;
endif;--endif;
endprocessm110;
----------------------------------------------分钟个位
m220:
process(clk,sec1,sec2,md1,md2)
begin
ifclk'eventandclk='1'then
ifmin2="1001"and(sec1="0101"andsec2="1001")then
min2<="0000";
elsifmin2="1001"and(md1='0'andmd2="00")then
min2<="0000";
elseif(sec1="0101"andsec2="1001")or(md1='0'andmd2="00")then
min2<=min2+1;
endif;
endif;endif;
endprocessm220;
---------------------------------------------秒十位
s110:
process(clk)
begin
ifclk'eventandclk='1'then
if(sec1="0101"andsec2="1001")then
sec1<="0000";
elseifsec2="1001"then
sec1<=sec1+1;
endif;
endif;endif;
endprocesss110;
--------------------------------------------秒个位
s220:
process(clk)
begin
ifclk'eventandclk='1'then
ifsec2="1001"then
sec2<="0000";
elsesec2<=sec2+1;
endif;
endif;
endprocesss220;
-------------------------------------------时间设置小时部分
sethour1:
process(clk,seth2)
begin
ifclk'eventandclk='1'then
ifseth1="0010"andseth2="0011"then
seth1<="0000";
elsifseth2="1001"then
seth1<=seth1+1;
endif;
endif;
endprocesssethour1;
sethour2:
process(clk,md1,md2,seth1)
begin
ifclk'eventandclk='1'then
if(seth1="0010"andseth2="0011")orseth2="1001"then
seth2<="0000";
elsifmd1='1'andmd2="00"thenseth2<=seth2+1;
endif;
endif;
endprocesssethour2;
-------------------------------------------时间设置分钟部分
setmin1:
process(clk,setm2)
begin
ifclk'eventandclk='1'then
ifsetm1="0101"andsetm2="1001"then
setm1<="0000";
elsifsetm2="1001"then
setm1<=setm1+1;
endif;
endif;
endprocesssetmin1;
setmin2:
process(clk,md1,md2)
begin
ifclk'eventandclk='1'then
ifsetm2="1001"then
setm2<="0000";
elsifmd1='1'andmd2="01"thensetm2<=setm2+1;
endif;
endif;
endprocesssetmin2;
--------------------------------------------闹铃
speaker:
process(clk,hou1,hou2,min1,min2)
begin
ifclk'eventandclk='1'then
ifseth1=hou1andseth2=hou2andsetm1=min1andsetm2=min2then
clken<='1';elseclken<='0';
endif;
endif;
endprocessspeaker;
disp:
process(md1,hou1,hou2,min1,min2,sec1,sec2,seth1,seth2,setm1,setm2)
begin
ifmd1='0'then---------------计时时间显示和设置模式
h1<=hou1;h2<=hou2;
m1<=min1;m2<=min2;
s1<=sec1;s2<=sec2;
else-----------闹铃时间显示和设置模式
h1<=seth1;h2<=seth2;
m1<=setm1;m2<=setm2;
s1<="1111";s2<="1111";
endif;
endprocessdisp;
endone;
第四章实验仿真结果与分析
本实验是以md1和md2为控制整个闹钟的校时,校分,校闹钟时、分,分别将md1,md2[0],md2[1],送到实验上的三个键,由这三个键来控制整个校时,校分,校闹钟时,校闹钟分的过程。
当计数的时,分和闹钟所事先设置时、分相等时,就产生蜂鸣。
当md1=1,md2=00,闹钟校分闹钟时个位和时十位会以二十四进制循环自动增加。
仿真波形见图2。
.
图2闹钟校分闹钟时仿真波形图
当md1=0,md2=00时对时钟进行校时,时个位和时十位会以二十四进制循环自动增加。
仿真波形见图3。
图3时钟校时仿真波形
当md1=0,md2=10和md1=0,md2=11时是正常计时秒从零开始计时,每秒加一,当到达五十九在来一个脉冲后,秒十位和秒个位清零,从零开始直到六十一直循环,并且向分个位清零;分位的原理同秒的一样;而时与秒,分的不同之处是,当时计数到二十三时清零并且不向任何位进位。
仿真波形见图4:
图4正常计时仿真波形
当md1=0,md2=01时是对进行校分,分个位和分十位会以六十进制循环增加,并且不对时进位。
仿真波形见图5:
图5时钟校分时仿真波形
md1=1,md2=01闹钟校时闹钟分个位和分十位会以六十进制循环增加,并且不对时进位。
仿真波形:
图6闹钟校时仿真波形
RTLviewer仿真图见图7.
图7RTLviewer仿真图
为验证所设计程序是否正确,将程序下载到FPGA器件中进行硬件测试。
在QuartusⅡ开发环境中进行管脚锁定,连接好数码管驱动电路,然后将目标文件下载到器件中。
最终可以看到时、分、秒正常显示。
(由于译码器功能实现不足,实际中并没有真实看到现象,但通过原理很容易推出)。
引脚分配如图8所示。
图8引脚分配图
心得体会:
通过这次课程设计使我懂得了理论与实际相结合是很重要的,只有把所学的理论知识与实践相结合起来,从理论中得出结论,才能提高自己的实际动手能力。
在设计的过程中,可以说得是困难重重,但每次仔细分析再加上同学的帮助还是能克服,同时在设计的过程中发现了自己的不足之处。
参考文献
1、阎石主编.《数字电子技术基础》(第五版).高等教等育出版社;
2、潘松黄继业主编《EDA技术实用教程》(第2版).科学出版社.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数字 闹钟 设计
![提示](https://static.bdocx.com/images/bang_tan.gif)