VHDL关于出租车计费器设计的一段程序,望高手解释一下!小弟初学者,谢谢!!

如题,请高手赐教!
其输入端口用START ,STOP ,PAUSE ,J S 模拟
汽车起动、停止、暂停、加速4 种运动状态,为低电平有效。
该模块通过对传感器采集到的脉冲(CL K) 进行计数而计
算出出租车行驶过程的路程,并按计费规则计费
里程计费模块的部分程序如下:
process (clk ,start ,stop ,pause ,js)
variable a ,b : std logic ;
variable aa :integer range 0 to 100 ;
variable chf ,lc :integer range 0 to 8000 ;
variable num:integer range 0 to 9 ;
begin
if (clk′event and clk =′1′) then
if (stop =′0′) then
chf : = 0 ;
num: = 0 ;
b : =′1′;
aa : = 0 ;
lc : = 0 ;
elsif ( start =′0′) then
b : =′0′;
chf : = 700 ;
lc : = 0 ;
elsif ( start =′1′and js =′1′and pause =′1′) then
if (b =′0′) then
num: = num + 1 ;
end if ;
if (num = 9) then
lc : = lc + 5 ;
num: = 0 ;
aa : = aa + 5 ;
end if ;
elsif ( start =′1′and js =′0′and pause =′1′) then
lc : = lc + 1 ;
aa : = aa + 1 ;
end if ;
if (aa > = 100) then
a : =′1′;
aa : = 0 ;
else
a : =′0′;
end if ;
if (lc < 300) then
null ;
elsif (chf < 2000 and a =′1′) then
chf : = chf + 220 ;
elsif (chf > = 2000 and a =′1′) then
chf : = chf + 330 ;
end if ;
end if ;
chefei < = chf ;
luc < = lc ;
end process ;

process (clk ,start ,stop ,pause ,js)
variable a ,b : std logic ;
variable aa :integer range 0 to 100 ;
variable chf ,lc :integer range 0 to 8000 ;
variable num:integer range 0 to 9 ;
begin
if clk′event and clk =‘1’ then
if stop =‘0’ then
chf : = 0 ;
num: = 0 ;
b : =‘1’;
aa : = 0 ;
lc : = 0 ;
elsif start =′0′ then
b : =′0′;
chf : = 700 ;
lc : = 0 ;
elsif start =′1′and js =′1′and pause =′1′ then
if b =′0′)then
num: = num + 1 ;
end if ;
if num = 9)then
lc : = lc + 5 ;
num: = 0 ;
aa : = aa + 5 ;
end if ;
elsif start =′1′and js =′0′and pause =′1′then
lc : = lc + 1 ;
aa : = aa + 1 ;
end if ;
if aa > = 100 then
a : =′1′;
aa : = 0 ;
else
a : =′0′;
end if ;
if lc < 300 then
null ;
elsif chf < 2000 and a =′1′ then
chf : = chf + 220 ;
elsif chf > = 2000 and a =′1′ then
chf : = chf + 330 ;
end if ;
end if ;
chefei < = chf ;
luc < = lc ;
end process ;
把if后的括号都去了,不需要的,你再试试,如果不行再联系。
温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜