电子综合实验报告数字钟.docx

上传人:b****5 文档编号:5628346 上传时间:2022-12-29 格式:DOCX 页数:10 大小:172.73KB
下载 相关 举报
电子综合实验报告数字钟.docx_第1页
第1页 / 共10页
电子综合实验报告数字钟.docx_第2页
第2页 / 共10页
电子综合实验报告数字钟.docx_第3页
第3页 / 共10页
电子综合实验报告数字钟.docx_第4页
第4页 / 共10页
电子综合实验报告数字钟.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

电子综合实验报告数字钟.docx

《电子综合实验报告数字钟.docx》由会员分享,可在线阅读,更多相关《电子综合实验报告数字钟.docx(10页珍藏版)》请在冰豆网上搜索。

电子综合实验报告数字钟.docx

电子综合实验报告数字钟

电子综合实验报告——数字钟

1、实验题目:

数字钟

2、实验内容:

设计一个带闹钟功能的24小时计时器。

它包括以下几个组成部分:

① 显示屏,由8个七段数码管组成,用于显示当前时间(时:

分:

秒)或正在设置的当前时间;② Time键、HSet键、MSet键分别用来启动设置时钟的时、分;③ 复位键,用来还原时钟到初始默认值;④ Alarm键,用于启动设置闹钟时间;⑤ A键组,用于输入2进制闹钟时间;

扬声器(这里用一个发光二极管代替),在当前时钟时间与闹钟时间相同时,发出蜂鸣声(二极管亮)。

 

主要功能:

 

(1) 计时功能:

这是本数字闹钟设计的基本功能,每隔一分钟计时一次,并在显示屏上显示当前时间。

 

(2) 闹钟功能:

如果当前时间与设置的闹钟时间相同,则“扬声器”发出“蜂鸣声”(二极管亮)。

 

(3) 设置新的数字钟时间:

用户用Time键、HSet键、MSet键对当前时间进行修改。

 

(4) 设置新的闹钟时间:

用户用Alarm键及A键组对闹钟时间进行修改。

 

(5) 显示所设置的闹钟时间:

A键组直接展示输入的闹钟时间。

3、设计方案

根据系统的设计要求,整个系统分为4个模块:

时间计数器、闹钟寄存器、分频器、数码管显示模块。

 功能介绍:

 

 

(1) 时间计数器:

实际上是一个异步复位、异步置数的累加器,通常情况下进行时钟累加计数,必要时可置入新的时钟值,然后从该值开始新的计数。

 

(2) 闹钟寄存器:

用于保存用户设置的闹钟时间,并可设置新的闹钟时钟时间并判断当前时间是否等于闹钟时间。

(3)分频器:

把板上输入的6MHz的频率分为1Hz和1kHz,1Hz用于数码管显示,1kHz用于时钟计时。

(4)数码管显示模块:

用来显示闹钟时间或当前时间。

设计思路:

 

顶层RTL图:

(一)时间计数器:

 

      在正常计时,前面计数器的cout(进位端)作为下一个计数器的信号。

当修改当前时间时,选用频率更快的信号,使所显示的时间的值较快的达到要设定的值。

此处用一个2选1的选择器来选择适当的信号。

此处分和时的修改是分开进行的,分别用Mkey和Hkey进行控制(即:

他们作为多路选择器的sel信号)。

VHDL语言:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitytimesis

port(clk_1Hz:

instd_logic;

set:

instd_logic;

rst:

instd_logic;

s1:

instd_logic;

s2:

instd_logic;

z:

outstd_logic;

sec_l,sec_h:

outstd_logic_vector(3downto0);

min_l,min_h:

outstd_logic_vector(3downto0);

hour_l,hour_h:

outstd_logic_vector(3downto0));

endtimes;

architecturebehaveoftimesis

signalzd:

std_logic;

begin

process(clk_1Hz,set,rst,s1,s2,zd)

variablemsecond1:

std_logic_vector(3downto0):

="1000";

variablemsecond2:

std_logic_vector(3downto0):

="0101";

variablemminute1:

std_logic_vector(3downto0):

="0100";

variablemminute2:

std_logic_vector(3downto0):

="0011";

variablemhour11:

std_logic_vector(3downto0):

="1000";

variablemhour22:

std_logic_vector(3downto0):

="0000";

begin

ifclk_1Hz'eventandclk_1Hz='1'then

ifmminute1="0000"andmminute2="0000"then

zd<='1';

else

zd<='0';

endif;

ifset='0'then

ifs1='0'then

mminute1:

=mminute1+1;

ifmminute1="1010"then

mminute1:

="0000";mminute2:

=mminute2+1;

ifmminute2="0110"then

mminute2:

="0000";

endif;

endif;

endif;

ifs2='0'then

mhour11:

=mhour11+1;

ifmhour11="1010"then

mhour11:

="0000";

ifmhour22<"0010"then

mhour22:

=mhour22+1;

endif;

elsifmhour22="0010"andmhour11="0100"then

mhour22:

="0000";mhour11:

="0000";

endif;

endif;

elsifrst='0'then

msecond1:

="1000";msecond2:

="0101";

mminute1:

="0100";mminute2:

="0011";

mhour11:

="1000";mhour22:

="0000";

elsemsecond1:

=msecond1+1;

ifmsecond1="1010"then

msecond1:

="0000";msecond2:

=msecond2+1;

ifmsecond2="0110"then

msecond2:

="0000";mminute1:

=mminute1+1;

ifmminute1="1010"then

mminute1:

="0000";mminute2:

=mminute2+1;

ifmminute2="0110"then

mminute2:

="0000";mhour11:

=mhour11+1;

ifmhour11="1010"then

mhour11:

="0000";

ifmhour22<"0010"then

mhour22:

=mhour22+1;

endif;

elsifmhour22="0010"andmhour11="0100"then

mhour22:

="0000";mhour11:

="0000";

endif;

endif;

endif;

endif;

endif;

endif;

endif;

sec_l<=msecond1;sec_h<=msecond2;

min_l<=mminute1;min_h<=mminute2;

hour_l<=mhour11;hour_h<=mhour22;

z<=zd;

endprocess;

endarchitecturebehave;

(二)闹钟寄存器:

 

       闹钟系统的闹钟时间由闹钟寄存器保存和传递,并与当前的时间进行比较。

若两者相等(分和时分别比较,将两者的结果经过与门输出),则二极管发光。

VHDL语言:

libraryieee;

useieee.std_logic_1164.all;

entityjicunis

generic(n:

integer:

=8);

port(D1:

instd_logic_vector(3downto0);

D2:

instd_logic_vector(3downto0);

D3:

instd_logic_vector(3downto0);

D4:

instd_logic_vector(3downto0);

CP:

instd_logic;

set:

instd_logic;

s1:

instd_logic;

s2:

instd_logic;

Q1:

outstd_logic_vector(3downto0);

Q2:

outstd_logic_vector(3downto0);

Q3:

outstd_logic_vector(3downto0);

Q4:

outstd_logic_vector(3downto0));

endjicun;

architectureoneofjicunis

signaltmp1:

std_logic_vector(3downto0);

signaltmp2:

std_logic_vector(3downto0);

signaltmp3:

std_logic_vector(3downto0);

signaltmp4:

std_logic_vector(3downto0);

begin

u1:

process(CP)

begin

ifCP'eventandCP='1'then

tmp1<=D1;

tmp2<=D2;

tmp3<=D3;

tmp4<=D4;

endif;

endprocess;

u2:

process(CP)

begin

ifCP'eventandCP='1'then

Q1<=tmp1;

Q2<=tmp2;

Q3<=tmp3;

Q4<=tmp4;

endif;

endprocessu2;

endone;

(3)分频器

把板上输入的6MHz的频率分为1Hz和1kHz,1Hz用于数码管显示,1kHz用于时钟计时。

VHDL语言:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entityfreqis

generic(clk1kHz:

integer:

=6000;

clk1Hz:

integer:

=6000000);

port(clk_sys:

instd_logic;

clk_1kHz:

outstd_logic;

clk_1Hz:

outstd_logic);

endfreq;

architectureoneoffreqis

signalclk1,clk2:

std_logic;

begin

p1:

process(clk_sys)

variablecnt1:

integerrange0toclk1kHz;

begin

ifclk_sys'eventandclk_sys='1'then

ifcnt1

cnt1:

=cnt1+1;

else

cnt1:

=0;

clk1<=notclk1;

endif;

endif;

endprocessp1;

p2:

process(clk_sys)

variablecnt2:

integerrange0toclk1Hz;

begin

ifclk_sys'eventandclk_sys='1'then

ifcnt2

cnt2:

=cnt2+1;

else

cnt2:

=0;

clk2<=notclk2;

endif;

endif;

endprocessp2;

clk_1kHz<=clk1;

clk_1Hz<=clk2;

endone;

(四)数码管显示模块:

 

     由模8计数器,3—8译码器,8选1多路选择器和七段译码器组成。

逻辑图:

3、仿真验证:

  

(1)时间计数器:

波形图:

信号说明:

EndTime:

4usGridSize:

100ns

clk_1Hz:

时钟信号`set:

设置时间

rst:

复位键s1:

更改当前时间的时

s2:

更改当前时间的分

结论:

当set键和s1均由1变为0时,更改时;当set键和s2均由1变为0时,更改分,当set键和s1均为0时,时间正常走;当rst由1变为0时,时钟复位。

(二)闹钟寄存器:

 

波形图:

信号说明:

EndTime:

1usGridSize:

100ns

CP:

设置闹钟

D1/D2/D3/D4:

分别输入闹钟的时、分

结论:

当CP为1时,开始设置闹钟,D1/D2/D3/D4分别输入4位2进制数,决定闹钟的时、分

(四)数码管显示模块:

 

波形图:

信号说明:

EndTime:

1usGridSize:

100ns

clk_1kHz:

时钟信号

d0~d7:

输入数据

结论:

当clk_1kHz开始变化,d0~d7接受的时间计数器传来的数据按频率输出,数码管显示变化中的时间。

4、下载验证

对计时功能,闹钟功能,整点报时,设置新的时间,设计新的闹钟时间的功能进行验证。

管脚分配:

5、实验日志

 

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

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

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1