【正文】
=39。139。 g1=39。039。r1=39。039。y1=39。139。g2=39。039。r2=39。139。y2=39。039。 else if l1=1 then st=011。eoc:=39。039。h1:=0。l1:=0。h2:=0。l2:=0。 else l1:=l11。l2:=l21。 end if。 end if。 end if。when 011=if car=39。039。 then st=000。支干道綠燈亮25秒 else if eoc=39。039。 then h1:=2。l1:=9。 h2:=2。l2:=4。 eoc:=39。139。 g1=39。039。r1=39。139。y1=39。039。g2=39。139。r2=39。039。y2=39。039。 else if h2=0 and l2=1 then st=100。eoc:=39。039。h2:=0。l2:=0。h1:=0。l1:=5。 elsif l2=0 then l2:=9。h2:=h21。l1:=l11。 elsif l1=0 then l1:=9。h1:=h11。l2:=l21。 else l2:=l21。l1:=l11。 end if。 end if。 end if。when 100=if car=39。039。 then st=000。支干道黃燈亮5秒 else if eoc=39。039。 then h1:=0。l1:=4。 h2:=0。l2:=4。 eoc:=39。139。 g1=39。039。r1=39。139。y1=39。039。g2=39。039。r2=39。039。y2=39。139。 else if l2=1 then st=001。eoc:=39。039。h1:=0。l1:=0。h2:=0。l2:=0。 else l1:=l11。l2:=l21。 end if。 end if。 end if。when others=NULL。end case。end if。r_a=r1。g_a=g1。y_a=y1。r_b=r2。g_b=g2。y_b=y2。one1=l1。ten1=h1。one2=l2。ten2=h2。end process。end。頂層文件模塊library ieee。use 。use 。entity jtd isport(clk_2k,car:in std_logic。2khz輸入時(shí)鐘信號(hào) scan:out std_logic_vector(1 downto 0)。數(shù)碼管片選輸出信號(hào) seg7:out std_logic_vector(6 downto 0)。七段譯碼輸出信號(hào) ra,ga,ya,rb,gb,yb:out std_logic)。主支干道紅黃綠燈end。architecture behave of jtd isponent div定義時(shí)鐘分頻元件port(clk2khz:in std_logic。 clk1hz:out std_logic)。end ponent。ponent state5定義交通燈控制及計(jì)時(shí)元件port(clk1hz,car:in std_logic。 one1,ten1,one2,ten2:out integer range 0 to 10。 r_a,g_a,y_a,r_b,g_b,y_b:out std_logic)。end ponent。ponent display定義掃描顯示譯碼元件port(clk2khz:in std_logic。 one1,ten1,one2,ten2:in integer range 0 to 10。 scan:out std_logic_vector(1 downto 0)。 seg_7:out std_logic_vector(6 downto 0))。end ponent。signal clk_1hz:std_logic。signal onea,tena,oneb,tenb:integer range 0 to 10。beginu1:div port map(clk2khz=clk_2k,clk1hz=clk_1hz)。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)。u3:display port map (clk2khz=clk_2k,one1=onea,ten1=tena, one2=oneb,ten2=tenb,scan=scan,seg_7=seg7)。 end。23