DIY编程器网

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 81|回复: 0
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
楼主
发表于 2011-4-26 09:40:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
出租车计价器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,cha0ut std_logic_vector(3 downto 0); --费用数据
km1,km0ut 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"0000001"then en1"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;

程序仿真图



注:等待累计时间为3分钟时,f得到15个计价脉冲。计价器的数值增加15。即等效于加1.5元。
出租计价器程序仿真图-3
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 分享分享 支持支持 反对反对
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|文字版|手机版|DIY编程器网 ( 桂ICP备14005565号-1 )

GMT+8, 2025-8-15 22:58 , 耗时 0.087037 秒, 18 个查询请求 , Gzip 开启.

各位嘉宾言论仅代表个人观点,非属DIY编程器网立场。

桂公网安备 45031202000115号

DIY编程器群(超员):41210778 DIY编程器

DIY编程器群1(满员):3044634 DIY编程器1

diy编程器群2:551025008 diy编程器群2

QQ:28000622;Email:libyoufer@sina.com

本站由桂林市临桂区技兴电子商务经营部独家赞助。旨在技术交流,请自觉遵守国家法律法规,一旦发现将做封号删号处理。

快速回复 返回顶部 返回列表