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