(1)模块说明:
该模忘实现了数码管既可以显示正常时间,又可以显示闹钟时间的功能;调时过程的定时闪烁功能也在此模块中真正实现。
(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
begin
process(thl,tml,tsl,thO,tmO,tsO,bhl,bml,bhO,bmO,q2Hz,f1ashs,f1ashh,flashm,seishow)
begin
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;hO<=thO;mini<=wllllw;minO<=wllllff;
secl<=tsl;sec0<=ts0;
elsif(flashs='1'andq2Hz=,1')then
hl<=thl;hO<=thO;
minl<=tml;min0<=tni0;
secl<=Bllir,;secO<=ttllllw;
else
hl<=thl;hO<=thO;
minl<=tml;min0<=tm0;secl<=tsl;secO<=tsO;endif;
elsifseishow二T'then—若seishow为"1”,数码管显示闹钟时间一一
if(flashh二T‘andq2Hz二T')thenhi<=,,iiii,,;ho<=ffinr,;minl<=bml;minO<=:
bmO;
secl<=tt0000”;sec0<="0000”;
elsif(flashm二T'andq2Hz二T)then
hl<=bhl;hO<=bhO;
minl<=ffllir,;minO<=,,llir,;
sec1<="0000“;sec0<="0000”;
else
hl<=bhl;hO<=bhO;
mini<=bml;min0<=bm0;
sec1<="0000”;sec0<="0000“;
endif;
endif;
endprocess;
endrtl;
(3)模块图:
:
showoora
th1|7..41
sac1[7..4J
L
tm1[7..4)
L
ts1[7.,4]
hip..4)
L
thO[3..O]
Sfe&3[3..0]
L
wop..0]
min(X3..0]
r—
ts-9[3..O)
L
bMp..4)
bm1[7..4J
bW|3..O]
—
j—
q2Hz
i—
flashs
i—
fias-hh
i—
fl35-hm
—
sel_5how
instil)
8>动态扫描显示模块(scarified,vhd)
(1)模块说明:
由4组输入信号和输出信号进而实现了时钟时、分的动态显示。
(2)源程序:
libraryieee;
useieee・stdlogic_l164.all;
useieee・stdlogic_unsigned・all;entityscan_ledis
port(clkl:
instdlogic;
hO:
instdlogic_vector(3downto0):
hl:
instdlogic_vector(7downto4);minO:
instdlogic_vector(3downto0):
mini:
instdlogic_vector(7downto4);
ML:
out
MH:
out
HL:
out
HH:
out);
stdlogic_vector(7stdlogic_vector(7stdlogic_vector(7stdlogic_vector(7
downtodowntodowntodownto
0)
0)
0)
0)
endscanled;architectureoneofseanledis
signalt4:
stdlogic_vector(ldownto0):
signala:
stdlogic_vector(3downto0);begin
pl:
process(clkl)
begin
ifclklreventandclkl二ithent4<=cnt4+l;
ift4=3then
t4<="00";
endif;
endif;
endprocesspl;
p2:
process(cnt4,hl,hO,mini,minO)
begin
caset4is—控制数码管位选
when,,00'r=>caseminOis
when"0000w=>ML<=,r11000000w;
when”0001"=>ML<=T1111001";
when"0010”=>ML<=T0100100”;
when"0011ff=>ML<="10110000tt;
whenH0100M=>ML<=M10011001
whenh0101m=>ML<=m10010010m;
when”0110”=>ML<=”10000010";
when,,01ir=>ML<=M11111000M;
whenM1000H=>ML<=hl0000000r,;
whenm1001m=>ML<=m10010000m;whenothers^NULL;
endcase;
when"01"=>caseminiis
whenff0000w=>MH<=w11000000'*;whenM000r=>MH<=Millll00r;when"0010”=>MH<=T0100100”;when"0011,r=>MH<=T0110000”;when"0100”=>MH<=T0011001”;when"0101"=>MH<=T0010010”;when"0110”=>MH<=T0000010”;when"Oil1”=>MH<=T1111000”;whenT000”=>MH<=T0000000”;whenT001”=>MH<=TOO10000";whenothers^NULL;
endcase;
whenT0"=>casehOis
when"0000”=>HL<="11000000w;
when"0001”=>HL<=T1111001";when"0010”=>HL<=T0100100”;when"0011ff=>HL<="10110000ff;when"0100”=>HL<=T0011001";when"0101"=>HL<=T0010010";when"0110”=>HL<=T0000010”;when"0111”=>HL<=T1111000”;whenT000”=>HL<=T0000000”;whenM1001M=>HL<=M10010000M;whenothers=>NULL;
endcase;
when,,H,,=>casehlis
when"0000”=>HH<="11000000w;
when"0001”=>HH<=T1111001";when"0010"=>HH<=T0100100";when"0011,r=>HH<=T0110000”;when"0100”=>HH<=T0011001";when"0101”=>HH<=T0010010";when"0110”=>HH<=T0000010”;when"0111"=>HH<=T1111000”;whenT000”=>HH<=T0000000”;when"1001”=>HH<=T0010000";whenothers=>NULL;
endcase;
whenothers=>null;
endcase;
endprocessp2;endone;
(3)模块图:
jscan_ted
\
dkl
ML[7..O]
-4
r—
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
6pOrv^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