基于vhdl的多功能数字钟设计报告.doc

上传人:F****n 文档编号:98878330 上传时间:2019-09-15 格式:DOC 页数:14 大小:551.50KB
返回 下载 相关 举报
基于vhdl的多功能数字钟设计报告.doc_第1页
第1页 / 共14页
基于vhdl的多功能数字钟设计报告.doc_第2页
第2页 / 共14页
基于vhdl的多功能数字钟设计报告.doc_第3页
第3页 / 共14页
基于vhdl的多功能数字钟设计报告.doc_第4页
第4页 / 共14页
基于vhdl的多功能数字钟设计报告.doc_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《基于vhdl的多功能数字钟设计报告.doc》由会员分享,可在线阅读,更多相关《基于vhdl的多功能数字钟设计报告.doc(14页珍藏版)》请在金锄头文库上搜索。

1、基于VHDL的多功能数字钟设计报告班卫时章一、设计要求1、具有以二十四小时制计时、显示、整点报时、时间设置和闹钟的功能。2、设计精度要求为1秒。二、设计环境:Quartus II 三、系统功能描述1、系统输入:时钟信号clk采用50MHz;系统状态及较时、定时转换的控制信号为k、set,校时复位信号为reset,均由按键信号产生。2、系统输出:LED显示输出;蜂鸣器声音信号输出。3、多功能数字电子钟系统功能的具体描述如下:(一)计时:正常工作状态下,每日按24h计时制计时并显示,蜂鸣器无声,逢整点报时。(二)校时:在计时显示状态下,按下“k”键,进入“小时”待校准状态,若此时按下“set”键,

2、小时开始校准;之后按下“k”键则进入“分”待校准状态;继续按下“k”键则进入“秒”待复零状态;再次按下“k”键数码管显示闹钟时间,并进入闹钟“小时”待校准状态;再次按下“k”键则进入闹钟“分”待校准状态;若再按下“k”键恢复到正常计时显示状态。若校时过程中按下“reset”键,则系统恢复到正常计数状态。(1)“小时”校准状态:在“小时”校准状态下,显示“小时”的数码管以2Hz闪烁,并按下“set”键时以2Hz的频率递增计数。(2)“分”校准状态:在“分”校准状态下,显示“分”的数码管以2Hz闪烁,并按下“set”键时以2Hz的频率递增计数。(3)“秒”校准状态:在“秒复零”状态下,显示“秒”的

3、数码管以2Hz闪烁,并以1Hz的频率递增计数。(4)闹钟“小时”校准状态:在闹钟“小时”校准状态下,显示“小时”的数码管以2Hz闪烁,并按下“set”键时以2Hz的频率递增计数。(5)闹钟“分”校准状态:在闹钟“分”校准状态下,显示“分”的数码管以2Hz闪烁,并按下“set”键时以2Hz的频率递增计数。(三)整点报时:蜂鸣器在“59”分钟的第“51”、“53”、“55”、“57”秒发频率为500Hz的低音,在“59”分钟的第“59”秒发频率为1000Hz的高音,结束时为整点。(四)显示:采用扫描显示方式驱动4个LED数码管显示小时、分,秒由两组led灯以4位BCD 码显示。(五)闹钟:闹钟定时

4、时间到,蜂鸣器发出频率为1000Hz的高音,持续时间为60秒。四、各个模块分析说明1、分频器模块(freq.vhd)(1)模块说明:输入一个频率为50MHz的CLK,利用计数器分出1KHz的q1KHz,500Hz的q500Hz,2Hz的q2Hz和1Hz的q1Hz。(2) 源程序:library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;entity freq is port (CLK: in std_logic ; -输入时钟信号 q1KHz: buffer std_logic; q500Hz: buf

5、fer std_logic; q2Hz: buffer std_logic; q1Hz: out std_logic);end freq; architecture bhv of freq is beginP1KHZ:process(CLK)variable cout:integer:=0;begin if CLKevent and CLK=1 then cout:=cout+1; -每来个时钟上升沿时cout开始计数if cout=25000 then q1KHz=0; -当cout=25000时,q1KHz输出“0” elsif cout50000 then q1KHz=1; -当2500

6、0cout=50000时,q1KHz else cout:=0; -输出“1”,完成1KHz频率输出end if; end if; end process;P500HZ:process(q1KHz) -q1KHz作为输入信号,分出q500Hzvariable cout:integer:=0;beginif q1KHzevent and q1KHz=1 thencout:=cout+1;if cout=1 then q500Hz=0; -二分频 elsif cout=2 then cout:=0;q500Hz=1;end if; end if; end process;P2HZ:process(

7、q500Hz)variable cout:integer:=0;beginif q500Hzevent and q500Hz=1 thencout:=cout+1;if cout=125 then q2Hz=0; elsif cout250 then q2Hz=1; else cout:=0;end if; end if; end process;P1HZ:process(q2Hz)variable cout:integer:=0;beginif q2Hzevent and q2Hz=1 thencout:=cout+1;if cout=1 then q1Hz=0; elsif cout=2

8、then cout:=0;q1Hz=1;end if; end if; end process;end bhv;(3)模块图:2、控制器模块(contral.vhd)(1)模块说明:输入端口k,set键来控制6个状态,这六个状态分别是:显示计时时间状态,调计时的时、分、秒的3个状态,调闹铃的时、分的3个状态,reset键是复位键,用来回到显示计时时间的状态。(2) 波形仿真图:(3) 模块图:3、 二选一模块(mux21a.vhd)(1)源程序:library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;

9、entity mux21a isport(a,b,s:in bit; y:out bit);end entity mux21a;architecture one of mux21a isbegin process(a,b,s)beginif s=0 then y=a; -若s=0,y输出a,反之输出b。else y=b;end if;end process;end architecture one;(2)仿真波形图:(3) 模块图:4、 计时模块a. 秒计时(second.vhd)(1)仿真波形图:(2)模块图:b.分计时(minute.vhd)(1)仿真波形图:(2)模块图:c.小时计时(h

10、our.vhd)(1)仿真波形图:(2)模块图:d.闹钟分计时(cntm60b.vhd)(1)仿真波形图:(2)模块图:e.闹钟小时计时(cnth24b.vhd)(1)仿真波形图:(2)模块图:5、闹钟比较模块(compare.vhd)(1)模块说明:比较正常计数时间与闹钟定时时间是否相等,若相等,compout输出“1”,反之输出“0”。(2)仿真波形图:(3)模块图:6、报时模块(bell.vhd)(1)模块说明:该模块既实现了整点报时的功能,又实现了闹铃的功能,蜂鸣器通过所选频率的不同,而发出不同的声音。(2)仿真波形图:(3)模块图:7、控制显示模块(show_con.vhd)(1)模

11、块说明:该模块实现了数码管既可以显示正常时间,又可以显示闹钟时间的功能;调时过程的定时闪烁功能也在此模块中真正实现。(2)源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity show_con is port(th1,tm1,ts1:in std_logic_vector(7 downto 4); th0,tm0,ts0:in std_logic_vector(3 downto 0); bh1,bm1:in std_logic_vector(7 downto 4); bh0,bm0

12、:in std_logic_vector(3 downto 0); sec1,min1,h1: out std_logic_vector(7 downto 4); sec0,min0,h0: out std_logic_vector(3 downto 0); q2Hz,flashs,flashh,flashm,sel_show:in std_logic);end show_con;architecture rtl of show_con isbeginprocess(th1,tm1,ts1,th0,tm0,ts0,bh1,bm1,bh0,bm0,q2Hz,flashs,flashh,flash

13、m,sel_show) begin if sel_show=0then if ( flashh=1and q2Hz=1)then h1=1111;h0=1111; -显示小时数码管以2Hz闪烁 min1=tm1;min0=tm0; sec1=ts1;sec0=ts0; elsif (flashm=1and q2Hz=1)then h1=th1;h0=th0; min1=1111;min0=1111; sec1=ts1;sec0=ts0; elsif (flashs=1and q2Hz=1)then h1=th1;h0=th0; min1=tm1;min0=tm0; sec1=1111;sec0=1111; else h1=th1;h0=th0; min1=tm1;min0=tm0; sec1=ts1;sec0=ts0; end if; elsif sel_show=1then-若sel_show为“1”,数码管显示闹钟时间 if(flashh=1 and q2Hz=1)then h1=

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 教学/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号