【正文】
1 數(shù)字時鐘設(shè)計 (1)能顯示周、時、分、秒,精確到 (2)可自行設(shè)置時間 (3)可設(shè)置鬧鈴,并且對鬧鈴時間長短可控制 ( 1)根據(jù)題目要求可分解為正常計時、時間設(shè)置和鬧鈴設(shè)置三大模塊 ( 2)正常計時模塊可分解為周、時、分、秒等子模塊 ( 3)時間設(shè)置模塊分別進行秒置數(shù)、分置數(shù)、時置數(shù)和周置數(shù) ( 4)鬧鈴設(shè)置模塊分解為 鬧鐘判定和鬧鈴時長設(shè)定 時間重置 正常計數(shù) 鬧鐘設(shè)定 數(shù)字顯示 數(shù)字鐘 2 否 是 是 否 開始 重置時間? 秒重置 分重置 時重置 正常計時 正常計時 時間重置? 3 是 Second1(秒計數(shù) 6 進制和 10 進制 ) Library ieee。 Use 。 Use 。 Entity second1 is Port( clks,set:in std_logic。 s1,s0:in std_logic_vector(3 downto 0)。 Secs,Secg: buffer std_logic_vector(3 downto 0)。 cout1:out std_logic)。 End second1。 Architecture a of second1 is Begin Process(clks,set) variable ss,sg: std_logic_vector(3 downto 0)。(ss:秒十位; sg 秒個位 ) variable co: std_logic。 Begin If set=39。139。 then ss:=s1。 sg:=s0。 設(shè)置鬧鐘? 時設(shè)定 分設(shè)定 時刻到達? 響鈴 時間顯示 4 Elsif clks39。event and clks=39。139。 then if ss=0101 and sg=1001 then ss:=0000。 sg:=0000。co:=39。139。 elsif sg1001 then sg:=sg+1。co:=39。039。 elsif sg=1001 then sg:=0000。ss:=ss+1。co:=39。039。 end if。 end if。 cout1=co。 (進位信號) Secs=ss。 Secg=sg。 end process。 End a。 仿真波形圖: Min1(分計數(shù)器 6 進制和 10 進制 alm 實現(xiàn)整點報時) Library ieee。 Use 。 Use 。 Entity min1 is Port(clkm,set:in std_logic。 m1:in std_logic_vector(3 downto 0)。 5 m0:in std_logic_vector(3 downto 0)。 mins,ming:out std_logic_vector(3 downto 0)。 enmin,alarm: out std_logic)。 End。 Architecture a of min1 is Begin Process(clkm,set) variable ms,mg :std_logic_vector(3 downto 0)。 variable so,alm :std_logic。 Begin if set=39。039。 then ms:=m1。mg:=m0。 Elsif clkm39。event and clkm=39。139。 then if ms=0101 and mg=1001 then ms:=0000。mg:=0000。 so :=39。139。 alm:=39。139。 elsif mg1001 then mg:=mg+1。 so :=39。039。alm:=39。039。 elsif mg=1001 then mg:=0000。ms:=ms+1。 so :=39。039。alm:=39。039。 end if。 end if。 alarm=alm。 enmin= so。 mins=ms。 ming=mg。 End process。 End a。 仿真波形圖: 6 Hour1(時計數(shù)器 4 進制與 2 進制) Library ieee。 Use 。 Use 。 Entity hour1 is Port(clkh,set:in std_logic。 h1,h0:in std_logic_vector(3 downto 0)。 hours,hourg:buffer std_logic_vector(3 downto 0)。 enhour: out std_logic)。 End。 Architecture a of hour1 is Begin Process(clkh,set) variable hs,hg :std_logic_vector(3 downto 0)。 variable ho:std_logic。 Begin If set=39。139。 then hs:=h1。 hg:=h0。 Elsif clkh39。event and clkh=39。139。 then if hs=0010and hg=0011 then hs:=0000。hg:=0000。 ho :=39。139。 elsif hg1001 then hg:=hg+1。 ho :=39。039。 elsif hg=1001 then hg:=0000。hs:=hs+1。 ho :=39。039。 end if。 end if。 hours=hs。 hourg=hg。 7 enhour=ho。 End process。 End a。 仿真波形圖: Library ieee。 (星期計數(shù)器, 7 進制 ) Use 。 Use 。 Use 。 Entity week is Port(clkd,set,reset:in std_logic。 d1:in std_logic_vector(3 downto 0)。 ――置數(shù)端(星期) day:buffer std_logic_vector(3 downto 0))。 ――星期輸出端 end。 Architecture a of week is Begin Process(clkd,reset,set,d1) Begin If reset=39。039。 then day=0000。 ――對星期計時器清 0 Elsif set=39。039。 then day=d1。 ――對星期計時器置 d1的數(shù) Elsif clkd39。event and clkd=39。139。 then If day=6 then day=0000。 ――重復(fù)計數(shù) Else day=day+1。 End if。 End if。 End process。 End。 8 仿真波形圖: Second2(秒 置數(shù)模塊, 6 進制和 10 進制 ) Library ieee。 Use 。 Use 。 Entity second2 is Port( clks1:in std_logic。 Secs,Secg: out std_logic_vector(3 downto 0))。 End。 Architecture a of second2 is Begin Process(clks1) variable ss,sg: std_logic_vector(3 downto 0)。(ss:秒十位; sg 秒個位 ) Begin if clks139。event and clks1=39。139。 then if ss=0101 and sg=1001 then ss:=0000。 sg:=0000。 elsif sg1001 then sg:=sg+1。 elsif sg=1001 then sg:=0000。ss:=ss+1。 end if。 end if。 Secs=ss。 Secg=sg。 end process。 End a。 9 仿真波形圖: Min2( 分 置數(shù)模塊, 6 進制和 10 進制) Library ieee。 Use 。 Use 。 Entity min2 is Port(clkm1:in std_logic。 mins,ming:buffer std_logic_vector(3 downto 0))。 End。 Architecture a of min2 is Begin Process(clkm1) variable ms,mg :std_logic_vector(3 downto 0)。 Begin if clkm139。event and clkm1=39。139。 then if ms=0101 and mg=1001 then ms:=0000。mg:=0000。 elsif mg1001 then mg:=mg+1。 elsif mg=1001 then mg:=0000。ms:=ms+1。 end if。 end if。 mins=ms。 ming=mg。 End process。 End a。 10 仿真波形圖: Hour2(時 置數(shù)模塊, 4 進制與 2 進制) Library ieee。 Use 。 Use 。 Entity hour2 is Port(clkh1:in std_logic。 hours,hourg:buffer std_logic_vector(3 downto 0))。 End。 Architecture a of hour2 is Begin Process(clkh1) variable hs,hg :std_logic_vector(3 downto 0)。 Begin if clkh139。event and clkh1=39。139。 then if hs=0010and hg=0011 then hs:=0000。hg:=0000。 elsif hg1001 then hg:=hg+1。 elsif hg=1001 then hg:=0000。hs:=hs+1。 end if。 end if。 hours=hs。 hourg=hg。 End process。 End a。 11 仿真波形圖: Library ieee。 (星期置數(shù)模塊, 7 進制) Use 。 Use 。 Use 。 Entity week2 is Port(clkd1:in std_logic。 day:buffer std_logic_vector(3 downto 0))。 ――星