vhl课程设计电子钟闹铃_第1页
vhl课程设计电子钟闹铃_第2页
vhl课程设计电子钟闹铃_第3页
vhl课程设计电子钟闹铃_第4页
vhl课程设计电子钟闹铃_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

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

文档简介

1、、系统功能概述一)、系统实现的功能:1、具有“时”、“分”、“秒”的十进制数字显示(小时从00 23)。2、具有手动校时、校分、校秒的功能。3、有定时和闹钟功能,能够在设定的时间发出闹铃声。的信号,4、能进行整点报时。从 59分 50秒起,每隔 2秒发一次低音“嘟”连续 5 次,最后一次为高音“嘀”的信号。二)、各项设计指标: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 为闹铃模块提供时钟,处理后能产生“嘟” 、“嘀”和变化key_sltsec_set 、的闹铃声音; clk_1hz 为计时模块提供时钟信号,每秒计数一次; 选择设置对象: 定时或正常时间; key_a

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

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

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

6、信号二分频产生的高低音,并组合,能输出三种声音状态嘟”、“嘀”、闹铃。而该三种声音要被秒、分、时的输出触发才能输出PWM。(二)系统各个模块的VHDL程序:(1)、CNT60_A_SE模块:程序源代码如下: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_cl

7、k: in std_logic;-1:alarm0:clk- 设置模式选择:闹铃调节模式、时间调节模式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 is

8、 signal 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);signal clk1,clk2,tclk,aclk,ac_slt: std_logic;begin process(alarm_clk) - 当 该端口输入一个脉冲时,修改设置模式:时间调整或闹铃模式 切换beginif alarm_clkev

9、ent and alarm_clk=1 thenif ac_slt=0 then-如果为定时模式,将改为闹铃模式ac_slt=1;elseac_slt=0;end if;end if;end process;process(key,clk,ac_slt)-根据设置模式,处理 key 上的脉冲信号beginif 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, 产生一个高电平,添加一脉冲

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

11、e works at high voltageif qout2_l=1001 and qout2_h=0101 thenqout2_l=0000;-afull mode is completed and acarryout is generatedqout2_h=0000;elsif qout2_l=1001 thenqout2_l=0000;qout2_h=qout2_h+1;elseqout2_l=qout2_l+1;- in process of countingend if;end process;end if;end if;process(aclk,clr,enb)-修改闹铃的定时值

12、beginif clr=1 then-clearing works at the state of high voltagealarm_l=0000;alarm_h=0000;elsif aclkevent and aclk=1 thenif enb=1 then-enable works at high voltageif alarm_l=1001 and alarm_h=0101 thenalarm_l=0000;-afull mode is completed and acarryout is generatedalarm_h=0000;elsif alarm_l=0101 thenal

13、arm_l=0000;alarm_h=alarm_h+1;elsealarm_l=alarm_l+1;- in process of countingend if;产生进位 , 显end if;process(qout2_l,qout2_h,alarm_l,alarm_h,alarm_clk)-示时间或闹铃定时值end if;end process;beginif qout2_l=0000 and qout2_h=0000 thenco=1;elseco=0;end if;if ac_slt=0 then -显示时间qout_sl=qout2_l;qout_sh=qout2_h;else显示定

14、时值qout_sh=alarm_h;qout_sl=alarm_l;end if;end process;process(qout2_l,qout2_h) -根据秒的状态输出“嘟” 、“嘀”触发信号beginif qout2_h=0101 thenif qout2_l=0000 thenout_do=1;elsif qout2_l=0010 thenout_do=1;elsif qout2_l=0100 thenout_do=1;elsif qout2_l=0110 thenout_do=1;elsif qout2_l=1000 thenout_do=1;elseout_do=0;end if

15、;elsif qout2_h=0000 thenif qout2_l=0000 thenout_di=1;out_do=0;elseout_di=0;end if;elseout_do=0;out_di=0;end;(2)、CNT60_A_Mir模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cnt60_a_min isport(clk,clr,enb: in std_logic; -clk:时钟输入信号,clr :清零端,enb:使能端key: in std_logic; -

16、输入按键脉冲,调整闹铃定时或时间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:out std_logic;-闹铃触发信号,时间到后输出高电平触发闹铃out_do,out_di: out std_logic- 在整点报时中输出“嘟”

17、“嘀”触发信);end;architecture a of cnt60_a_min is signal 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);signal clk1,clk2,tclk,aclk,ac_slt: std_logic;beginprocess(alarm_clk) -当 该端口输入一个

18、脉冲时,修改设置模式:时间调整或闹铃模式 切换beginif alarm_clkevent and alarm_clk=1 thenif ac_slt=0 then-如果为定时模式,将改为闹铃模式ac_slt=1;elseac_slt=0;end if;end if;end process;process(key,clk,ac_slt) -根据设置模式,处理 key 上的脉冲信号beginif ac_slt=0 then -时间调整模式aclk=0;if clk=1 and key=1 then-clk=1则 tclk=0 ,通过挖洞方式添加一个脉冲tclk=0;则 tclk=1, 产生一个高

19、elsif clk=0 and key=1 then-clk=0,电平,添加一脉冲tclk=1;elsetclk=clk;end if;elsif ac_slt=1 then -闹铃调整模式tclk=clk;aclk=key; -key上的脉冲直接修改闹铃定时值end if;end process;process(tclk,clr,enb)-60 进制计数,个位、十位放在两个临时变量中,表示分的状态beginif clr=1 then-clearing works at the state of high voltageqout2_l=0000;qout2_h=0000;elsif tclke

20、vent and tclk=1 thenif enb=1 then-enable works at high voltageif qout2_l=1001 and qout2_h=0101 thenqout2_l=0000;-afull mode is completed and acarryout is generatedqout2_h=0000;elsif qout2_l=1001 thenqout2_l=0000;qout2_h=qout2_h+1;elseqout2_l=qout2_l+1;- in process of countingend if;end if;end if;end

21、 process;process(aclk,clr,enb) -修改闹铃的定时值beginif clr=1 then-clearing works at the state of high voltagealarm_l=0000;alarm_h=0000;elsif aclkevent and aclk=1 thenif enb=1 then-enable works at high voltageif alarm_l=1001 and alarm_h=0101 thenalarm_l=0000;-afull mode is completed and acarryout is generat

22、edalarm_h=0000;elsif alarm_l=0101 thenalarm_l=0000;alarm_h=alarm_h+1;elseend if;end if;end if;end process;alarm_l=alarm_l+1;- in process of countingprocess(qout2_l,qout2_h,alarm_l,alarm_h,alarm_clk) -产生进位 , 显示时间或闹铃定时值 of high voltagebeginif qout2_l=0000 and qout2_h=0000 thenco=1;elseco=0;end if;if a

23、c_slt=0 thenqout_ml=qout2_l;qout_mh=qout2_h;elseqout_mh=alarm_h;qout_ml=alarm_l;end if;end process;process(qout2_l,qout2_h,alarm_l,alarm_h)-判断定时值与时间值相等,输出闹铃触发信号beginif qout2_l=alarm_l and qout2_h=alarm_h thenout_alarm=1;elseout_alarm=0;end if;end process;process(qout2_l,qout2_h) -根据分的状态输出“嘟” 、“嘀”触发信

24、号beginif qout2_l=1001 and qout2_h=0101 thenout_do=1;elseout_do=0;end if;if qout2_l=0000 and qout2_h=0000 thenout_di=1;elseout_di=0;end if;end process;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; -

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

26、 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 downto 0);signal alarm_h:std_logic_vector(3 downto 0);signal clk1,clk2,tclk,aclk,ac_slt: std_logic;begin process(alarm_clk) - 当 该端口输入一个脉冲时,修改设置模式:时间调整或闹铃模式 切

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

28、then-clk=0,电平,添加一脉冲tclk=1;elsetclk=clk;end if;elsif ac_slt=1 then -闹铃调整模式tclk=clk;aclk=key; -key上的脉冲直接修改闹铃定时值end if;end process;process(tclk,clr,enb)-24 进制计数,个位、十位放在两个临时变量中, 表示时的状态beginif clr=1 then-clearing works at the state of high voltageqout2_l=0000;qout2_h=0000;elsif tclkevent and tclk=1 theni

29、f enb=1 then-enable works at high voltageif qout2_l=1001 thenqout2_l=0000;-afull mode is completed and acarryout is generatedqout2_h=qout2_h+1;elsif qout2_l=0011 and qout2_h=0010 thenqout2_l=0000;qout2_h=0000;elseqout2_l=qout2_l+1;- in process of countingend if;end if;end if;end process;process(aclk

30、,clr,enb) -修改闹铃的定时值beginif clr=1 then-clearing works at the state of high voltagealarm_l=0000;alarm_h=0000;elsif aclkevent and aclk=1 thenif enb=1 then-enable works at high voltageif alarm_l=1001 thenalarm_l=0000;-afull mode is completed and acarryout is generatedalarm_h=qout2_h+1;elsif alarm_l=0011

31、 and alarm_h=0010 thenalarm_l=0000;alarm_h=0000;elsealarm_l=alarm_l+1;- in process of countingend if;end if;end if;产生进位 , 显end process;process(qout2_l,qout2_h,alarm_l,alarm_h,alarm_clk) -示时间或闹铃定时值 of high voltage beginif qout2_l=0000 and qout2_h=0000 thenco=1;elseco=0;end if;if ac_slt=0 thenqout_hl=

32、qout2_l;qout_hh=qout2_h;elseqout_hh=alarm_h;qout_hl=alarm_l;end if;end process;定时值与时间值相等,则process(qout2_l,qout2_h,alarm_l,alarm_h)-输出闹钟触发信号beginif qout2_l=alarm_l and qout2_h=alarm_h thenout_alarm=1;elseout_alarm=0;end if;end process;end;2、系统以及各个模块的仿真波形1)、系统仿真波形:注:由于下面的模块仿真存在毛刺,导致系统的仿真图有一定的问题。(2) 、C

33、NT60_A_SE模块:注:在 50、 52、 54、 56、 58 处有嘟触发输出, 00处有嘀触发输出等。(3) 、CNT60_A_Mir模块:注:本图展示了按键调节时间值和定时值的仿真波形(部分仿真图)注:该模块的仿真波形图,具有嘟、嘀声音触发输出,定时与时间相等时有闹铃触发输出等。(4) 、CNT24_A_HOUR块注:该模块的仿真图,包含按键调整时间、定时值,闹钟触发输出等。(5)、PWM_OU模块(分三段剪切下来的,展示了三种声音的效果)(1)、“嘟”、“嘀”输出波形(只有在 en有脉冲,打幵PWM后,才有效)注:在打幵输出后,当两路嘟、嘀触发输入同时有效时分别输出嘟、嘀声音。当两路闹铃触发同时有效时幵始闹铃声音的输出。注:闹铃输出的变化情况(“嘀”、“嘟”交替发声)注:闹铃输出的变化情况。3、下载时选择的幵发系统模式以及管脚定义表1 GW48-CK开发系统工作模式:3接口名称类型(输入/输出)结构图上的信号名引脚号说明

温馨提示

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

最新文档

评论

0/150

提交评论