EDA电子钟设计.docx

上传人:b****3 文档编号:10972420 上传时间:2023-05-28 格式:DOCX 页数:17 大小:275.34KB
下载 相关 举报
EDA电子钟设计.docx_第1页
第1页 / 共17页
EDA电子钟设计.docx_第2页
第2页 / 共17页
EDA电子钟设计.docx_第3页
第3页 / 共17页
EDA电子钟设计.docx_第4页
第4页 / 共17页
EDA电子钟设计.docx_第5页
第5页 / 共17页
EDA电子钟设计.docx_第6页
第6页 / 共17页
EDA电子钟设计.docx_第7页
第7页 / 共17页
EDA电子钟设计.docx_第8页
第8页 / 共17页
EDA电子钟设计.docx_第9页
第9页 / 共17页
EDA电子钟设计.docx_第10页
第10页 / 共17页
EDA电子钟设计.docx_第11页
第11页 / 共17页
EDA电子钟设计.docx_第12页
第12页 / 共17页
EDA电子钟设计.docx_第13页
第13页 / 共17页
EDA电子钟设计.docx_第14页
第14页 / 共17页
EDA电子钟设计.docx_第15页
第15页 / 共17页
EDA电子钟设计.docx_第16页
第16页 / 共17页
EDA电子钟设计.docx_第17页
第17页 / 共17页
亲,该文档总共17页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

EDA电子钟设计.docx

《EDA电子钟设计.docx》由会员分享,可在线阅读,更多相关《EDA电子钟设计.docx(17页珍藏版)》请在冰点文库上搜索。

EDA电子钟设计.docx

EDA电子钟设计

EDA电子钟设计

一、设计目的

1.掌握VHDL语言的基本运用。

2.掌握复杂系统的EDA设计方法。

3.学习多层次、多模块系统设计。

4.了解数字钟的工作原理,利用VHDL语言实现数字钟。

5.掌握QuartusⅡ的简单操作并会使用EDA实验箱。

6.掌握各芯片的逻辑功能及使用方法。

二、系统总体设计

我们设计的是多功能数字钟,共有5个系统模块组成,分别是:

液晶显示屏、调时控制开关(用的是拨码开关)、LED显示状态灯及蜂鸣器报时系统和时钟频率系统。

我们设计的是以24小时制显示,数码管扫描显示时、分、秒;能够正常计时和调时、调分等校时功能;经过我们设计的数字钟具有蜂鸣器整点报时的功能,还具备设置闹钟功能。

LED显示

 

图2.1多功能数字钟模拟系统基本组成框图

三、详细设计

3.1数字钟的基本工作原理

3.1.1时基T产生电路

数字钟以其显示时间的直观性、走时准确性作为一种计时工具,数字钟的基本组成部分离不开计数器,在控制逻辑电路的控制下完成预定的各项功能。

由晶振产生的频率非常稳定的脉冲,经整形、稳定电路后,产生一个频率为1Hz的、非常稳定的计数时钟脉冲。

3.1.2调时、调分信号的产生

由计数器的计数过程可知,正常计数时,当秒计数器(60进制)计数到59时,再来一个脉冲,则秒计数器清零,重新开始新一轮的计数,而进位则作为分计数器的计数脉冲,使分计数器计数加1。

现在我们把电路稍做变动:

把秒计数器的进位脉冲和一个频率为2Hz的脉冲信号同时接到一个2选1数据选择器的两个数据输入端,而位选信号则接一个脉冲按键开关,当按键开关不按下去时(即为0),则数据选择器将秒计数器的进位脉冲送到分计数器,此时,数字钟正常工作;当按键开关按下去时(即为1),则数据选择器将另外一个2Hz的信号作为分计数器的计数脉冲,使其计数频率加快,当达到正确时间时,松开按键开关,从而达到调时的目的。

调节小时的时间也一样的实现。

3.1.3计数显示电路

计数部分:

由两个60进制计数器和一个24进制计数器组成,其中60进制计数器可用6进制计数器和10进制计数器构成;24进制的小时计数同样可用6进制计数器和10进制计数器得到:

当计数器计数到24时,“2”和“4”同时进行清零,则可实现24进制计数。

3.2设计思路

根据系统设计要求,系统设计采用自底向上的设计方法,由时钟分频部分、计时部分、按键部分调时部分和显示部分五个部分组成。

这些模块都放在一个顶层文件中。

3.2.1时钟计数

首先下载程序进行复位清零操作,电子钟从00:

00:

00计时开始。

sethour可以调整时钟的小时部分,setmin可以调整分钟,步进为1。

由于电子钟的最小计时单位是1s,因此提供给系统的内部的时钟频率应该大于1Hz,这里取100Hz。

CLK端连接外部10Hz的时钟输入信号clk。

对clk进行计数,当clk=10时,秒加1,当秒加到60时,分加1;当分加到60时,时加1;当时加到24时,全部清0,从新计时。

用6位数码管分别显示“时”、“分”、“秒”,通过OUTPUT(6DOWNTO0)上的信号来点亮指定的LED七段显示数码管。

3.2.2时间设置

手动调节分钟、小时,可以对所设计的时钟任意调时间,这样使数字钟真正具有使用功能。

我们可以通过实验板上的键7和键4进行任意的调整,因为我们用的时钟信号均是1HZ的,所以每LED灯变化一次就来一个脉冲,即计数一次。

根据系统设计要求,系统设计采用自顶向下设计方法,由时钟分频部分、计时部分、按键部分调时部分和显示部分五个部分组成。

这些模块都放在一个顶层文件中。

1)通过对md1按键高低电平的控制可以进入时钟的另一个调时模式,调试模式和计时模式是分开互不影响的。

然后再通过对md2[1]和md2[2]对时钟进行时间设定。

等到计时到达设置时间时,实现打铃功能。

2)用6位数码管分别显示“时”、“分”、“秒”,通过DOUT(6DOWNTO0)上的信号来点亮指定的LED七段显示数码管。

3)由于电子钟的最小计时单位是1s,因此提供给系统的内部的时钟频率应该大于1Hz,这里取100Hz。

CLK端连接外部10Hz的时钟输入信号clk。

对clk进行计数,当clk=10时,秒加1,当秒加到60时,分加1;当分加到60时,时加1;当时加到24时,全部清0,从新计时。

4)首先下载程序进行复位清零操作,电子钟从00:

00:

00计时开始。

md2[1]可以调整时钟的小时部分,md2[2]可以调整分钟,步进为1。

顶层设计分析:

对于电子钟的设计,这里将采用自底向上的设计方法进行设计,因此首先需要进行电子钟的底层设计。

本节将首先介绍电子钟的系统结构和模块划分,然后设计出顶层VHDL设计程序。

源程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityszzis

------------------------------------------------端口定义

port(clk:

instd_logic;

clk1:

instd_logic;

md1:

instd_logic;

md2:

instd_logic_vector(1downto0);

ledout1:

outstd_logic;

ledout2:

outstd_logic;

speak:

outstd_logic;

dout:

outstd_logic_vector(6downto0);

selout:

outstd_logic_vector(2downto0));

endszz;

architectureoneofszzis

signalsel:

std_logic_vector(2downto0);

signalhou1:

std_logic_vector(3downto0);

signalhou2:

std_logic_vector(3downto0);

signalmin1:

std_logic_vector(3downto0);

signalmin2:

std_logic_vector(3downto0);

signalseth1:

std_logic_vector(3downto0);

signalseth2:

std_logic_vector(3downto0);

signalsetm1:

std_logic_vector(3downto0);

signalsetm2:

std_logic_vector(3downto0);

signalsec1:

std_logic_vector(3downto0);

signalsec2:

std_logic_vector(3downto0);

signalh1:

std_logic_vector(3downto0);

signalh2:

std_logic_vector(3downto0);

signalm1:

std_logic_vector(3downto0);

signalm2:

std_logic_vector(3downto0);

signals1:

std_logic_vector(3downto0);

signals2:

std_logic_vector(3downto0);

begin

----------------------------------------------模6计数

choice:

process(clk1)

begin

ifclk1'eventandclk1='1'then

ifsel="101"then

sel<="000";

else

sel<=sel+1;

endif;

endif;

endprocesschoice;

-----------------------------------------------小时十位

h110:

process(clk,hou2,min1,min2,sec1,sec2,md1,md2)

begin

ifclk'eventandclk='1'then

if(hou1="0010"andhou2="0011")and(min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001")then

hou1<="0000";

elsifhou1="0010"andhou2="0011"andmd1='0'andmd2="01"then--当时间为23点且处于校时状态时

hou1<="0000";

elsif(hou2="1001"and(min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001"))or(hou2="1001"andmd1='0'andmd2="01")then

hou1<=hou1+1;

endif;

endif;

endprocessh110;

-----------------------------------------------小时个位

h220:

process(clk,min1,min2,sec1,sec2,md1,md2,hou1)

begin

ifclk'eventandclk='1'then

if(hou1="0010"andhou2="0011")and(min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001")then

hou2<="0000";

elsifhou2="1001"and(min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001")then

hou2<="0000";

elsif(hou2="1001"andmd1='0'andmd2="01")or(hou1="0010"andhou2="0011")then

hou2<="0000";--md<='1';

elsif((min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001"))or(md1='0'andmd2="01")then

hou2<=hou2+1;--speak<=clk;

endif;

endif;

endprocessh220;

-----------------------------------------------分钟十位

m110:

process(clk,min2,sec1,sec2,md1,md2)

begin

ifclk'eventandclk='1'then

if(min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001")then

min1<="0000";

elsifmin1="0101"andmin2="1001"and(md1='0'andmd2="00")then

min1<="0000";

elsif(min2="1001"and(sec1="0101"andsec2="1001"))or(min2="1001"andmd1='0'andmd2="00")then

min1<=min1+1;

endif;

endif;--endif;

endprocessm110;

----------------------------------------------分钟个位

m220:

process(clk,sec1,sec2,md1,md2)

begin

ifclk'eventandclk='1'then

ifmin2="1001"and(sec1="0101"andsec2="1001")then

min2<="0000";

elsifmin2="1001"and(md1='0'andmd2="00")then

min2<="0000";

elseif(sec1="0101"andsec2="1001")or(md1='0'andmd2="00")then

min2<=min2+1;

endif;

endif;endif;

endprocessm220;

---------------------------------------------秒十位

s110:

process(clk)

begin

ifclk'eventandclk='1'then

if(sec1="0101"andsec2="1001")then

sec1<="0000";

elseifsec2="1001"then

sec1<=sec1+1;

endif;

endif;endif;

endprocesss110;

--------------------------------------------秒个位

s220:

process(clk)

begin

ifclk'eventandclk='1'then

ifsec2="1001"then

sec2<="0000";

elsesec2<=sec2+1;

endif;

endif;

endprocesss220;

-------------------------------------------时间设置小时部分

sethour1:

process(clk,seth2)

begin

ifclk'eventandclk='1'then

ifseth1="0010"andseth2="0011"then

seth1<="0000";

elsifseth2="1001"then

seth1<=seth1+1;

endif;

endif;

endprocesssethour1;

-------------------------------------------

sethour2:

process(clk,md1,md2,seth1)

begin

ifclk'eventandclk='1'then

if(seth1="0010"andseth2="0011")orseth2="1001"then

seth2<="0000";

elsifmd1='1'andmd2="00"then

seth2<=seth2+1;

endif;

endif;

endprocesssethour2;

-------------------------------------------时间设置分钟部分

setmin1:

process(clk,setm2)

begin

ifclk'eventandclk='1'then

ifsetm1="0101"andsetm2="1001"then

setm1<="0000";

elsifsetm2="1001"then

setm1<=setm1+1;

endif;

endif;

endprocesssetmin1;

----------------------------------------------

setmin2:

process(clk,md1,md2)

begin

ifclk'eventandclk='1'then

ifsetm2="1001"then

setm2<="0000";

elsifmd1='1'andmd2="01"then

setm2<=setm2+1;

endif;

endif;

endprocesssetmin2;

--------------------------------------------闹铃

speaker:

process(clk1,hou1,hou2,min1,min2)

begin

ifclk1'eventandclk1='1'then

------------------------------------------------闹钟判断,一分钟响铃

ifseth1=hou1andseth2=hou2andsetm1=min1andsetm2=min2then

speak<=clk;

ledout1<=clk;

elsespeak<='0';

ledout1<='0';

----------------------整点报时,3秒钟响铃

if"0000"=min1and"0000"=min2andsec1="0000"then

ifsec2="0000"orsec2="0001"orsec2="0010"then

speak<='1';

ledout2<=clk;

elsespeak<='0';

ledout2<='0';

endif;

endif;

endif;

endif;

endprocessspeaker;

-------------------------------------------译码显示部分

disp:

process(sel,md1,hou1,hou2,min1,min2,sec1,sec2,seth1,seth2,setm1,setm2)

begin

ifsel="101"then

selout<="101";

caseh1is

when"0000"=>dout<="0111111";

when"0001"=>dout<="0000110";

when"0010"=>dout<="1011011";

whenothers=>dout<="1000000";

endcase;

elsifsel="100"then

selout<="100";

caseh2is

when"0000"=>dout<="0111111";

when"0001"=>dout<="0000110";

when"0010"=>dout<="1011011";

when"0011"=>dout<="1001111";

when"0100"=>dout<="1100110";

when"0101"=>dout<="1101101";

when"0110"=>dout<="1111101";

when"0111"=>dout<="0000111";

when"1000"=>dout<="1111111";

when"1001"=>dout<="1101111";

whenothers=>dout<="1000000";

endcase;

elsifsel="011"then

selout<="011";

casem1is

when"0000"=>dout<="0111111";

when"0001"=>dout<="0000110";

when"0010"=>dout<="1011011";

when"0011"=>dout<="1001111";

when"0100"=>dout<="1100110";

when"0101"=>dout<="1101101";

whenothers=>dout<="1000000";

endcase;

elsifsel="010"then

selout<="010";

casem2is

when"0000"=>dout<="0111111";

when"0001"=>dout<="0000110";

when"0010"=>dout<="1011011";

when"0011"=>dout<="1001111";

when"0100"=>dout<="1100110";

when"0101"=>dout<="1101101";

when"0110"=>dout<="1111101";

when"0111"=>dout<="0000111";

when"1000"=>dout<="1111111";

when"1001"=>dout<="1101111";

whenothers=>dout<="1000000";

endcase;

elsifsel="001"then

selout<="001";

cases1is

when"0000"=>dout<="0111111";

when"0001"=>dout<="0000110";

when"0010"=>dout<="1011011";

when"0011"=>dout<="1001111";

when"0100"=>dout<="1100110";

when"0101"=>dout<="1101101";

whenothers=>dout<="1000000";

endcase;

elsifsel="000"then

selout<="000";

cases2is

when"0000"=>dout<="0111111";

when"0001"=>dout<="0000110";

when"0010"=>dout<="1011011";

when"0011"=>dout<="1001111";

when"0100"=>dout<="1100110";

when"0101"=>dout<="1101101";

when"0110"=>dout<="1111101";

when"0111"=>dout<="0000111";

when"1000"=>dout<="1111111";

when"1001"=>dout<="1101111";

whenothers=>dout<="1000000";

endcase;

endif;

ifmd1='0'then---------------计时时间显示和设置模式

h1<=hou1;h2<=hou2;

m1<=min1;m2<=min2;

s1<=sec1;s2<=sec2;

else-----------闹铃时间现实和设置模式

h1<=seth1;h2<=seth2;

m1<=setm1;m2<=setm2;

s1<="1111";s2<="1111";

endif;

endprocessdisp;

endone;

四、仿真分析

各端口的功能为:

clk,clk1端:

时钟信号输入端。

dout[0..6]:

数码管选择端。

Selout[2..0]:

七段码译码器扫描接口输入端。

md1,md[1..0]:

三个输入端。

ledout1,ledout2:

显示灯。

speak:

蜂鸣器。

图4.1波形仿真图

实验连线:

clk接时钟信号CLK0,

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

当前位置:首页 > 求职职场 > 简历

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

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