怎么成为艺术生:关于vhdl程序,高分求解释,要详细的说明

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 11:11:27
输入端口START,STOP,PAUSE,JS分别为汽车启动,停止,暂停,加速按键。
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;
模块X见图13-3。

图13-3 模块X
该模块把车费和路程转化为四位十进制数,daclk的频率要比clk快的多。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity x is
port(daclk:in std_logic;
ascore,bscore:in integer range 0 to 8000;
age,ashi,abai,aqian,bge,bshi,bbai,bqian:out std_logic_vector(3 downto 0));
end x;
architecture rt1 of x is
begin
process(daclk,ascore)
variable comb1:integer range 0 to 8000;
variable comb1a,comb1b,comb1c,comb1d:std_logic_vector(3 downto 0);
begin
if(daclk'event and daclk='1')then
if(comb1<ascore)then
if(comb1a=9 and comb1b=9 and comb1c=9)then
comb1a:="0000";
comb1b:="0000";
comb1c:="0000";
comb1d:=comb1d+1;
comb1:=comb1+1;
elsif(comb1a=9 and comb1b=9)then
comb1a:="0000";
comb1b:="0000";
comb1:=comb1+1;
comb1c:=comb1c+1;
elsif(comb1a=9)then
comb1a:="0000";
comb1b:=comb1b+1;
comb1:=comb1+1;
else
comb1a:=comb1a+1;
comb1:=comb1+1;
end if;
else
ashi<=comb1b;
age<=comb1a;
abai<=comb1c;
aqian<=comb1d;
comb1:=0;
comb1a:="0000";
comb1b:="0000";
comb1c:="0000";
comb1d:="0000";
end if;
end if;
end process;
process(daclk,bscore)
variable comb2:integer range 0 to 8000;
variable comb2a,comb2b,comb2c,comb2d:std_logic_vector(3 downto 0);
begin
if(daclk'event and daclk='1')then
if(comb2<bscore)then
if(comb2a=9 and comb2b=9 and comb2c=9)then
comb2a:="0000";
comb2b:="0000";
comb2c:="0000";
comb2d:=comb2d+1;
comb2:=comb2+1;
elsif(comb2a=9 and comb2b=9)then
comb2a:="0000";
comb2b:="0000";
comb2:=comb2+1;
comb2c:=comb2c+1;
elsif(comb2a=9)then
comb2a:="0000";
comb2b:=comb2b+1;
comb2:=comb2+1;
else
comb2a:=comb2a+1;
comb2:=comb2+1;
end if;
else
bshi<=comb2b;
bge<=comb2a;
bbai<=comb2c;
bqian<=comb2d;
comb2:=0;
comb2a:="0000";
comb2b:="0000";
comb2c:="0000";
comb2d:="0000";
end if;
end if;
end process;
end rt1;

这么专业的东西我不太会,虽然我过去也学过

建议你到比较专业一点的BBS走走

比如“程序员之家”等等

(这里的人多数都是复制答案的。。。)