毕业设计(论文)-基于VHDL的数字钟设计.doc_第1页
毕业设计(论文)-基于VHDL的数字钟设计.doc_第2页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

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

文档简介

安徽工业经济职业技术学院毕业论文(设计)题 目: 基于vhdl的数字钟设计 系 别:电子信息技术系专 业:电子信息工程技术学 号:201254427学生姓名:指导教师:职 称:二一四年 五月 月 十三 日【摘要】 20世纪90年代,国际上电子和计算机技术较为先进的国家,一直在积极探索新的电子电路设计方法,并在设计方法、工具等方面进行了彻底的变革,取得了巨大成功。在电子技术设计领域,可编程逻辑器件(如cpld、fpga)的应用,已得到广泛的普及,这些器件为数字系统的设计带来了极大的灵活性。 eda技术在电子系统设计领域越来越普及,本设计主要利用vhdl语言在eda平台上设计一个电子数字钟, 【关键词】数字钟 eda vhdl语言 目录摘要:. 1 关键词:. 1 绪论.31.设计目的 . 4 2.设计内容 .4 3.设计原理 .43.1数字钟的基本工作原理.43.2数字钟设计的电路原理图.6.4.单元模块的设计.64.1秒计数器的模块.64.2分计数器的模块.84.3时计数器的模块.104.4整点报时器模块.124.5调时调分模块.134.6 led显示译码器模块.15 5.仿真结果.17.结语. 17参考文献 . 18 绪论 是电子设计自动化(lcctronic design automation)的缩写,是90年代初从cad(计算机辅助设备),cam(计算机辅助制造),cat(计算机辅助测试)和cae(计算机辅助工程)的概念发展而来的。eda技术是以计算机为工具,根据硬件描述语言hdl完成的设计文件,自动的完成逻辑编译,化简,分割,综合及优化,布局布线,仿真以及对特定目标芯片的适配编译和编程下载等工作,这种将设计实体内外部分的概念是vhdl系统设计的基本点。应用vhdl进行工程设计的优点是多方面的。其优点是:与其它硬件描述语言相比,vhdl具有更强的行为描述能力,从而解决了他成为系统设计领域最佳的硬件描述语言,强大的行为描述能力是避开具体的器件结构,从逻辑行为上描述和设计大规模电子系统的重要保证;vhdl丰富的仿真语句和库函数,使得在任何大系统的设计早期就能查验设计系统的功能和可行性,及时可对设计进行。它的计时周期为24小时,显示满刻度为24时59分59秒,另外还具有校时功能和闹钟功能。总的程序由几个各具不同功能的单元模块程序拼接而成,其中包括分频程序模块、时分秒计数和设置程序模块、比较器程序模块、三输入数据选择器程序模块、译码显示程序模块和拼接程序模块。并且使用quartus ii软件进行电路波形仿真,下载到eda实验箱进行验证。 1.设计目的 1)熟练地运用数字系统的设计方法进行数字系统设计; 2)能进行较复杂的数字系统设计; 3)按要求设计一个数字钟。 2.设计内容 1)要求显示秒、分、时,显示格式如下: 图显示格式2)可清零、可调时,具有整点报时功能。3.设计原理 3.1数字钟的基本工作原理: 数字钟以其显示时间的直观性、走时准确性作为一种计时工具,数字钟的基本组成部分离不开计数器, 在控制逻辑电路的控制下完成预定的各项功能。数字钟的基本原理方框图: 数字钟实现原理框图1)时钟计数:完成时、分、秒的正确计时并且显示所计的数字;对秒、分 60进制计数,即从0到59循环计数,时钟24进制计数,即从0到23循环计数,并且在数码管上显示数值。 2)时间设置:手动调节分钟、小时,可以对所设计的时钟任意调时间,这样使数字钟真正具有使用功能。我们可以通过实验板上的键7和键4进行任意的调整,因为我们用的时钟信号均是1hz的,所以每led灯变化一次就来一个脉冲,即计数一次。 3)清零功能:reset为复位键,低电平时实现清零功能,高电平时正常计数。可以根据我们自己任意时间的复位。 4)蜂鸣器在整点时有报时信号产生,蜂鸣器报警。产生“滴答.滴答”的报警声音。 5)led灯在时钟显示时有花样显示信号产生。即根据进位情况,led不停的闪烁,从而产生“花样”信号。 根据总体方框图及各部分分配的功能可知,本系统可以由秒计数器、分钟计数器、小时计数器、整点报时、分的调整以及小时的调整和一个顶层文件构成。采用自顶向下的设计方法,子模块利用vhdl语言设计,顶层文件用原理图的设计方法。显示:小时采用数字时钟 控制单元 时调整 分调整 使能端信号 clk信号 时显示 分显示 秒显示 24进制 60进制 60进制 led显示 整点报时 花样显示 24进制,而分钟均是采用6进制和10进制的组合。3.2数字钟设计的电路原理图 24进制数字钟的电路图4.单元模块的设计4.1.秒计数器模块 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity second is port( clk,reset,setmin:in std_logic; enmin:out std_logic; daout:out std_logic_vector(6 downto 0); end entity second; architecture fun of second is signal count:std_logic_vector(6 downto 0); signal enmin_1,enmin_2:std_logic; -enmin_1为59秒时的进位信号 begin daout=count; -enmin_2由clk调制后的手动调分脉冲信号串 enmin_2=(setmin and clk); -setmin为手动调分控制信号,高电平有效 enmin=(enmin_1 or enmin_2); -enmin为向分进位信号 process(clk,reset,setmin) begin if(reset=0) then count=0000000; -若reset为0,则异步清零 elsif(clkevent and clk=1)then -否则,若clk上升沿到 if(count(3 downto 0)=1001)then -若个位计时恰好到“1001”即9 if(count16#60#)then -又若count小于16#60#,即60h if(count=1011001)then -又若已到59d enmin_1=1;count=0000000; -则置进位为1及count复0 else count=count+7; -未到59d,则加7,而+7=+1+6,则作“加6校正” end if; else -若count不小于16#60#(即count等于或大于16#60#) count=0000000; -count复0 end if; -end if(count16#60#) elsif(count16#60#)then -若个位计数未到“1001”则转此句再判 count=count+1; -若count16#60#则count加1 enmin_1=0 after 100 ns; -则没有发生进位 else end if; end if; end process; end fun 编译过程:仿真图如下:4.2分计数器模块 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity minute is port( clk,clk1,reset,sethour:in std_logic; enhour:out std_logic; daout:out std_logic_vector(6 downto 0); end entity minute; architecture fun of minute is signal count:std_logic_vector(6 downto 0); signal enhour_1,enhour_2:std_logic; begin daout=count; enhour_2=(sethour and clk1); enhour=(enhour_1 or enhour_2); process(clk,reset,sethour) begin if(reset=0)then count=0000000; -若reset=0,则异步清零 elsif(clkevent and clk=1)then -否则,若clk上升沿到 if(count(3 downto 0)=1001)then -若个位计时恰好到“1001”即9 if(count16#60#)then -又若count小于16#60#,即60if(count=1011001)then -又若已到59d enhour_1=1; -则置进位为1count=0000000; -count复0 else count=count+7; -若count未到59d,则加7,即作“加6校正” end if; -使前面的16#60#的个位转变为8421bcd的容量 else count=0000000; -count复0(有此句,则对无效状态电路可自启动) end if; elsif(count16#60#)then count=count+1; -若count16#60#则count加1 enhour_1=0after 100 ns; -没有发生进位 else count=0000000; -否则,若count不小于16#60#count复0 end if; end if; end process; end fun; 编译过程:仿真图如下:4.3.时计数器模块 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity hour is port( clk,reset:in std_logic; daout:out std_logic_vector(5 downto 0); end entity hour; architecture fun of hour is signal count:std_logic_vector(5 downto 0); begin daout=count; process(clk,reset) begin if(reset=0)then count=000000; -若reset=0,则异步清零 elsif(clkevent and clk=1)then -否则,若clk上升沿到 if (count(3 downto 0)=1001)then -若个位计时恰好到1001即9 if(count=16#23#)then -23进制 count=count+7; -若到23d则 else count=000000; -复0 end if; elsif(count16#23#)then -若未到23d,则count进1 count=count+1; else -否则清零 count=000000; end if; end if; end process; end fun; 编译过程:仿真图如下:4.4.整点报时器模块 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity alert is port( clk:in std_logic; dain:in std_logic_vector (6 downto 0); speak:out std_logic; lamp:out std_logic_vector (2 downto 0); end alert; architecture fun of alert is signal coun:std_logic_vector (1 downto 0); signal count1:std_logic_vector (1 downto 0); begin speaker:process(clk) begin speak=10)then count1=00; -count1为三进制加法计数器 else count1=count1+1; end if; end if; end if; end process speaker; lamper:process(clk) begin if(rising_edge(clk)then if(coun=10)then if(coun=00)then lamp=001; -循环点亮三只灯 elsif(coun=01)then lamp=010; elsif(coun=10)then lamp=100; end if; coun=coun+1; else coun=00; end if; end if; end process lamper; end fun; 编译过程:仿真图如下:4.5调时调分模块 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity seltime is port( clk1,reset:in std_logic; sec,min:in std_logic_vector(6 downto 0); hour:in std_logic_vector(5 downto 0); daout:out std_logic_vector(3 downto 0); dp:out std_logic; sel:out std_logic_vector(2 downto 0); end seltime; architecture fun of seltime is signal count:std_logic_vector(2 downto 0); begin sel=count; process(clk1,reset) begin if(reset=0)then count=101)then count=000; else countdaout=sec(3 downto 0);dpdaout(3)=0;daout(2 downto 0)=sec(6 downto 4);dpdaout=min(3 downto 0);dpdaout(3)=0;daout(2 downto 0)=min(6 downto 4);dpdaout=hour(3 downto 0);dpdaout(3 downto 2)=00; daout(1 downto 0)=hour(5 downto 4);dp=0; end case; end process; end fun; 编译过程:仿真图如下:4.6.led显示译码器模块 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity deled is port(num:in std_logic_vector(3 downto 0); led:out std_logic_vector(6 downto 0); end deled; architecture fun of deled is begin led=1111110when num=0000else 0110000when num=0001else 1101101when num=0010else 1111001when num=0011else 0110011when num=0100else 1011011when num=0101else 1011111when num=0110else 1110000when num=0111else 1111111when num=1000else 1111011when num=1001else 1110111when num=1010else 0011111when num=1011else 1001110when num=1100else 0111101when num=1101else 1001111when num=1110else 1000111when num=1111; end fun;编译过程:仿真图如下:5.仿真结果 下图是最后仿真的结果,但是总是无法选中芯片,都是000,得不到正确的结果。可能的原因是fpga的时钟输出为20mhz,经过分频器得到1khz和1hz的频率需要多次的计数,由于计数值太大无法得到正确的仿真结果。数字钟仿真波形 6.结语 本次试验的数字时钟能只够显示时间,其它功能如闹铃、调时、分、秒都能在此基础上进一步的实现,

温馨提示

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

评论

0/150

提交评论