【正文】
clk2khz=39。 then if count=999 then clk1:=not clk1。 else count:=count+1。end if。end process。掃描顯示譯碼模塊library ieee。use 。掃描時(shí)鐘信號(hào) one1,ten1,one2,ten2:in integer range 0 to 10。片選輸出信號(hào) seg_7:out std_logic_vector(6 downto 0))。architecture three of display is signal data:integer range 0 to 10。 signal t:std_logic_vector(1 downto 0)。 when 1=seg77=0000110。 when 3=seg77=1001111。 when 5=seg77=1101101。 when 7=seg77=0000111。 when 9=seg77=1101111。 end case。seg_7=seg77。event and clk2khz=39。 then 00到11循環(huán)計(jì)數(shù)器 if t=11 then t=00。 end if。end process。scan=00。scan=01。scan=10。scan=11。 end case。end three。use 。entity state5 isport(clk1hz,car:in std_logic。倒計(jì)時(shí)數(shù) r_a,g_a,y_a,r_b,g_b,y_b:out std_logic)。architecture two of state5 is signal st:std_logic_vector(2 downto 0)。beginprocess(clk1hz)5 states variable eoc:std_logic。beginif clk1hz39。139。039。139。039。039。039。139。039。l1:=10。l2:=10。 else st=001。l1:=4。l2:=9。when 001=if car=39。 then st=000。039。l1:=4。l2:=9。139。139。039。039。039。139。039。eoc:=39。h1:=0。h2:=0。 elsif l1=0 then l1:=9。l2:=l21。h2:=h21。 else l1:=l11。 end if。 end if。039。主干道黃燈亮5秒 else if eoc=39。 then h1:=0。 h2:=0。 eoc:=39。 g1=39。r1=39。y1=39。g2=39。r2=39。y2=39。 else if l1=1 then st=011。039。l1:=0。l2:=0。l2:=l21。 end if。when 011=if car=39。 then st=000。039。l1:=9。l2:=4。139。039。139。039。139。039。039。eoc:=39。h2:=0。h1:=0。 elsif l2=0 then l2:=9。l1:=l11。h1:=h11。 else l2:=l21。 end if。 end if。039。支干道黃燈亮5秒 else if eoc=39。 then h1:=0。 h2:=0。 eoc:=39。 g1=39。r1=39。y1=39。g2=39。r2=39。y2=39。 else if l2=1 then st=001。039。l1:=0。l2:=0。l2:=l21。 end if。when others=NULL。end if。g_a=g1。r_b=r2。y_b=y2。ten1=h1。ten2=h2。end。use 。entity jtd isport(clk_2k,car:in std_logic。數(shù)碼管片選輸出信號(hào) seg7:out std_logic_vector(6 downto 0)。主支干道紅黃綠燈end。 clk1hz:out std_logic)。ponent state5定義交通燈控制及計(jì)時(shí)元件port(clk1hz,car:in std_logic。 r_a,g_a,y_a,r_b,g_b,y_b:out std_logic)。ponent display定義掃描顯示譯碼元件port(clk2khz:in std_logic。 scan:out std_logic_vector(1 downto 0)。end ponent。signal onea,tena,oneb,tenb:integer range 0 to 10。u2:state5 port map (clk1hz=clk_1hz,car=car,r_a=ra,g_a=ga,y_a=ya, r_b=rb,g_b=gb,y_b=yb,one1=onea,ten1=tena,one2=oneb,ten2=tenb)。