📄 taxi.txt
字号:
五 结束语
通过对系统的测试结果分析符合预期结果,满足题目要求。基于FPGA所设计的多功能计程车计价器趋于简单、开发时间短;整个控制系统的所需元器件少、集成度较高、所占的空间小且可靠性也很高。不仅仅实现了计程车计费的功能,其多功能表现在它可以通过选择键来选择显示计程车累计走的总路程和乘客乘载的时间。应用于实际当中,比较有实用价值,可行性也较高,是个不错的创意。此外,如果实现软、硬件的相互结合还可以实现很多功能比如可以
集成计算机网络、IC卡、语音报价、自动打印等新技术实现运营数据存储管理和税费计算控制。实现计价器的计费显示、自动打印发票、语音报价等功能一体化,有待进一步扩展。
参考文献
[1] 高书莉、罗朝霞. 《可编程逻辑设计技术及应用》[M].北京:人民邮电出版社,2001年(第一版)。
[2] 黄正谨、徐坚、章小丽等. 《CPLD系统设计技术入门与应用》[M].北京:电子工业出版社,2002年(第一版)。
[3] 潘松、黄继业. 《EDA技术实用教程》[M].北京:科学出版社,2002年(第一版)。
[4] 赵俊超 《集成电路设计VHDL教程》 [M] 北京:北京希望电子出版社 2002年8月 (第一版)
附录(程序) ---- 计程车计价器试验
----
*****************************************************************************************************
---- 功能:模拟实际计程车计价器功能 ----
---- 文件名: taxi.vhd
----
---- 设计者: 黄松
----
---- 说 明:
----
整个自动控制系统由四个模块构成:描分频模块、控制模块、计量模块和译码显示模块。不仅仅实现了计程车计价器的计价功能,还可以通过选择信号选择显示计程车的行程总时间和总路程。
---- 最后修改日期:2003年7月29日
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity taxi is
Port ( clk,st,clr,d_in,choose : in std_logic;
--st:计程车启动/等候;
--d_in:“里”输入;--choose:选择显示;
--clr:清零;
--L_x:译码显示;
L_1 : out std_logic_vector(6 downto 0);
L_2 : out std_logic_vector(6 downto 0);
L_3 : out std_logic_vector(6 downto 0);
L_4 : out std_logic_vector(6 downto 0) );
end taxi;
architecture Behavioral of taxi is
signal M_15,M_20,d_xx,sec,fen : std_logic;
--M_15、M_20分别表示1.5元和2元
--d_xx 表示超出基础的公里数
-- fen表示分钟位
signal L1,L2,L3,L4 : integer range 0 to 10;
signal Ll1,Ll2,Ll3,Ll4 : integer range 0 to 10;
signal Lll2,Lll3 : integer range 0 to 10;
signal Led1,Led2,Led3,Led4 :
integer range 0 to 10;
signal d : integer range 0 to 3000;
begin
*************************************
秒分频模块
----把系统提供的32MHz的频率分频为1Hz
*************************************
div_sec:process(clr,clk)
variable c : integer range 0 to 32000000;
begin
if clr='1' then c:=0;
elsif rising_edge(clk) then
if c<32000000 then c:=c+1;
else c:=1;
end if;
end if;
if c>16000000 then sec<='1';
else sec<='0';
end if;
end process;
*************************************
控制模块
----描述计价器整个工作过程,系统的核心。
*************************************
taxi_time:process(clr,sec,st)
variable c : integer range 0 to 180;
begin
if clr='1' or st='1'then c:=0;
elsif rising_edge(sec) then
if c<180 then c:=c+1;
else c:=121;
end if;
end if;
if c=120 then M_20<='1';M_15<='0';
elsif c=180 then M_20<='0';M_15<='1';
else M_20<='0';M_15<='0';
end if;
end process;
road:process(clr,d_in,sec,st)
variable c : integer range 0 to 7;
begin
if clr='1' then c:=0;
elsif rising_edge(sec) then
if st='1' then
if d_in='1' then
if c<8 then c:=c+1;
else c:=7;
end if;
end if;
end if;
end if;
if c=8 then d_xx<='1';
else d_xx<='0';
end if;
end process;
*************************************
计量模块
----计程车计价器系统多功能实现的保证。可以分为计价部分、计时部分和计程部分。
*************************************
--------------------------------------------------------
---- 计价 ----
--------------------------------------------------------
money:process(d_xx,M_15,M_20,clr,sec)
variable a,b,c : integer range 0 to 3000;
begin
if clr='1' then a:=0;b:=0;c:=0;
elsif rising_edge(sec) then
if d_xx='1' then a:=a+16;
elsif m_15='1' then b:=b+15;
elsif m_20='1' then c:=c+20;
end if;
end if;
d<=a+b+c+100; --10元起步费
end process;
money_led:process(clr,d,clk,sec)
-- 价格换算
variable c : integer range 0 to 9100;
variable i,t,j,k : integer range 0 to 10;
begin
if clr='1' then i:=0;t:=0;j:=0;k:=0;c:=0;
elsif rising_edge(clk) then
if sec='1' then c:=d;i:=0;t:=0;j:=0;k:=0;
elsif c>999 then c:=c-1000; i:=i+1;
--对百元计数
elsif c<=999 and c>99 then
c:=c-100; j:=j+1;
--对十元计数
elsif c<=99 and c>9 then c:=c-10; k:=k+1; --对元计数
else t:=c ; --对角计数
l1<=t ; l4<=I ; l3<=j ; l2<=k;
end if;
end if;
end process;
--------------------------------------------------------
---- 计时 ----
--------------------------------------------------------
ALL_time_m:process(clr,sec)
variable m,mm : integer range 0 to 10;
--mm表示秒计数的十位
-- m表示秒计数的个位
begin
if clr='1' then m:=0;mm:=0;
elsif rising_edge(sec) then
if mm<6 then
if m<9 then m:=m+1;
else m:=0;mm:=mm+1;
end if;
else mm:=0;
end if;
end if;
if mm=6 then mm:=0;m:=0;fen<='1';
else fen<='0';
end if;
Ll1<=m ; Ll2<=mm;
end process;
ALL_time_f:process(clr,fen)
variable f,ff : integer range 0 to 10;
begin
if clr='1' then f:=9;ff:=3;
elsif rising_edge(fen) then
if ff<6 then
if f<9 then f:=f+1;
else f:=0;ff:=ff+1;
end if;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -