基于VHDL的多功能数字钟设计报告Word文档下载推荐.docx
《基于VHDL的多功能数字钟设计报告Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《基于VHDL的多功能数字钟设计报告Word文档下载推荐.docx(20页珍藏版)》请在冰豆网上搜索。
useieee・stdlogic_l164.all;
useieee・stdlogiconsigned・all;
entityfreqisport(CLK:
instdlogic;
qlKHz:
bufferstdlogic;
q500Hz:
q2Hz:
qlHz:
outstdlogic):
endfreq;
architecturebhvoffreqisbegin
P1KHZ:
process(CLK)variablecout:
integer:
=0;
begin
ifCLK1eventandCLK二T'
thencout:
=cout+l;
ifcout<
=25000thenqlKHz<
='
0'
;
elsifcout<
50000thenqlKHz<
=,1elsecout:
endif;
endprocess;
P500HZ:
process(qlKHz)—qlKHz作为输入信号,分出qSOOHz
variablecout:
begin
ifq1KHzreventandqlKHz=Tthen
cout:
ifcout=lthenq500Hz<
―二分频
elsifcout=2thencout:
=0:
q500Hz<
=rT;
P2HZ:
process(q500Hz)
ifq500Hzreventandq500Hz二T‘thencout:
=125thenq2Hz<
elsifcout<
250thenq2Hz〈二T‘;
elsecout:
P1HZ:
process(q2Hz)
ifq2Hzreventandq2Hz二Tthencout:
ifcout=lthenqlHz〈=O;
elsifcout=2thencout:
二0;
qlHz〈二i;
endbhv;
2x控制器模块(contral.vhd)
(1)模块说明:
输入端口k,set键来控制6个状态,这六个状态分别是:
显示计时时间状态,调计时的时、分、秒的3个状态,调闹铃的时.分的3个状态,reset键是复位键,用来回到显示计时时间的状态。
(2)波形仿真图:
Sene
dk
reset
set
obh
cth
OW
£
1沁flakinfloshz
lrf-l
04
06
5
衬纟
Oto
n
(3)模块图:
300as
7
160.0ns
•
400.0ns
240pz
460.a0ns
:
control
»
elk
—
k
ctm
!
纯t
cts
\—
ebh
I
cbm
>
flashh
flashnn
flashs
s-eLsfww
jinstl
二选一模块(mux21a.vhd)
(1)源程序:
useieee・stdlogic_unsigned.all;
entitymux21aisport(a,b,s:
inbit;
y:
outbit);
endentitymux21a;
architectureoneofmux21ais
process(a,b,s)
ifs='
0,then
y<
=a;
―若s=0,y输出a,反之输出b。
elsey<
=b;
endif;
endprocess;
endarchitectureone;
(2)仿真波形图:
=mux21a
?
y
i—
b
i——
s
inst2
••••••••••••・••••・•・・・•••••••••••••・••・・・•・•・••夕
4.计时模块
a.秒计时(second,vhd)
(1)仿真波形图:
xsldo阳
jnjinjuwurLnjrLnjWiJirLrLnjinLrwumniJinuLrLnJLnjiJTnLnnrLnrLninjij
「「门门x
(2)模块图:
(•••••••••■•••••••
r&
st
s»
D[3..O]
sMip..43
co
1—
irtst4
b・分计时(minute,vhd)
elksk>
ski1[7..4]
c.小时计时(hour,vhd)
[hour
\
dksk»
3[3..0J
4
sMip..4]
inst6
d.闹钟分计时(cntm60b.vhd)
Nano
33u,5.9?
38.®
L3.印u,IS.IT18.7?
321.2.9g3
LnjuinirLnarLnnmarLnnnjwnjiRnnrLruwinjumnmnnjuuiruinr
BP
亘
[mirr^b
i
i■
•ensld0[3..0J
dksldip..4J
inst7
e.闹钟小时计时(cnth24b.vhd)
(1)仿真波形图:
\-Gntti^b\
■—ensWO[3..O]
;
—dksldip..4J—*
!
irast8j
5、闹钟比较模块(compare,vhd)
比校正常计数时间与闹钟定时时间是否相等,若相等,compout输出T,反之输出“0”。
(2)仿真波形图:
1-compare
th1[7..4joompout
tM[3..O]
t(nO[3...O]
bhip..4]
bmf[7.,4]
bh0[3.,0]
bmO[3..0]
jinst§
6、报时模块(bell.vhd)
该模块既实现了整点报时的功能,又实现了闹铃的功能,蜂鸣器通过所选频率的不同,而发出不同的声音。
Wane
1ps5.1?
us10.^4us】5.3pus204f8us25.§
us3072us
16.5ns
#
openbel
compout
1■■■=■!
■■■=■■■■■'
=1=「「「i
qlKKz
曲测蒯ill咂测皿测测呱测i■■删测呱
q500Hz
jmnjwinjTrLnjTrLnnnjTrLrLnjwuuirLnjirLnjinjinrLnjinjirLrLrL
(±
1tnl
〔5~
[±
jtnO
9
13tsl
5
□tsO
:
0XlX2:
〈3X4X5X&
X7:
〈6:
「mX0)(lX2〉:
3)(4X5X6X7:
〈6)(9X0
bell
l■l■l^l■■lWMlll■l皿L_n_n_nn._nn.jitl一iiil_
jtell
tell
ts.tp.4]tmop.o
ts.O[3..O]compoutqlKHzq5O3Hz•opsnbel
irrstl1
7x控制显示模块(show_con<
vhd)
该模忘实现了数码管既可以显示正常时间,又可以显示闹钟时间的功能;
调时过程的定时闪烁功能也在此模块中真正实现。
(2)源程序:
libraryieee;
useieee・stdlogic_l164.all;
useieee・stdlogiconsigned・all;
entityshowconis
seel,mini,hl:
outstdlogic_vector(7downto4);
sec0,min0,hO:
outstdlogic_vector(3downto0):
q2Hztflashs,flashh,flashm,sel_show:
instdlogic);
endshowcon;
architecturertlofshowconis
process(thl,tml,tsl,thO,tmO,tsO,bhl,bml,bhO,bmO,q2Hz,f1ashs,f1ashh,flashm,seishow)
ifsel_show=r0rthen
if(flashh=,11andq2Hz=,1'
)thenhl<
llir,;
hO<
=,,llir,;
一显示小时数码管以2Hz闪烁minl<
=tml;
min0<
=tm0;
secl<
=tsl;
sec0<
=ts0;
elsif(flashm='
1'
andq2Hz=,1'
)then
hl<
=thl;
=thO;
mini<
=wllllw;
minO<
=wllllff;
elsif(flashs='
minl<
=tml;
min0<
=tni0;
=Bllir,;
secO<
=ttllllw;
else
secl<
=tsO;
elsifseishow二T'
then—若seishow为"
1”,数码管显示闹钟时间一一
if(flashh二T‘andq2Hz二T'
)thenhi<
=,,iiii,,;
ho<
=ffinr,;
minl<
=bml;
minO<
=:
bmO;
=tt0000”;
sec0<
="
0000”;
elsif(flashm二T'
andq2Hz二T)then
=bhl;
=bhO;
=ffllir,;
=,,llir,;
sec1<
0000“;
mini<
=bml;
=bm0;
sec1<
0000”;
endif;
endrtl;
(3)模块图:
showoora
th1|7..41
sac1[7..4J
L
tm1[7..4)
ts1[7.,4]
hip..4)
thO[3..O]
Sfe&
3[3..0]
wop..0]
min(X3..0]
r—
ts-9[3..O)
bMp..4)
bm1[7..4J
bW|3..O]
j—
q2Hz
fias-hh
fl35-hm
sel_5how
instil)
8>动态扫描显示模块(scarified,vhd)
由4组输入信号和输出信号进而实现了时钟时、分的动态显示。
useieee・stdlogic_unsigned・all;
entityscan_ledis
port(clkl:
instdlogic;
hO:
instdlogic_vector(3downto0):
hl:
instdlogic_vector(7downto4);
minO:
mini:
instdlogic_vector(7downto4);
ML:
out
MH:
HL:
HH:
out);
stdlogic_vector(7stdlogic_vector(7stdlogic_vector(7stdlogic_vector(7
downtodowntodowntodownto
0)
endscanled;
architectureoneofseanledis
signalt4:
stdlogic_vector(ldownto0):
signala:
stdlogic_vector(3downto0);
pl:
process(clkl)
ifclklreventandclkl二ithent4<
=cnt4+l;
ift4=3then
t4<
00"
endprocesspl;
p2:
process(cnt4,hl,hO,mini,minO)
caset4is—控制数码管位选
when,,00'
r=>
caseminOis
when"
0000w=>
ML<
=,r11000000w;
when”0001"
=>
=T1111001"
0010”=>
=T0100100”;
0011ff=>
10110000tt;
whenH0100M=>
=M10011001
whenh0101m=>
=m10010010m;
when”0110”=>
=”10000010"
when,,01ir=>
=M11111000M;
whenM1000H=>
=hl0000000r,;
whenm1001m=>
=m10010000m;
whenothers^NULL;
endcase;
01"
caseminiis
whenff0000w=>
MH<
=w11000000'
*;
whenM000r=>
=Millll00r;
when"
0011,r=>
=T0110000”;
0100”=>
=T0011001”;
0101"
=T0010010”;
0110”=>
=T0000010”;
Oil1”=>
=T1111000”;
whenT000”=>
=T0000000”;
whenT001”=>
=TOO10000"
whenT0"
casehOis
0000”=>
HL<
11000000w;
0001”=>
10110000ff;
0100”=>
=T0011001"
=T0010010"
0111”=>
whenM1001M=>
=M10010000M;
whenothers=>
NULL;
when,,H,,=>
casehlis
HH<
0010"
=T0100100"
0101”=>
0111"
1001”=>
=T0010000"
whenothers=>
null;
endprocessp2;
endone;
jscan_ted
dkl
ML[7..O]
-4
HX3.0]
MH[7..O]
T
■
h1[7..4j
HL[7..O]
mirv3[3..0]
B
min1[7..4]
inst17
五、端口设定
k:
button2,set:
buttonl,reset:
buttonO;
Bell:
SW1用于开关蜂鸣器;
=
Q忤Qa就rwls
()pe^)ASTiiTTaT
Gre^p)as*2irfifl
Q卩吨asp匹“
(ir^)as'
zSFTT
3哪)asporTia
Orc^pjftsiSHF
(4FW)A5*ZSTiT
Gfchp)As*ion"
ih
Ofvp)astrhfzs
m-t••..'
•r;
:
「.-•-
0PW)AS7t^G
OPOPP)AS7【心
(myftwzwra
珂"
tS[25
単呼呼制ligg
缈呷仮TiigS
Si:
-i\j.\=
Ti^S
(W卿)便onTzfl
QP卿WlINiQ
"
与綱A£
・?
fSTZa
Ore^p)as-£
onTI
6p<
w)as*z537J
Orv^p)AS*ZOnTF
<
4Fe^p)ft$-ZSTTb*
ftpcw)AS*ZDNZfl"
3沖)as丘on7b
“却A£
2
ONLB
—4
叽即)E
ONZQ
却AST:
DhTZB
OfC^p)AS7
otTzb
-♦
Q咛p)AST
|・・:
OFVP)AST
orris
•q
QMPP”讥
I「2d2C~MdToJduTSodbudbaTaTEdTbTHjeFmj
rczo
jncxino
E;
P
)gp
FG-no
inch:
Miso~[iTS■—石
呼Q
O
kins~
4更]T丘ZEZE"
u
ZHN3d:
I汀皿【【EdnH~Md:
••'
ns~MJdnrwidnrwjdn<
TNJd就VMMnrwida3~Njd