根据VHDL的多功能数字钟设计报告_第1页
根据VHDL的多功能数字钟设计报告_第2页
根据VHDL的多功能数字钟设计报告_第3页
根据VHDL的多功能数字钟设计报告_第4页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

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

文档简介

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

2、,按下“k”键,进入“小时”待校准状态,若此时按下“set”键,小时开始校准;之后按下“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数码管显示小

4、时、分,秒由两组led灯以4位bcd 码显示。(五)闹钟:闹钟定时时间到,蜂鸣器发出频率为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 isport (clk: in std_logic ; -输入时钟信号q1khz:

5、 buffer std_logic;q500hz: buffer std_logic;q2hz: buffer std_logic;q1hz: out std_logic);end freq;architecture bhv of freq isbeginp1khz:process(clk)variable cout:integer:=0;beginif clkevent and clk=1 thencout:=cout+1; -每来个时钟上升沿时cout开始计数if coutelse cout:=0; -输出“1”,完成1khz频率输出end if;end if;end process;p5

6、00hz:process(q1khz) -q1khz作为输入信号,分出q500hz variable cout:integer:=0;beginif q1khzevent and q1khz=1 thencout:=cout+1;if cout=1 then q500hzelsif cout=2 then cout:=0;q500hzend if;end if;end process;p2hz:process(q500hz)variable cout:integer:=0;beginif q500hzevent and q500hz=1 thencout:=cout+1;if coutelsi

7、f coutelse 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 q1hzelsif cout=2 then cout:=0;q1hzend if;end if;end process;end bhv;(3)模块图:2、控制器模块(contral.vhd)(1)模块说明:输入端口k,set键来控制6个状态,这六个状态分别是:显示计时时间状态,调计时的时、分、秒的

8、3个状态,调闹铃的时、分的3个状态,reset键是复位键,用来回到显示计时时间的状态。(2)波形仿真图:(3)模块图: 3、二选一模块(mux21a.vhd)(1)源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity mux21a isport(a,b,s:in bit;y:out bit);end entity mux21a;architecture one of mux21a isbeginprocess(a,b,s)beginif s=0 thenyend if;end pr

9、ocess;end architecture one;(2)仿真波形图:(3)模块图: 4、计时模块 a.秒计时(second.vhd) (1)仿真波形图:(2)模块图:b.分计时(minute.vhd) (1)仿真波形图:(2)模块图:c.小时计时(hour.vhd) (1)仿真波形图:(2)模块图: d.闹钟分计时(cntm60b.vhd) (1)仿真波形图:(2)模块图:e.闹钟小时计时(cnth24b.vhd)(1)仿真波形图:(2)模块图:5、闹钟比较模块(compare.vhd)(1)模块说明:比较正常计数时间与闹钟定时时间是否相等,若相等,compout 输出“1”,反之输出“0

10、”。(2)仿真波形图: (3)模块图: 6、报时模块(bell.vhd)(1)模块说明:该模块既实现了整点报时的功能,又实现了闹铃的功能,蜂鸣器通过所选频率的不同,而发出不同的声音。(2)仿真波形图:(3)模块图:7、控制显示模块(show_con.vhd)(1)模块说明:该模块实现了数码管既可以显示正常时间,又可以显示闹钟时间的功能;调时过程的定时闪烁功能也在此模块中真正实现。(2)源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all; entity show_con is port(th1,

11、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: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_

12、logic);end show_con;architecture rtl of show_con isbeginprocess(th1,tm1,ts1,th0,tm0,ts0,bh1,bm1,bh0,bm0,q2hz,flashs,flashh,flashm,sel_sho w)beginif sel_show=0thenif ( flashh=1and q2hz=1)thenh1min1sec1elsif (flashm=1and q2hz=1)thenh1min1sec1elsif (flashs=1and q2hz=1)thenh1min1sec1elseh1min1sec1end if

13、;elsif sel_show=1then-若sel_show为“1”,数码管显示闹钟时间if(flashh=1 and q2hz=1)thenh1min1sec1elsif ( flashm=1 and q2hz=1)thenh1min1sec1elseh1 min1sec1end if ; end if;end process;end rtl;(3)模块图:8、动态扫描显示模块(scan_led.vhd)(1)模块说明:由4组输入信号和输出信号进而实现了时钟时、分的动态显示。(2)源程序:library ieee;use ieee.std_logic_1164.all;use ieee.s

14、td_logic_unsigned.all;entity scan_led isport(clk1:in std_logic;h0:in std_logic_vector(3 downto 0);h1:in std_logic_vector(7 downto 4);min0:in std_logic_vector(3 downto 0);min1:in std_logic_vector(7 downto 4);ml:out std_logic_vector(7 downto 0);mh:out std_logic_vector(7 downto 0);hl:out std_logic_vect

15、or(7 downto 0);hh:out std_logic_vector(7 downto 0);end scan_led;architecture one of scan_led issignal cnt4:std_logic_vector(1 downto 0); signal a: std_logic_vector(3 downto 0) ; beginp1:process(clk1)beginif clk1event and clk1 =1 thencnt4if cnt4=3 thencnt4end if;end if;end process p1;p2:process(cnt4,h1,h0,min1,min0)begincase cnt4 is -控制数码管位选when 00=case min0 iswhen 0000=mlwhen 0001=mlwhen 0010=mlwhen 0011=mlwhen 0100=mlwhen 0101=mlwhen 0110=mlwhen 0111=mlwhen 1000=mlwhen 100

温馨提示

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

评论

0/150

提交评论