出租车计费器.doc

上传人:土8路 文档编号:9979555 上传时间:2021-04-08 格式:DOC 页数:10 大小:128.50KB
返回 下载 相关 举报
出租车计费器.doc_第1页
第1页 / 共10页
出租车计费器.doc_第2页
第2页 / 共10页
出租车计费器.doc_第3页
第3页 / 共10页
出租车计费器.doc_第4页
第4页 / 共10页
出租车计费器.doc_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《出租车计费器.doc》由会员分享,可在线阅读,更多相关《出租车计费器.doc(10页珍藏版)》请在三一文库上搜索。

1、上海电力学院课程设计报告课程设计名称: FPGA设计实践课程 设计课题名称: 出租车计费器 班级: 2008141 指导老师: 赵倩 姓名: 丁晓亮 学号: 20082614 成绩: 设计时间: 2011-6-277-1 设计地点: 知行楼 303 实验室 计算机信息与工程学院出租车计费器报告一、 设计目的:熟练使用Altera QuartusII 仿真软件。掌握VHDL硬件描述语言进行硬件编程。理解FPGA技术的层次化设计方法。二、 实验器材和工具软件:FPGA开发版,Quartus II软件三、 设计内容: l. 能实现计费功能, 计费标准为:按行驶里程收费, 起步费为7.00元, 并在车

2、行3公里后再按2.2元/公里, 当计费器计费达到或超过一定收费(如20元)时, 每公里加收50%的车费,车停止不计费。2. 实现预置功能:能预置起步费、每公里收费、车行加费里程。3. 实现模拟功能:能模拟汽车启动、停止、暂停、车速等状态。4. 设计动态扫描电路:将车费显示出来, 有两位小数。5. 用VHDL语言设计符合上述功能要求的出租车计费器, 并用层次化设计方法设计该电路。6. 各计数器的计数状态用功能仿真的方法验证, 并通过有关波形确认电路设计是否正确。7. 完成电路全部设计后, 通过系统实验箱下载验证设计课题的正确性。四、 设计具体步骤:顶层原理图:工作原理:由工作板上的时钟脉冲通过分

3、频器控制计费模块产生路费和路程的二进制数且最多都为十三位,输入转换模块使路程和路费转换成四个四位输出, 继而通过LED转换模块转换成LED代码,最终在LED显示出来。计费模块原理图:VHDL语言:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;-written by DingXiaoLiang on 2011.6.27;2011.7.1USE IEEE.STD_LOGIC_UNSIGNED.ALL;USE IEEE.numeric_std.ALL;entity chuzuche is port(luf3,luf2,luf1,luf0,luc3,luc2,luc

4、1,luc0:buffer std_logic_vector(3 downto 0); clk,start,stop,pause:in std_logic);end chuzuche;architecture behav_chuzuche of chuzuche isbeginprocess(clk,stop,start,pause)variable c1,c2:std_logic;beginif (clk Event and clk=1) then if (stop=0) then luf3=0000; luf2=0000; luf1=0000;luf0=0000; luc3=0000; l

5、uc2=0000; luc1=0000;luc0=0000; elsif (start=0 and pause=1) then luf3=0000; luf2=0111; luf1=0000;luf0=0000; luc3=0000; luc2=0000; luc1=0000;luc0=0000; elsif (start=1 and pause=1) then luc0=luc0+0001; end if;if luc0=1001 then luc0=0000; luc1=luc1+0001;end if;if luc1=1001 then luc1=0000; luc2=luc2+0001

6、;end if;if luc2=1001 then luc2=0000; luc3=luc3+0001;end if;if luc3=1001 then luc3=0011 or luc2=0001) then -路程超过30 (3000M) if (luf30010) then -路费低于20元if (luf1=1000 and luf0=0110) then luf0=luf0+0010; luf1=0000;c1:=1;elsif(luf1=1000 and luf0=1000) then luf0=0000;luf1=0001;c1:=1; elsif(luf1=0111 and lu

7、f0=1000) then luf0=0000;luf1=0000;c1:=1;elsif(luf1=1001 and luf0=0110) then luf0=luf0+0010;luf1=0001;c1:=1;elsif(luf1=1001 and luf0=1000) then luf0=0000;luf1=0010;c1:=1;elsif(luf10111 and luf0=1000) then luf0=0000;luf1=luf1+0011;c1:=0;else luf0=luf0+0010;luf1=luf1+0010;c1:=0; end if; else -路费大于20元if

8、 (luf0=0110 and luf1=0111) then luf0=luf0+0011;luf1=0000;c1:=1;elsif(luf0=0110 and luf1=1000) then luf0=luf0+0011;luf1=0001;c1:=1;elsif(luf0=0110 and luf1=1001) then luf0=luf0+0011;luf1=0010;c1:=1;elsif(luf0=0111 and luf1=0101) then luf0=0000 ; luf1=luf1+0100;c1:=0;elsif(luf0=0111 and luf1=0110) the

9、n luf0=0000 ;luf1=0000;c1:=1;elsif(luf0=0111 and luf1=0111) then luf0=0000 ;luf1=0001;c1:=1;elsif(luf0=0111 and luf1=1000) then luf0=0000 ; luf1=0010;c1:=1;elsif(luf0=0111 and luf1=1001) then luf0=0000 ; luf1=0011;c1:=1;elsif(luf0=1000 and luf1=0101) then luf0=0001 ; luf1=luf1+0100;c1:=0;elsif(luf0=

10、1000 and luf1=0110) then luf0=0001 ; luf1=0000;c1:=1;elsif(luf0=1000 and luf1=0111) then luf0=0001 ;luf1=0001;c1:=1;elsif(luf0=1000 and luf1=1000) then luf0=0001 ; luf1=0010;c1:=1;elsif(luf0=1000 and luf1=1001) then luf0=0001 ;luf1=0011;c1:=1;elsif(luf0=1001 and luf1=0101) then luf0=0010 ; luf1=luf1

11、+0100;c1:=0;elsif(luf0=1001 and luf1=0110) then luf0=0010; luf1=0000;c1:=1;elsif(luf0=1001 and luf1=0111) then luf0=0010 ; luf1=0001;c1:=1;elsif(luf0=1001 and luf1=1000) then luf0=0010 ; luf1=0010;c1:=1;elsif(luf0=1001 and luf1=1001) then luf0=0010 ; luf1=0011;c1:=1;else luf0=luf0+0011;luf1=luf1+001

12、1;c1:=0;end if; end if;if(luf2=1001 and c1=1) then luf2=0000;c2:=1;elsif(luf2=1000 and c1=1) then luf2=luf2+0001;c2:=0; end if;if(luf3=1001 and c2=1) then luf3=0000;c2:=0;elsif(luf3=1000 and c2=1) then luf3=luf3+0001;c2:=0;end if;end if;end if;end if;end process;end behav_chuzuche;工作原理:由时钟脉冲作用,且各个控制

13、端都为低电平有效,开始起作用,停止,暂停,加速都不起作用时,开始普通的路程累加,路费的预置为7.00元,摁下停止键时,计费与路程全部清零,暂停键时使路程数与路费计数保持,用两个不同频率的时钟脉冲的选择确定车行的速度。当路程累加到3.00公里即3000M时,开始加法计费,每经过0.1公里路费累加0.22元,当车费超过20.00元时按每0.1公里0.33元的费用累加。通过四个二进制输出动态显示车费与路程情况。二选一频率(车速选择)模块:VHDL语言:library ieee;use ieee.std_logic_1164.all; entity xuan1 isport(a,b,c :in std

14、_logic; y:out std_logic);end xuan1;architecture behave_xuan1 of xuan1 is beginwith c selecty=a when 0, b when others;end behave_xuan1;工作原理:当c端所接的为低电平时选择a所对应分频器的输出频率,当c端所接的为高电平时选择b所对应分频器的输出频率。分频模块: VHDL语言:分频器1:library ieee;use ieee.std_logic_1164.all; entity fenpin isport( clkin :in std_logic; clkout

15、:out std_logic);end fenpin; architecture behave_fenpin of fenpin is constant N: Integer:=24999999;signal Counter:Integer RANGE 0 TO N;signal Clk: Std_Logic;begin process(clkin) begin if rising_edge(clkin) then if Counter=N then Counter=0; Clk=NOT Clk; else Counter= Counter+1; end if; end if; end pro

16、cess; clkout= Clk;end behave_fenpin;分频器2:library ieee;use ieee.std_logic_1164.all; entity fenpin2 isport( clkin :in std_logic; clkout:out std_logic);end fenpin2; architecture behave_fenpin2 of fenpin2 is constant N: Integer:=12499999;signal Counter:Integer RANGE 0 TO N;signal Clk: Std_Logic;begin pr

17、ocess(clkin) begin if rising_edge(clkin) then if Counter=N then Counter=0; Clk=NOT Clk; else Counter= Counter+1; end if; end if; end process; clkout= Clk;end behave_fenpin2;工作原理:通过选择不同频率的分频器来实现不同的车速。数码管显示模块:VHDL语言:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;entity xianshi isport(shuru:in std_logic_vect

18、or(3 downto 0); shuchu:out std_logic_vector(6 downto 0);end xianshi;architecture behav_xianshi of xianshi isbegin with shuru selectshuchu=1000000 when 0000,-0 1111001 when 0001,-1 0100100 when 0010,-2 0110000 when 0011,-3 0011001 when 0100,-4 0010010 when 0101,-5 0000010 when 0110,-6 1111000 when 01

19、11,-7 0000000 when 1000,-8 0010000 when 1001,-9 1111111 when others;end behav_xianshi;工作原理:将输入的四位二进制数转显示编码显示,共使用八个数码管,通过引脚分配接到数码管上予以显示。仿真波形:五、 设计收获以及存在的问题:在实验中,我收获了许多。通过一个学期的学习我对FPGA有了进一步的认识,但是通过本次实验,我将以前所学的各个知识点进行了联系,对于原本课程实验中的一些模块进行了整合,完成了这次的实验。我们这次实验用到了分频器、数据选择器、显示模块。在运用VHDL语言进行编译的过程中,使我更加的熟悉了这种语

20、言。当然,实验中还是会有一定的问题,我对VHDL的语言掌握得还不够熟练,还不能很好的进行编译,有时还会遇到不知道该用什么语句来进行编写。比如“不等于”我开始时不知道该怎样编写,通过查书本知道了是要使用“=”。我相信通过这次的实践课程,我会更好的掌握VHDL语言。六、心得体会本次实验中,我们学习了熟练使用Altera QuartusII 仿真软件、掌握VHDL硬件描述语言进行硬件编程、理解FPGA技术的层次化设计方法。实验过程中,我先对整个系统进行了划分,将它划分成一个个模块,对各个模块进行编程,再进行运行,并生成各个电路模块,在将他们连接在一起,这样就可以实现电路的功能了。出租车计费器是我们日常生活中经常能够见到的,比较贴近生活实际,所以在编程过程中比较能够了解它的原理,使编程可以变得比较简单。但是计费模块的编程是我花了很长时间才完成的,由于需要分成20元以下和20元以上,这就使我需要分开来编程,在考虑进位时,我还需要将各个情况罗列出来,并且将他们用if语句来完成编译。这是需要将各个情况都考虑进来,并且将他们进行分类,这需要我的细心和耐心。通过这次的实验,我慢慢的掌握了VHDL硬件描述语言进行硬件编程,对于Altera QuartusII 仿真软件使用也越来越得心应手了。对于今后的实验我相信也是有很大帮助的。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1