vhdl语言翻译

来源:百度知道 编辑:UC知道 时间:2024/06/25 01:49:20
大家帮我看看这段程序,我关键不知道里面定义了的a和b是什么意思

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity jifei is
port ( clk,start,stop,pause,js :in std_logic;
chefei,luc : out integer range 0 to 8000);
end jifei;
architecture rtl of jifei is
begin
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(sta

计费是这样的:
初始车费7.00元,可以走3.00公里;
3.00公里以外:
当车费小于20.00元时,一公里2.20元;
当车费大于20.00元时,一公里3.30元。

a的功能是每当aa计数到100时,输出一个时钟周期的a=1信号,表示到了整一公里。
然后最后一个if语句:路程(lc)<3.00公里时,无动作;否则来一个a=1信号,即到了整一公里,且车费(chf)<20时,车费一公里加2.20元;车费>=20时,车费一公里加3.30元。

b是为了让stop、start、js的控制能够有正确的顺序。
若js=1,则只有按了stop后,又让start=0,使车费初始化为7.00元,使b=0,然后再start=1开始计费,10个时钟周期增加5。
而js=0就只是在计数,可能做测试用,或者表示“奸商”,让路程和车费加速增加,1个时钟周期增加1。

呵呵,最佳答案在此,这回没问题了吧?