数字电路课程设计实验电子钟.docx

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

数字电路课程设计实验电子钟.docx

《数字电路课程设计实验电子钟.docx》由会员分享,可在线阅读,更多相关《数字电路课程设计实验电子钟.docx(15页珍藏版)》请在冰点文库上搜索。

数字电路课程设计实验电子钟.docx

数字电路课程设计实验电子钟

本科实验报告

多功能数字钟

题目:

多功能数字钟

一、设计要求

要求设计一个具有“时”、“分”、“秒”的十进制数字显示的电子钟,具体要求如下:

1、具有手动校时、校分、校秒的功能。

2、定时与闹钟功能,能在设定的时间发出闹铃声。

3、能进行整点报时,能发出仿中央人民广播电台的整点报时信号。

(从59分50秒起,每隔2秒钟发出一次低音“嘟”的信号,连续5次,最后一次要求高音“嘀”的信号,此信号结束即达到整点)

二、设计分析及系统方案设计

1、系统分析

作为时钟设计,首先需要的是定时器。

输入1Hz秒信号进入通过模60计数器(秒),其进位端作为分信号clk的发生器;之后把该分钟clk信号输入到下一个模60计数器(分),其进位端作为小时信号clk的发生器;最后把小时信号clk输入到模24计数器,这样,时钟的基本框架就完成了。

系统要求能做时钟“具有手动校时、校分、校秒的功能”,因此可以设定一个校时模块,通过人为添加进位端信号达到校时目的。

另外,系统还要求“定时与闹钟功能”,“能进行整点报时”,这个可以通过一个模块进行判定,当达到设定要求时,输出一定频率的信号给SPEAKER.

2、系统方案设计

通过上述分析,系统可以分为四个部分:

校时与闹钟设定模块、显示模块、时钟计数模块以及定时响铃模块。

系统总体结果框图如下:

三、系统以及模块硬件电路设计

1、硬件电路图

2、引脚名称附表

四、系统的VHDL设计

1、系统原理图(GDF)

2、系统各模块的VHDL实现1、小时时间计数模块SHIlibraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entityshiis

port(clk:

instd_logic;

;输入分钟的输出进位信号;输出小时进位信号,无意义rco:

outstd_logic;

q1:

outstd_logic_vector(3downto0);;输出小时低位数据q2:

outstd_logic_vector(3downto0);输出小时高位数据);

end;

architectureaofshiis

signaltempq1:

std_logic_vector(3downto0);

signaltempq2:

std_logic_vector(3downto0);

begin

process(clk)

begin

ifclk'eventandclk='1'then

if((tempq1="0011")and(tempq2="0010"))then;如果时间为‘24’tempq1<="0000";;低位高位全清零,进位端置1

tempq2<="0000";rco<='1';

elsiftempq1="1001"then;如果低位时间为‘9’

tempq2<=tempq2+1;tempq1<="0000";;低位清零,高位加1rco<='0';

else

tempq1<=tempq1+1;

rco<='0';;否则低位时间加1

endif;

endif;

endprocess;

q1<=tempq1;

q2<=tempq2;

end;

2、分钟和秒钟时间计数模块FENMIAO

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entityfenmiaois

port(clk:

instd_logic;

;对分钟输入秒钟的输出进位信号;对秒钟输入1Hz;输出进位端

;输出时间低位数据

;输出时间高位数据rco:

outstd_logic;q1:

outstd_logic_vector(3downto0);q2:

outstd_logic_vector(3downto0)

);

end;

architectureaoffenmiaois

signaltempq1:

std_logic_vector(3downto0);

signaltempq2:

std_logic_vector(3downto0);

begin

process(clk)

begin

ifclk'eventandclk='1'then

if((tempq1="1001")and(tempq2="0101"))then;;如果时间为‘59’tempq1<="0000";

tempq2<="0000";

rco<='1';

elsiftempq1="1001"then;如果低位时间数据为‘9’;高位低位时间全部清零,进位端置‘1’tempq2<=tempq2+1;;高位时间加1,低位清零

tempq1<="0000";

rco<='0';

else

tempq1<=tempq1+1;;否则低位加1

rco<='0';

endif;

endif;

q1<=tempq1;

q2<=tempq2;

endprocess;

end;

3、分频模块FENPIN

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entityfenpinis

port(

clk:

instd_logic;;输入1KHz信号

;输出1HZ信号q1sec:

outstd_logic);

end;

architecturetdOFfenpinis

signalx:

std_logic;

begin

process(clk)

variablecnt:

integerrange0to511;

begin

ifclk'eventandclk='1'then

ifcnt<1999then;对信号1024分频

cnt:

=cnt+1;

else

cnt:

=0;

x<=notx;

endif;

endif;

endprocess;

q1sec<=x;

end;

4、调时间允许模块SET

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entitysetis

port(

set:

instd_logic;

clk:

instd_logic;

adds:

instd_logic;

addm:

instd_logic;

addh:

instd_logic;;调时允许信号;工作主频;调节时间;调节分钟;调节秒钟os:

outstd_logic;;调节时间允许om:

outstd_logic;;调节分钟允许oh:

outstd_logic

);

end;

architectureaofsetis

begin

process(clk)

begin

ifset='0'then

os<=adds;

om<=addm;

oh<=addh;;如果允许调节时间;把按键值赋给输出信号;调节秒钟允许

elseNULL;

endif;

endprocess;

end;

5、调闹钟时间模块SETS

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entitysetsis

port(

set:

instd_logic;

add:

instd_logic;;闹钟调时允许信号;调节按键

q1:

outstd_logic_vector(3downto0);;低位输出q2:

outstd_logic_vector(3downto0);高位输出);

end;

architectureaofsetsis

signaltempq1:

std_logic_vector(3downto0);

signaltempq2:

std_logic_vector(3downto0);

begin

process(add)

begin

ifset='0'then;如果调时不允许,闹钟清零tempq1<="0000";

tempq2<="0000";

elsifadd'eventandadd='1'then;否则按按键值设定时间if((tempq1="0011")and(tempq2="0010"))thentempq1<="0000";

tempq2<="0000";

elsiftempq1="1001"then

tempq2<=tempq2+1;

tempq1<="0000";

else

tempq1<=tempq1+1;

endif;

endif;

endprocess;

q1<=tempq1;

q2<=tempq2;

end;

6、调闹钟分钟秒钟模块SETFM

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entitysetfmis

port(

set:

instd_logic;

add:

instd_logic;;调节闹钟允许信号;调节按按键之设定时间

q1:

outstd_logic_vector(3downto0);;低位数据输出q2:

outstd_logic_vector(3downto0);高位数据输出);

end;

architectureaofsetfmis

signaltempq1:

std_logic_vector(3downto0);

signaltempq2:

std_logic_vector(3downto0);

begin

process(add)

begin

ifset='0'then;如果闹钟调节不允许,闹钟清零tempq1<="0000";

tempq2<="0000";

elsifadd'eventandadd='1'then;否则按设定值

if((tempq1="1001")and(tempq2="0101"))thentempq1<="0000";

tempq2<="0000";

elsiftempq1="1001"then

tempq2<=tempq2+1;

tempq1<="0000";

else

tempq1<=tempq1+1;

endif;

endif;

endprocess;

q1<=tempq1;

q2<=tempq2;

end;

7、定时模块DINGSHI

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entitydingshiis

port(clk:

instd_logic;

sl:

instd_logic_vector(3downto0);;时钟秒信号低位sh:

instd_logic_vector(3downto0);;时钟秒信号高位ml:

instd_logic_vector(3downto0);;时钟分信号低位mh:

instd_logic_vector(3downto0);;时钟分信号高位hl:

instd_logic_vector(3downto0);;时钟时信号低位hh:

instd_logic_vector(3downto0);;时钟时信号高位ssl:

instd_logic_vector(3downto0);;闹钟秒信号低位ssh:

instd_logic_vector(3downto0);;闹钟秒信号高位sml:

instd_logic_vector(3downto0);;闹钟分信号低位smh:

instd_logic_vector(3downto0);;闹钟分信号高位shhl:

instd_logic_vector(3downto0);;闹钟时信号低位shh:

instd_logic_vector(3downto0);;闹钟时信号高位sounder:

outstd_logic

);

end;

architectureaofdingshiis

signalclk1:

std_logic;

signaltemp1:

std_logic;

signaltemp2:

std_logic;

begin;扬声器

process(clk)

begin

if(hh=shhandhl=shhl)then;如果时钟与闹钟设定值时、分

;相同,且秒高位相同,则响铃

if(mh=smhandml=sml)then

if(sh=ssh)then

temp1<=clk;

endif;

endif;

endif;

endprocess;

process(clk)

begin;二分频,产生512Hz信号ifclk'eventandclk='1'then

clk1<=notclk1;

endif;

endprocess;

process(clk)

begin

if(mh="0101"andml="1001")then

if(sh="0101")the;如果时钟分信号为‘59’,秒信号高位为

;‘5’,低位为‘0’,‘2’,‘4’,‘6’,‘8’

;则响铃

casesliswhen"0000"=>temp2<=clk1;when"0010"=>temp2<=clk1;when"0100"=>temp2<=clk1;when"1000"=>temp2<=clk1;whenothers=>NULL;when"0110"=>temp2<=clk1;endcase;

endif;

elsif(mh="0000"andml="0000")then;如果时分均为‘0’,则响

;铃

if(sh="0000"andsl="0000")then

temp2<=clk;endif;

endif;

endprocess;

sounder<=(temp2ortemp1);

end;

8、输出显示模块OUTPUTS(系统有三个输出模块,大体雷同,这里以其中一个为例)

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entityoutputhis

port(clk:

instd_logic;

;系统工作主频mode:

instd_logic;;显示模式选择信号hl:

instd_logic_vector(3downto0);;时钟信号低位hh:

instd_logic_vector(3downto0);;时钟信号高位shhl:

instd_logic_vector(3downto0);;闹钟信号低位

shh:

instd_logic_vector(3downto0);;闹钟信号高位

ohh:

outstd_logic_vector(3downto0);;输出信号低位ohl:

outstd_logic_vector(3downto0);输出信号高位);

end;

architectureaofoutputhis

begin

process(clk)

begin

ifclk'eventandclk='1'then

ifmode='1'then;

else

endif;

endif;

endprocess;;如果mode选择1,则输出显示闹钟;否则mode选择0,则输出显示时钟ohh<=shh;ohl<=shhl;ohh<=hh;ohl<=hl;

end;

五、结论以及结果说明

1、运行环境说明

(1)系统运行的软硬件环境

计算机平台:

WindowsXp(servicepack3)

软件调试环境:

MaxPlus2

下载系统:

EPF10K10LC84-4

(2)系统运行结果

·24小时制时钟显示

·按new键可以选择显示数码管显示内容:

显示时间或显示闹钟

·set键未按下时可以对时钟/闹钟进行修改:

adds修改秒;addm修改分;addh修改时

·闹钟允许,则时钟时间与闹钟一致时,扬声器发声

·整点报时,且从59分50秒起,每隔2秒钟发出一次低音“嘟”的信号,连续5次,最后一次高音“嘀”的信号,此信号结束即达到整点。

2、运行结果分析

框图1:

因为初始化时,系统默认闹钟为00:

00:

00,因此扬声器响铃

框图2:

有按键adds按下时,秒钟最低位加一框图3:

有按键addm按下时,分钟最低位加一

框图4:

有按键addh按下时,时钟最低位加一

框图5:

set不允许,则不能调时

注:

因为时间程度不允许,不可能模拟整点报时功能

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

当前位置:首页 > 工程科技 > 能源化工

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

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