EDA课程设计1.docx

上传人:b****4 文档编号:4877429 上传时间:2022-12-11 格式:DOCX 页数:18 大小:337.28KB
下载 相关 举报
EDA课程设计1.docx_第1页
第1页 / 共18页
EDA课程设计1.docx_第2页
第2页 / 共18页
EDA课程设计1.docx_第3页
第3页 / 共18页
EDA课程设计1.docx_第4页
第4页 / 共18页
EDA课程设计1.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

EDA课程设计1.docx

《EDA课程设计1.docx》由会员分享,可在线阅读,更多相关《EDA课程设计1.docx(18页珍藏版)》请在冰豆网上搜索。

EDA课程设计1.docx

EDA课程设计1

EDA课程设计

一.课程题目与要求

1.题目:

数字电子时钟

2.要求:

1)能显示周、时、分、秒,精确到0.1s

2)可自行设置调节时间

3)可设置闹铃,并且对闹铃时间长短可控制

二.设计思路

一)设计框图

二)设计思路:

1.根据分频原理设计出十进制、六进制、二十四进制、七进制来组成0.1s,秒,分,时,周。

2.增加一个时间设置模块,通过输入一次控制信号使分、时、周加一,即给分、时、周一个clk信号,这样可以设置三个控制信号:

分、时、周clk信号,按一次给相应信号加一个clk,并用一个或门把前一级的进位信号和时间设置模块产生的clk连起来一起控制计数器。

3.闹铃可以通过时间匹配时输出高电平给闹铃使其发出声音,闹铃设置也是给出几个控制信号通过输入脉冲形成一个已定时间,在响铃允许下对比当前时间,若匹配则输出高电平,另外加一个闹铃设置使能信号,在设置闹钟时间时闹铃不能对比时间。

闹铃长短可通过一个计数器来实现,持续输出高电平直到计数器达到所设秒数。

三.设计模块简介

1.秒模块

注释:

第一个Ti10代表0.1s,时用一个十进制计数器实现的,第二个Ti10代表秒的个位,也是一个十进制,逢十进一,向秒的十位进一(Ti6的clk),Ti6代表代表秒的十位,是6进制计数器,这样便组成60进制,精度为0.1s的秒模块。

2.分模块

注释:

Ti10代表分的个位,是一个十进制计数器,逢十进一,向分的十位进一(Ti6的clk),Ti6代表分的十位,是一个六进制计数器,这样便组成了60进制的分模块。

3.时模块

注释:

这是一个五位字宽的计数器,来一个clk信号,计数器自加一,一直加到23复位为0,因此便组成了一个24进制的时模块。

4.周模块

注释:

这是一个由七进制构成的周模块,从0-6代表星期一到星期天。

5.时分位模块

注释:

这是一个把时模块的个位、十位分开的模块,由于设置闹钟时要设置它的时的个位、十位,所以这个模块实现的就是分开时的两位数。

6.调时模块

注释:

这是一个调节时间的模块,当en为“1”时,按一次M(H或W)就给分(时或周)模块加一分,即M1(H1或W1)输出“1”,这个再给分(时或周)模块一个clk信号。

7.闹钟设置模块

注释:

这个是闹钟设置模块,当en为“1”时,按一次H(M)即时(分)加一小时(一分钟),enout是闹钟的对比模块的使能信号,当其为“1”时,闹钟的时间匹配模块才开始工作,H1、H2分别是所设闹钟的小时的个位、十位,M1、M2为分的个位、十位,用于与当前时间比较,一致则闹钟起振。

8.闹钟时间匹配比较模块

注释:

当从闹钟设置模块得到的时间和当前时间一样时Qout输出“1”给扬声器使其发出声音。

En为接收闹钟设置模块enout信号来决定其是否工作,mode为闹钟时长设置接收引脚。

9.闹钟时长选择模块

注释:

当sel引脚输入一个脉冲信号时,pout信号加“1”,一共有四种模式:

5、10、15、20可供选择。

时长选择可通过程序改变(0-31)。

四.模块具体程序及仿真图

1.十进制

1)程序:

LIBRARYIEEE;

USEIEEE.std_logic_1164.ALL;

useieee.std_logic_unsigned.all;

ENTITYti10IS

port(CLK:

INstd_logic;

RST:

instd_logic;

ck:

outstd_logic;

time10:

outstd_logic_vector(3downto0));

ENDti10;

architectureONEofti10is

signaltim10:

std_logic_vector(3downto0):

="0000";

begin

process(clk)

begin

if(rst='1')thentim10<="0000";else

if(clk'eventandclk='1')then

if(tim10="1001")then

tim10<="0000";ck<='1';

elsetim10<=tim10+‘1’;ck<='0';

endif;

endif;

endif;

endprocess;

time10<=tim10;

endONE;

2)仿真图

说明:

a.ret复位信号,clk时钟信号,ck进位信号

b.time10输出信号

2.六进制

1)程序:

LIBRARYIEEE;

USEIEEE.std_logic_1164.ALL;

useieee.std_logic_unsigned.all;

ENTITYti6IS

port(CLK:

INstd_logic;

RST:

instd_logic;

ck:

outstd_logic;

time:

outstd_logic_vector(3downto0));

ENDti6;

architectureONEofti6is

signaltim6:

std_logic_vector(3downto0):

="0000";

begin

process(clk)

begin

if(rst='1')thentim6<="0000";else

if(clk'eventandclk='1')then

if(tim6="0101")then

tim6<="0000";ck<='1';

elsetim6<=tim6+‘1’;ck<='0';

endif;

endif;

endif;

endprocess;

time<=tim6;

endONE;

2)仿真图

说明同上

3.24进制

程序:

LIBRARYIEEE;

USEIEEE.std_logic_1164.ALL;

useieee.std_logic_unsigned.all;

ENTITYti24IS

port(CLK:

INstd_logic;

RST:

instd_logic;

ck:

outstd_logic;

time24:

outstd_logic_vector(4downto0));

ENDti24;

architectureONEofti24is

signaltim24:

std_logic_vector(4downto0):

="00000";

begin

process(clk)

begin

if(rst='1')thentim24<="00000";else

if(clk'eventandclk='1')then

if(tim24="10111")then

tim24<="00000";ck<='1';

elsetim24<=tim24+1;ck<='0';

endif;

endif;

endif;

endprocess;

time24<=tim24;

endONE;

2)仿真图

说明略

3.24进制分位模块

1)程序:

LIBRARYIEEE;

USEIEEE.std_logic_1164.ALL;

useieee.std_logic_unsigned.all;

ENTITYcha24IS

port(Pin:

instd_logic_vector(4downto0);

h1,h2:

outstd_logic_vector(3downto0));

endcha24;

architectureONEofcha24is

signals:

std_logic_vector(4downto0);

begin

process(Pin)

begin

if(pin<"01010")thenh2<="0000";s<=Pin;

elsif(Pin<"10100")thenh2<="0001";s<=Pin-10;

elseh2<="0010";s<=Pin-20;

endif;

h1(3downto0)<=s(3downto0);

endprocess;

endONE;

2)仿真图

说明:

a.pin为四位24进制数输入信号

b.h[13..10],h[23..20]分别为pin的个位、十位四位数

4.七进制

1)程序

LIBRARYIEEE;

USEIEEE.std_logic_1164.ALL;

useieee.std_logic_unsigned.all;

ENTITYti7IS

port(CLK:

INstd_logic;

RST:

instd_logic;

ck:

outstd_logic;

time7:

outstd_logic_vector(3downto0));

ENDti7;

architectureONEofti7is

signaltim7:

std_logic_vector(3downto0):

="0000";

begin

process(clk)

begin

if(rst='1')thentim7<="0000";else

if(clk'eventandclk='1')then

if(tim7="0110")then

tim7<="0000";ck<='1';

elsetim7<=tim7+1;ck<='0';

endif;

endif;

endif;

endprocess;

time7<=tim7;

endONE;

2)仿真图

说明:

5.时间调节模块

1)程序:

LIBRARYIEEE;

USEIEEE.std_logic_1164.ALL;

useieee.std_logic_unsigned.all;

ENTITYse_timeIS

port(m,h,w:

INstd_logic;

en:

instd_logic;

clk:

instd_logic;

m1,h1,w1:

outstd_logic);

ENDse_time;

architectureONEofse_timeis

begin

process(m,h,w,clk,en)

begin

if(en='0')thenm1<='0';h1<='0';w1<='0';

elseif(clk'eventandclk='1')then

if(m='1')thenm1<='1';

elsem1<='0';

endif;

if(h='1')thenh1<='1';

elseh1<='0';

endif;if(w='1')thenw1<='1';

elsew1<='0';

endif;

endif;

endif;

endprocess;

endONE;

2)仿真图

说明:

a.clk时钟信号,en时间设置使能信号

b.w、h、m分别为时间设置的周、时、分输入信号,分别输入一个“1”,w1、h1、m1分别产生一个“1”作为对应模块的clk。

6.闹钟设置

1)程序

LIBRARYIEEE;

USEIEEE.std_logic_1164.ALL;

useieee.std_logic_unsigned.all;

ENTITYse_ringIS

port(m,h:

INstd_logic;

en:

instd_logic;

clk:

instd_logic;

enout:

outstd_logic;

m1,m2,h1,h2:

outstd_logic_vector(3downto0));

ENDse_ring;

architectureONEofse_ringis

signalmm1:

std_logic_vector(3downto0):

=(others=>’0’);

signalmm2:

std_logic_vector(3downto0):

=(others=>’0’);

signalhh1:

std_logic_vector(3downto0):

=(others=>’0’);

signalhh2:

std_logic_vector(3downto0):

=(others=>’0’);

begin

process(m,h,clk,en)

begin

if(en='0')then

enout<='1';

elseenout<='0';

if(clk'eventandclk='1')then

if(m='1')thenif(mm1="1001")then

if(mm2="0101")thenmm2<="0000";

elsemm2<=mm2+1;

endif;

mm1<="0000";

elsemm1<=mm1+1;

endif;

endif;

if(h='1')then

if(hh1="0011"andhh2="0010")thenhh1<="0000";hh2<="0000";

elseif(hh1="1001")thenhh2<=hh2+1;hh1<="0000";

elsehh1<=hh1+1;

endif;

endif;

endif;

endif;

endif;

endprocess;

m1(3downto0)<=mm1(3downto0);

m2(3downto0)<=mm2(3downto0);

h1(3downto0)<=hh1(3downto0);

h2(3downto0)<=hh2(3downto0);

endONE;

2)仿真图

说明:

a.clk时钟信号,en闹钟设置使能信号

b.m、h分别为设置闹钟的分、时控制信号,输入一个脉冲,对应位加一

c.enout为时间设置完时输出的给闹钟时间匹配模块的驱动信号

d.后四个为所设闹钟时间的分,时

7.闹钟时长选择

1)程序:

LIBRARYIEEE;

USEIEEE.std_logic_1164.ALL;

useieee.std_logic_unsigned.all;

ENTITYsel_modeIS

port(sel:

INstd_logic;

Pout:

outstd_logic_vector(1downto0));

ENDsel_mode;

ArchitectureONEofsel_modeis

signalmode:

std_logic_vector(1downto0);

begin

process(sel,mode)

begin

if(sel'eventandsel='1')thenmode<=mode+1;

endif;

endprocess;

pout<=mode;

endONE;

2)仿真图

说明:

a.Sel闹钟时长选择信号,输入一个“1”,pout加一个“1”

b.Pout模式输出信号,共有四种。

8.闹钟时间匹配

1)程序:

LIBRARYIEEE;

USEIEEE.std_logic_1164.ALL;

useieee.std_logic_unsigned.all;

ENTITYringIS

port(mt1,mt2,ht1,ht2:

INstd_logic_vector(3downto0);

mr1,mr2,hr1,hr2:

instd_logic_vector(3downto0);

en,clk:

instd_logic;

mode:

instd_logic_vector(1downto0);

Qout:

outstd_logic);

ENDring;

architectureONEofringis

signaltt:

std_logic_vector(4downto0):

="00101";

signalcount:

std_logic_vector(4downto0):

="00000";

begin

process(mode)

begin

casemodeis

when"00"=>tt<="00101";

when"01"=>tt<="01010";

when"10"=>tt<="01111";

whenothers=>tt<="10100";

endcase;

endprocess;

process(mt1,mt2,ht1,ht2,mr1,mr2,hr1,hr2,en,tt,clk,count)

begin

if(clk'eventandclk='1')then

if(en='1'andcount

count<=count+1;

elsif(en='1'andcount>=ttand((mt1=mr1)and(mt2=mr2)and(ht1=hr1)and(ht2=hr2)))thenQout<='0';

elsecount<="00000";

endif;

endif;

endprocess;

endONE;

2)仿真图

说明:

a.clk时钟信号,en模式驱动信号

b.mt1、mt2、ht1、ht2分别为当前时钟的分、时的个位、十位

mr1、mr2、hr1、hr2分别为所设闹钟的分、时的个位、十位,当这八个一致时,根据mode决定qout输出高电平的时间

c.mode闹钟时长选择输入信号

d.qout闹铃输出信号

9.总仿真图

说明:

a.clk时钟信号,rst复位信号,en调节时间使能信号,w、h、m分别为调时钟的周、时、分控制信号,按一次控制信号,时钟对应部分加一。

b.ck为周模块的进位信号,ss,s1,s2,m1,m2,h1,h2,week分别为时钟的0.1s,个秒个位,秒十位,分个位,分十位,时个位,时十位及周。

c.ring_en为闹钟设置使能信号,当其为“1”时可调闹钟时间,sel为闹钟响铃方式选择信号,来一个脉冲模式加一(四种模式循环),m_ring,h_ring分别为闹钟设置的分,时,在m_ring为“1”时来一个m_ring,h_ring输入一个脉冲,闹钟的分,时分别加一即在ring_en为“1”时m_ring,h_ring上有几个脉冲就是所设置的闹钟时间。

d.ring为闹钟响铃输出信号,当所设时间和时钟当前时间相同时ring输出“1”,闹钟发出声音,否则为

“0”。

10.电路原理图

 

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

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

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

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