;
文章:行业新闻EDA文摘电源技术无线通信测量仪表嵌入式类电子技术制造技术半导体网络/协议展会实验家电维修  
  下载:EDA教程电源技术电子书籍电子元件无线通信通信网络电路图纸嵌入式类单片机传感/控制电子教材模拟数字
.... 音视频类
消费电子机械电子行业软件C/C++FPGA/ASIC规则标准家电维修DSPIC资料ARM软件电路图电子技术论坛
 
位置:电子发烧友 > 行业新闻 > 嵌入式类 > FPGA/ASIC技术 >出租车计价器VHDL程序与仿真 退出登录 用户管理
栏目导航


· 单片机类 · 接口/总线/驱动
· ARM · DSP
· FPGA/ASIC技术 · 设计应用
· 嵌入式操作系统 · 电视卡
热门文章
· [组图] 电子元器件基础知识...
· [图文] USB接口定义
· [图文] 三极管开关电路图
· [组图] RS232 RS485接口原理...
· [组图] [组图]电动车充电器...
· [组图] 电子捕鱼器电路图
· [组图] 高品质音调电路的制...
· [组图] JRC4558电路
· [图文] M51134P低音炮电路图...
· [图文] TL494脉宽调制控制电...
相关文章

· LED控制VHDL程序与仿...
· LCD控制VHDL程序与仿...
· [图文] 出租车计价器VHDL程...
· 步进电机定位控制系...
· 多功能波形发生器VH...
· [组图] 使用LeonardoSpectr...
· [组图] 基于μPD78F0034单片...

出租车计价器VHDL程序与仿真
作者:本站  来源:www.elecfans.com  发布时间:2008-6-27 10:49:29 减小字体 增大字体

出租车计价器VHDL程序与仿真

--文件名:taxi.hd。
--功能:出租车计价器。
--最后修改日期:2004.4.9。
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); --费用数据
       km1,km0:out std_logic_vector(3 downto 0);          --公里数据           
       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;                         --秒计数器
signal c3,c2,c1,c0:std_logic_vector(3 downto 0);          --制费用计数器
signal k1,k0:std_logic_vector(3 downto 0);               --公里计数器
signal m1:std_logic_vector(2 downto 0);                 --分的十位计数器
signal m0:std_logic_vector(3 downto 0);                 --分的个位计数器
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';          --此IF语句得到频率为15Hz的信号
        else q_15<=q_15+1;f_15<='0';
        end if;
        if q_16=14 then q_16<=0;f_16<='1';          --此IF语句得到频率为16Hz的信号
        else q_16<=q_16+1;f_16<='0';
        end if;
        if q_1=239 then q_1<=0;f_1<='1';            --此IF语句得到频率为1Hz的信号
        else q_1<=q_1+1;f_1<='0';
        end if;
        if en1='1' then f<=f_15;                    --此IF语句得到计费脉冲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语句完成等待计时
           if m0="1001" then m0<="0000";                --此IF语句完成分计数
              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';             --此IF语句得到en1使能信号
           else en1<='0';
           end if;
        else w<=w+1;en1<='0';
        end if;
     elsif fin='1' then
        if k0="1001" then k0<="0000";                    --此IF语句完成公里脉冲计数
           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';               --此IF语句得到en0使能信号
        else en0<='0';
        end if;       
     else en1<='0';en0<='0';
     end if;
cha3<=c3;cha2<=c2;cha1<=c1;cha0<=c0;                   --费用数据输出
km1<=k1;km0<=k0;min1<='0'&m1;min0<=m0;              --公里数据、分钟数据输出
  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";                       --此IF语句完成对费用的计数
        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;  


程序仿真图


 
注:1. 仿真图中秒跟分的关系为3进制,即w为2时就归0;
    2. 出租车总行驶5公里,等待累计时间为4分钟,总费用为16.2元。
出租计价器程序仿真全图
 
出租计价器程序仿真图-1
 
注:行驶公里数为4时,f得到16个计价脉冲数,计价器加16。既等效于加1.6元。
出租计价器程序仿真图-2 
 
注:等待累计时间为3分钟时,f得到15个计价脉冲。计价器的数值增加15。即等效于加1.5元。
出租计价器程序仿真图-3

[] [返回上一页] [打 印] [收 藏]
 
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
 
关于本站- 意见反馈 - 网站导航 - 帮助 - 隐私政策 - 联系我们 - 使用条款 - 安全承诺 - 友情连接
站长QQ:39550527 Powered by: 飓风网络(电路图
Copyright 2006-2008 Elecfans.Com.电子发烧友: 粤ICP备07065979号All Rights Reserved