EDA数字钟资料_第1页
EDA数字钟资料_第2页
EDA数字钟资料_第3页
EDA数字钟资料_第4页
EDA数字钟资料_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

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

文档简介

1、ed砒术课程设计报告题 目:fpga数字钟设计班 级:学 号:姓 名:同组人员:指导教师:2016年3月29日1. 绪论 12. 功能要求 13设计原理 12.1 基本原理 12.2 总体结构框图 24模块设计 21.1 分频模块 21.2 秒计数模块 41.3 分计数器模块 51.4 时计数器模块 71.5 显示模块 81.6 报时模块 91.7 顶层文件的设计 115. 硬件调试 116. 总结 13参考文献 13fpg徽字钟设计1. 绪论ed徽术是以大规模可编程逻辑器件为设计载体,以硬件描述语言为系统逻辑描述的主要表达方式, 以计算机、 大规模可编程逻辑器件的开发软件及实验开发系统为设计

2、工具, 通过有关的开发软件, 最终形成集成电子系统或专用集成芯片的一门新技术。 全定制和定制专用集成电路正成为新的发展热点, 专用集成电路的设计与应用必须依靠专门的eda:具,21世纪将是ed儆术的高速发展期。现在随着科学技术的迅猛发展, 我们已不在需要用传统的方法去设计数字钟, 基于fpgar小系统板,在quartusii平台上可以更加简单的设计一个数字钟。2. 功能要求1) 具有时,分,秒,计数显示功能,以 24 小时循环计时。2) 具有清零,调节小时、分钟功能。3) 具有整点报时功能。3设计原理3.1 基本原理数字时钟主要由:分频器、扫描显示译码器、 (秒计数器、分计数器、时计数器)或(

3、 六十进制计数器、 、十二进制计数器 电路) 、报时电路组成。fpga1小系统板中的时钟脉冲提供20mhz的脉冲信号,用于分频器的输入信号和扫描显示译码器的扫描。分频器的功能是将20mhz 的脉冲信号转换为200hz的扫描显示信号或1hz的时钟信号,用于秒的计数。秒为60进制计数器,当 1hz 的脉冲信号来临时,开始计数。计数到 59 时,会输出 enfen 高电平,用于分的计数。 setfen 为手动进位端, 置入高电平时也会使 enfen 产生高电平。分计数器为 60 进制计数器, 当 enfen 高电平来临时, 分计数器会开始计数, 计数到 59 时,会产生 enshi 的高电平。 se

4、tshi 为手动置 数端,当 setshi 高定平时, 也会使 enshi 为高电平。 enshi 为时计数器的计数脉冲输入, enshi 高电平时, 时计数器开始计数。 时计数器为 24 进制计数器, 计数到 24 时会自动清零。 reset 为异步清零端, 高定平时, 所有时钟显示数码管均为 0 。 selout 为数码管扫描地址,接入数码管地址的低三位。segout为数码管的输入端,分别接入数码管的a,b,c,d,e,f,g 端口。 output为整点报时输出端。当分为59, 秒为58时,outputl 点亮第一个led灯,当分为59 ,秒为59时,output2 点亮地二个led灯,当

5、分为00,秒为00时,outputl、output2 同时点亮两 个led其他情况时,led均处于灭等状态这样完成报时功能。3.2总体结构框图图3-1总体结构框图4.模块设计4.1 分频模块分频程序产生1hz和200hz的脉冲。1hz的计时脉冲,用于时分秒计数,200hz 的脉冲用于8位八段数码管的扫描显示。代码文件如下,仿真波形如下图4-1所示。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fenpin isport( clk_20m:in std_logic;clk_1hz:o

6、ut std_logic;clk_200hz:out std_logic );end fenpin;architecture fun of fenpin issignal count:std_logic_vector(24 downto 0);signal count1:std_logic_vector(7 downto 0);beginprocess(clk_20m)beginif (clk_20mevent and clk_20m=1) thenif(count=1001100010010110100000000) then count=0000000000000000000000000;

7、clk_1hz=1;else count= count+1;clk_1hz=0;end if;end if;end process;process(clk_20m)beginif (clk_20mevent and clk_20m=1) thenif(count1=11001000) thencount1=00000000;clk_200hz=1;else count1= count1+1;clk_200hz=0;end if;end if;end process;end fun;图4-1分频仿真波形图4.2秒计数模块随着clk脉冲信号的不断到来,countmiao记录出clk的脉冲个数,计数

8、 到59时,在下一个clk脉冲信号到来时,输出端enfen输出高定平,即向分 进 位,同时 countmiao 清零。reset 为清零端,reset 低电平时,当 countmiao 计数从零重新开始计数。setfen为分的手动进位端,当setfen 高定平时且clk 脉冲到来时,输出enfen高电平,向分进位。代码如下,仿真波形如下图 4-4所示。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity miao isport( clk,reset,setfen:in std_logic;

9、enfen:out std_logic;countmiao:out std_logic_vector(7 downto 0);end miao;architecture fun of miao issignal count:std_logic_vector(7 downto 0);signal enfen_1,enfen_2:std_logic;begincountmiao=count;enfen_2=(setfen and clk);enfen=(enfen_1 or enfen_2);process(clk,reset,setfen)beginif(reset=0) thencount=0

10、0000000”;enfen_1=0;elsif(clkevent and clk=1) thenif(count(3 downto 0)=1001) thenif(count16#60#)thenif(count=01011001) then count=00000000”;enfen_1=1;elsecount=count+7;end if;elsecount=00000000”; enfen_1=0;end if;elsif(count16#60#) then count=count+1;enfen_1=0;else count=00000000”; enfen_1=1;end if;e

11、nd if;end process;end fun;替 mu hlcvwt图4-2秒计数器仿真波形图4.3 分计数器模块imiao为秒计数器的enfen 进位输出端,当enfen (imiao )高电平到来时, clk 高电平时,且countfen 开始计数。countfen 计数到59时,下一个enfen (imiao )、clk到来时,enshi高电平,即向时进位,同时countfen 清零reset 为清零端,当reset低电平时,countfen计数从零重新开始计数setshi为时 的手动进位端,当setshi高定平时且clk脉冲到来时,输出en时高电平, 向时进位。代码如下,仿真波形

12、如下图4-3所示。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fen is port( imiao,clk,reset,setshi:in std_logic;enshi:out std_logic;countfen:out std_logic_vector(7 downto 0);end fen;architecture fun of fen is signalenshi_1,enshi_2:std_logic; signal count:std_logic_vector(7

13、downto 0);begincountfen=count; enshi_2=(setshi and clk);enshi=(enshi_1 or enshi_2);process(imiao,reset,setshi)beginif(reset=0) then count=00000000”;elsif(imiaoevent and imiao=1) thenif(count(3 downto 0)=1001) thenif(count16#60#) then if(count=01011001) then count=00000000”;enshi_1=1;else count=count

14、+7;end if;else count=00000000”;end if;elsif(count16#60#) then count=count+1;enshi_1=0;else count=00000000”;end if;end if;end process;end fun;司123s3lem忡m ” t岬*i ii画b迎通芭匡蛇道也烟巨丝笆迎旭旭x1d笆回迪运翅直运巡运j亘冠b芭母l母q arklstlshi0 ain厕用e 解的g 期的g 寝plg 郭尸. 寒? g i图vj isknatm图4-3分计数器仿真波形图 &5. i外,口ihlhlhihi4.4 时计数器模块ifen为分

15、计数器的enshi进位输出端,当enshi (ifen )为高电平时, countshi 计数。countshi 计数到 23 时,当下一个 enshi (ifen )、clk 到来 时,countshi 会自动清零。reset为清零端,当reset 低电平时,countfen 计 数从零重新开始计数。代码如下,仿真波形如下图4-4所示。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity shi isport(ifen,reset:in std_logic;countshi:out st

16、d_logic_vector(7 downto 0);end shi;architecture fun of shi issignal count:std_logic_vector(7 downto 0);begin countshi=count;process(ifen,reset) begin if(reset=0) then count=00000000”;elsif(ifenevent and ifen=1) thenif(count(3 downto 0)=1001) thenif(count16#23#) thencount=count+7;else count=00000000”

17、;end if;elsif(count16#23#) thencount=count+1;else count=00000000”;end if;end if;end process;end fun;图4-4时计数器仿真波形图4.5 显示模块扫描显示译码器是用来显示时钟数值的装置, 将数字时钟的高低电平信号用数码管的数值显示出来。八个数码管中,用六个数码管显示时、分和秒,另外两个可做为时和分、分和秒之间的间隔,始终不显示。 首先对八个数码管进行扫描,每一时刻都只有一个数码管处于扫描状态,并将此时的数字时钟的高低电平通过十六进制的 bcd 码转换为数码管显示数值。首先下载程序进行复位清零操作 ,

18、 电子钟从 00: 00: 00 计时开始。 sethour 可以调整时钟的小时部分, setmin可以调整分钟 , 步进为1。代码如下,仿真波形如下图4-5 所示。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity saomiao isport( clk_smxs:in std_logic;shi:in std_logic_vector(7 downto 0);fen:in std_logic_vector(7 downto 0);miao:in std_logic_vector(7

19、downto 0);selout:out std_logic_vector(7 downto 0);segout:out std_logic_vector(6 downto 0) );end saomiao;architecture fun of saomiao issignal temp:std_logic_vector(2 downto 0);signal seg:std_logic_vector(6 downto 0);signal sel:std_logic_vector(7 downto 0);beginselout=sel;segout=111 then temp=000;else

20、 tempnum:=shi(7downto4);selnum:=shi(3downto0);selnum:=fen(7downto4);sel=11101111;-000001000);selnum:=fen(3 downto -00000011when001=num:=miao(7 selnum:=miao(3 selsel seg seg seg seg seg seg seg seg seg seg seg= null;end case;end if;end process;end fun;t3mbsih tine 目四:iqora;iffin.dusstaitend:5邛uxh ock

21、bb owe中ju不1+1 i国uki国国 510ut5:造” lu 194u.-h hi.4e 叩 ux00 do3d0ccqumiitmooolfl鹿鹿图4-5扫描显示仿真波形图4.6 报时模块nput为分计数器的输出端,当输出58、59和00 (十六进制)时,整点报时器(baoshi)的输出端output 为高电平,点亮led灯。当intput 为58、 59时,点亮一个led灯,当input为00时,点亮两个led灯。其他情况时, led灯均不发光。代码如下,仿真波形如下图 4-6所示。library ieee;use ieee.std_logic_1164.all;use ieee.

22、std_logic_unsigned.all;entity baoshi isport( clk:in std_logic;inputmiao,inputfen:in std_logic_vector(7 downto 0);output:out std_logic_vector(1 downto 0) );end baoshi;architecture fun of baoshi issignal temp:std_logic_vector(1 downto 0);signal nummiao,numfen:std_logic_vector(7 downto 0);beginnummiao=inputmiao;numfen=inputfen;outputtemptemptemptemptempsegout5outputpin_1107b7_n0的segout4outputpin_106606_no3segout3outputpin_105606_ho3segout2outputpin j 046b6_n 口esegoutloutputpin j 03606=ndsegout0outputpin j 016b6_nd哥-output group098bli(7outp

温馨提示

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

评论

0/150

提交评论