日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > EDA > 電子設(shè)計自動化
[導(dǎo)讀]程序設(shè)計與仿真。 1. 出租車計價器VHDL程序 --文件名:taxi.hd --功能:出租車計價器 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; enti

程序設(shè)計與仿真。
1. 出租車計價器VHDL程序
--文件名:taxi.hd
--功能:出租車計價器
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity taxi is
port ( clk_240  :in std_logic;                           --頻率為240Hz的時鐘                        
       start :in std_logic;                               --計價使能信號
       stop:in std_logic;                                --等待信號
       fin:in std_logic;                                 --公里脈沖信號
       cha3,cha2,cha1,cha0:out std_logic_vector(3 downto 0); --費用數(shù)據(jù)
       km1,km0:out std_logic_vector(3 downto 0);          --公里數(shù)據(jù)           
       min1,min0: out std_logic_vector(3 downto 0));       --等待時間  
end taxi;
architecture behav of taxi is
signal f_15,f_16,f_1:std_logic;                       --頻率為15Hz,16Hz,1Hz的信號
signal q_15:integer range 0 to 15;                     --分頻器
signal q_16:integer range 0 to 14;                     --分頻器
signal q_1:integer range 0 to 239;                     --分頻器
signal w:integer range 0 to 59;                        --秒計數(shù)器
signal c3,c2,c1,c0:std_logic_vector(3 downto 0);         --制費用計數(shù)器
signal k1,k0:std_logic_vector(3 downto 0);              --公里計數(shù)器
signal m1:std_logic_vector(2 downto 0);                --分的十位計數(shù)器
signal m0:std_logic_vector(3 downto 0);                --分的個位計數(shù)器
signal en1,en0,f:std_logic;                            --使能信號
begin
feipin:process(clk_240,start)
begin
  if clk_240'event and clk_240='1' then
    if start='0' then q_15<=0;q_16<=0;f_15<='0';f_16<='0';f_1<='0';f<='0';
    else
      if q_15=15 then q_15<=0;f_15<='1';          --此語句得到頻率為15Hz的信號
      else q_15<=q_15+1;f_15<='0';
      end if;
      if q_16=14 then q_16<=0;f_16<='1';          --此語句得到頻率為16Hz的信號
      else q_16<=q_16+1;f_16<='0';
      end if;
      if q_1=239 then q_1<=0;f_1<='1';            --此語句得到頻率為1Hz的信號
      else q_1<=q_1+1;f_1<='0';
      end if;
      if en1='1' then f<=f_15;                    --此語句得到計費脈沖f
      elsif en0='1' then f<=f_16;
      else f<='0';
      end if;
    end if;
  end if;
end process;
process(f_1)
begin
  if f_1'event and f_1='1' then
    if start='0' then
w<=0;en1<='0';en0<='0';m1<="000";m0<="0000";k1<="0000";k0<="0000";
    elsif stop='1' then
      if w=59 then w<=0;                             --此語句完成等待計時
        if m0="1001" then m0<="0000";                --此語句完成分計數(shù)
          if m1<="101" then m1<="000";
          else m1<=m1+1;
          end if;
        else m0<=m0+1;
        end if;
        if m1&m0>"0000001"then en1<='1';             --此語句得到en1使能信號
        else en1<='0';
        end if;
      else w<=w+1;en1<='0';
      end if;
    elsif fin='1' then
      if k0="1001" then k0<="0000";                    --此語句完成公里脈沖計數(shù)
        if k1="1001" then k1<="0000";
        else k1<=k1+1;
        end if;
      else k0<=k0+1;
      end if;
      if k1&k0>"00000010" then en0<='1';               --此語句得到en0使能信號
      else en0<='0';
      end if;       
    else en1<='0';en0<='0';
    end if;
cha3<=c3;cha2<=c2;cha1<=c1;cha0<=c0;                   --費用數(shù)據(jù)輸出
km1<=k1;km0<=k0;min1<='0'&m1;min0<=m0;              --公里數(shù)據(jù)、分鐘數(shù)據(jù)輸出
  end if;
end process;
process(f,start)
begin
  if start='0' then c3<="0000";c2<="0001";c1<="0000";c0<="0000";
  elsif f'event and f='1' then
    if c0="1001" then c0<="0000";                       --此語句完成對費用的計數(shù)
      if c1="1001" then c1<="0000";
        if c2="1001" then c2<="0000";
          if c3<="1001" then c3<="0000";
          else c3<=c3+1;
          end if;
        else c2<=c2+1;
        end if;
      else c1<=c1+1;
      end if;
    else c0<=c0+1;
    end if;
  end if;
end process;
end behav;  

2. 程序仿真圖

注:1. 仿真圖中秒跟分的關(guān)系為3進(jìn)制,即w為2時就歸0;

2. 出租車總行駛5公里,等待累計時間為4分鐘,總費用為16.2元。


圖8.22.3 出租計價器程序仿真全圖
 

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉