ImageVerifierCode 换一换
格式:DOCX , 页数:28 ,大小:157.65KB ,
资源ID:20149434      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/20149434.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(vhdl闹钟电子钟.docx)为本站会员(b****1)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

vhdl闹钟电子钟.docx

1、vhdl闹钟电子钟数字电路课程设计院系: 电信学院专业: 姓名: 学号: 200982083 完成日期:2011-12-24数字钟的设计一、系统功能概述(一)、系统实现的功能:1、具有“时”、“分”、“秒”的十进制数字显示(小时从00 23)。2、具有手动校时、校分、校秒的功能。3、有定时和闹钟功能,能够在设定的时间发出闹铃声。(二)、各项设计指标: 1、显示部分采用的6个LED显示器,从高位至低位分别显示时、分、秒。 2、有一个设置调闹钟定时时间、正常时间的按钮,选择调的对象。 3、有三个按钮分别调时、分、秒的时间。 4、有一个按钮用作开启/关闭闹铃。5、另外需要两个时钟信号来给系统提供脉冲

2、信号,使时钟和闹钟正常工作,分别为1Hz、1kHz的脉冲。二、系统组成以及系统各部分的设计1、系统结构描述 /要求:系统(或顶层文件)结构描述,各个模块(或子程序)的功能描述;(一) 系统的顶层文件:1、 顶层文件图:(见下页)2、 各模块的解释:(1)、7个输入量clk_1khz、clk_1hz、key_slt、key_alarm、sec_set、min_set、hour_set:其中clk_1khz为闹铃模块提供时钟,处理后能产生“嘟”、“嘀”和变化的闹铃声音;clk_1hz为计时模块提供时钟信号,每秒计数一次;key_slt选择设置对象:定时或正常时间;key_alarm能够开启和关闭闹

3、铃;sec_set、min_set、hour_set用于设置时间或定时,与key_slt相关联。各按键输出为脉冲信号。(2)、CNT60_A_SEC模块: 这个模块式将clk_1hz这个时钟信号进行60进制计数,并产生一个分钟的触发信号。该模块能将当前计数值实时按BCD码的格式输出。将该输出接到两位LED数码后能时时显示秒的状态。通过alarm_clk可以选择设置对象为时间还是定时值。在设置时间模式上,key上的一个输入脉冲可以将clk的输入信号加一。在设置定时模式上,key上的脉冲只修改定时值,不影响时间脉冲clk的状态。同时该模块具有两个输出口out_do、out_di来触发整点报时的“嘟

4、”、“嘀”声音。(3)、CNT60_A_MIN模块: 这个模块式将CNT60_A_SEC的输出信号进行60进制计数,并产生一个时位的触发信号。该模块能将当前计数值实时按BCD码的格式输出。将该输出接到两位LED数码后能时时显示分的状态。通过alarm_clk可以选择设置对象为时间还是定时值。在设置时间模式上,key上的一个输入脉冲可以将clk的输入信号加一。在设置定时模式上,key上的脉冲只修改定时值,不影响时间脉冲clk的状态。 同时该模块具有三个输出口out_do、out_di、out_alarm来触发整点报时的“嘟”、“嘀”、闹铃声音。(4)、CNT24_A_HOUR模块: 这个模块式将

5、CNT60_A_MIN的输出信号做24进制计数。该模块能将当前计数值实时按BCD码的格式输出。将该输出接到两位LED数码后能时时显示时的状态。通过alarm_clk可以选择设置对象为时间还是定时值。在设置时间模式上,key上的一个输入脉冲可以将clk的输入信号加一。在设置定时模式上,key上的脉冲只修改定时值,不影响时间脉冲clk的状态。同时该模块具有一个输出口out_alarm来触发整点报时的闹铃声音。(5)、PWM_OUT模块:该模块为PWM产生模块,通过EN可开启和关闭PWM输出。模块根据CLK信号二分频产生的高低音,并组合,能输出三种声音状态“嘟”、“嘀”、闹铃。而该三种声音要被秒、分

6、、时的输出触发才能输出PWM。(二) 系统各个模块的VHDL程序:(1)、CNT60_A_SEC模块: 程序源代码如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cnt60_a_sec isport( clk,clr,enb: in std_logic;-clk:时钟输入信号,clr:清零端,enb:使能端 key: in std_logic; -输入按键脉冲,调整闹铃定时或时间 alarm_clk: in std_logic;-1:alarm 0:clk -设置模式选择:闹铃

7、调节模式、时间调节模式 qout_sl: out std_logic_vector(3 downto 0); -显示输出秒的低位 qout_sh: out std_logic_vector(3 downto 0);-显示输出秒的高位 co: out std_logic; -进位输出,触发分计数模块 out_do: out std_logic;-在整点报时中输出“嘟”触发信号 out_di: out std_logic -在整点报时中输出“嘀”触发信号);end;architecture a of cnt60_a_sec issignal qout2_l:std_logic_vector(3 d

8、ownto 0);signal qout2_h:std_logic_vector(3 downto 0);signal alarm_l:std_logic_vector(3 downto 0);signal alarm_h:std_logic_vector(3 downto 0);signal clk1,clk2,tclk,aclk,ac_slt: std_logic;beginprocess(alarm_clk) -当该端口输入一个脉冲时,修改设置模式:时间调整或闹铃模式切换begin if alarm_clkevent and alarm_clk=1 then if ac_slt=0 th

9、en-如果为定时模式,将改为闹铃模式 ac_slt=1; else ac_slt=0; end if; end if;end process;process(key,clk,ac_slt)-根据设置模式,处理key上的脉冲信号begin if ac_slt=0 then -时间调整模式 aclk=0; if clk=1 and key=1 then -clk=1则tclk=0,通过挖洞方式添加一个脉冲 tclk=0; elsif clk=0 and key=1 then -clk=0,则tclk=1,产生一个高电平,添加一脉冲 tclk=1; else tclk=clk; end if; el

10、sif ac_slt=1 then -闹铃调整模式 tclk=clk; aclk=key; -key上的脉冲直接修改闹铃定时值 end if;end process;process(tclk,clr,enb) -60进制计数,个位、十位放在两个临时变量中,表示秒的状态begin if clr=1 then-clearing works at the state of high voltage qout2_l=0000; qout2_h=0000; elsif tclkevent and tclk=1 then if enb=1 then-enable works at high voltage

11、 if qout2_l=1001 and qout2_h=0101 then qout2_l=0000;-a full mode is completed and a carryout is generated qout2_h=0000; elsif qout2_l=1001 then qout2_l=0000; qout2_h=qout2_h+1; else qout2_l=qout2_l+1;- in process of counting end if; end if; end if;end process; process(aclk,clr,enb)-修改闹铃的定时值begin if

12、clr=1 then-clearing works at the state of high voltage alarm_l=0000; alarm_h=0000; elsif aclkevent and aclk=1 then if enb=1 then-enable works at high voltage if alarm_l=1001 and alarm_h=0101 then alarm_l=0000;-a full mode is completed and a carryout is generated alarm_h=0000; elsif alarm_l=0101 then

13、 alarm_l=0000; alarm_h=alarm_h+1; else alarm_l=alarm_l+1;- in process of counting end if; end if; end if;end process; process(qout2_l,qout2_h,alarm_l,alarm_h,alarm_clk)- 产生进位,显示时间或闹铃定时值begin if qout2_l=0000 and qout2_h=0000 then co=1; else co=0; end if; if ac_slt=0 then - 显示时间 qout_sl=qout2_l; qout_

14、sh=qout2_h; else - 显示定时值 qout_sh=alarm_h; qout_sl=alarm_l; end if;end process;process(qout2_l,qout2_h) - 根据秒的状态输出“嘟”、“嘀”触发信号begin if qout2_h=0101 then if qout2_l=0000 then out_do=1; elsif qout2_l=0010 then out_do=1; elsif qout2_l=0100 then out_do=1; elsif qout2_l=0110 then out_do=1; elsif qout2_l=10

15、00 then out_do=1; else out_do=0; end if; elsif qout2_h=0000 then if qout2_l=0000 then out_di=1; out_do=0; else out_di=0; end if; else out_do=0; out_di=0; end if;end process;end;(2)、CNT60_A_MIN模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cnt60_a_min isport( clk,c

16、lr,enb: in std_logic; -clk:时钟输入信号,clr:清零端,enb:使能端 key: in std_logic; -输入按键脉冲,调整闹铃定时或时间 alarm_clk: in std_logic; -1:alarm 0:clk -设置模式选择:闹铃调节模式、时间调节模式 qout_ml: out std_logic_vector(3 downto 0); -显示输出分的低位 qout_mh: out std_logic_vector(3 downto 0); -显示输出分的高位 co: out std_logic; -进位输出,触发时计数模块 out_alarm:ou

17、t std_logic;-闹铃触发信号,时间到后输出高电平触发闹铃 out_do,out_di: out std_logic-在整点报时中输出“嘟”“嘀”触发信号);end;architecture a of cnt60_a_min issignal qout2_l:std_logic_vector(3 downto 0);signal qout2_h:std_logic_vector(3 downto 0);signal alarm_l:std_logic_vector(3 downto 0);signal alarm_h:std_logic_vector(3 downto 0);signa

18、l clk1,clk2,tclk,aclk,ac_slt: std_logic;beginprocess(alarm_clk) -当该端口输入一个脉冲时,修改设置模式:时间调整或闹铃模式切换begin if alarm_clkevent and alarm_clk=1 then if ac_slt=0 then-如果为定时模式,将改为闹铃模式 ac_slt=1; else ac_slt=0; end if; end if;end process;process(key,clk,ac_slt) -根据设置模式,处理key上的脉冲信号begin if ac_slt=0 then -时间调整模式 a

19、clk=0; if clk=1 and key=1 then-clk=1则tclk=0,通过挖洞方式添加一个脉冲 tclk=0; elsif clk=0 and key=1 then-clk=0,则tclk=1,产生一个高电平,添加一脉冲 tclk=1; else tclk=clk; end if; elsif ac_slt=1 then -闹铃调整模式 tclk=clk; aclk=key; -key上的脉冲直接修改闹铃定时值 end if;end process; process(tclk,clr,enb) -60进制计数,个位、十位放在两个临时变量中,表示分的状态begin if clr

20、=1 then-clearing works at the state of high voltage qout2_l=0000; qout2_h=0000; elsif tclkevent and tclk=1 then if enb=1 then-enable works at high voltage if qout2_l=1001 and qout2_h=0101 then qout2_l=0000;-a full mode is completed and a carryout is generated qout2_h=0000; elsif qout2_l=1001 then qo

21、ut2_l=0000; qout2_h=qout2_h+1; else qout2_l=qout2_l+1;- in process of counting end if; end if; end if;end process; process(aclk,clr,enb) -修改闹铃的定时值begin if clr=1 then-clearing works at the state of high voltage alarm_l=0000; alarm_h=0000; elsif aclkevent and aclk=1 then if enb=1 then-enable works at

22、high voltage if alarm_l=1001 and alarm_h=0101 then alarm_l=0000;-a full mode is completed and a carryout is generated alarm_h=0000; elsif alarm_l=0101 then alarm_l=0000; alarm_h=alarm_h+1; else alarm_l=alarm_l+1;- in process of counting end if; end if; end if;end process; process(qout2_l,qout2_h,ala

23、rm_l,alarm_h,alarm_clk) - 产生进位,显示时间或闹铃定时值of high voltagebegin if qout2_l=0000 and qout2_h=0000 then co=1; else co=0; end if; if ac_slt=0 then qout_ml=qout2_l; qout_mh=qout2_h; else qout_mh=alarm_h; qout_ml=alarm_l; end if;end process;process(qout2_l,qout2_h,alarm_l,alarm_h) 判断定时值与时间值相等,输出闹铃触发信号begin

24、 if qout2_l=alarm_l and qout2_h=alarm_h then out_alarm=1; else out_alarm=0; end if;end process;process(qout2_l,qout2_h) - 根据分的状态输出“嘟”、“嘀”触发信号begin if qout2_l=1001 and qout2_h=0101 then out_do=1; else out_do=0; end if; if qout2_l=0000 and qout2_h=0000 then out_di=1; else out_di=0; end if;end process;

25、end;(3)、CNT24_A_HOUR模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cnt24_a_hour isport( clk,clr,enb: in std_logic; -clk:时钟输入信号,clr:清零端,enb:使能端 key: in std_logic; -输入按键脉冲,调整闹铃定时或时间 alarm_clk: in std_logic;-1:alarm 0:clk-设置模式选择:闹铃调节模式、时间调节模式 qout_hl: out std_logic_v

26、ector(3 downto 0); -显示输出时的低位 qout_hh: out std_logic_vector(3 downto 0); -显示输出时的高位 co: out std_logic; -进位输出 out_alarm:out std_logi-闹铃触发信号输出);end;architecture a of cnt24_a_hour issignal qout2_l:std_logic_vector(3 downto 0);signal qout2_h:std_logic_vector(3 downto 0);signal alarm_l:std_logic_vector(3 d

27、ownto 0);signal alarm_h:std_logic_vector(3 downto 0);signal clk1,clk2,tclk,aclk,ac_slt: std_logic;beginprocess(alarm_clk) -当该端口输入一个脉冲时,修改设置模式:时间调整或闹铃模式切换begin if alarm_clkevent and alarm_clk=1 then if ac_slt=0 then-如果为定时模式,将改为闹铃模式 ac_slt=1; else ac_slt=0; end if; end if;end process;process(key,clk,a

28、c_slt) -根据设置模式,处理key上的脉冲信号begin if ac_slt=0 then -时间调整模式 aclk=0; if clk=1 and key=1 then-clk=1则tclk=0,通过挖洞方式添加一个脉冲 tclk=0; elsif clk=0 and key=1 then-clk=0,则tclk=1,产生一个高电平,添加一脉冲 tclk=1; else tclk=clk; end if; elsif ac_slt=1 then -闹铃调整模式 tclk=clk; aclk=key; -key上的脉冲直接修改闹铃定时值 end if;end process; process(tclk,clr,enb) -24进制计数,个位、十位放在两个临时变量中,表示时的状态begin if clr=1 then-clearing works at the state of high voltage qout2_l=0000; qout2_h=0000; elsif tclkevent and tclk=1 then if enb=1 then-enable works at high volt

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1