当前位置:编程学习 > JS >>

VHDL程序不理解

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 rt1 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(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;
end rt1;
其中进程里面的变量赋值是什么意思?

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;

题目是这样的(1) 计费器按行使里程计费,起步价为7.00 元,行驶
里程不满3 km ,按7.00 元计算。
(2) 在车行3 km 后按2.20 元/ km 计费,当计费器达
到或超过20 元时, 每公里加收50 %的车费, 车停止不
计费。

请高手帮忙解释下,如果可以的话QQ聊,谢谢啦O(∩_∩)O~

追问:那为什么aa的赋值范围是0-100,num的赋值范围是0-9呢?这有什么意义呢?能不能加QQ聊下?谢谢咯O(∩_∩)O~
答案: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;

这个仅仅是定义进程里面要用到的变量而已。

在进程里,变量与信号的赋值时刻不一样。

变量赋值呀

上一个:java开发问题
下一个:一个关于VFP程序的问题?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,