【文章內(nèi)容簡介】
end process。 出租車計費器的設(shè)計 第 16 頁 共 50 頁 process(Clk1hz) begin if(Clk1hz39。event and Clk1hz=39。139。) then count=count+1。 if count6 then ena1=39。139。load1=39。039。clr1=39。039。 elsif count=6 then load1=39。139。ena1=39。039。clr1=39。039。 elsif count=7 then ena1=39。039。load1=39。039。clr1=39。139。 end if。 end if。 end process。 PROCESS(CLK,ENA1) IS BEGIN IF CLR1= 39。139。 THEN CQ1= 0000。 elsif(Motor39。event and Motor=39。139。) then IF ENA1= 39。139。 THEN if(CQ1=1001) then CQ1=0000。 if(CQ2=9) then CQ2=0000。 if(CQ3=1001) then CQ3=0000。 if(CQ4=1001) then CQ4=0000。 else CQ4=CQ4+1。 end if。 出租車計費器的設(shè)計 第 17 頁 共 50 頁 else CQ3=CQ3+1。 end if。 else CQ2=CQ2+1。 end if。 else CQ1=CQ1+1。 end if。 end if。 END IF 。 CQA=(CQ4amp。CQ3amp。CQ2amp。CQ1)。 end process。 PROCESS ( LOAD1,CQA) IS BEGIN IF LOAD1 39。EVENT AND LOAD1= 39。139。 THEN DOUT=CQA。 END IF。 END PROCESS。 process (clk) begin IN3=DOUT(15 DOWNTO 12)。 IN2=DOUT(11 DOWNTO 8)。 IN1=DOUT(7 DOWNTO 4)。 IN0=DOUT(3 DOWNTO 0)。 if (clk39。event and clk=39。139。)then if (s=111) then s=000。 else s=s+1。 出租車計費器的設(shè)計 第 18 頁 共 50 頁 end if。 end if。 sel=s。 end process。 process (s) begin case s is when 000=lout4=1111。 when 001=lout4=1111。 when 010=lout4=in2。 when 011=lout4=in1。 when 100=lout4=in0。 when 101=lout4=0000。 when 110=lout4=1111。 when 111=lout4=1111。 when others=lout4=XXXX。 end case。 case lout4 is when 0000=lout7=0111111。 when 0001=lout7=0000110。 when 0010=lout7=1011011。 when 0011=lout7=1001111。 when 0100=lout7=1100110。 when 0101=lout7=1101101。 when 0110=lout7=1111101。 when 0111=lout7=0000111。 when 1000=lout7=1111111。 when 1001=lout7=1100111。 when 1010=lout7=0111111。 出租車計費器的設(shè)計 第 19 頁 共 50 頁 when 1111=lout7=1000000。 when others=lout7=XXXXXXX。 end case。 end process。 end one。 報警模塊 報警模塊 輸入端由 Clk 構(gòu)成,其主要用途在于為蜂嗚器提供不同頻率,其輸出端由 spk 端構(gòu)成,其是一個蜂鳴器用于報警。 圖 蜂鳴器模塊 其仿真圖如下: 圖 蜂鳴器模塊仿真圖 其程序如下: library ieee。 use 。 use 。 use 。 entity teltcl is port( Clk : in std_logic。 spk : buffer std_logic)。 end teltcl。 architecture one of teltcl is signal tone : std_logic_vector(10 downto 0)。 Clk spkteltclinst 出租車計費器的設(shè)計 第 20 頁 共 50 頁 signal tone_count : std_logic_vector(10 downto 0)。 signal tone_index : integer range 0 to 15。 signal clk10_count : std_logic_vector(17 downto 0)。 signal time : integer range 0 to 150。 signal clk10 : std_logic。 begin process(clk) generate 10hz clock signal begin if(clk39。event and clk=39。139。) then clk10_count=clk10_count+1。 if(clk10_count=163fff) then clk10=not clk10。 end if。 END IF 。 end process。 process(clk10) begin if(clk1039。event and clk10=39。139。) then if(time=150) then time=0。 else time=time+1。 end if。 end if。 end process。 process(clk10) begin if(clk1039。event and clk10=39。139。) then case time is 出租車計費器的設(shè)計 第 21 頁 共 50 頁 when 0=tone_index=3。 when 1=tone_index=3。 when 2=tone_index=3。 when 3=tone_index=3。 when 4=tone_index=5。 when 5=tone_index=5。 when 6=tone_index=5。 when 7=tone_index=6。 when 8=tone_index=8。 when 9=tone_index=8。 when 10=tone_index=8。 when 11=tone_index=9。 when 12=tone_index=6。 when 13=tone_index=8。 when 14=tone_index=5。 when 15=tone_index=5。 when 16=tone_index=12。 when 17=tone_index=12。 when 18=tone_index=12。 when 19=tone_index=15。 when 20=tone_index=13。 when 21=tone_index=12。 when 22=tone_index=10。 when 23=tone_index=12。 when 24=tone_index=9。 when 25=tone_index=9。 when 26=tone_index=9。 when 27=tone_index=9。 when 28=tone_index=9。 出租車計費器的設(shè)計 第 22 頁 共 50 頁 when 29=tone_index=9。 when 30=tone_index=0。 when 31=tone_index=0。 when 32=tone_index=9。 when 33=tone_index=9。 when 34=tone_index=9。 when 35=tone_index=10。 when 36=tone_index=7。 when 37=tone_index=7。 when 38=tone_index=6。 when 39=tone_index=6。 when 40=tone_index=5。 when 41=tone_index=5。 when 42=tone_index=5。 when 43=tone_index=6。 when 44=tone_index=8。 when 45=tone_index=8。 when 46=tone_index=9。 when 47=tone_index=9。 when 48=tone_index=3。 when 49=tone_index=3。 when 50=tone_i