基于VHDL语言的简易电子钟课程设计.doc_第1页
基于VHDL语言的简易电子钟课程设计.doc_第2页
免费预览已结束,剩余24页可下载查看

下载本文档

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

文档简介

设计题目:简易数字电子钟 专业班级: 电子信息工程二班学号:姓名:指导教师: 引言 目录第1章 数字电子钟计内容及要求 1.1 设计内容 1.2功能说明 第二章数字电子钟系统框图及工作原理 2.1 系统框图 2.2 电子钟总体工作原理与设计 第3章 各功能模块的设计 3.1正常计时模块 3.2分频模块产生电路 3.3分时模块产生电路 3.4秒模块产生电路 3.5分模块产生电路 3.6时模块产生电路 3.7扫描模块产生电路第四章系统调试与分析 4.1 系统调试 4.1.1 调试方法 4.1.2 调试故障及解决方法 4.2 结果分析 第五章 课程设计感想 引言数字时钟是一种用数字电路技术实现时、分、秒计时的装置,数字时钟走时精度高,稳定性好,使用方便,不需要经常调校,数字式时钟用秒脉冲发生器的精度稳定保证了数字钟的质量电子设计自动化(eda)技术发展越来越迅速,利用计算机辅助设计已成为发展趋势。vhdl语言具有强大的电路描述和建模能力,用vhdl开发的数字电路与开发平台以及硬件实现芯片无关,可移植性、可重用性好。vhdl语言能够在系统级、行为级、寄存器传输级、门级等各个层次对数字电路进行描述,并可以在不同层次进行不同级别的仿真,能极大得保证设计的正确性和设计指标的实现。quartus 设计软件提供了一个完整的、多平台的设计环境,它可以轻易满足特定设计项目的要求。数字时钟是一种用数字电路技术实现时、分、秒计时的装置,数字时钟走时精度高,稳定性好,使用方便,不需要经常调校,数字式时钟用秒脉冲发生器的精度稳定保证了数字钟的质量第一章 数字电子钟计内容及要求1.1设计内容1学习altera公司的fpga/cpld的结构、特点和性能。2学习集成开发软件max+plus ii/quartus ii的使用及设计过程。3熟悉eda工具设计数字电路设计方法,掌握vhdl硬件描述语言设计方法。4根据给定题目设计数字电路,来加深对可编程逻辑器件的理解和掌握。1.2功能要求说明1在所选择器件内完成简易时钟的设计,要求设计完成后芯片具有时、分、秒的计时;译码;输出七段码;最大计时23时59分59秒;秒闪功能。2简易时钟要求具有对时功能,具体对时的实现方式自行决定,要求设计合理,以操作简单为原则(根具具体的工作进度,可以考虑增加整点报时等附加功能)。3在相应的器件平台上完成设计的输入、编译、综合或适配通过。第二章 数字电子钟系统框图及工作原理2.1工作原理 系统主要由振荡器、分频器、计数器、译码显示电路和校时电路组成。振荡器产生稳定的分频脉冲信号,作为数字钟的时间基准,然后经过分频器输出标准秒脉冲。秒计数器满60分向分计数器进位,分计数器满60后向小时计数器进位,小时计数器按照二十四进制计数。计数器的输出分别由译码器送显示器显示。2.2设计内容 数字电子钟由振荡器、分频器、计数器、译码显示电路和校时电路组成。振荡器产生稳定的高频脉冲信号,作为数字钟的时间基准,然后经过分频器输出标准秒脉冲。秒计数器满60后向分计数器进位,分计数器满60后向小时计数器进位,小时计数器按照“24翻1”规律计数。计数器的输出分别经译码器送显示器显示。1)时钟产生电路。将开发板上的时钟信号经过分频得到不同频率的时钟,分别作用于定时计数、led扫描。 2)控制逻辑电路。完成电子钟的系统逻辑控制。 3)计时电路。主要按照时钟模式完成计时功能。 4)译码电路。根据计时模块的状态输出值来确定对应位的数据,从而驱动显示电路。 5)显示控制电路。主要执行选择所对应位的数据功能,显示正确的时间。第三章各功能模块的设计 顶层电路设计library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity zong isport( cp,rst:in std_logic; out1: out std_logic_vector(7 downto 0); out2: out std_logic_vector(7 downto 0); end zong; architecture rtl of zong is component fenpin/调用分频电路port( clk1: in std_logic; clk:out std_logic );end component;component fenshi/调用分时电路port( clks,rst: in std_logic; sl,sh,ml,mh,hl,hh:in std_logic_vector(3 downto 0); num: out std_logic_vector(3 downto 0); outbit:out std_logic_vector(7 downto 0);end component;component second/调用秒电路port(clk,rst:in std_logic; enmin:out std_logic; sh:out std_logic_vector(3 downto 0); sl:out std_logic_vector(3 downto 0) );end component;component minute/调用分电路 port(clk1,rst:in std_logic; enhor:out std_logic; mh:out std_logic_vector(3 downto 0); ml:out std_logic_vector(3 downto 0) );end component;component hour/调用小时电路port(clk2,rst:in std_logic; hh:out std_logic_vector(3 downto 0); hl:out std_logic_vector(3 downto 0) ); end component; component clks/调用扫描脉冲电路port( clk1:in std_logic; clks:out std_logic); end component; component saomiao/调用扫描电路port( clk1: in std_logic; clks: out std_logic); end component; component saomiao2/调用翻译电路 port( clks:in std_logic; num:in std_logic_vector(3 downto 0); outled:out std_logic_vector(7 downto 0); end component; signal clk,clk2,enmin,enhor:std_logic; signal s0,s1,m0,m1,h0,h1,num:std_logic_vector(3 downto 0 ); begin u0:fenpin port map(cp,clk); u1:fenshi port map(clk2,rst,s0,s1,m0,m1,h0,h1,num,out1); u2:second port map(clk,rst,enmin,s1,s0); u3:minute port map(enmin,rst,enhor,m1,m0); u4:hour port map(enhor,rst,m1,m0); u5:clks port map(cp,clk2); u6:saomiao port map(cp,clk2); u7:saomiao2port map(clk2,num,out2); end rtl;3.1 正常扫描(分时复用脉冲)模块产生电路 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all; entity clks is port( clk1: in std_logic; clks:out std_logic);end clks; architecture a_counter of clks is signal hm: std_logic_vector(24 downto 0); signal fpb: std_logic; begin process(clk1) begin if (clk1event and clk1=1) then if hm=50 then hm=0000000000000000000000000; fpb=not fpb; else hm=hm+1; end if; end if; end process; end a_counter;3.2分频模块电路设计(产生秒脉冲)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all; entity fenpin is port( clk1: in std_logic; clk:out std_logic );end fenpin; architecture a_counter of fenpin is signal lm : std_logic_vector(24 downto 0); signal fpa: std_logic; begin process(clk1) begin if (clk1event and clk1=1) then if lm=24999999 then lm=0000000000000000000000000; fpa=not fpa; else lm=lm+1; end if; end if; end process; end a_counter; 3.2分时模块电路电路(分时复用)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all; entity fenshi is port( clks,rst: in std_logic; sl,sh,ml,mh,hl,hh:in std_logic_vector(3 downto 0); num: out std_logic_vector(3 downto 0); outbit:out std_logic_vector(7 downto 0);end fenshi; architecture a_counter of fenshi is signal st:std_logic_vector(2 downto 0); begin process (clks) begin if(clksevent and clks=1) then stnum=sl; outbitnum=sh; outbitnum=ml; outbitnum=mh; outbitnum=hl; outbitnum=hh; outbitoutbit=00000000; end case; end process; end a_counter; 3.4秒模块生成电路设计library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity second is port(clk,rst:in std_logic; enmin:out std_logic; sh:buffer std_logic_vector(3 downto 0); sl:buffer std_logic_vector(3 downto 0) );end second;architecture arch_tcx of second isbegin process(clk,rst) begin if rst=0 then sl=0000; sh=0000; enmin=0; elsif (clkevent and clk=1) then if sl=9 then sl=0000; if sh=5 then enmin=1; sh=0000; else sh=sh+1; end if; else sl=sl+1; end if; end if; end process; end arch_tcx;3.5 分模块生成电路设计library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity minute is port(clk1,rst:in std_logic; enhor:out std_logic; mh:inout std_logic_vector(3 downto 0); ml:inout std_logic_vector(3 downto 0) );end minute;architecture arch_tcx of minute is signal en2: std_logic_vector(1 downto 0); signal sl,sh:std_logic_vector(3 downto 0); begin process(clk1,rst) begin if rst=0 then ml=0000; mh=0000; enhor=0; elsif (clk1event and clk1=1) then if ml=9 then ml=0000; if sh=5 then enhor=1; mh=0000; else mh=mh+1; end if; else ml=ml+1; end if; end if; end process; end arch_tcx;3.6 时模块生成电路设计 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity hour is port(clk2,rst:in std_logic; hh:inout std_logic_vector(3 downto 0); hl:inout std_logic_vector(3 downto 0) );end hour;architecture arch_tcx of hour is begin process(clk2,rst) begin if rst=0 then hl=0000; hh=0000; elsif (clk2event and clk2=1) then if hl=4 then hl=0000; if hh=2 then hh=0000; else hh=hh+1; end if; else hloutledoutledoutledoutledoutledoutledoutledoutledoutledoutledoutledoutledoutledoutledoutledoutledoutled=00111111; end case; end process; end a_counter; 第四章 系统调试与分析4.1 系统调试4.1.1 调试方法实验运用的是vhdl语言与原理图混合设计的方法,因此有程序调试和原理图调试两部分。实验步骤如下:1、 新建工程、vhdl文档输入设计模块子程序2、 调试各个子程序是否存在语法错误的问题3、 对各子模块进行波形仿真,验证输出是否正确4、 各子模块生成图元文件5、 新建工程、原理图文档,将各个子模块文件夹下的文档拷贝到新建工程中6、 根据系统设计框图将各个模块图元文件连接成原理图7、 检验原理图是否正确8、 最后原理图仿真,检查波形图是否正确4.1.2 调试故障及解决方法 在整个实验调试过程中,最主要出现的问题是对vhdl语言的不熟悉,导致在程序编写的过程中出现了不少语法错误导致影响实验结果的问题。其次是软件运用不熟练使得影响实验进度,有时也会影响了实验调试。针对实验中出现了问题,总结了以下一些解决方案和注意事项:1、 程序书写的过程中要注意书写的层次,便于出错时对程序的查找;2、 程序输入时应仔细认真,以免个别字母的错误输入影响实验结果;3、 分模块设计分模块调试,便于对错误的纠正;4、 项目名必须与顶层文件名相同;5、 程序命名过程中,以一定的意义字母命名,便于之后读程序;6、 在原理图设计上,注意总线的书写。设计中主要用的是vhdl语言中的if语句和case语句,因此要对这两种语句的运用十分熟悉。并且其不区分大小写,所以在命名时应注意此问题。4.2 结果分析 4.2.1管脚配置及编译:第五章课程设计感想本次课程设计,我们学会了如何利用vhdl语言设计数字电子钟。本设计使用了基于altera公司的开发软件工具quartus ii,本系统即实现了可以输出三电子波形的简易多功能波形发生器,仿真结果证明,该设计正确有效,可以作为制作实物的理论依据。本次实验不仅仅要求对程序进行正确的编写并进行编译,同时,将四种模块连接以后,还要对qsf文件进行正确的管脚配置。总电路图成功编译后,将接口插座j002与j102连接、j006与j

温馨提示

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

评论

0/150

提交评论