基于FPGA的数字时钟的设计1.docx

上传人:b****8 文档编号:12699774 上传时间:2023-06-07 格式:DOCX 页数:21 大小:23.04KB
下载 相关 举报
基于FPGA的数字时钟的设计1.docx_第1页
第1页 / 共21页
基于FPGA的数字时钟的设计1.docx_第2页
第2页 / 共21页
基于FPGA的数字时钟的设计1.docx_第3页
第3页 / 共21页
基于FPGA的数字时钟的设计1.docx_第4页
第4页 / 共21页
基于FPGA的数字时钟的设计1.docx_第5页
第5页 / 共21页
基于FPGA的数字时钟的设计1.docx_第6页
第6页 / 共21页
基于FPGA的数字时钟的设计1.docx_第7页
第7页 / 共21页
基于FPGA的数字时钟的设计1.docx_第8页
第8页 / 共21页
基于FPGA的数字时钟的设计1.docx_第9页
第9页 / 共21页
基于FPGA的数字时钟的设计1.docx_第10页
第10页 / 共21页
基于FPGA的数字时钟的设计1.docx_第11页
第11页 / 共21页
基于FPGA的数字时钟的设计1.docx_第12页
第12页 / 共21页
基于FPGA的数字时钟的设计1.docx_第13页
第13页 / 共21页
基于FPGA的数字时钟的设计1.docx_第14页
第14页 / 共21页
基于FPGA的数字时钟的设计1.docx_第15页
第15页 / 共21页
基于FPGA的数字时钟的设计1.docx_第16页
第16页 / 共21页
基于FPGA的数字时钟的设计1.docx_第17页
第17页 / 共21页
基于FPGA的数字时钟的设计1.docx_第18页
第18页 / 共21页
基于FPGA的数字时钟的设计1.docx_第19页
第19页 / 共21页
基于FPGA的数字时钟的设计1.docx_第20页
第20页 / 共21页
亲,该文档总共21页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

基于FPGA的数字时钟的设计1.docx

《基于FPGA的数字时钟的设计1.docx》由会员分享,可在线阅读,更多相关《基于FPGA的数字时钟的设计1.docx(21页珍藏版)》请在冰点文库上搜索。

基于FPGA的数字时钟的设计1.docx

基于FPGA的数字时钟的设计1

基于FPGA的数字时钟的设计之答禄夫天创作

创作时间:

贰零贰壹年柒月贰叁拾日

课题:

基于FPGA的数字时钟的设计

学院:

电气信息工程学院

专业:

丈量控制与仪器

班级:

08测控

(2)班

姓名:

潘志东

学号:

08314239

合作者姓名:

颜志林

2010年12月12日

综述

近年来随着数字技术的迅速发展,各种中、大规模集成电路在数字系统、控制系统、信号处理等方面都得到了广泛的应用。

这就迫切要求理工科大学生熟悉和掌握经常使用中、大规模集成电路功能及其在实际中的应用方法,除通过实验教学培养数字电路的基本实验方法、分析问题和故障检查方法以及双踪示波器等经常使用仪器使用方法等基本电路的基本实验技能外,还必须培养大学生工程设计和组织实验能力。

本次课程设计的目的在于培养学生对基本电路的应用和掌握,使学生在实验原理的指导下,初步具备基本电路的分析和设计能力,并掌握其应用方法;自行拟定实验步调,检查和排除故障、分析和处理实验结果及撰写实验陈述的能力。

综合实验的设计目的是培养学生初步掌握小型数字系统的设计能力,包含选择设计方案,进行电路设计、装置、调试等环节,运用所学知识进行工程设计、提高实验技能的实践。

数字电子钟是一种计时装置,它具有时、分、秒计时功能和显示时间功能;具有整点报时功能。

本次设计我查阅了大量的文献资料,学到了很多关于数字电路方面的知识,而且更加巩固和掌握了课堂上所学的课本知识,使自己对数字电子技术有了更进一步的认识和了解。

1、课题要求

本课程是电子与信息类专业的专业的专业基础必修课——“数字电路”的配套实验课程。

目的在于培养学生的理论联系实际,分析和解决问题的能力。

通过本课程设计,使学生在理论设计、计算机仿真、指标调测、故障排除等方面得到进一步的训练,加强学生的实践能力。

学生通过设计、仿真、调试、撰写设计陈述等过程,培养学生的动手能力和严谨的工作作风。

1)根据课题要求,复习巩固数字电路有关专业基础知识;

2)掌握数字电路的设计方法,特别是熟悉模块化的设计思想;

3)掌握QUARTUS-2软件的使用方法;

4)熟练掌握EDA工具的使用,特别是原理图输入,波形仿真,能对仿真波形进行分析;

5)具备EDA技术基础,能够熟练使用VHDL语言进行编程,掌握条理化设计方法;

6)掌握多功能数字钟的工作原理,学会分歧进制计数器及时钟控制电路的设计方法;

7)能根据设计要求对设计电路进行仿真和测试;

8)掌握将所设计软件下载到FPGA芯片的下载步调等等。

9)将硬件与软件连接起来,调试电路的功能。

基本功能:

能进行正常的时、分、秒计时功能,分别由6个数码管显示24小时,60分钟,60秒钟的计数器显示。

附加功能:

1)能利用硬件部分按键实现“校时”“校分”“清零”功能;

2)能利用蜂鸣器做整点报时:

当计时到达59’59’’时开始报时,鸣叫时间1秒钟;

3)定时闹铃:

本设计中设置的是在七点时进行闹钟功能,鸣叫过程中,能够进行中断闹铃工作。

自己工作:

负责软件的编程与波形的仿真分析。

2、方案设计与分析

1、时钟功能,具有显示时、分、秒的功能;

2、具有整点报时功能,在整点时使用蜂鸣器进行报时,具有闹钟功能,鸣叫过程中,具有中断闹铃功能。

设计要点

数字钟一般是由振荡器、分频器、计数器、译码器、显示器等几部分组成。

这些都是数字电路中应用最广泛的基本电路,本设计分模块设计实现各部分功能,采取软件编程控制FPGA芯片内部发生振动周期为1s的脉冲。

并将信号送入计数器进行计算,并把累加的结果以“时”、“分”、“秒”的数字显示出来。

“秒”的显示由两级计数器和译码器组成的六十进制计数电路实现;“分”的显示电路“秒”相同,“时”的显示由两级计数器和译码器组成的二十四进制电路来实现。

所有计时结果由六位数码管显示。

数字电子钟由振荡器、分频器计数器、译码显示、报时等电路组成。

振荡器发生稳定的高频脉冲信号,作为数字钟的时间基准,然后经过分频器输出尺度秒脉冲。

秒计数器满60后向分计数器进位,分计数器满60后向小时计数器进位,小时计数器依照“24翻1”规律计数。

计满后各计数器清零,重新计数。

计数器的输出分别经译码器送数码管显示,计时出现误差时,可以用校时电路“校时”“校分”“清零”。

秒脉冲可以通过分频电路得到。

通过报时设计模块可以实现整点报时及定时闹铃,译码显示由七段译码器完成,显示由数码管构成,采取的是动态显示方式。

数码管动态显示:

动态扫描电路将计数器输出的8421BGD码转换为数码管需要的逻辑状态,而且输出数码管的片选信号和为选信号。

所谓动态扫描显示方式是在显示某一位LED显示块的数据的时候,让其它位不显示,然后再显示下一位的数据。

只要包管每一位显示的时间间隔不要太大,利用人眼的视觉暂留的现象,就可以造成各位数据同时显示的假象。

一般每一位的显示时间为1~10ms。

3、单元电路的设计,仿真与分析

(1)分频模块(fenpin)

1)程序:

libraryieee;

useieee.std_logic_1164.all;

entityfenpinis

port(clk6:

instd_logic;

q1000,q5,q1:

outstd_logic);

endfenpin;

architectureccc_arcoffenpinis

signalx:

std_logic;

begin

process(clk6)

variablecnt:

integerrange0to24999;

begin

ifclk6'eventandclk6='1'then

ifcnt<24999then

cnt:

=cnt+1;

else

cnt:

=0;

x<=notx;

endif;

endif;

endprocess;

q1000<=x;

process(x)

variablecnt2:

integerrange0to999;

variabley:

std_logic;

begin

ifx'eventandx='1'then

ifcnt2<999then

cnt2:

=cnt2+1;

q1<='0';

else

cnt2:

=0;

q1<='1';

endif;

endif;

ifx'eventandx='1'then

y:

=noty;

endif;

q5<=y;

endprocess;

endccc_arc;

2)仿真波形:

3)仿真结果分析:

发生用于计时,扫描输入,扫描显示,以及蜂鸣器所需的各个频率的信号。

(2)秒模块(second)

1)程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitysecondis

port(clk1,en1:

instd_logic;

qa:

outstd_logic_vector(3downto0);

co1:

outstd_logic;

qb:

outstd_logic_vector(3downto0));

endsecond;

architectureccofsecondis

signalcout2,cout1:

std_logic_vector(3downto0);

signalmm:

std_logic;

begin

process(clk1,en1)

begin

ifen1='1'then

cout2<="0000";cout1<="0000";

elsif(clk1'eventandclk1='1')then

if(cout2=1andcout1=8)thencout2<=cout2;cout1<=cout1+1;mm<='1';

elsif(cout2=1andcout1=9)thencout2<="0000";cout1<="0000";mm<='0';

elseif(cout1=9)thencout2<=cout2+1;cout1<="0000";mm<='0';

elsecout2<=cout2;cout1<=cout1+1;mm<='0';

endif;

endif;

endif;

endprocess;

co1<=mm;

qa<=cout2;

qb<=cout1;

endcc;

2)仿真波形:

3)仿真结果分析:

该模块实际是一个六十进制计数器,而六十秒为一分钟,故用此模块可以作为秒部分设计,通过观察可知,仿真波形是正确可行的。

(3)分模块(minute)

1)程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityminuteis

port(clk2,en2:

instd_logic;

qc:

outstd_logic_vector(3downto0);

co2:

outstd_logic;

qd:

outstd_logic_vector(3downto0));

endminute;

architecturebbofminuteis

signalcout2,cout1:

std_logic_vector(3downto0);

signalcc:

std_logic;

begin

process(clk2,en2)

begin

ifen2='1'then

if(clk2'eventandclk2='1')then

if(cout2=1andcout1=8)thencout2<=cout2;cout1<=cout1+1;cc<='1';

elsif(cout2=1andcout1=9)thencout2<="0000";cout1<="0000";cc<='0';

elseif(cout1=9)thencout2<=cout2+1;cout1<="0000";cc<='0';

elsecout2<=cout2;cout1<=cout1+1;cc<='0';

endif;

endif;

endif;

endif;

endprocess;

co2<=cc;

qc<=cout2;

qd<=cout1;

endbb

2)仿真波形:

3)仿真结果分析:

此模块实际也是一个六十进制的计数器模块,六十分钟即为一个小时,用此模块就成功解决了分设计模块这个难题。

从仿真波形可知,该设计时正确的。

(4)时模块(hour)

1)程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityhouris

port(clk3,en3:

instd_logic;

qe:

outstd_logic_vector(3downto0);

qf:

outstd_logic_vector(3downto0));

endhour;

architectureaaofhouris

signalcout2,cout1:

std_logic_vector(3downto0);

begin

process(clk3,en3)

begin

ifen3='1'then

if(clk3'eventandclk3='1')then

if(cout2=4andcout1=0)thencout2<="0000";cout1<="0000";

elseif(cout1=9)thencout2<=cout2+1;cout1<="0000";

elsecout2<=cout2;cout1<=cout1+1;

endif;

endif;

endif;

endif;

endprocess;

qe<=cout2;

qf<=cout1;

endaa;

2)仿真波形:

3)仿真结果分析:

这是一个24计数器,用来暗示24小时,通过波形可知,程序设计正确,正常计时是每次清零后从00:

00:

00开始计时的,若要从预置时间开始,可以通过“校时”“校分”“清零”三个按键调整时间。

(5)数码显示驱动模块

1)程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityhhhis

port(n1,n2,n3,n4,n5,n6:

instd_logic_vector(3downto0);

a:

instd_logic_vector(2downto0);

qqq:

outstd_logic_vector(3downto0));

endhhh;

architectureddofhhhis

begin

withaselect

qqq<=n1when"000",

n2when"001",

n3when"010",

n4when"011",

n5when"100",

n6when"101",

"0000"whenothers;

enddd;

2)仿真波形:

3)仿真结果分析:

其实这是一个选择器,从波形图可以很容易看出来。

它是用来选择需要显示的数字,比方秒的十位,就会选择n1到译码显示器显示出来,具备驱动数码管的作用!

(6)片选模块(sell)

1)程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitygggis

port(m:

instd_logic_vector(2downto0);

b:

outstd_logic_vector(5downto0));

endggg;

architectureeeofgggis

begin

withmselect

b<="100000"when"000",

"010000"when"001",

"001000"when"010",

"000100"when"011",

"000010"when"100",

"000001"when"101",

"000000"whenothers;

endee;

2)仿真波形:

3)仿真结果分析:

设置时间时将所需的数据传给显示模块,当设置闹铃时将数据传给闹钟和显示模块。

(7)译码显示模块(display)

1)程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitydecoderis

port(x:

instd_logic_vector(3downto0);

y:

outstd_logic_vector(6downto0));

enddecoder;

architectureoneofdecoderis

begin

withxselect

y<="1111110"when"0000",

"0110000"when"0001",

"1101101"when"0010",

"1111001"when"0011",

"0110011"when"0100",

"1011011"when"0101",

"1011111"when"0110",

"1110000"when"0111",

"1111111"when"1000",

"1111011"when"1001",

"0000000"whenothers;

endone;

2)仿真波形:

3)仿真结果分析:

此模块是用来显示时间的,采取动态显示方式。

(8)报时模块(alart)

1)程序:

libraryieee;

useieee.std_logic_1164.all;

entitysstis

port(h1,h0,m1,m0,s1,s0:

instd_logic_vector(3downto0);

clk4:

instd_logic;

q500:

outstd_logic);

endsst;

architecturesssofsstis

begin

process(clk4,m1,m0,s1,s0)

begin

if(clk4'eventandclk4='1')then

if((h1="0000"andh0="0111"andm1="0000"andm0="0000")

or(m1="0101"andm0="1001"ands1="0101"ands0="1001"))then

q500<='1';

else

q500<='0';

endif;

endif;

endprocess;

endsss;

2)仿真波形:

3)仿真结果分析:

通过观察波形可知,当时钟时间与整点或闹铃预设时间相同时,给出一个脉冲信号,使蜂鸣器鸣叫,实现整点报时和定时闹铃功能。

(9)六进制计数器模块(cnt6)

1)程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitycnt6is

port(clk5:

instd_logic;

n:

outstd_logic_vector(2downto0));

endcnt6;

architecturebehavofcnt6is

signalq1:

std_logic_vector(2downto0);

begin

process(clk5)

begin

ifclk5'eventandclk5='1'then

ifq1<5thenq1<=q1+1;

elseq1<=(others=>'0');

endif;

endif;

endprocess;

n<=q1;

endbehav;

2)仿真波形:

4)仿真结果分析:

很明显可以看出这是一个简单的六进制计数器。

它与3-6译码器配合作用发生片选信号。

(10)两输入与模块(and2a)

1)程序:

libraryieee;

useieee.std_logic_1164.all;

entityandais

port(a1,b1:

instd_logic;

y:

outstd_logic);

endanda;

architectureanofandais

begin

y<=a1andb1;

endan;

2)仿真波形:

3)仿真结果分析:

经观察波形,程序正确。

该与门的两个输入端分别为秒模块和分模块的进位输出信号,当它们均为高电平时,时模块使能端即为高电平,时模块工作。

(11)两输入或模块(or2a)

1)程序:

libraryieee;

useieee.std_logic_1164.all;

entityor_1is

port(a1,b1:

instd_logic;

y:

outstd_logic);

endor_1;

architectureooofor_1is

begin

y<=a1orb1;

endoo;

2)仿真波形:

3)仿真结果分析:

在整个数字钟程序设计中,两处用到两输入或门。

一处是分模块,或门两输入分别是秒模块的进位输出信号和外部校分信号,任一一个信号为高电平,分模块使能端就为高电平,分模块工作。

另一处是在时模块的使能端,它受分模块进位输出和外部校时信号输入的控制,只要其一位高电平,时模块都将工作。

4、顶层电路设计及仿真结果与分析

1)程序:

libraryieee;

useieee.std_logic_1164.all;

entitydigital_clockis

port(clk,sa,sb,sc:

instd_logic;

q1:

outstd_logic;

r:

outstd_logic_vector(5downto0);

q0:

outstd_logic_vector(6downto0));

enddigital_clock;

architecturemainofdigital_clockis

componentanda

port(a1,b1:

instd_logic;

y:

outstd_logic);

endcomponent;

componentor_1

port(a1,b1:

instd_logic;

y:

outstd_logic);

endcomponent;

componentfenpin

port(clk6:

instd_logic;

q1000,q1,q5:

outstd_logic);

endcomponent;

componenthour

port(clk3,en3:

instd_logic;

qe:

outstd_logic_vector(3downto0);

qf:

outstd_logic_vector(3downto0));

endcomponent;

componentminute

port(clk2,en2:

instd_logic;

qc:

outstd_logic_vector(3downto0);

co2:

outstd_logic;

qd:

outstd_logic_vector(3downto0));

endcomponent;

componentsecond

port(clk1,en1:

instd_logic;

qa:

outstd_logic_vector(3downto0);

co1:

outstd_logic;

qb:

outstd_logic_vector(3downto0));

endcomponent;

componentsstis

port(h1,h0,m1,m0,s1,s0:

instd_logic_vector(3downto0);

clk4:

instd_logic;

q500:

outstd_logic);

endcomponent;

componenthhh

port(n1,n2,n3,n4,n5,n6:

instd_logic_vector(3downto0);

a:

instd_logic_vector(2downto0);

qqq:

outstd_lo

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2