VHDL课程设计多功能数字钟Word文档格式.docx
- 文档编号:812973
- 上传时间:2023-04-29
- 格式:DOCX
- 页数:33
- 大小:100.48KB
VHDL课程设计多功能数字钟Word文档格式.docx
《VHDL课程设计多功能数字钟Word文档格式.docx》由会员分享,可在线阅读,更多相关《VHDL课程设计多功能数字钟Word文档格式.docx(33页珍藏版)》请在冰点文库上搜索。
正常工作状态下,每日按24小时计时制计时并显示,蜂鸣器逢整点报时。
校时:
在计时显示状态下,按下“set键”,进入“小时”校时状态,再次按下“set键”,进入“分”校时状态,继续按下“set键”,进入“秒”校时状态,第四次按下“set键”又回复到正常计时显示状态。
1)“小时”校时状态:
进入“小时”校时状态后,显示“小时”的数码管闪烁,每按动“k”键一次,“小时”+1,若不按动“k”键则小时数不变,一直按下“k”键则小时数以4Hz的频率递增计数。
2)“分”校时状态:
进入“分”校时状态后,显示“分”的数码管闪烁,每按动“k”键一次,“分”+1,若不按动“k”键则分数不变,一直按下“k”键则分数以4Hz的频率递增计数。
3)“秒”校时状态:
进入“秒”校时状态后,显示“秒”的数码管闪烁,每按动“k”键一次,“秒”+1,若不按动“k”键则秒数不变,一直按下“k”键则秒数以4Hz的频率递增计数。
整点报时:
蜂鸣器在“59”分钟的第51、53、55、57秒发出频率为512Hz的低音,在“59”秒发出频率为1024Hz的高音,结束时为整点。
显示:
采用6个LED数码管分别显示时、分、秒。
闹钟:
闹钟定时时间到,蜂鸣器发出周期为1s的滴、滴声,持续时间为10秒;
闹钟定时显示。
闹钟定时设置:
在闹钟显示状态下,按下“set键”,进入“小时”校时状态,再次按下“set键”,进入“分”校时状态,继续按下“set键”,进入“秒”校时状态,第四次按下“set键”又回复到闹钟显示状态。
闹钟的时、分、秒设置过程和计时设置有所不同,在闹钟闪烁的状态下,可以直接在4*4的矩阵键盘上输入想要调整的时间即可。
计时显示和闹钟显示之间的转换:
按动“mode”键,数字钟将在计时显示和闹钟定时显示之间转换。
4)多功能数字钟系统结构逻辑框图如下:
mode
5)控制器的MDS图如下:
set=1
四、各功能模块的源程序代码:
--fenpin模块
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityfenpinis
port(
clk40M,pause:
instd_logic;
clk1000hz,clk1hz,clk4hz,clk500hz:
outstd_logic
);
endfenpin;
architectureoneoffenpinis
signala:
integerrange0to20970:
=0;
signalclk1000,clk1,clk4,clk500:
std_logic;
signals:
std_logic:
='
1'
;
begin
process(clk40M,pause)
ifrising_edge(clk40M)then
ifa=20970then
clk1000<
=notclk1000;
a<
elsea<
=a+1;
endif;
endif;
endprocess;
clk1000hz<
=clk1000;
process(clk1000)
variablea1:
integerrange0to249:
ifrising_edge(clk1000)then
ifa1=249thenclk4<
=notclk4;
a1:
elsea1:
=a1+1;
endif;
endprocess;
clk4hz<
=clk4;
integerrange0to2:
ifa1=2thenclk500<
=notclk500;
clk500hz<
=clk500;
process(clk1000)
integerrange0to499:
ifa1=499thenclk1<
=notclk1;
ifrising_edge(pause)then
s<
=nots;
clk1hz<
=clk1ands;
endone;
--CONTOR模块
useieee.std_logic_arith.all;
entitycontoris
port(clk,k,set,reset,mode:
chs,cht,cms,cmt,css,cst,flashh,flashm,flashs,sel_show:
outstd_logic);
endcontor;
architecturecontor_archofcontoris
typestatesis(s0,s1,s2,s3,s4,s5,s6,s7);
signalcurrent_state,next_state:
states;
begin
process(reset,clk,next_state,mode)
if(reset='
)then
current_state<
=s0;
elsif(clk'
eventandclk='
=next_state;
process(current_state,k,set,mode)
casecurrent_stateis
whens0=>
flashh<
0'
flashm<
flashs<
cht<
cmt<
cst<
chs<
cms<
css<
sel_show<
if(mode='
)thennext_state<
=s4;
elsif(k='
andset='
)then
next_state<
=s1;
else
next_state<
whens1=>
if(set='
=s2;
whens2=>
)then
=s3;
whens3=>
cst<
chs<
if(set='
)then
whens4=>
if(mode='
elsif(k='
=s5;
whens5=>
)then
=s6;
whens6=>
=s7;
whens7=>
If(set='
endcase;
endcontor_arch;
********TIMER模块****
--*************cnt60模块*****
entitycnt60is
port(clkin,rst:
instd_logic;
mh,ml:
bufferstd_logic_vector(3downto0);
co:
bufferstd_logic);
endcnt60;
architecturecnt60xofcnt60is
process(clkin)
if(rising_edge(clkin))then
if(mh="
0101"
andml="
1001"
mh<
="
0000"
co<
ml<
elsif(ml="
=mh+1;
elseml<
=ml+1;
ifrst='
then
endcnt60x;
--********MUX2-1模块********
entitymux2_1is
port(d0,d1,en:
sel:
y:
endmux2_1;
architecturemux2_1_archofmux2_1is
begin
process(d0,d1,sel)
if(sel='
y<
=d0;
elsif(sel='
anden='
=d1;
endmux2_1_arch;
--*************cnt24模块*****
entitycnt24is
endcnt24;
architecturecnt24xofcnt24is
0010"
0011"
endcnt24x;
--*************TIMER总的模块*****
entitytimeris
port(rst,chs,f4,cms,k,clk1hz,css:
hh,hl,mh,ml,sh,sl:
outstd_logic_vector(3downto0)
endentity;
architectureoneoftimeris
componentmux2_1is
y:
endcomponent;
componentcnt60is
co:
componentcnt24is
signalco1,co2,y1,y2,y3:
std_logic;
U1:
mux2_1portmap(clk1hz,f4,k,css,y1);
U2:
mux2_1portmap(co1,f4,k,cms,y2);
U3:
mux2_1portmap(co2,f4,k,chs,y3);
U4:
cnt60portmap(y1,rst,sh,sl,co1);
U5:
cnt60portmap(y2,rst,mh,ml,co2);
U6:
cnt24portmap(y3,rst,hh,hl);
endone;
――*****************Time_com模块*********
entitytime_comis
port(r,hh,mh,sh,hl,ml:
instd_logic_vector(3downto0);
test,chs,cms,css,f4,k:
bsg,bmg,bhg,bsd,bmd,bhd:
comout:
endtime_com;
architecturetime_comxoftime_comis
signalchoose,choose1,choose2:
com:
process(hh,mh,sh,hl,ml,bhd,bhg,bmg,bmd,bsg)
if(bhg=hhandbhd=hlandbmg=mhandbmd=mlandbsg=sh)then
comout<
--set:
process(f4)
process(chs)
ifrising_edge(test)then
choose<
=notchoose;
ifchs='
then
ifchoose='
ifr>
"
bhg<
else
bhg<
=r;
endif;
bhd<
bhd<
process(cms)
choose1<
=notchoose1;
ifcms='
ifchoose1='
bmg<
bmg<
bmd<
bmd<
process(css)
choose2<
=notchoose2;
ifcss='
ifchoose2='
bsg<
bsg<
bsd<
bsd<
endtime_comx;
--*****************Show_contor模块****************************
entityshow_contoris
port(hh,mh,sh,bhh,bmh,bsh,hl,ml,sl,bhl,bml,bsl:
flashh,flashm,flashs,clk1,sel_show:
sld0,shd1,mld3,mhd4,hld6,hhd7:
outstd_logic_vector(3downto0));
endshow_contor;
architectureshow_contor_archofshow_contoris
process(clk1)
ifsel_show='
then
sld0<
=sl;
shd1<
=sh;
mld3<
=ml;
mhd4<
=mh;
hld6<
=hl;
hhd7<
=hh;
elsifsel_show='
=bsl;
=bsh;
=bml;
=bmh;
=bhl;
=bhh;
if(clk1='
andflashs='
1111"
andflashm='
andflashh='
endshow_contor_arch;
--****************decode模块代码*********************
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VHDL 课程设计 多功能 数字