【正文】
red: out std_logic_vector(1 downto 0)。 green: out std_logic_vector(1 downto 0)。 yellow: out std_logic_vector(1 downto 0))。 end。 architecture BEHAVIOR of traffic_FSM is type Sreg0_type is (r0g1, r0y1, g0r1, y0r1, y0y1, y0g1, g0y1, r0r1)。 signal state : Sreg0_type。 signal light: std_logic_vector(5 downto 0)。 begin if (reset=39。139。) then state=r0g1。 設(shè)定當(dāng)前為橫向紅燈亮,豎向綠燈亮 sign_state=“01”。選擇 20秒倒計時 recount=?1?。 裝入計數(shù)初值并啟動倒計時 else if (clk39。event and clk=39。139。) then case STATE is when r0g1 = if (a_m=39。139。 and clk_1Hz=39。139。) then if (next_state = ?1?) then 當(dāng)前計數(shù)完畢,轉(zhuǎn)入下一種計時 recount=39。139。 state=r0y1。 sign_state = 01。 else recount=?0?。 state=r0g1。否則,繼續(xù)倒計時 end if。 when r0y1 = now state: red0 on yellow1 flash if (a_m=39。139。 and clk_1Hz=39。139。) then if (next_state = 39。139。) then recount=39。139。 state=g0r1。 sign_state = 10。 else recount=39。039。 state=r0y1。 end if。 when g0r1 = now state: green0 on red1 on