EDA课程设计多功能数字钟.doc_第1页
EDA课程设计多功能数字钟.doc_第2页
EDA课程设计多功能数字钟.doc_第3页
EDA课程设计多功能数字钟.doc_第4页
EDA课程设计多功能数字钟.doc_第5页
已阅读5页,还剩7页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

多功能数字钟 【摘要】运用EDA知识,利用QuartusII制作数字钟。数字钟由分频模块,计数模块、显示模块、报时模块等几部分构成,数字钟的时、分、秒由一个24进制计数器(00-23),两个60进制计数器(00-59)级联构成。以10进制计数器74160来实现时间计数单元的计数功能。利用一片7447,采用分时复用方式,连接LED数码管显示。【关键词】VHDL 数字钟 Quartus11.0 校时Design of multi-functional digital clockAbstract:Inthisstudy,MultifunctiondigitalclockonthedesignandsimulationthroughUsingQuartus2software;downloadedtotheFPGAafterSuccessfulsimulation,clockdisplayontheled;achievetherequiredfunctionsthroughreusingswitchmainmodulesare:dynamicdisplaycircuit,Settheclockhours,themusiccircuit,keypadcircuit;featuresinclude:clockdisplay,alarmclockandhourlychime。Keywords:EDA、VHDL、QuartusII、DigitalClock引言EDA技术是一门迅速发展的新技术,涉及面广,内容丰富。利用EDA技术进行电子系统设计具有很多特点。EDA将大量的电路功能集成到一个芯片中,并且可以由用户自行设计逻辑功能,提高了系统的集成度和可靠性。运用EDA技术可以方便、快捷设计电路系统。 本文基于EDA系统,在Quartus II 11.0软件平台上,完成了多功能数字钟电路的设计。采用VHDL硬件描述语言描述数字钟电路,完成对电路的功能仿真。在设计过程中,重点探讨了数字钟电路的设计思路和功能模块划分,通过分析仿真波形表明设计的本电路完成了预期的功能。1 多功能数字钟工作原理1.1 多功能数字钟系统原理本多功能数字钟由计数模块、控制模块、报时控制模块以及显示模块构成,顶层系统框图如图1.1所示。计数控制模块RESET图1.1 多功能数字钟系统顶层框图分时蜂鸣器输出CLK调时调分报时控制 秒清零各模块电路功能如下:1)秒计数器、分计数器、时计数器组成最基本的数字钟,其计数输出送7段译码电路由数码管显示。2)基准频率分频器可分频出标准的1Hz频率信号,用于秒计数的时钟信号;分频出4HzZ频率信号,用于校时、校分的快速递增信号;分频出64Hz频率信号,用于对按动“校时”,“校分”按键的消除抖动。1.2工作原理数字钟的计时周期为24小时,显示满刻度为23时59分59秒,另外具备校时功能和报时功能。因此,一个基本的数字钟主要由“时”“分”“秒”计数器校时电路组成。将标准信号送入“秒计数器”,“秒计数器”采用60进制计数器,每累加60 秒发送一个“分脉冲”信号,该信号将被送到“时计数器”,“时计数器”采用24进制计数器,可实现对一天24 小时的累计。译码显示电路将“时”“分”“秒”计数器的输出状态六段显示译码器译码。通过六位LED七段显示器显示出来。校时电路是用来对“时”“分”显示数字进行校时调整的。1.3 多功能数字钟结构框图本多功能数字钟硬件结构主要由分频器,时、分、秒计数器及译码器,时、分、秒显示部分,整点报时电路模块,校时模块构成。其中,显示模块采用六位七段数码管,报时模块采用蜂鸣器。多功能数字钟结构框图如图1.2所示。图1.2 多功能数字钟结构框图图1.2 多功能数字钟结构框图图1.2 多功能数字钟结构框图2 顶层原理图系统顶层原理图如图2.1所示。图2.1 系统顶层原理图时序仿真:程序仿真主要由计数器完成,在时钟脉冲作用下,完成始终功能,由时序图可以看出每个时钟上升沿到来时加一,当接受到REST信号,即REST为高电平,所有计数为零,并重新计数,SETMIN 和SETHOUR可以完成调节时钟功能,都是高电平调节,每来一个脉冲,相应的时或分加1。时序仿真图如图2.2所示。图2.2 时序仿真图3 数字钟计时模块设计时计时器为一个24进制计数器,分、秒计时器均为60进制计数器。当秒计时器接受到一个秒脉冲时,秒计数器开始从1计数到60,此时秒显示器将显示00、01、02、.、59、00;每当秒计数器数到00时,就会产生一个脉冲输出送至分计时器,此时分计数器数值在原有基础上加1,其显示器将显示00、01、02、.、59、00;每当分计数器数到00时,就会产生一个脉冲输出送至时计时器,此时时计数器数值在原有基础上加1,其显示器将显示00、01、02、.、23、00。即当数字钟运行到23点59分59秒时,当秒计时器在接受一个秒脉冲,数字钟将自动显示00点00分00秒。3.1 时计数模块时计数模块:时计数,在分进位信号为高电平时,计数一次,以24次为一个循环时计数模块就是一个2位10进制计数器,记数到23清零。时计数模块原理图如图3.1所示。VHDL的RTL描述如下:图3.1 时计数器原理图时计数;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cnt_h is port(en,clk,clr:in std_logic; dout:out std_logic_vector(7 downto 0); c:out std_logic);end cnt_h;architecture rtl of cnt_h issignal t:std_logic_vector(7 downto 0);begin process(en,clk,clr) variable t:std_logic_vector(7 downto 0); begin if en=1 then if clk event and clk=1 then t:=t+1; if t(3 downto 0)=XA then t(7 downto 4):=t(7 downto 4)+1; t(3 downto 0):=X0; end if; if tX23 then t:=X00; end if; end if; if clr=1 then t:=X00; end if; end if; dout=t; end process;end rtl;时计数器模块仿真波形如图3.2所示。经观察仿真波形可知,本模块设计实现了23进制的时计数功能。 图3.2 时计数器仿真波形3.2 分计数模块分计数模块:分计数,在秒进位信号为高电平时,计数一次,以60次为一个循环计数,同时产生分进位信号影响时计数;分计数模块原理图如图3.3,CLK和RESET控制DAOUT,SEHOUR控制ENHOUR。 分计数;library ieee;图3.3 分计数原理图use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fenz isport (reset,clk,sethour,clk1: in std_logic;daout: out std_logic_vector(6 downto 0);enhour:buffer std_logic);end;architecture two of fenz issignal d:std_logic_vector(6 downto 0);signal enhour1,enhour2:std_logic;beginprocess(clk,clk1,reset,sethour)beginif reset=1then d=0000000;elsif (clkevent and clk=1) thenif d16#60# thenif d=1011001 thend=0000000;enhour1=1;else d=d+1;enhour1=0;if d(3 downto 0)=1001 then d=d+7;end if;end if;end if; end if; end process;daout=d;enhour=(enhour1 or enhour2);enhour2=(sethour and clk1);end;分计数器模块仿真图如图3.4所示。经观察波形可知,分计数器模块实现了60进制计数功能。图3.4 分计数器仿真结果3.3秒计数器模块秒计数模块:秒计数,在频率为1HZ的时钟下以60次为循环计数,并产生进位信号影响分计数;秒计数器模块原理图如图3.5所示,CLK和RESET控制DAOUT,SETIME和CLK控制ENMIN。 图3.5 秒计数器原理图秒计数;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity miao1 isport (clk,reset,setmin: in std_logic;daout: out std_logic_vector(6 downto 0);enmin:buffer std_logic);end;architecture two of miao1 issignal d:std_logic_vector(6 downto 0);signal enmin1,enmin2:std_logic;beginprocess(clk,reset,setmin)beginif reset=1then d=0000000;elsif (clkevent and clk=1) thenif d16#60# thenif d=1011001 thend=0000000;enmin1=1;else d=d+1;enmin1=0;if d(3 downto 0)=1001 then d=d+7;end if;end if;end if; end if; end process;daout=d;enmin=(enmin1 or enmin2);enmin2=(setmin and clk);end;秒计数器仿真波形如图3.6所示。 图3.6 秒计数器仿真波形3.5 分频模块图3.7 分频电路原理图分频模块原理图如图3.7所示。分频;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity FENP isport(clk1:in std_logic;clk:out std_logic);end;architecture one of FENP issignal a:std_logic_vector(8 downto 0);signal b,c:std_logic;beginprocess(clk1)beginif clk1event and clk1=1 thenif a=100000000 thenb=1;a=000000000;elsea=a+1;b=0;end if;end if;end process;clk=b;end;分频电路仿真图如图3.8所示。图3.8 分频电路仿真图4 显示模块显示部分利用六位七段数码管进行时、分、秒的显示。显示模块的原理图如图4.1,当SEL取不同值时DAOUT分别选择输出SEC .MIN .HOUR。显示; 图4.1 显示模块原理图library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity xians isport(clk2,reset:in std_logic;miao1,fenz:in std_logic_vector(6 downto 0);hour :in std_logic_vector(5 downto 0);daout:out std_logic_vector(3 downto 0);sel:out std_logic_vector(2 downto 0);end;architecture one of xians issignal q: std_logic_vector(2 downto 0);beginprocess(clk2,reset,miao1,fenz,hour)beginif reset=1thenq=000;elsif (clk2event and clk2=1) then q=q+1;end if;end process;process(q,reset)beginif reset=1thendaout=0000;elsecase q iswhen 101=daout=miao1(3 downto 0);when 100=daout(2 downto 0)=miao1(6 downto 4);daout(3)=0;when 011=daout=fenz(3 downto 0);when 010=daout(2 downto 0)=fenz(6 downto 4);daout(3)=0;when 001=daout=hour(3 downto 0);when 000=daout(1 downto 0)=hour(5 downto 4);daout(3 downto 2)=00;when others=null;end case; end if; end process;sel=q;end;显示模块仿真波形如图4.2所示。 图4.2 显示模块波形图5 七段数码管驱动模块本数字钟显示模块采用七段共阳极数码管,故需要对数码管进行显示的驱动。数码管驱动模块原理图如图5.1所示。数码管驱动;ibrary ieee;use ieee.std_logic_1164.all; 图5.1 驱动模块原理图use ieee.std_logic_unsigned.all;entity qiduan isport(q: in std_logic_vector(3 downto 0);sel: in std_logic_vector(2 downto 0);y: out std_logic_vector(6 downto 0);end;architecture rt1 of qiduan issignal d: std_logic_vector(3 downto 0);beginprocess(sel)begincase sel iswhen 000=d=q;when 001=d=q;when 010=d=q;when 011=d=q;when 100=d=q;when 101=d=q;when others=null;end case; end process;process(d)begincase d iswhen 0000=y=0111111;when 0001=y=0000110;when 0010=y=1011011;when 0011=y=1001111;when 0100=y=1100110;when 0101=y=1101101;when 0110=y=1111101;when 0111=y=0000111;when 1000=y=1111111;when 1001=y=1101111;when others=null;end case;end process;end;仿真波形如图5.2。 图5.2 仿真结果6 报时模块本数字钟具有整点报时功能,电路在整点前10秒钟内开始整点报时,即当时间在59分50秒到59分59秒期间时,报时模块电路产生报时控制信号,使蜂鸣器发声。报时模块原理图如下,当DAIN为0的时候SPEAK发声。图6.1 报时模块原理图报时模块;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity baos isport (clk: in std_logic;dain: in std_logic_vector(6 downto 0);speak:out std_logic;camp:out std_logic_vector(2 downto 0);end;architecture two of baos issignal a:std_logic_vector( 2 downto 0);beginprocess(clk)beginif (clkevent and clk=1) thenif dain=0000000 thena=a+1;case a iswhen 001= camp=001;wh

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论