EDA课程设计多功能数字钟课程设计报告剖析.docx
《EDA课程设计多功能数字钟课程设计报告剖析.docx》由会员分享,可在线阅读,更多相关《EDA课程设计多功能数字钟课程设计报告剖析.docx(18页珍藏版)》请在冰豆网上搜索。
![EDA课程设计多功能数字钟课程设计报告剖析.docx](https://file1.bdocx.com/fileroot1/2023-1/31/88e4cb2d-30ce-43a2-b270-138ecd18ff47/88e4cb2d-30ce-43a2-b270-138ecd18ff471.gif)
EDA课程设计多功能数字钟课程设计报告剖析
多功能数字电子钟
一、设计要求
1、具有以二十四小时计时、显示、整点报时、时间设置和闹钟的功能。
2、设计精度要求为1S。
二.系统功能描述
1.系统输入:
系统状态及校时、定时转换的控制信号为k、mode、set;
时钟信号clk,采用1024Hz;
系统复位信号为reset。
输入信号均由按键产生。
系统输出:
LED显示输出,蜂鸣器声音信号输出。
多功能数字钟系统功能的具体描述如下:
2.计时:
正常工作状态下,每日按24h计时制计时并显示,蜂鸣器无声,逢整点报时。
3.校时:
在计时状态显示下,按下“set键”,进入“小时”校准状态,之后按下“k键”则进入“分”校准状态,继续按下“k键”则进入“秒复零”状态,第三次按下“k键”又恢复到正常计时显示状态。
1)“小时”校准状态:
在“小时”校准状态下,显示“小时”数码管以1Hz的频率递增计数。
2)“分”校准状态:
在“分”校准状态下,显示“分”的数码管以1Hz的频率递增计数。
3)“秒”复零状态:
在“秒复零”状态下,显示“秒”的数码管复零。
4.整点报时:
蜂鸣器在“59”分钟的第“51”、“53”、“55”、“57‘秒发频率为512Hz的低音,在“59”分钟的第“59”秒发频率为1024Hz的高音,结束时为整点。
5.显示:
要求采用扫描显示方式驱动6个LED数码管显示小时、分、秒。
闹钟:
闹钟定时时间到,蜂鸣器发出周期为1s的“滴”、“滴”声,持续时间为10s;闹钟定时显示。
6.闹钟定时设置:
在闹钟定时显示状态下,按下“set键”,进入闹钟的“时”设置状态,之后按下“k键”进入闹钟的“分”设置状态,继续按下“k键”则进入“秒”设置状态,第三次按下“k键”又恢复到闹钟定时显示状态。
1)闹钟“小时”设置状态:
在闹钟“小时”设置状态下,显示“小时”的数码管以1Hz的频率递增计数。
2)闹钟:
“分”设置状态:
在闹钟“分”设置状态下,显示“分”的数码管以1Hz的频率递增计数。
三、控制器的MDS图及多功能数字系统结构逻辑框图
1、控制器的MDS图
Mode=1,set=0
S0:
显示计时时间s1:
调计时的时s2:
调计时的分s3:
调计时的秒
S4:
显示闹铃时间s5:
调闹铃的时s6:
调闹铃的分s7:
调闹铃的秒
2、多功能数字系统结构逻辑框图
四、各功能模块设计说明及源程序
1、控制器:
设计说明:
根据外部的输入控制信号,完成各个状态之间的转换,并在相应状态输出相应的控制信号,从而对整个系统的工作进行控制。
控制器:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
entitycontlis
port(clk,reset,k,set:
instd_logic;
cht,cmt,cst,cha,cma,csa,flashh,,sel_showflashm,flashs:
outstd_logic);
endcontl;
architecturearofcontlis
typestate_typeis(s0,s1,s2,s3,s4,s5,s6,s7);
signalstate:
state_type;
begin
process(clk,reset,k,set)
begin
if(rising_edge(clk))then
if(reset='1')then
state<=s0;
endif;
casestateis
whens1=>sel_show<='1';
cht<='1';flashh<='1';
if(k='1')then
state<=s2;
elsestate<=s1;
endif;
whens2=>sel_show<='1';
cmt<='1';flashm<='1';
if(k='1')then
state<=s3;
elsestate<=s2;
endif;
whens3=>sel_show<='1';
cst<='1';flashs<='1';
if(k='1')then
state<=s0;
elsestate<=s3;
endif;
whens4=>sel_show<='0';
if(k='0'andset='1')then
state<=s5;
elsif(k='1'andset='0')then
state<=s0;
elsestate<=s4;
endif;
whens5=>sel_show<='0';
cha<='1';flashh<='1';
if(k='1')then
state<=s6;
elsestate<=s5;
endif;
whens6=>sel_show<='0';
cma<='1';flashm<='1';
if(k='1')then
state<=s1;
elsestate<=s0;
endif;
whens7=>sel_show<='0';
csa<='1';flashs<='1';
if(k='0'andset='1')then
state<=s4;
elsestate<=s7;
endif;
whens0=>sel_show<='1';
if(k='0'andset='1')then
state<=s1;
elsif(k='1'andset='0')then
state<=s4;
elsestate<=s0;
endif;
endcase;
endif;
endprocess;
endar;
2、计时校时电路:
设计说明:
该电路实现计时、校时功能。
源程序:
二十四进制计数器:
源程序:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
entitym24is
port(en,clk:
instd_logic;
p0,p1:
outstd_logic_vector(3downto0));
endm24;
architecturearofm24is
signalq0,q1:
integerrange0to15;
begin
process(clk)
begin
if(rising_edge(clk))then
if(en='0'or(q0=3andq1=2))then
q0<=0;q1<=0;
elsif(q0=9)then
q0<=0;q1<=q1+1;
elseq0<=q0+1;
endif;
endif;
p0<=conv_std_logic_vector(q0,4);
p1<=conv_std_logic_vector(q1,4);
endprocess;
endar;
六十进制计数器:
源程序:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
entitym60is
port(en,clk:
instd_logic;
x:
outstd_logic;
p0,p1:
outstd_logic_vector(3downto0));
endm60;
architecturearofm60is
signalq0,q1:
integerrange0to15;
begin
process(clk)
begin
if(rising_edge(clk))then
if(en='0'or(q0=9andq1=5))then
q0<=0;q1<=0;x<='1';
elsif(q0=9)then
q0<=0;q1<=q1+1;
elseq0<=q0+1;x<='0';
endif;
endif;
p0<=conv_std_logic_vector(q0,4);
p1<=conv_std_logic_vector(q1,4);
endprocess;
endar;
选择器源程序:
libraryieee;
useieee.std_logic_1164.all;
entityconlis
port(f1,f4,c:
instd_logic;
f:
outstd_logic);
endconl;
architecturearofconlis
begin
process(c,f1,f4)
begin
if(c='0')then
f<=f1;
elsef<=f4;
endif;
endprocess;
endar;
3、显示控制电路:
设计说明:
该模块控制最终显示的计时时间还是闹铃时间。
源程序:
libraryieee;
useieee.std_logic_1164.all;
entityshow_conis
port(ts1,ts2,tm1,tm2,th1,th2,bs1,bs2,bm1,bm2,bh1,bh2:
instd_logic_vector(3downto0);
s1,s2,m1,m2,h1,h2,line:
outstd_logic_vector(3downto0);
sel_show,clk,flashs,flashm,flashh:
instd_logic);
endshow_con;
architecturearofshow_conis
signalq:
integerrange0to1;
begin
process(clk)
begin
if(rising_edge(clk))then
q<=q+1;
if(flashh='1'andq=1)then
h1<="1111";h2<="1111";
elsif(flashm='1'andq=1)then
m1<="1111";m2<="1111";
elsif(flashs='1'andq=1)then
s1<="1111";s2<="1111";
else
if(sel_show='1')then
s1<=ts1;
s2<=ts2;
m1<=tm1;
m2<=tm2;
h1<=th1;
h2<=th2;
else
s1<=bs1;
s2<=bs2;
m1<=bm1;
m2<=bm2;
h1<=bh1;
h2<=bh2;
endif;
endif;
endif;
line<="1110";
endprocess;
endar;
4、定时比较电路:
设计说明:
包含两个模块,定时模块和比较模块;完成定时时间的设定、定时时间的输出、计时时间与定时时间比较并输出相应的比较结果控制蜂鸣器的工作,从而实现闹铃功能。
比较模块源程序:
libraryieee;
useieee.std_logic_1164.all;
entitycom_t_dis
port(clk:
instd_logic;
comout:
outstd_logic;
th1,th2,tm1,tm2,ts1,ts2,h1,h2,m1,m2:
instd_logic_vector(3downto0);
bh1,bh2,bm1,bm2,bs1,bs2:
outstd_logic_vector(3downto0));
endcom_t_d;
architecturearofcom_t_dis
begin
process(clk)
begin
if(rising_edge(clk))then
if(th1=h1andth2=h2andtm1=m1andm2=tm2)then
comout<='1';
bh1<=th1;
bh2<=th2;
bm1<=tm1;
bm2<=tm2;
bs1<=ts1;
bs2<=ts2;
elsecomout<='0';
bh1<=th1;
bh2<=th2;
bm1<=tm1;
bm2<=tm2;
bs1<=ts1;
bs2<=ts2;
endif;
endif;
endprocess;
endar;
定时模块逻辑框图:
总图:
5、报时闹铃电路:
设计说明:
该模块整点报时和闹铃输出。
源程序:
libraryieee;
useieee.std_logic_1164.all;
entitybelis
port(m1,m2,s1,s2:
instd_logic_vector(3downto0);
bell:
outstd_logic;
compout,f512,f1024,clk,k:
instd_logic);
endbel;
architecturearofbelis
begin
process(m1,m2,s1,s2,compout,clk)
begin
if(rising_edge(clk))then
if(k='1')then
if(compout='1')thenbell<=f1024;
elsif(m1="0101"andm2="1001"ands1="0101"ands2="0001")thenbell<=f512;
elsif(m1="0101"andm2="1001"ands1="0101"ands2="0011")thenbell<=f512;
elsif(m1="0101"andm2="1001"ands1="0101"ands2="0101")thenbell<=f512;
elsif(m1="0101"andm2="1001"ands1="0101"ands2="0111")thenbell<=f512;
elsif(m1="0101"andm2="1001"ands1="0101"ands2="1001")thenbell<=f512;
elsebell<=clk;
endif;
elsebell<=clk;
endif;
endif;
endprocess;
endar;
6、动态显示电路:
设计说明:
该模块由一个八选一选择器、一个模8计数器、一译码驱动电路组成。
用于控制显示正常计时时间或闹铃时间。
源程序:
八选一模块:
libraryieee;
useieee.std_logic_1164.all;
entitymux8to1is
port(d0,d1,d2,d3,d4,d5,d6,d7:
instd_logic_vector(3downto0);
a:
instd_logic_vector(2downto0);
q:
outstd_logic_vector(3downto0));
endmux8to1;
architecturearofmux8to1is
begin
process(d0,d1,d2,d3,d4,d5,d6,d7,a)
begin
caseais
when"000"=>q<=d0;
when"001"=>q<=d1;
when"010"=>q<=d2;
when"011"=>q<=d3;
when"100"=>q<=d4;
when"101"=>q<=d5;
when"110"=>q<=d6;
when"111"=>q<=d7;
whenothers=>q<="XXXXXXXX";
endcase;
endprocess;
endar;
模八计数器:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
entitym8is
port(en,clk:
instd_logic;
q:
outstd_logic_vector(2downto0));
endm8;
architecturearofm8is
signalq0:
integerrange0to10;
begin
process(clk)
begin
if(rising_edge(clk))then
if(en='0'orq0=7)then
q0<=0;
elseq0<=q0+1;
endif;
endif;
q<=conv_std_logic_vector(q0,3);
endprocess;
endar;
译码驱动电路
libraryieee;
useieee.std_logic_1164.all;
entitytra4to8is
port(a:
instd_logic_vector(3downto0);
q:
outstd_logic_vector(6downto0));
endtra4to8;
architecturearoftra4to8is
begin
process(a)
begin
caseais
when"0000"=>q<="1111110";
when"0001"=>q<="0110000";
when"0010"=>q<="1101101";
when"0011"=>q<="1111001";
when"0100"=>q<="0110011";
when"0101"=>q<="1011011";
when"0110"=>q<="0011111";
when"0111"=>q<="1110000";
when"1000"=>q<="1111111";
when"1001"=>q<="1110011";
when"1111"=>q<="0000000";
when"1110"=>q<="0000001";
whenothers=>q<="XXXXXXX";
endcase;
endprocess;
endar;
:
五.各个大模块的防真图
(一)、控制器
(二)、计时校时电路
(三)、显示控制电路
(四)分频器
(五)总体仿真图
六、总结及体会
通过这次VHDL课程设计,我学到了很多,对于原本掌握的不好的数字逻辑相关知识,在课程设计具体实践中有了很深刻的认识,在对于MAX+plusⅡ的操作上也有很大的提高,增加了操作的熟练程度,现在我已经有信心做任何的设计课题。
在学到新知识的同时,我也认识到了VHDL设计的困难性
最后,感谢老师们帮我处理一些解决不了的问题,还要感谢在我思维陷入困境时给予我指点,让我获得灵感的同学们,谢谢大家!