




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、;大连理工大学本科实验报告题目:数字钟的VHDL设计课程名称: 数字电路课程设计 学院(系): 电子信息与电气工程学部 专 业: 电子信息工程 班 级: 学生姓名: 学 号: 完成日期: 成 绩: 2013 年 12 月 15 日数字钟的VHDL设计1. 设计任务及要求:设计任务:设计一台能显示时、分、秒的数字钟。具体要求如下:(1)设计一个数字钟,能够显示当前时间,分别用6个数码管显示小时、分钟、秒钟的时间,秒针的计数频率为1Hz,可由系统脉冲分频得到。(2)在整点进行提示,可通过LED闪烁实现,闪烁频率及花型可自己设计。(3)能够调整小时和分钟的时间,调整的形式为通过按键进行累加。(4)具
2、有闹钟功能,闹钟时间可以任意设定(设定的形式同样为通过按键累加),并且在设定的时间能够进行提示,提示同样可以由LED闪烁实现设计要求:(1) 编写设计报告,要求包括方案选择、程序代码清单、调试过程、测试结果及心得体会。2. 设计原理时显示器秒显示器分显示器时译码器秒译码器分译码器报时时计数器分计数器秒计数器校时电路 1HZ分频器振荡器图1 数字钟的系统框图该系统由振荡器、分频器、“时、分、秒”计数器、译码器及显示器、校时电路、整点报时电路等组成。石英晶体振荡器和分频器产生整个系统的时基信号,它直接决定计时系统的精度。“秒计数器”采用六十进制计数器,每累计60秒向“分计数器”进位;“分计数器”采
3、用六十进制计数器,每累计60分向“时计数器”进位;“时计数器”采用二十四进制计数器,按照“24翻1”规律计数。“时、分、秒”计数器的输出经译码器送显示器显示。校时电路用来当计时出现误差时对“时、分、秒”进行校对调整。整点报时电路是根据计时系统的输出状态产生一脉冲信号,然后去触发音频发生器实现报时。 3. 设计过程3.1. 设计思路时钟脉冲信号作为数字钟的时间基准,再经分频器输出标准秒脉冲。秒计数器计满60后向分计数器进位,分计数器计满60后向小时计数器进位,小时计数器是计满24后,系统自动复位重新开始计数。计数器的输出经译码电路后送到显示器显示。可以用校时电路进行校时。整点报时电路在每小时的最
4、后50秒开始报时间隔一秒报一次时直至下一小时开始。3.2. 数字钟的设计方案数字钟的设计包括编码模块、分频模块、秒计时模块、分计时模块、小时计时模块、闹钟模块和报时模块。该数字钟可以实现3个功能:计时功能、报时功能、闹铃和设置时间功能。3.2.1. 编码模块编码模块主要是对时、分、秒的设置输入。3.2.2. 分频模块在数字钟的设计中,外部输入时钟信号clk1的频率为50Mhz,其分频后的频率为clk,使其分频结果为1hz,用来提供给秒计时模块、分计时模块、小时计时模块。3.2.3. 秒计时模块将“秒计时脉冲”clk接信号源单元的1HZ脉冲信号,此时秒显示将从00计时到59,然后回到00,重新计
5、时。在秒位进行计时的过程中。秒计时器是由一个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
6、接信号源单元的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;
7、-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 r
8、un2 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<=
9、39;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&q
10、uot;ts2<="0000" elsif(tclk'event 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(rese
11、t='0')then as1<="0000"as2<="0000" elsif(aclk'event 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 proces
12、s;-结束进程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<=&
13、#39;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; ou
14、t1: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
15、 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 -闹铃调整模式
16、tclk<=clk;aclk<=inc; -inc上的脉冲直接修改闹铃定时值end if;end process;process(tclk,reset) beginif(reset='0')then ts1<="0000"ts2<="0000" elsif(tclk'event and tclk='1')then if ts2<"0010" then if(ts1="1001") then ts1<="0000"ts2&
17、lt;=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<=&
18、quot;0000" elsif(aclk'event and aclk='1')then if as2<"0010" 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&qu
19、ot; -计数过程 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"
20、and ts2="0011" then c<='1' else c<='0' end if;if ts1=as1 and ts2=as2 thenalight<='1'elsealight<='0'end if;end process;end run1;library ieee;-xianshiuse ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity xianshi isport(clk:in std_logic
21、_vector(3 downto 0); qq:out std_logic_vector(6 downto 0);end;architecture run3 of xianshi isbeginprocess(clk)begincase clk iswhen "0000"=>qq<="1000000"when "0001"=>qq<="1111001"when "0010"=>qq<="0100100"when "0011&quo
22、t;=>qq<="0110000"when "0100"=>qq<="0011001"when "0101"=>qq<="0010010"when "0110"=>qq<="0000010"when "0111"=>qq<="1111000"when "1000"=>qq<="0000000"when ot
23、hers=>qq<="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 shi
24、6,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;c
25、omponent 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_log
26、ic; 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:integ
27、er range 0 to 49999999;begin if(clk'event 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 ran
28、ge 0 to 99999;begin if(clk'event 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
29、 49999;begin if(clk'event 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='1'then 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="
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 新疆机电职业技术学院《创业管理》2023-2024学年第二学期期末试卷
- 兰州职业技术学院《道路景观设计》2023-2024学年第一学期期末试卷
- 昆明冶金高等专科学校《装饰图案基础》2023-2024学年第二学期期末试卷
- 日照航海工程职业学院《首饰设计与制作》2023-2024学年第二学期期末试卷
- 西藏民族大学《医学免疫学研究进展》2023-2024学年第二学期期末试卷
- 吉林电子信息职业技术学院《软件设计开发综合实训》2023-2024学年第二学期期末试卷
- 铜仁职业技术学院《生物质废弃物资源化利用》2023-2024学年第二学期期末试卷
- 上海杉达学院《细胞及分子生物学实验》2023-2024学年第二学期期末试卷
- 江海职业技术学院《天然药物化学》2023-2024学年第一学期期末试卷
- 延安职业技术学院《高频电子电路》2023-2024学年第二学期期末试卷
- 医保业务培训大纲
- 北师大版2024-2025学年度第二学期一年级数学期中检测(含答案)
- 2025年中国短圆柱滚子轴承市场调查研究报告
- 教师的情绪管理课件
- 湖北省十一校2024-2025学年高三第二次联考数学试卷(解析版)
- 英语-华大新高考联盟2025届高三3月教学质量测评试题+答案
- MOOC 数字逻辑电路实验-东南大学 中国大学慕课答案
- (2024年)知识产权全套课件(完整)
- 国家开放大学《人文英语4》边学边练参考答案
- 入团志愿书(2016版本)(可编辑打印标准A4) (1)
- 新版入团志愿书入团志愿书
评论
0/150
提交评论