【正文】
39。139。mylift=down。 else udsig=39。039。 mylift=up。 end if。 elsif position=6 then if stoplight=000000 and fuplight=000000 and fdnlight=000000 then udsig=39。139。mylift=doorclose。 else udsig=39。139。 mylift=down。 end if。 end if。 end if。 when up = position=position+1。pos:=pos+1。 if position 6 and( stoplight(pos)=39。139。 or fuplight(pos)=39。139。) then mylift=stop。 elsif pos=6 and (stoplight(pos)=39。139。 or fdnlight(pos)=39。139。) then mylift=stop。 else mylift=doorclose。 end if。 when down = position=position1。 pos:=pos1。 if position1 and (stoplight(pos)=39。139。 or fdnlight(pos)=39。139。) then mylift=stop。 elsif pos=1 and (stoplight(pos)=39。139。 or fuplight(pos)=39。139。) then mylift=stop。 else mylift=doorclose。end if。 when stop = mylift=dooropen。 when dooropen = doorlight=39。139。if udsig=39。039。 thenif position6 and (stoplight(position)=39。139。 or fuplight(position)=39。139。) then clearup=39。139。else clearup=39。139。cleardn=39。139。end if。 elsif udsig=39。139。 thenif position1 and (stoplight(position)= 39。139。 or fdnlight(position)=39。139。) then cleardn=39。139。else clearup=39。139。cleardn=39。139。 end if。end if。mylift=doorwait1。 end case。 end if。 end if。end process controllift。controllight:process(reset,buttonclk) begin if reset=39。139。 then stoplight=000000。 fuplight=000000。fdnlight=000000。 elsif buttonclk39。event and buttonclk=39。139。 then if clearup=39。139。 then stoplight(position)=39。039。fuplight(position)=39。039。 elsif f1upbutton=39。139。 then fuplight(1)=39。139。 elsif f2upbutton=39。139。 then fuplight(2)=39。139。 elsif f3upbutton=39。139。 then fuplight(3)=39。139。 elsif f4upbutton=39。139。 then fuplight(4)=39。139。 elsif f5upbutton=39。139。 then fuplight(5)=39。139。 end if。 if cleardn=39。139。 then stoplight(position)=39。039。 fdnlight(position)=39。039。 elsif f2dnbutton=39。139。 then fdnlight(2)=39。139。 elsif f3dnbutton=39。139。 then fdnlight(3)=39。139。 elsif f4dnbutton=39。139。 then fdnlight(4)=39。139。 elsif f5dnbutton=39。139。 then fdnlight(5)=39。139。 elsif f6dnbutton=39。139。 then fdnlight(6)=39。139。 end if。 if stop1button=39。139。 then stoplight(1)=39。139。 elsif stop2button=39。139。 then stoplight(2)=39。139。 elsif stop3button=39。139。 then stoplight(3)=39。139。 elsif stop4button=39。139。 then stoplight(4)=39。139。 elsif stop5button=39。139。 then stoplight(5)=39。139。 elsif stop6button=39。139。 then stoplight(6)=39。139。 end if。 end if。end process controllight。end art。分頻器程序:library ieee。use 。use 。entity div is port( clk_in:in std_logic。 div_out:out std_logic)。end。architecture a of div is signal fre_N:integer range 0 to 10。signal clk_tmp:std_logic。begin div_out=clk_tmp。process(clk_in)begin if falling_edge(clk_in) then if fre_N10 then fre_N=0。 clk_tmp=not clk_tmp。 else fre_N=fre_N+1。 end if。 end if。 end process。end a。譯碼器程序:library ieee。use 。use 。entity yima isport( aaa:integer range 1 to 6。 bbb:out std_logic_vector(3 downto 0))。end。architecture a of yima isbeginprocess(aaa)begin if aaa=1 then bbb=0001。 elsif aaa=2 then bbb=0010。 elsif aaa=3 then bbb=0011。 elsif aaa=4 then bbb=0100。 elsif aaa=5 then bbb=0101。 elsif aaa=6 then bbb=0110。end if。end process。end a。數(shù)據(jù)選擇器程序:library ieee。use 。entity led is port( input:in std_logic_vector(3 downto 0)。 output:out std_logic_vector(6 downto 0))。end。architecture a of led is begin output=0110000 when input=0001 else 1101101 when input=0010 else 1111001 when input=0011 else 0110011 when input=0100 else 1011011 when input=0101 else 1011111 when input=0110 else 0000000。end