已阅读5页,还剩25页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
大连理工大学本科实验报告题目:数字钟课程名称: 数字电路课程设计 学院(系):电子信息与电气工程专 业: 电气工程及其自动化班 级: 电气1004 学生姓名: 学 号: 完成日期: 成 绩: 2012 年 12 月 14 日题目:数字钟1 设计要求该数字钟具有如下六种功能:(1)具有时、分、秒的十进制数字显示(小时从0023)的计时器(具有清零功能和设置起始时间功能);(2)具有手动校时、校分、校秒的功能,利用DE2 Key键,分别对每一个数码管进行校时(校正模式下,时钟处于停滞状态),校时之后的时间可以通过开关赋给24小时计数器模块和倒计时模块;(3)定时与闹钟功能,能在设定的时间发出闹铃声(用开发板上红色的LED灯全亮来表示),程序中实现闹铃30秒;(4)能进行零点报时,要求发出仿中央人民广播电台的整点报时信号,即从23时59分50秒起,每隔2秒钟发出一次低音“嘟”的信号,连续5次,最后一次要求高音“嘀”的信号,此信号结束即达到零点(用开发板上的绿色LED灯亮来表示);(5)设计一个秒表,显示1%秒、60秒、手动停止,手动清零;(6)设计一个倒计时,显示小时、分钟、秒、%1秒,可清零,可设置起始时间。2 设计分析及系统方案设计系统总共有5个状态,分别对应设计要求中的(1)24小时计数器(2)时钟校准(3)闹铃(4)倒计时(5)秒表程序开始利用50MHz的时钟分别构造1Hz的时钟和100Hz的时钟。先用50MHz时钟构造模500000计数器,用作分频产生100HZ信号,然后用100HZ信号构造模100计数器,用作分频产生1HZ信号,从而构造出周期是1秒和0.01秒的时钟。(1) 时间显示此部分是用1HZ的时钟驱动秒的个位,然后通过进位关系分别带动其余5位时间,从而完成时间显示功能。当清零位置0时,时间一直显示为0。(2) 手动校时此部分通过三个DE2的KEY按键来实现。第一个是状态转换按键,通过它来将状态转换到校时状态;第二个是校准位置选择按键,通过它来选择此时校准哪一位;第三个是对所选位置进行加一的按键。设置好时间之后可以通过两个开关分别将设置好的时间送到正常显示模块和倒计时模块。(3) 闹铃功能此部分通过和手动校时部分相同的操作过程来设置闹铃,系统提供一个可以打开和关闭闹铃的开关。闹铃部分的信号是一个单独的信号,对该信号的设置并不影响时钟的正常运行。当闹铃的小时、分钟和秒的信号分别和时钟的小时、分钟和秒的信号对应相等时,闹铃启动,进行30秒的闹铃提醒。(4) 零点报时在正常显示24小时的状态中,当时间信号运行到23:59:50时,开始零点报时,程序中以驱动绿色LED灯亮来代表。(5) 秒表功能此部分由100HZ的时钟驱动%1秒位,通过进位关系分别带动其余7位时间完成计时功能。秒表的信号是一个单独的信号,使用秒表并不影响时钟的正常运行。对秒表可以进行清零和暂停操作,通过两个开关来实现。(6)倒计时功能此部分就是24小时正常显示模块的逆过程。用100HZ的时钟驱动%1秒的个位,然后通过退位关系分别带动其余7位完成倒计时功能。倒计时的信号为独立的信号,使用倒计时并不影响时钟的正常运行。倒计时设有清零位,用开关控制。数字钟原理框图如下:3系统以及模块硬件电路设计(1)输入信号clk0:系统时钟(50MHZ)state:状态转换按键positionselect:位置选择按键jiayi:校准、设闹钟时对所选的位进行加一的按键queding:校时之后的确定开关queding1:设置倒计时之后再确定开关kainaozhong:闹钟开关控制qingling: 秒表清零开关zanting:秒表暂停开关qingling1: 正常显示的清零开关qingling2:倒计时的清零开关(2)输出信号输出到数码管显示:bighour:out std_logic_vector(6 downto 0); -时针十位 smallhour:out std_logic_vector(6 downto 0); -时针个位 bigminute:out std_logic_vector(6 downto 0); -分针十位 smallminute:out std_logic_vector(6 downto 0); -分针个位 bigsecond:out std_logic_vector(6 downto 0); -秒针十位 smallsecond:out std_logic_vector(6 downto 0); -秒针个位 bigpercentsecond:out std_logic_vector(6 downto 0); -%1秒十位 smallpercentsecond:out std_logic_vector(6 downto 0); -%1秒个位 lednaozhong :LED代表闹铃输出baoshi:零点报时指示灯1baoshi1:零点报时指示灯2开发系统模式以及管脚定义如下:4 系统的VHDL设计-定义库 - library ieee; use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;-定义实体 - entity homework is port( - -输入信号 - -1/系统时钟 clk0:in std_logic; -2/状态转换按键 state:in std_logic; -3/校准时进行位置选择 的按键 positionselect:in std_logic; -4/校准、设闹钟时对所选的位进行加一的按键 jiayi:in std_logic; -5/校时之后确定开关(赋给正常显示模块) queding:in std_logic; -6/设置倒计时之后再确定开关 queding1:in std_logic; -7/闹钟开关控制 kainaozhong:in std_logic; -8/秒表清零开关 qingling:in std_logic; -9/秒表暂停开关 zanting:in std_logic; -10/正常显示的清零开关 qingling1:in std_logic; -11/倒计时的清零开关 qingling2:in std_logic; - -输出信号 - - -输出到数码管显示 - bighour:out std_logic_vector(6 downto 0); -时针十位 smallhour:out std_logic_vector(6 downto 0); -时针个位 bigminute:out std_logic_vector(6 downto 0); -分针十位 smallminute:out std_logic_vector(6 downto 0); -分针个位 bigsecond:out std_logic_vector(6 downto 0); -秒针十位 smallsecond:out std_logic_vector(6 downto 0); -秒针个位 bigpercentsecond:out std_logic_vector(6 downto 0); -%1秒十位 smallpercentsecond:out std_logic_vector(6 downto 0); -%1秒个位 - -LED代表闹铃输出 lednaozhong:out std_logic_vector(17 downto 0); -零点报时指示灯1 baoshi:out std_logic_vector(7 downto 0); -零点报时指示灯2 baoshi1:out std_logic );end;-定义结构体 - architecture shuzizhong of homework is -产生100HZ信号时的计数器 signal cnt0:integer range 0 to 499999; -产生1HZ信号时的计数器 signal cnt1:integer range 0 to 99;-100HZ信号 signal clk1:std_logic;-1HZ信号 signal clk2:std_logic;- 送数码管显示的时针,分针,秒针,%1秒信号 - signal bh:std_logic_vector(3 downto 0); -时针十位 signal sh:std_logic_vector(3 downto 0); -时针个位 signal bm:std_logic_vector(3 downto 0); -分针十位 signal sm:std_logic_vector(3 downto 0); -分针个位 signal bs:std_logic_vector(3 downto 0); -秒针十位 signal ss:std_logic_vector(3 downto 0); -秒针个位 signal bps:std_logic_vector(3 downto 0); -%1秒十位 signal sps:std_logic_vector(3 downto 0); -%1秒个位 -状态为000时的时钟信号 ( 正常显示) - signal bh0:std_logic_vector(3 downto 0); -时针十位 signal sh0:std_logic_vector(3 downto 0); -时针个位 signal bm0:std_logic_vector(3 downto 0); -分针十位 signal sm0:std_logic_vector(3 downto 0); -分针个位 signal bs0:std_logic_vector(3 downto 0); -秒针十位 signal ss0:std_logic_vector(3 downto 0); -秒针个位 - -状态为001时的时钟信号 ( 校准时) - signal bh1:std_logic_vector(3 downto 0); -时针十位 signal sh1:std_logic_vector(3 downto 0); -时针个位 signal bm1:std_logic_vector(3 downto 0); -分针十位 signal sm1:std_logic_vector(3 downto 0); -分针个位 signal bs1:std_logic_vector(3 downto 0); -秒针十位 signal ss1:std_logic_vector(3 downto 0); -秒针个位 -状态为010时的时钟信号 ( 设置闹钟时) - signal bh2:std_logic_vector(3 downto 0); -时针十位 signal sh2:std_logic_vector(3 downto 0); -时针个位 signal bm2:std_logic_vector(3 downto 0); -分针十位 signal sm2:std_logic_vector(3 downto 0); -分针个位 signal bs2:std_logic_vector(3 downto 0); -秒针十位 signal ss2:std_logic_vector(3 downto 0); -秒针个位 -状态为011时的时钟信号 ( 设置倒计时时 ) - signal bh3:std_logic_vector(3 downto 0); -时针十位 signal sh3:std_logic_vector(3 downto 0); -时针个位 signal bm3:std_logic_vector(3 downto 0); -分针十位 signal sm3:std_logic_vector(3 downto 0); -分针个位 signal bs3:std_logic_vector(3 downto 0); -秒针十位 signal ss3:std_logic_vector(3 downto 0); -秒针个位 signal bps3:std_logic_vector(3 downto 0); -%1秒十位 signal sps3:std_logic_vector(3 downto 0); -%1秒个位 -状态为100时的时钟信号 ( 设置秒表 ) - signal bh4:std_logic_vector(3 downto 0); -时针十位 signal sh4:std_logic_vector(3 downto 0); -时针个位 signal bm4:std_logic_vector(3 downto 0); -分针十位 signal sm4:std_logic_vector(3 downto 0); -分针个位 signal bs4:std_logic_vector(3 downto 0); -秒针十位 signal ss4:std_logic_vector(3 downto 0); -秒针个位 signal bps4:std_logic_vector(3 downto 0); -%1秒十位 signal sps4:std_logic_vector(3 downto 0); -%1秒个位 -表示状态转换时的信号 - signal statesignal:std_logic_vector(2 downto 0); -表示位置选择时的信号 - signal positionselectsignal:std_logic_vector(2 downto 0); - -程序开始 - begin-状态转换 -statesignal=000-正常计时 -statesignal=001-校准 -statesignal=010-闹钟 -statesignal=011-倒计时 -statesignal=100-秒表 -process(state) begin if(stateevent and state=1)then if(statesignal=100)then statesignal=000; else statesignal秒个位 -positionselectsignal=100-秒十位 -positionselectsignal=011-分个位 -positionselectsignal=010-分十位 -positionselectsignal=001-时个位 -positionselectsignal=000-时十位 - process(positionselect) begin if( positionselectevent and positionselect=1)then if(positionselectsignal=101)then positionselectsignal=000; else positionselectsignal=positionselectsignal+1; end if; end if; end process;-产生100HZ信号 -process(clk0)beginif(clk0event and clk0=1)then if cnt0=499999 then cnt0=0; clk1=1; else cnt0=cnt0+1; clk1=0; end if;end if;end process;-产生1HZ信号 -process(clk1)beginif(clk1event and clk1=1)then if cnt1=99 then cnt1=0; clk2=1; else cnt1=cnt1+1; clk2=0; end if;end if;end process;- -正常显示24小时计时 - process(clk2,statesignal,queding,ss1,bs1,sm1,bm1,sh1,bh1)beginif(statesignal=000) then if(qingling1=0)then ss0=0000; bs0=0000; sm0=0000; bm0=0000; sh0=0000; bh0=0000; else if(clk2event and clk2=1)then if(ss0=9)then ss0=0000; if(bs0=5)then bs0=0000; if(sm0=9)then sm0=0000; if(bm0=5)then bm0=0000; if(bh02)then if(sh0=9)then sh0=0000; bh0=bh0+1; else sh0=sh0+1; end if; else if(sh0=3)then sh0=0000; bh0=0000; else sh0=sh0+1; end if; end if; else bm0=bm0+1; end if; else sm0=sm0+1; end if; else bs0=bs0+1; end if; else ss0=ss0+1; end if; if(bh0=2)then if(sh0=3)then if(bm0=5)then if(sm0=9)then if(bs0=5)then if ss0=1 or ss0=3 or ss0=5 or ss0=7 then baoshi=11111111; else baoshi=00000000; end if; elsif(bs0=4)then if(ss0=9)then baoshi=11111111; else baoshi=00000000; end if; end if; end if; end if; end if; end if; if bh0=2 and sh0=3 and bm0=5 and sm0=9 and bs0=5 and ss0=9 then baoshi1=1; else baoshi1=0; end if; end if; end if;end if;if(queding=1 and statesignal=001) then ss0=ss1; bs0=bs1; sm0=sm1; bm0=bm1; sh0=sh1; bh0=bh1;end if;end process;-时间校准 -1时针十位校准 - process(jiayi)beginif(statesignal=001)then if(positionselectsignal=000)then if(jiayievent and jiayi=1)then if(bh1=0010)then bh1=0000; else bh1=bh1+1; end if; end if; end if;end if;end process;-2时针个位校准 - process(jiayi)beginif(statesignal=001)then if(positionselectsignal=001)then if(jiayievent and jiayi=1)then if(sh1=1001)or(bh1=0010 and sh1=0011) then sh1=0000; else sh1=sh1+1;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- TCECS 1262-2023 拱桥缆索吊运系统应用技术规程
- GB 50139-2014 内河通航标准
- 湖北省荆州市石首市2023-2024学年一年级上学期语文期末试卷(含答案)
- 河北新金钢铁招聘试题及答案
- 房屋租赁合同协议范本
- 机器人调试工程师校招面试题及答案
- 恒申控股招聘题库及答案
- 公务员面试劳务面试题及答案
- 国机集团招聘真题及答案
- 公务员考试首都试题及答案
- 2025年考研英语二真题及答案解析(完整版)
- 2025-2026新版人教版8八年级数学上册(全册)教案设计
- 细菌性支气管肺炎的护理个案
- 地暖施工方案
- 车位过户网签合同范本
- 2025年医疗健康保健品营销策略
- 2025独家代理商合同协议书范本
- 银行理财产品线上营销方案
- 全国大学生职业规划大赛《无人机应用技术》专业生涯发展展示【高职(专科)】
- 2025年中远海运招聘1189人(含社招)笔试参考题库附带答案详解
- 输卵管切除术护理查房
评论
0/150
提交评论