EDA数字钟设计文档格式.docx
《EDA数字钟设计文档格式.docx》由会员分享,可在线阅读,更多相关《EDA数字钟设计文档格式.docx(18页珍藏版)》请在冰豆网上搜索。
outstd_logic_vector(2downto0);
seg7:
outstd_logic_vector(7downto0);
seg_s_l,seg_s_h,seg_m_l,seg_m_h,seg_h_l,seg_h_h:
bufferintegerrange0to9);
ENDENTITYs_clock_signal;
ARCHITECTUREmzmOFs_clock_signalIS
SIGNALsec1_t,sec2_t,min1_t,min2_t,hour1_t,hour2_t:
integerrange0to9;
SIGNALcarry1,carry2,carry3:
STD_LOGIC;
SIGNALcnt:
std_logic_vector(2downto0);
SIGNALcnt_freq:
integerrange0to999;
SIGNALsel:
SIGNALclk_1Hz:
std_logic;
functioni2seg7(i:
inintegerrange0to9)
returnstd_logic_vectoris
variableseg7:
std_logic_vector(7downto0);
begin
caseiis
when0=>
seg7:
=x"
3f"
;
--digitaltubesdisplay0to9
when1=>
06"
when2=>
5B"
when3=>
4F"
when4=>
66"
when5=>
6D"
when6=>
7D"
when7=>
07"
when8=>
7F"
when9=>
6F"
whenothers=>
=(others=>
'
0'
);
endcase;
returnseg7;
endfunctioni2seg7;
BEGIN
p1:
PROCESS(clk_1Hz,reset,sec1_t,sec2_t)
BEGIN
IFreset='
1'
THEN
sec1_t<
=0;
sec2_t<
ELSIFrising_edge(clk_1Hz)THEN
IFsec1_t=9THEN
IFsec2_t=5THEN
ELSE
=sec2_t+1;
ENDIF;
=sec1_t+1;
IF(sec1_t=9ANDsec2_t=5)THEN
carry1<
='
seg_s_l<
=sec1_t;
seg_s_h<
=sec2_t;
ENDPROCESSp1;
p2:
PROCESS(reset,min1_t,min2_t,carry1)
IFreset='
min1_t<
min2_t<
ELSIFrising_edge(carry1)THEN
IFmin1_t=9THEN
min1_t<
IFmin2_t=5THEN
min2_t<
=min2_t+1;
=min1_t+1;
IF(min1_t=9ANDmin2_t=5)THEN
carry2<
seg_m_l<
=min1_t;
seg_m_h<
=min2_t;
ENDPROCESSp2;
p3:
PROCESS(reset,hour1_t,hour2_t,carry2,carry3)
hour1_t<
hour2_t<
ELSIFrising_edge(carry2)THEN
IF(hour1_t=3ANDhour2_t=2)THEN
IFhour1_t=9THEN
IFhour2_t=2THEN
=hour2_t+1;
=hour1_t+1;
IF(hour1_t=0ANDhour2_t=0)THEN
carry3<
seg_h_l<
=hour1_t;
seg_h_h<
=hour2_t;
ENDPROCESSp3;
ca1<
=carry1;
ca2<
=carry2;
ca3<
=carry3;
p4:
process(clk,reset,sel)
ifreset='
then
cnt<
'
cnt_freq<
=0;
clk_1Hz<
='
elsifrising_edge(clk)then
ifcnt=7then--6countertoscandigitaltubes
cnt<
else
=cnt+1;
endif;
ifcnt_freq=999then--1kdivid
cnt_freq<
clk_1Hz<
=notclk_1Hz;
=cnt_freq+1;
ifcnt_freq=499then
clk_1Hz<
endif;
casecntis--dynamicscaning
when"
000"
=>
sel<
="
seg7<
=i2seg7(seg_s_l);
001"
=i2seg7(seg_s_h);
010"
01000000"
011"
=i2seg7(seg_m_l);
100"
=i2seg7(seg_m_h);
101"
110"
=i2seg7(seg_h_l);
111"
=i2seg7(seg_h_h);
ZZZ"
endcase;
seline<
=sel+"
endif;
endprocessp4;
ENDmzm;
(1)秒计数器的源程序
ENTITYsecondIS
PORT(clk,reset:
sec1,sec2:
OUTSTD_LOGIC_VECTOR(3DOWNTO0);
carry:
OUTSTD_LOGIC);
ENDsecond;
ARCHITECTURErt1OFsecondIS
SIGNALsec1_t,sec2_t:
STD_LOGIC_VECTOR(3DOWNTO0);
PROCESS(clk,reset)
BEGIN
="
0000"
ELSIFclk'
eventANDclk='
IFsec1_t="
1001"
sec1_t<
IFsec2_t="
0101"
IFsec1_t="
AND
sec2_t="
carry<
sec1<
sec2<
ENDPROCESS;
ENDrt1;
图3-3秒计数器局部放大仿真波形
(2)分计数器的源程序
ENTITYminuteIS
min1,min2:
ca