【文章內(nèi)容簡(jiǎn)介】
lock=lock1。 grade=01。 if(ascend=39。139。 and descend=39。039。 ) then—若升檔信號(hào) =’1’,則轉(zhuǎn)入 s2狀態(tài) state=s2。clrad=39。139。讀取檔位升降信號(hào)后發(fā)出清檔位信號(hào),防止檔位繼續(xù)改變 else state=s1。clrad=39。039。否則停留在 s1狀態(tài) end if。 when s2=第二檔 doorout=x2。 clr=clr2。 lock=lock2。 8 / 15 grade=10。 if(descend=39。139。 and ascend=39。039。) then—若降檔信號(hào) =’1’,則轉(zhuǎn)入 s1狀態(tài) state=s1。 elsif(ascend=39。139。 and descend=39。039。) then—若升檔信號(hào) =’1’,則轉(zhuǎn)入 s3 狀態(tài) state=s3。 else state=s2。clrad=39。039。否則停留在 s2狀態(tài) end if。 when s3=第三檔 doorout=x3。 clr=clr3。 lock=lock3。 grade=11。 if(descend=39。139。 and ascend=39。039。) then—若降檔信號(hào) =’1’,則轉(zhuǎn)入 s2狀態(tài) state=s2。clrad=39。139。 else state=s3。clrad=39。039。 否則停留在 s3狀態(tài) end if。 when others= doorout=x2。 clr=clr2。 lock=lock2。 grade=10。 state=s2。 clrad=39。139。 end case。 end if。 end process p1。 END control_architecture。 count計(jì)數(shù)模塊 LIBRARY ieee。 USE 。 USE 。 ENTITY count IS PORT ( clrad : in std_logic。清升降檔 doorin : IN STD_LOGIC。門(mén)控信號(hào) clr : IN STD_LOGIC。 清零信號(hào) input_s : IN STD_LOGIC。待測(cè)信號(hào)輸入 9 / 15 tp1 : OUT STD_LOGIC_VECTOR(3 downto 0)。最低位 tp2 : OUT STD_LOGIC_VECTOR(3 downto 0)。 tp3 : OUT STD_LOGIC_VECTOR(3 downto 0)。 tp4 : OUT STD_LOGIC_VECTOR(3 downto 0)。最高位 ascend : OUT STD_LOGIC。升 descend : OUT STD_LOGIC—降 )。 END count。 ARCHITECTURE count_architecture OF count IS signal tq1,tq2,tq3,tq4:std_logic_vector(3 downto 0)。 BEGIN process(input_s,clr,clrad,doorin) begin if(clr=39。139。and doorin=39。039。) or (clrad=39。139。) then –清零信號(hào) clr 或請(qǐng)檔位信號(hào) clrad=’1’時(shí),清零 tq1=0000。 tq2=0000。 tq3=0000。 tq4=0000。 descend=39。039。 ascend=39。039。 異步清零 elsif(input_s39。event and input_s=39。139。) then if doorin=39。139。 then—門(mén)控信號(hào)為高電平則計(jì)數(shù)開(kāi)始 if tq1=1001 then tq1=0000。 if tq2=1001 then tq2=0000。 if tq3=1001 then tq3=0000。低位 =9 則進(jìn)位到高位 if tq4=1001 then tq4=1111。 ascend=39。139。若 9999則升檔信號(hào) =’1’, tq 置為 ”1111”防止以后檢測(cè)為降檔 else t