【正文】
downto 0)。beginprocess(reset,clk)begin if reset=39。039。) then if clk_scan_ff=scan_val1 then clk_scan_ff=00。 ena_s=39。end process。 then ena_one=39。 clk_2hz_ff=0000000。) then if ena_s=39。139。039。 end if。end。 elsif (clk39。139。 sign_state=“000”時,南北方向綠燈亮25s。 sign_state=“010”時,南北方向紅燈亮15s。 sign_state=“100”時,東西方向黃燈亮5s。 end case。entity hld2 isport(reset:in std_logic。 sign_state:in std_logic_vector(2 downto 0)。constant yellowew_time:integer:=5。constant greensn_time:integer:=25。 elsif (clk39。139。 when 001=load=conv_std_logic_vector(yellowsn_time,8)。 when 101=load=conv_std_logic_vector(greenew_time,8)。 end if。東西方向紅燈設(shè)定為15s。東西方向綠燈設(shè)定為25s。南北方向黃燈設(shè)定為5s。139。event and clk=39。 then if (recount=39。 end if。 when 2=led(24 downto 0)=1110000000000000000000000。 when others=led(24 downto 0)=0000000000000000000000000。use 。 ena_1hz:in std_logic。 next_state:out std_logic)。139。event and clk=39。 then if (recount=39。 end if。 when 2=led(24 downto 0)=1110000000000000000000000。 when 6=led(24 downto 0)=1111111000000000000000000。 when 10=led(24 downto 0)=1111111111100000000000000。 when 14=led(24 downto 0)=1111111111111110000000000。 when 18=led(24 downto 0)=1111111111111111111000000。 when 22=led(24 downto 0)=1111111111111111111111100。 end case。139。library ieee。 clk:in std_logic。 a_m:in std_logic。 sign_state:out std_logic_vector(2 downto 0)。end。signal light:std_logic_vector(5 downto 0)。or reset=39。039。) then if (ena_scan=39。039。 else rebn_ff:=rebn_ff。 end if。139。139。) thencase state is when rewgsn= if (a_m=39。) then if (next_state=39。 state=rewysn。 state=rewgsn。 and ena_scan=39。) then recount=39。139。 end if。139。139。039。039。039。 else recount=39。 end if。 and ena_1hz=39。) then recount=39。 else recount=39。 elsif (a_m=39。) then if (st_transfer=39。139。 end if。139。139。039。039。039。 else recount=39。 end if。039。 end if。yellow=light(3 downto 2) and (flash_1hz amp。library ieee。 ena_scan:out std_logic。ponent hld2port(reset:in std_logic。 sign_state:in std_logic_vector(2 downto 0)。 clk:in std_logic。 led:out std_logic_vector(24 downto 0)。 clk:in std_logic。 a_m:in std_logic。 sign_state:out std_logic_vector(2 downto 0)。end ponent。use 。 clk:in std_logic。 next_state:out std_logic。 yellow:out std_logic_vector(1 downto 0)。signal ena_1hz_1:std_logic。signal sign_state_1:std_logic_vector(2 downto 0)。u3:hld3 portmap(reset,clk,ena_1hz_1,recount_1,load,next_state_1)。sign_state=sign_state_1。next_state=next_state_1。beginu1:hld1 portmap(reset,clk,ena_scan_1,ena_1hz_1,flash_1hz_1)。signal recount_1:std_logic。end。 red:out std_logic_vector(1 downto 0)。 st_butt:in std_logic。use 。系統(tǒng)的VHDL程序如下:library ieee。 green:out std_logic_vector(1 downto 0)。 next_state:in std_logic。 ena_1hz:in std_logic。end ponent。 recount:in std_logic。end ponent。 ena_scan:in std_logic。 flash_1hz:out std_logic)。package traffic isponent hld1port(reset:in std_logic。green=light(1 downto 0)。light=010010 when (state=rewgsn) else 011000 when (state=rewysn) else 100001 when (state=gewrsn) else 100100 when (state=yewrsn) else 110000。 end case。when others= state=rewgsn。 state=rewgsn。139。139。 end if。 sign_state=001。139。139。 sign_state=110。) then state=gewrsn。 and ena_scan=39。 state=gewrsn。 state=yewrsn。) then if (next_state=39。when gewrsn= if (a_m=39。 state=gewrsn。139。139。 end if。 sign_state=101。139。139。 sign_state=011。 state=rewgsn。) then if (st_transfer=39。 elsif (a_m=39。 else recount=39。) then recount=39。 and ena_1hz=39。event and clk=39。 sign_state=011。end process。039。 st_transfer=39。) then if (rebn_ff=3) then rebn_ff:=rebn_ff1。event and clk=39。) then rebn_ff:=111111。beginif (st_butt=39。signal state:sreg0_type。 green:out std_logic_vector(1 downto 0)。 next_state:in std_logic。 ena_1hz:in std_logic。use 。039。end process。 when 24=led(24 downto 0)=1111111111111111111111111。 when 20=led(24 downto 0)=1111111111111111111110000。 when 16=led(24 downto 0)=1111111111111111100000000。 when 12=led(24 downto 0)=1111111111111000000000000。 when 8=led(24 downto 0)=1111111110000000000000000。 when 4=led(24 downto 0)=1111100000000000000000000。 case conv_integer(t_ff) is when 0=led(24 downto 0)=1000000000000000000000000。) then t_ff=load1。) then if ena_1hz=39。 led=0000000000000000000000000。architecture bhv of hld3 issignal t_ff:std_logic_vector(7 downto 0)。 load:in std_logic_vector(7 downto 0)。entity hld3 isport(reset:in std_logic。倒計時控制電路程序代碼library ieee。 …… when 23=led(24 downto 0)=1111111111111111111111110。 case conv_integer(t_ff) is