




已阅读5页,还剩16页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
数字电路与自动化课程设计报告 设计题目:数字电子钟 姓名:林立萍 陈平英 班级:10级应电2班 学号:1006010225 1006010213 小组成员:林立萍0225 陈平英0213 设计时间:2011年12月15日2011年12月30日目录 一 . 设计目的 二 . 设计要求 三 . 设计方案四 . 设计原理五 . 设计过程六 . 调试过程中的问题和解决方法七. 设计小结 八 VHDL程序九 . EDA实物图片十. 参考书目 一、设计目的 1.熟练地运用数字系统的设计方法进行数字系统的设计; 2.掌握运用数字钟的VHDL语言设计方法; 3.熟悉编程的过程; 4.理解运用分频、计时、多路选择器等课本理论; 5.进一步的学习电路的调试;二、设计要求1、 显示 (1)小时分钟秒钟 (2)小时、分钟和秒钟各用两个数码管来显示 (3)小时、分钟、秒钟之间用一杠来显示 (4) 杠每秒闪烁一次2、时钟(1)一个时钟3、整点报时(当整点的时候,LED闪烁)4、校准(1)能够实现对小时、分钟、秒钟的调整 (2)按键去抖动 三、设计方案:1、采用一个时钟信号,即扫描时钟,而秒时钟通过扫描时钟分频得到的。2、利用嵌套的模式,在秒时钟的情况下且无模式选择时,让秒分时自动跳时。3、使用防抖动的原理,减少按键产生的干扰。4、当按键an1有效时,运用多路选择器,依次实现校时、校分和校秒多种模式的选择,在校准模式的时候,让数码管闪烁,杠不闪烁。当按键an2有效时,当模式选择在校时或校分或校秒时,其数码管显示的值累加;当按键an3有效时,当模式选择在校时或校分或校秒时,其数码管显示的值递减。5、 在整点时,运用流水灯进行整点报时显示。6、 用阴极数码管来译码显示时分秒的数值。四、设计原理 1、定义模块1、动态扫描模块2、分频模块3、去抖动模块4、模式选择模块5、(显示+闪烁)模块6、跳时模块7、校时模块(加法模块和减法模块)8、整点报时模块(LED灯移位显示模块)9、译码模块五、设计过程1、定义模块(1)、定义实体:对输入信号(扫描时钟sec_clk,按键(an1,an2,an3))、输出信号(动态扫描seg,LED输出temp,七段数码管data)进行声明(2)、定义结构体:对中间信号进行声明。1、动态扫描模块在扫描时钟为上升沿的时候,进行计数,再将中间信号赋值给输出seg,达到轮流显示,由于扫描时钟的频率大于人的视觉惰性20ms,所以我们看过去,八个数码管能够全部同时看到数字,。process(sec_clk)-动态扫描begin if rising_edge(sec_clk) then cnt=cnt+1; end if;end process;seg=cnt;2、 分频模块 在扫描时钟为上升沿的时候,进行计数,然后对扫描时钟进行1024分频,将其值赋给秒时钟clk,对扫描时钟进行64分频,将其值赋给秒时钟clk1。process(sec_clk,n)-分频beginif rising_edge(sec_clk) then n=n+1; end if;clk=n(9);clk1=n(6);end process;3、 去抖动模块由于按键输入时会有抖动干扰,对输出会产生误差,因此对按键进行去抖动,当扫描时钟为上升沿的时候,采用对按键进行移位延迟输出,即当按键输出满足四个高电平时,才使得按键输出有效,从而达到去抖动的效果。process(clk1)-去抖动 beginif rising_edge(clk1) then An_out(3 downto 0)= An_out(2 downto 0)& an1; Bn_out(3 downto 0)= Bn_out(2 downto 0)& an2; Cn_out(3 downto 0)= Cn_out(2 downto 0)& an3; if An_out=1111 then an1_out=1; else an1_out=0; end if; if Bn_out=1111 then an2_out=1; else an2_out=0;end if; if Cn_out=1111 then an3_out=1; else an3_out=0; end if;end if;end process;4、 模式选择模块在按键an1有效输出的情况下,对tz进行计数 ,选择时分秒的模块。process(an1_out)-模式的选择beginif an1_out=1 then tzif tz=01 then if clk=1 then -秒的个位的闪烁 dec=round(3 downto 0); else dec=1110 ; end if; else decif tz=01 then if clk=1 then -秒的十位的闪烁 dec=0&round(6 downto 4); else dec=1110 ; end if; else decif tz=10 then if clk=1 then -分的个位的闪烁 dec=round(10 downto 7); else dec=1110 ; end if; else decif tz=10 then if clk=1 then -分的十位的闪烁 dec=0&round(13 downto 11); else dec=1110 ; end if; else decif tz=11 then if clk=1 then -时的个位的闪烁 dec=round(17 downto 14); else dec=1110 ; end if; else decif tz=11 then if clk=1 then -时的十位的闪烁 dec=0&0&round(19 downto 18); else dec=1110 ; end if; else decif tz=01 or tz=10 or tz=11 then dec=1010; else decdec=1011;-不显示end case;end process;process(tz,clk)-横的闪烁beginif tz=00 then if clk=1 then round(23 downto 20)=1010; else round(23 downto 20)=1011; end if;else round(23 downto 20)1 and round(17 downto 14)3 then round(19 downto 0)=00000000000000000000;-清零 else if round (3 downto 0)9 then round(3 downto 0)= round(3 downto 0)+1;-秒个位的跳时 else round(3 downto 0)=0000; -清零 if round (6 downto 4)5 then round(6 downto 4)= round(6 downto 4)+1;-秒十位的跳时 else round(6 downto 4)=000;-清零 if round (10 downto 7)9 then round(10 downto 7)= round(10 downto 7)+1;-分个位的跳时 else round(10 downto 7)=0000;-清零 if round (13 downto 11)5 then round(13 downto 11)= round(13 downto 11)+1;-分十位的跳时 else round(13 downto 11)=000;-清零 if round ( 17 downto 14)9 then round(17 downto 14)= round(17 downto 14)+1;-时个位的跳时 else round(17 downto 14)=0000;-清零 if round (19 downto 18)3 then round(19 downto 18)= round(19 downto 18)+1;-时十位的跳时 else round(19 downto 18)=00;-清零 end if; end if; end if; end if; end if; end if;end if;7、 校时模块当按键an1有效时,当模式选择分别在秒、分、时块,分别进行加法计数和减法计数。 elsif tz=01 then -校秒 if an2_out=1and an3_out=0 then if round (3 downto 0)9 then round(3 downto 0)= round(3 downto 0)+1; else round(3 downto 0)=0000; if round (6 downto 4)5 then round(6 downto 4)= round(6 downto 4)+1; else round(6 downto 4)0 then round(3 downto 0)= round(3 downto 0)-1; else round(3 downto 0)0 then round(6 downto 4)= round(6 downto 4)-1; else round(6 downto 4)=101; end if; end if; end if; elsif tz=10 then-校分 if an2_out=1 and an3_out=0 then if round (10 downto 7)9 then round(10 downto 7)= round(10 downto 7)+1; else round(10 downto 7)=0000; if round (13 downto 11)5 then round(13 downto 11)= round(13 downto 11)+1; else round(13 downto 11)0 then round(10 downto 7)= round(10 downto 7)-1; else round(10 downto 7)0 then round(13 downto 11)= round(13 downto 11)-1; else round (13 downto 11)1 and round(17 downto 14)3 then round( 19 downto 18)=00; else if round( 17 downto 14)9 then round(17 downto 14)= round(17 downto 14)+1; else round(17 downto 14)=0000; if round ( 19 downto 18 )3 then round( 19 downto 18)= round( 19 downto 18)+1; else round( 19 downto 18)=00; end if; end if; end if; elsif an2_out=0 and an3_out=1 then if round(19 downto 18)=0 and round(17 downto 14)=0 then round( 19 downto 18)=10; round(17 downto 14)0 then round(17 downto 14)= round(17 downto 14)-1; else round( 17 downto 14)0 then round( 19 downto 18)= round( 19 downto 18)-1; else round( 19 downto 18)=10 ; end if; end if; end if; end if; end if;end if;end process;8、 整点报时模块(LED灯移位显示模块)当整点时,即分模块为零,dbs为高电平,则LED灯进行移位显示,否则不显示。process(round)-整点报时begin if round(10 downto 7)=0 and round(13 downto 11)=0 then dbs=1; else dbs=0; end if;end process;process(dbs)-流水灯beginif dbs=1 and rising_edge(clk) then if dtemp=00000000 then dtemp=1& dtemp(7 downto 1); elsif dtemp=00000001 then dtemp0); else dtemp=0&dtemp(7 downto 1); end if; end if;end process;tempdatadatadatadatadatadatadatadatadatadatadatadatadata=0000000; end case; end process;6、 调试过程中的问题和解决方法:我们先做分频模块,对程序进行综合时,发现时钟定义出错,分频概念不懂得运用,通过查资料,问老师和同学,最终实现了分频模块功能。接下来再做扫描模块,综合完之后,发现数码管不能显示,经过查看程序之后,发现没有扫描计数进行赋值输出。在设计按键去抖动模块时,发现按键an3没有作用,之后对按键an3赋予一个LED灯输出,发现按键an3高电平时,LED灯没有输出,检查程序,发现按键之间的嵌套出错,修改程序之后,可以实现按键an3的输出,最终达到去抖动功能。由于跳时、校时和模式选择我们选择嵌套模式,在嵌套过程中混乱,其中不能进行跳时,还有模式选择不起作用,并且所选择的模块无法进行闪烁,做完加法模块之后,我们考虑再做减法模块。在做减法计数时,数值为零时,不能正确赋值,检查程序后,一步一步进行改错、综合、调试,实现跳时,校时的功能。在做整点报时模块时,本想让流水灯在整点时进行移位闪烁,由于条件判断错误,使得流水灯只有在十秒时才移一个灯,通过咨询同学我们的问题,修改程序之后,达到预想的结果。七、设计小结通过这次的课程设计使我对数电软件知识有了更深的了解,从一开始只懂得对老师所给的程序进行编程,再到自己逐渐了解程序、编写程序、调试修改程序,逐步懂得程序综合完后所提示的错误,并且能够根据所提示的错误,进行针对性的修改。在课程设计中,我们更深一步的认识到了quartus II的用法,更加了解如何调试程序,检查程序中存在的问题,如何解决问题。也知道了理论和实践相结合,学与致用。八、VHDL程序 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity llo isport(sec_clk : in std_logic;-扫描时钟 an1、an2、an3: in std_logic;-按键 seg:out std_logic_vector(2 downto 0); -动态扫描输出 temp: out std_logic_vector( 7 downto 0);-LED灯 data: out std_logic_vector( 6 downto 0); -七段数码管 end;architecture one of llo issignal round:std_logic_vector(23 downto 0);-秒分时的显示signal cnt: std_logic_vector(2 downto 0);signal tz: std_logic_vector(1 downto 0);-多路选择器signal dec: std_logic_vector(3 downto 0);-选择signal An_out :std_logic_vector(3 downto 0);signal Bn_out :std_logic_vector(3 downto 0);signal Cn_out :std_logic_vector(3 downto 0);signal dtemp :std_logic_vector(7 downto 0);-彩灯signal an1_out: std_logic;signal an2_out: std_logic;signal an3_out: std_logic;signal n :std_logic_vector(9 downto 0);signal clk: std_logic;-秒时钟signal clk1: std_logic;-秒时钟signal dbs: std_logic;-报时的显示 beginprocess(sec_clk)-扫描begin if rising_edge(sec_clk) then cnt=cnt+1; end if;end process;seg=cnt;process(sec_clk,n)-分频beginif rising_edge(sec_clk) then n=n+1; end if;clk=n(9);clk1=n(6);end process;process(clk1)-去抖动 beginif rising_edge(clk1) then An_out(3 downto 0)= An_out(2 downto 0)& an1; Bn_out(3 downto 0)= Bn_out(2 downto 0)& an2; Cn_out(3 downto 0)= Cn_out(2 downto 0)& an3; if An_out=1111 then an1_out=1; else an1_out=0; end if; if Bn_out=1111 then an2_out=1; else an2_out=0;end if; if Cn_out=1111 then an3_out=1; else an3_out=0; end if;end if;end process;process(an1_out)-模式的选择beginif an1_out=1 then tzif tz=01 then if clk=1 then -秒的个位的闪烁 dec=round(3 downto 0); else dec=1110 ; end if; else decif tz=01 then if clk=1 then -秒的十位的闪烁 dec=0&round(6 downto 4); else dec=1110 ; end if; else decif tz=10 then if clk=1 then -分的个位的闪烁 dec=round(10 downto 7); else dec=1110 ; end if; else decif tz=10 then if clk=1 then -分的十位的闪烁 dec=0&round(13 downto 11); else dec=1110 ; end if; else decif tz=11 then if clk=1 then -时的个位的闪烁 dec=round(17 downto 14); else dec=1110 ; end if; else decif tz=11 then if clk=1 then -时的十位的闪烁 dec=0&0&round(19 downto 18); else dec=1110 ; end if; else decif tz=01 or tz=10 or tz=11 then dec=1010; else decdec=1011;-不显示end case;end process;process(tz,clk)-横的闪烁beginif tz=00 then if clk=1 then round(23 downto 20)=1010; else round(23 downto 20)=1011; end if;else round(23 downto 20)1 and round(17 downto 14)3 then round(19 downto 0)=00000000000000000000;-清零 else if round (3 downto 0)9 then round(3 downto 0)= round(3 downto 0)+1;-秒个位的跳时 else round(3 downto 0)=0000; -清零 if round (6 downto 4)5 then round(6 downto 4)= round(6 downto 4)+1;-秒十位的跳时 else round(6 downto 4)=000;-清零 if round (10 downto 7)9 then round(10 downto 7)= round(10 downto 7)+1;-分个位的跳时 else round(10 downto 7)=0000;-清零 if round (13 downto 11)5 then round(13 downto 11)= round(13 downto 11)+1;-分十位的跳时 else round(13 downto 11)=000;-清零 if round ( 17 downto 14)9 then round(17 downto 14)= round(17 downto 14)+1;-时个位的跳时 else round(17 downto 14)=0000;-清零 if round (19 downto 18)3 then round(19 downto 18)= round(19 downto 18)+1;-时十位的跳时 else round(19 downto 18)=00;-清零 end if; end if; end if; end if; end if; end if; end if; elsif tz=01 then -校秒 if an2_out=1and an3_out=0 then if round (3 downto 0)9 then round(3 downto 0)= round(3 downto 0)+1; else round(3 downto 0)=0000; if round (6 downto 4)5 then round(6 downto 4)= round(6 downto 4)+1; else round(6 downto 4)0 then round(3 downto 0)= round(3 downto 0)-1; else round(3 downto 0)0 then round(6 downto 4)= round(6 downto 4)-1; else round(6 downto 4)=101; end if; end if; end if; elsif tz=10 then-校分 if an2_out=1 and an3_out=0 then if round (10 downto 7)9 then round(10 downto 7)= round(10 downto 7)+1; else round(10 downto 7)=0000; if round (13 downto 11)5 then round(13 downto 11)= round(13 downto 11)+1; else round(13 downto 11)0 then round(10 downto 7)= round(10 downto 7)-1; else round(10 downto 7)0 then round(13 downto 11)= round(13 downto 11)-1; else round (13 downto 11)1 and round(17 downto 14)3 then round( 19 downto 18)=00; else if rou
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 美术课件儿童乐园
- 美术生班会课课件
- 幼儿园交通事故应急预案
- 企业信息安全管理体系认证
- 建筑工程起重机械安全监督管理规定
- 电力工程施工安全管控措施
- 建筑安全体验馆建设方案
- 医院开展安全生产月活动
- 2025年咖啡连锁经营项目规划申请报告模板
- 2025至2030全球及中国移动钱包行业项目调研及市场前景预测评估报告
- 月骨骨折查房
- 十典九章宣贯(终)
- 人工智能在控制中的应用
- 商品混凝土质量控制要点培训课件
- 客户关系管理程广见介绍
- 仲景心法传讲系列四
- 文创园物业管理方案
- 2023年6月广东省普通高中学业水平考试生物试卷含答案
- 盟史简介12.10.18课件
- 行车安全风险点告知牌
- 2019-2020鞍山八年第二学期语文期末考试带答案
评论
0/150
提交评论