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