




已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
大连理工大学本科实验报告题目:数字钟的VHDL设计课程名称: 数字电路课程设计 学院(系): 电子信息与电气工程学部 专 业: 电子信息工程 班 级: 学生姓名: 学 号: 完成日期: 成 绩: 2013 年 12 月 15 日数字钟的VHDL设计1. 设计任务及要求:设计任务:设计一台能显示时、分、秒的数字钟。具体要求如下:(1)设计一个数字钟,能够显示当前时间,分别用6个数码管显示小时、分钟、秒钟的时间,秒针的计数频率为1Hz,可由系统脉冲分频得到。(2)在整点进行提示,可通过LED闪烁实现,闪烁频率及花型可自己设计。(3)能够调整小时和分钟的时间,调整的形式为通过按键进行累加。(4)具有闹钟功能,闹钟时间可以任意设定(设定的形式同样为通过按键累加),并且在设定的时间能够进行提示,提示同样可以由LED闪烁实现设计要求:(1) 编写设计报告,要求包括方案选择、程序代码清单、调试过程、测试结果及心得体会。2. 设计原理时显示器秒显示器分显示器时译码器秒译码器分译码器报时时计数器分计数器秒计数器校时电路 1HZ分频器振荡器图1 数字钟的系统框图该系统由振荡器、分频器、“时、分、秒”计数器、译码器及显示器、校时电路、整点报时电路等组成。石英晶体振荡器和分频器产生整个系统的时基信号,它直接决定计时系统的精度。“秒计数器”采用六十进制计数器,每累计60秒向“分计数器”进位;“分计数器”采用六十进制计数器,每累计60分向“时计数器”进位;“时计数器”采用二十四进制计数器,按照“24翻1”规律计数。“时、分、秒”计数器的输出经译码器送显示器显示。校时电路用来当计时出现误差时对“时、分、秒”进行校对调整。整点报时电路是根据计时系统的输出状态产生一脉冲信号,然后去触发音频发生器实现报时。 3. 设计过程3.1. 设计思路时钟脉冲信号作为数字钟的时间基准,再经分频器输出标准秒脉冲。秒计数器计满60后向分计数器进位,分计数器计满60后向小时计数器进位,小时计数器是计满24后,系统自动复位重新开始计数。计数器的输出经译码电路后送到显示器显示。可以用校时电路进行校时。整点报时电路在每小时的最后50秒开始报时间隔一秒报一次时直至下一小时开始。3.2. 数字钟的设计方案数字钟的设计包括编码模块、分频模块、秒计时模块、分计时模块、小时计时模块、闹钟模块和报时模块。该数字钟可以实现3个功能:计时功能、报时功能、闹铃和设置时间功能。3.2.1. 编码模块编码模块主要是对时、分、秒的设置输入。3.2.2. 分频模块在数字钟的设计中,外部输入时钟信号clk1的频率为50Mhz,其分频后的频率为clk,使其分频结果为1hz,用来提供给秒计时模块、分计时模块、小时计时模块。3.2.3. 秒计时模块将“秒计时脉冲”clk接信号源单元的1HZ脉冲信号,此时秒显示将从00计时到59,然后回到00,重新计时。在秒位进行计时的过程中。秒计时器是由一个60进制的计数器构成的,具有置数和计数功能。其中reset为置数信号,当reset为1时,秒计时器置数。clk为驱动秒计时器的时钟,sec2、sec1为秒计时器的高位和低位输出。3.2.4. 分计时模块分计时电路:将“分计时脉冲”clk接信号源单元的c1脉冲信号,此时分显示将从00计时到59,然后回到00,重新计时。在分位进行计时的过程中。分计时器是由一个60进制的计数器构成的,具有置数和计数功能。其中rese为置数信号,当reset为1时,分计时器置数。fen4、fen3为分计时器的高位和低位输出。3.2.5. 小时计时模块将“小时计时脉冲”clk接信号源单元的c2脉冲信号,此时小时显示将从00计时到23,然后回到00,重新计时。时计时器是由一个24进制的计数器构成的,具有置数和计数功能。其中的reset为置数信号,当reset为1时,时计时器置数。shi6、shi5为时计时器的高位和低位输出。3.2.6. 报时模块当分位到59时,秒位计到51秒、53秒、55秒、57秒、59秒时报时一次,而后小时位加1。3.2.7.VHDL 引脚分配图4. 源程序4.1. 数字钟整体程序整个程序分为六个部分,分别为分频部分、校时部分、秒部分、分部分、小时部分和报时部分。4.2. VHDL程序及波形分析4.2.1. VHDL程序library ieee;-count60use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count60 isport(clk:in std_logic; reset:in std_logic; set:in std_logic; inc:in std_logic; out1:out std_logic_vector(3 downto 0); out2:out std_logic_vector(3 downto 0); c:out std_logic; alight:out std_logic); end;architecture run2 of count60 issignal ts1,ts2,as1,as2:std_logic_vector( 3 downto 0):=0000;signal tclk,aclk: std_logic;beginprocess(inc,clk,set)-根据设置模式,处理inc上的脉冲信号beginif set=0 then -时间调整模式aclk=0;if clk=1 and inc=1 then -clk=1则tclk=0,通过挖洞方式添加一个脉冲tclk=0;elsif clk=0 and inc=1 then -clk=0,则tclk=1,产生一个高电平,添加一脉冲tclk=1;elsetclk=clk;end if;elsif set=1 then -闹铃调整模式tclk=clk;aclk=inc; -inc上的脉冲直接修改闹铃定时值end if;end process;process(tclk,reset) beginif(reset=0)then ts1=0000;ts2=0000; elsif(tclkevent and tclk=1)then if ts1=1001 then ts1=0000; if ts2=0101 then ts2=0000; else ts2=ts2+1; end if; else ts1=ts1+1;-计数过程 end if;end if;end process;-结束进程process(aclk,reset) beginif(reset=0)then as1=0000;as2=0000; elsif(aclkevent and aclk=1)then if as1=1001 then as1=0000; if as2=0101 then as2=0000; else as2=as2+1; end if; else as1=as1+1;-计数过程 end if;end if;end process;-结束进程process(ts1,ts2,as1,as2)- 显示时间或闹铃定时值begin if set=0 then - 显示时间out1=ts1;out2=ts2;else - 显示定时值out1=as1;out2=as2;end if;end process;process(ts1,ts2,as1,as2) -判断定时值与时间值相等,输出闹铃触发信号begin if (ts1=1001 and ts2=0101) then c=1; else c=0; end if;if ts1=as1 and ts2=as2 thenalight=1;elsealight=0;end if;end process;end run2;library ieee;-count24use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count24 isport(clk:in std_logic; reset:in std_logic; set:in std_logic; inc:in std_logic; out1:out std_logic_vector(3 downto 0); out2:out std_logic_vector(3 downto 0); c:out std_logic;alight:out std_logic); end; architecture run1 of count24 issignal ts1,ts2,as1,as2:std_logic_vector( 3 downto 0):=0000;signal tclk,aclk: std_logic;beginprocess(inc,clk,set)-根据设置模式,处理inc上的脉冲信号beginif set=0 then -时间调整模式aclk=0;if clk=1 and inc=1 then -clk=1则tclk=0,通过挖洞方式添加一个脉冲tclk=0;elsif clk=0 and inc=1 then -clk=0,则tclk=1,产生一个高电平,添加一脉冲tclk=1;elsetclk=clk;end if;elsif set=1 then -闹铃调整模式tclk=clk;aclk=inc; -inc上的脉冲直接修改闹铃定时值end if;end process;process(tclk,reset) beginif(reset=0)then ts1=0000;ts2=0000; elsif(tclkevent and tclk=1)then if ts20010 then if(ts1=1001) then ts1=0000;ts2=ts2+1; else ts1=ts1+1; end if; elsif(ts2=0010) then if(ts1=0011) then ts1=0000;ts2=0000; -计数过程 else ts1=ts1+1; end if; end if;end if;end process;-结束进程process(aclk,reset) beginif(reset=0)then as1=0000;as2=0000; elsif(aclkevent and aclk=1)then if as20010 then if(as1=1001) then as1=0000;as2=as2+1; else as1=as1+1; end if; elsif(as2=0010) then if(as1=0011) then as1=0000;as2=0000; -计数过程 else as1=as1+1; end if; end if;end if;end process;-结束进程process(ts1,ts2,as1,as2)- 显示时间或闹铃定时值begin if set=0 then - 显示时间out1=ts1;out2=ts2;else - 显示定时值out1=as1;out2=as2;end if;end process;process(ts1,ts2,as1,as2) -判断定时值与时间值相等,输出闹铃触发信号begin if ts1=0010 and ts2=0011 then c=1; else c=0; end if;if ts1=as1 and ts2=as2 thenalight=1;elsealightqqqqqqqqqqqqqqqqqqqq=0010000;end case;end process;end;library ieee;-shizhonguse ieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entity shizhong isport (clk:in std_logic;-PIN_N2 reset:in std_logic;-PIN_N25 set:in std_logic;-PIN_N26 inc1,inc2,inc3:in std_logic;-PIN_G26,PIN_N23,PIN_P23 shi6,shi5,fen4,fen3,miao2,miao1:out std_logic_vector(6 downto 0); alight,light1,light2:out std_logic);-闹铃end;architecture run of shizhong issignal sshi6,sshi5,sfen4,sfen3,smiao2,smiao1: std_logic_vector(3 downto 0);signal c1,c2,c3,clk1s,clk2ms,clk1ms:std_logic;signal alight1,alight2,alight3:std_logic;component count60port(clk:in std_logic; reset:in std_logic; set:in std_logic; inc:in std_logic; out1:out std_logic_vector(3 downto 0); out2:out std_logic_vector(3 downto 0); c:out std_logic; alight:out std_logic);end component;component count24port(clk:in std_logic; reset:in std_logic; set:in std_logic; inc:in std_logic; out1:out std_logic_vector(3 downto 0); out2:out std_logic_vector(3 downto 0); c:out std_logic;alight:out std_logic);end component;component xianshi port(clk:in std_logic_vector(3 downto 0); qq:out std_logic_vector(6 downto 0);end component;beginprocess(clk)variable count1:integer range 0 to 49999999;begin if(clkevent and clk=1)then count1:=count1+1;-在clk 的上升沿计数 if count1=24999999 then clk1s=0; elsif count1=49999999 then clk1s=1; else count1:=0; end if; end if; end process;-产生周期为1s的时钟信号process(clk)variable count2:integer range 0 to 99999;begin if(clkevent and clk=1)then count2:=count2+1;-在clk 的上升沿计数 if count2=49999 then clk2ms=0; elsif count2=99999 then clk2ms=1; else count2:=0; end if;end if;end process; -产生周期为2ms的时钟信号 500Hzprocess(clk)variable count3:integer range 0 to 49999;begin if(clkevent and clk=1)then count3:=count3+1;-在clk 的上升沿计数 if count3=24999 then clk1ms=0; elsif count3=49999 then clk1ms=1; else count3:=0; end if;end if;end process;-产生周期为1ms的时钟信号1000Hzprocess(alight1,alight2,alight3)beginif alight1=1 and alight2=1 and alight3=1then alight=1; else alight=0;end if;end process;process(sfen4,sfen3,smiao2,smiao1)beginif sfen4=0101 and sfen3=1001 thenif smiao2=0101 thenif smiao1=0001 thenlight1=clk2ms;elsif smiao1=0011 thenlight1=clk2ms;elsif smiao1=0101 thenlight1=clk2ms;elsif smiao1=01
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 小儿胃食管反流课件
- 小儿肾积水护理课件
- 小儿病课件教学课件
- 摩托车公户协议的合同范本
- 买卖房协议合同补充协议
- 小儿推拿腹泻手法课件
- 代物清偿协议借款协议书
- ECFA协议离婚协议书
- 买方延迟收货免责协议书
- 网签合同协议范本模板模板
- 2025年电子商务师(职业资格专业初级)考试试卷及答案
- 海姆立克急救法科普知识
- 《基本医疗卫生与健康促进法》试题(附答案)
- 2025年度铝合金门购销及节能技术合同
- 2024届国家卫健委临床药师培训学员(抗感染专业)理论考核试题
- 【基层法工】基层法律服务工作者测试题附答案
- 浙江浙政钉管理办法
- 宁夏公休假管理办法
- 2024年10月19日北京市下半年事业单位七区联考《公共基本能力测验》笔试试题(海淀-房山-西城-通州-丰台-怀柔)真题及答案
- 2025年高考真题-政治(湖南卷) 含答案
- 2025年网络安全知识竞赛考试题库(100题)(含答案)
评论
0/150
提交评论