【正文】
沒有什么影響,觸發(fā)器置 1 后將保持 1 狀態(tài)不變。 校時電路的實(shí)現(xiàn)原理 8 當(dāng)電子鐘接通電源或者計(jì)時發(fā) 現(xiàn)誤差時,均需要校正時間。 二、設(shè)計(jì)要求 基本要求: 24 小時計(jì)數(shù)顯示; 具有校時功能(時,分) ; 9 附加要求: 實(shí)現(xiàn)鬧鐘功能(定時,鬧響); 三、源代碼 library ieee。 clk1:in std_logic。 dout:out std_logic_vector(6 downto 0)。 signal hou1:std_logic_vector(3 downto 0)。 signal seth1:std_logic_vector(3 downto 0)。 signal sec1:std_logic_vector(3 downto 0)。 signal m1:std_logic_vector(3 downto 0)。 begin 模 6 計(jì)數(shù) choice:process(clk1) begin if clk139。 else sel=sel+1。 小時十位 11 h110:process(clk,hou2,min1,min2,sec1,sec2,md1,md2) begin if clk39。 elsif hou1=0010and hou2=0011and md1=39。039。 end process h110。 then if (hou1=0010 and hou2=0011)and(min1=0101 and min2=1001) and (sec1=0101 and sec2=1001) then hou2=0000。 and md2=01)or (hou1=0010and hou2=0011) then hou2=0000。039。 end if。139。 and md2=00)then min1=0000。 end if。 分鐘個位 m220:process(clk,sec1,sec2,md1,md2) 13 begin if clk39。 elsif min2=1001and (md1=39。039。end if。139。 end if。event and clk=39。 end if。event and clk=39。 end if。event and clk=39。139。 end process sethour2。 then if setm1=0101and setm2=1001then setm1=0000。 end process setmin1。then if setm2=1001then setm2=0000。 end if。event and clk1=39。039。 disp:process(sel,md1,hou1,hou2,min1,min2,sec1,sec2,seth1,seth2,setm1,setm2) begin if sel=000 then selout=000。 when others =dout=1000000。 when 0001=dout=0000110。 when 0101=dout=1101101。 when 1001=dout=1101111。 case m1 is when 0000=dout=0111111。 when 0100=dout=1100110。 elsif sel=011 then selout=011。 when 0011=dout=1001111。 when 0111=dout=0000111。 end case。 when 0010=dout=1011011。 when others=dout=1000000。 when 0001=dout=0000110。 when 0101=dout=1101101。 when 1001=dout=1101111。 if md1=39。 m1=min1。 else 鬧鈴時間現(xiàn)實(shí)和設(shè)置模式 h1=seth1。 s1=1111。 end one。 use 。輸出 /進(jìn)位信號 end MINSECONDb。 begin IF CLK39。 ELSE COUNT2:=0。 if clrm=39。 elsif clk39。139。 if t1=1001 and t0=1000 then當(dāng)記數(shù)為 98(實(shí)際是經(jīng)過 59 個記時脈沖) co=39。計(jì)數(shù) elsif t0=1001 then clk1=not clk1。 co=39。 end if。 end SEC。 entity SECOND is port(clk,clr:in std_logic。 23 architecture SEC of SECOND is begin process(clk,clr) variable t1,t0:std_logic_vector(3 downto 0)。 t0:=0000。 then if t1=0101 and t0=1000 then當(dāng)記數(shù)為 58(實(shí)際是經(jīng)過 59 個記時脈沖) co=39。計(jì)數(shù) else t0:=0000。039。 sec1=t1。 分模塊程序清單 library ieee。 min1,min0:out std_logic_vector(3 downto 0)。 begin if clk39。139。 elsif t01001 then t0:=t0+1。 co=39。 end if。 end process。 use 。 architecture hour_arc of HOUR is begin process(clk) variable t1,t0:std_logic_vector(3 downto 0)。 then上升沿觸發(fā) if en=39。 elsif t01001 then低位小于 9 時,低位記數(shù)累加 t0:=t0+1。 end if。 end process。 use 。分別為秒個位 /時位;分個位 / daout:out std_logic_vector(3 downto 0)。計(jì)數(shù)信號 begin sel=count。) then if(count=111) then count=000。 case count is when111=daout= secm0。分十位 when011=daout=min0。 end case。 use 。低頻聲控制 end ALERT。 then if m1=0101 and m0=1001 and s1=0101 then當(dāng)秒高位為 5,低位為9 時且分高位為 5 if s0=0001 or s0=0011 or s0=0101 or s0=0111 then當(dāng)分的低位為 1 或 3 或 5 或 7 時 q500=39。否則輸出為 0 end if。高頻輸出為 1 else qlk=39。 end process。 entity DISPLAY is port(d:in std_logic_vector(3 downto 0)。顯示 0 when0001 =q=0000110。顯示 4 when0101 =q=1101101。顯示 8 when others =q=1101111。 28 頂層文件(原理圖輸入) ******************************************************************** 數(shù)字鐘設(shè)計(jì)模塊與程序(不含秒表) ********************************************************************* (原理圖輸入) 2. 秒模塊程序 library ieee。 sec1,sec0:out std_logic_vector(3 downto 0)。 begin if clr=39。 elsif clk39。139。 if t10101 then t1:=t1+1。 end if。 sec0=t0。 use 。 co:out std_logic)。event and clk=39。 then if t1=0101 and t0=1000 then co=39。 else t0:=0000。039。 end if。 end MIN。 entity HOUR is port(clk,en:in std_logic。 begin if clk39。139。 end if。 h0=t0。 use 。 sec1,sec0,min1,min0,h1,h0:in std_logic_vector(3 downto 0)。 architecture fun of SELTIME is signal count:std_logic_vector(2 downto 0)。139。 end if。 when011=daout= min1。 end process。 entity DISPLAY is port(d:in std_logic_vector(3 downto 0)。 when0001 =q=0000110。 when0101 =q=1101101。 when others =q=1101111。 library ieee。 q500,qlk:out std_logic)。139。039。139。 end if。有靜音模式。 use 。 entity CLK is port(clk0,clr,clr1,mclock,hoclock,tm,th,res,rst:in std_logic。 architecture Behavioral of CLK is signal sech,secl:std_logic_vector(3 downto 0)。 鬧鐘,時 /分高低位 signal clk:std_logic_vector(8 downto 0)。聲音,高音 /低音 /鬧鐘 begin process(clk0) 分頻模塊 begin if (clk039。 35 else clkl=clkl+1。 else clk=clk+1。 end process。 secl=0000。 then if sech=0101 and secl=1000 then secl=1001。 else sech=0000。 end process。 minl=0000。 minl=tml。 then if ((sech=0101)AND(secl=1001)) then if minh=0101 and minl=1000 then minl=1001。 else minh=0000。 end if。 then hh=0000。 then rst 使能,計(jì)時器時被賦值為調(diào)整時間 hh=thh。139。 elsif hl =1001 then hh= hh+1。 end if。139。039。139。 end if。 揚(yáng)聲器發(fā)生 end process。 tml=0000。 then tm沿觸發(fā) if tmh=0101 and tml=1000 then tml=1001。 40 else tmh=0000。 end process。 thl=0000。 then th沿觸發(fā) if thh=0010 and thl=0011 then thh=0000。 thl=0000。 41 process(clr1,mclock) 鬧鐘,分模塊 M60 begin if clr1=39。 elsif mclock39。 elsif ml1001 then ml=ml+1。 end if。 process(clr1,hoclock) 鬧鐘,小時模塊 M24 42 begin if clr1=39。 elsif hoclock39。 hol=000