【文章內(nèi)容簡介】
nce issignal temp1,temp2: std_logic。begin process(key,clk) begin if clk39。event and clk=39。039。 then 與時鐘信號同步,并且 temp2=temp1。 與存儲先前值 temp1=key。 end if。 end process。 key_out=temp1 and (not temp2) and clk。 消抖輸出end。 Frequency1模塊Frequency1模塊,由于外部時鐘信號clk的頻率為1MHz,而實際需要的內(nèi)部計時時鐘頻率為1Hz,需要一個分頻電路。輸入端口:clk外部時鐘信號輸出端口:clk_out分頻后信號library ieee。use 。use 。entity Frequency1 is port( clk:in std_logic。 外部時鐘信號 clk_out:out std_logic 分頻后信號 )。end Frequency1。architecture Frequency1_arc of Frequency1 isbegin process(clk) variable temp:integer range 0 to 999999。 begin if(clk39。event and clk=39。139。)then if(temp=999999)then 分頻計數(shù) temp:=0。 clk_out=39。039。 else temp:=temp+1。 clk_out=39。139。 end if。 end if。 end process。 end。 .4 StatusSelect模塊StatusSelect模塊,由于共需要顯示4個數(shù)字,需要循環(huán)點亮7位數(shù)碼管,該模塊通過輸入的時鐘信號,循環(huán)輸出4個選擇信號。當(dāng)緊急狀態(tài)信號到來,改變顯示狀態(tài),通過計數(shù)部分,實現(xiàn)閃爍,并輸出蜂鳴信號。輸入端口:clk時鐘信號,show緊急顯示輸出端口:sel選擇信號,voice蜂鳴信號library ieee。use 。entity StatusSelect is port( clk,show:in std_logic。 時鐘信號,緊急顯示 sel:out std_logic_vector(2 downto 0)。 選擇信號 voice:out std_logic 蜂鳴信號 )。end StatusSelect。architecture StatusSelect_arc of StatusSelect issignal temp:std_logic_vector(2 downto 0)。begin process(clk,show) variable t:integer range 0 to 499999。 variable a:std_logic。 begin if(clk39。event and clk=39。139。)then case show is when 39。039。 = 非緊急狀態(tài) voice=39。039。 case temp is when 000=temp=001。 when 001=temp=010。 when 010=temp=011。 when 011=temp=000。 when others=temp=000。 end case。 when others = 緊急狀態(tài) voice=a。 if(t=499999)then 閃爍計數(shù) t:=0。 a:=not a。 else t:=t+1。 end if。 if (a=39。139。) then case temp is when 000=temp=001。 when 001=temp=010。 when 010=temp=011。 when 011=temp=000。 when others=temp=000。 end case。 else temp=111。 end if。 end case。 end if。 sel=temp。 end process。end 。 TimeSelect模塊TimeSelect模塊,接收狀態(tài)選擇信號以及交通燈剩余時間信號,根據(jù)狀態(tài)選擇信號,選擇剩余時間的位數(shù)輸出給譯碼模塊,并選擇陰極控制顯示位置。輸入接口:sel狀態(tài)選擇信號, timeh1 timel1 timeh2 timel2剩余時間輸出接口:catn共陰極控制,time_out數(shù)字輸出library ieee。use 。entity TimeSelect is port( sel:in std_logic_vector(2 downto 0)。 狀態(tài)選擇信號 timeh1,timeh2,timel1,timel2:in std_logic_vector(3 downto 0)。 剩余時間 catn:out std_logic_vector(5 downto 0)。 共陰極控制 time_out:out std_logic_vector(3 downto 0) 數(shù)字輸出 )。end TimeSelect。architecture TimeSelect_arc of TimeSelect isbegin process(sel) begin case sel is 通過狀態(tài)信號選擇輸出 when 000=time_out=timeh1。 catn=111110。 when 001=time_out=timel1。 catn=111101。 when 010=time_out=timeh2。 catn=101111。 when 011=time_out=timel2。 catn=011111。 when others=time_out=0000。 catn=111111。 end case。 end p