数字电路(出租车计费器)_第1页
数字电路(出租车计费器)_第2页
数字电路(出租车计费器)_第3页
数字电路(出租车计费器)_第4页
数字电路(出租车计费器)_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、一、 课题要求(1) 技术要求1.掌握较复杂逻辑的设计、调试。2. 进一步掌握用VHDL语言设计数字逻辑电路。3.掌握用quartusII6.0软件进行编程设计。(2) 功能要求1.能实现计费功能,计费标准为:按行驶里程收费,起步费为7.00元,并在车行3公里后再按2.2元/公里,当计费器达到或超过一定收费(如20元)。每公里加收50%的车费,车停止不计费2 .实现预置功能、每公里收费、车行驶加费里程。3.实现模拟功能:能模拟汽车启动、停止、暂停、车速等状态。4. 设计动态扫描电路将车费显示出来。有两位小数。5. 用VHDL语言设计符合上述功能要求的出租车计费器。并用层次化设计方法设计该电路。

2、6 .各计数器的技术状态用功能的方法验证,并用有关波形确认电路设计是否正确7. 完成电路全部设计后,通过系统试验箱下载验证设计课题的正确性。二 本人工作:本人主要负责软件和硬件电路方面的设计,并进行引脚设定,以及与软硬件之间的调试运行,及时修改程序,帮助查找和分析问题,确保能够成功完成出租车计费器的设计。三 设计方案:3.1 主要中心组成显示模块FPGA按键模块 3.2 FPGA芯片内部主要程序:3.3 工作原理:基于CPLDFPGA的出租车计费器的组成如图1所示。各部分主要功能如下:(1)A计数器对车轮传感器送来的脉冲信号进行计数(每转一圈送一个脉冲)。不同车型的车轮直径可能不一样,通过“设

3、置1”对车型做出选择,以实现对不同车轮直径的车进行调整。(2)B计数器对百米脉冲进行累加,并输出实际公里数的BCD码给译码动态扫描模块。每计满500送出一个脉冲给C计数器。“设置2”实现起步公里数预制。(3)C计数器实现步长可变(即单价可调)的累加计数,每500米计费一次。“设置3”用来完成超价加费、起步价预制等。(4)译码动态扫描将路程与费用的数值译码后用动态扫描的方式驱动数码管。(5)数码管显示将公里数和计费金额均用四位LED数码管显示(2位整数,2位小数)。3.4功能模块设计出租车计费器由车型调整模块、计程模块、计费模块、译码动态及扫描等模块组成,整个系统采用模块化设计,首先用VHDL编

4、写功能模块,然后用顶层原理图将各功能模块连接起来。四 单元模块设计:首先出租车计费器的设计需要分频,所以需要设计了两个频率:4.1 oneMHZ:由于给定的50MHZ太大,这个程序完成5000分频,实现第一次分频,确保实现动态计数,并且保证频率在驱动范围之内。library ieee;use ieee.std_logic_1164.all;entity oneMHZ is port( daclk:in std_logic; clkout:out std_logic); end oneMHZ;architecture one of oneMHZ issignal data:integer ran

5、ge 0 to 5000;signal Q:std_logic;beginprocess(daclk) begin if daclkevent and daclk=1 then if(data=5000) then data=0; Q=not Q; else data=data+1; end if; end if;clkout=Q;end process;end one;4.2 twoMHZ:这个程序完成2500分频,实现第二次分频,确保最后数码管显示频率在合适范围library ieee;use ieee.std_logic_1164.all;entity twoMHZ is port( d

6、aclk:in std_logic; clkout:out std_logic); end twoMHZ;architecture one of twoMHZ issignal data:integer range 0 to 2500;signal Q:std_logic;beginprocess(daclk) begin if daclkevent and daclk=1 then if(data=2500) then data=0; Q=not Q; else data=data+1; end if; end if;clkout=Q;end process;end one; 4.3 Cha

7、rge:实现计费功能,按行驶里程收费,起步费为7.00元,并在车行3公里后再按2.2元/公里,当计费器达到或超过一定收费(如20元)。每公里加收50%的车费,车停止不计费,实现预置功能、每公里收费、车行驶加费里程,实现模拟功能,能模拟汽车启动、停止、暂停、车速等状态,将车费显示出来。有两位小数。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity charge is port( cp,ks,tz,zt: in std_logic; dis,mon : out integer range 0

8、 to 9999);end charge;architecture ch of charge isbegin process(cp,ks,tz,zt) variable dis1,mon1:integer range 0 to 9999; begin if(cpevent and cp=1) then if(tz=0)then dis1:=0;mon1:=0; elsif(ks=0) then dis1:=0;mon1:=700; elsif(ks=1and tz=1and zt=1) then dis1:=dis1+10; elsif(ks=1and tz=1and zt=0) then d

9、is1:=dis1;mon1:=mon1; end if; if(dis1300) then null; elsif(dis1300) then mon1:=mon1+22; elsif(dis1=600) then mon1:=mon1+33; end if; mon=mon1;dis=dis1; end if; end process;end ch; 4.4 Transform 实现将电路计数分高低位显示,将二进制转化为数码管可识别的十进制library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;ent

10、ity transform isport( daclk : std_logic; dis,mon :integer range 0 to 9999; dg,ds,db,dq,mg,ms,mb,mq: out std_logic_vector(3 downto 0);end transform;architecture tran of transform isbegin process(daclk,dis)variable d :integer range 0 to 9999;variable d1,d2,d3,d4 :std_logic_vector(3 downto 0);begin if(

11、daclkevent and daclk=1) then if(ddis) then if(d1=9 and d2=9 and d3=9) then d1:=0000;d2:=0000;d3:=0000; d4:=d4+1;d:=d+1; elsif(d1=9 and d2=9) then d1:=0000;d2:=0000;d3:=d3+1;d:=d+1; elsif(d1=9) then d1:=0000;d2:=d2+1;d:=d+1; else d1:=d1+1;d:=d+1; end if; else d:=0;d1:=0000;d2:=0000;d3:=0000;d4:=0000;

12、 end if;end if;dg=d1;ds=d2;db=d3;dq=d4;end process;process(daclk,mon)variable m :integer range 0 to 9999;variable m1,m2,m3,m4 :std_logic_vector(3 downto 0);begin if(daclkevent and daclk=1) then if(mmon) then if(m1=9 and m2=9 and m3=9) then m1:=0000;m2:=0000;m3:=0000;m4:=m4+1;m:=m+1; elsif(m1=9 and m

13、2=9) then m1:=0000;m2:=0000;m3:=m3+1;m:=m+1; elsif(m1=9) then m1:=0000;m2:=m2+1;m:=m+1; else m1:=m1+1;m:=m+1; end if; else m:=0;m1:=0000;m2:=0000;m3:=0000;m4:=0000; end if;end if;mg=m1;ms=m2;mb=m3;mqdadadadadadadadanull;end case;end process;end se;4.6 W 用第一次分频过的脉冲实现八进制计数,为下面实现动态扫描做准备library ieee;use

14、 ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity w isport( clk:in std_logic; a:out std_logic_vector(2 downto 0);end w;architecture ch1 of w isbegin process(clk) variable b:std_logic_vector(2 downto 0); begin if(clkevent and clk=1) then if(b=111) then b:=000; else b:=b+1; end if; end i

15、f; aqqqqqqqqnull;end case;end process;end one;4.8 数码管显示:显示模块由8个七段LED数码管组成。各个模块用四个数码管,三个表示整数部分,一个表示小数部分。由于小数点的位置是固定的,因此可以将小数点接到一个固定的高电平上一直显示。library ieee;use ieee.std-_logic_1164.all;entity led isport( a : in std_logic_vector(3 downto 0);L: out std_logic_vector(6 sownto 0) );end led;architecture one

16、of led is beginprocess(a)begincase a iswhen 0000=LLLLLLLLLLnull;end case;end process; end one;五 顶层模块设计:将各个程序块联合起来,实现层次化设计library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity taxi isport(cp,start,stop,pause:in std_logic; ss1:out std_logic_vector(7 downto 0); ss2:out std_log

17、ic_vector(6 downto 0);end entity taxi;architecture ym of taxi iscomponent oneMHZport(daclk:in std_logic; clkout:out std_logic);end component;component twoMHZport(daclk:in std_logic;clkout:out std_logic);end component;component chargeport( cp,ks,tz,zt : in std_logic; dis,mon : out integer range 0 to

18、9999);end component;component transformport(daclk : std_logic; dis,mon :integer range 0 to 9999; dg,ds,db,dq,mg,ms,mb,mq: out std_logic_vector(3 downto 0);end component;component wport(clk:in std_logic; a:out std_logic_vector(2 downto 0);end component;component selport(c:in std_logic_vector(2 downto

19、 0); dg,ds,db,dq,mg,ms,mb,mq:in std_logic_vector(3 downto 0); da:out std_logic_vector(3 downto 0);end component;component mux38aport(d:in std_logic_vector(2 downto 0); q:out std_logic_vector(7 downto 0);end component;component ledport( a : in std_logic_vector(3 downto 0);L: out std_logic_vector(6 do

20、wnto 0);end component;signal aa0,aa1:std_logic;signal a0,b0:integer range 0 to 9999;signal b2,a1,b1,c1,d1,e1,f1,g1,h1:std_logic_vector(3 downto 0);signal y:std_logic_vector(2 downto 0);beginu0:oneMHZ port map(daclk=cp,clkout=aa0);u1:twoMHZ port map(daclk=aa0,clkout=aa1);u2:charge port map(cp=aa1,ks=

21、start,tz=stop,zt=pause,dis=a0,mon=b0);u3:transform port map(daclk=aa0,dis=a0,mon=b0,dg=a1,ds=b1,db=c1,dq=d1,mg=e1,ms=f1,mb=g1,mq=h1);u4:w port map(clk=aa0,a=y);u5:sel port map(c=y,dg=a1,ds=b1,db=c1,dq=d1,mg=e1,ms=f1,mb=g1,mq=h1,da=b2);u6:mux38a port map (d=y,q=ss1);u7:led port map(a=b2,L=ss2);end ym

22、;六 调试结果:1、下载步骤:(1) 安装驱动插入USB下载线后,自动跳出窗口,手动设置 D:alteraquartus6.0driverusb_blaster(2)IDE环境设置Assigementsdeviceep2cst144c8 device&ping optionsconfigurationsuse configuration deviseEPCS1-编译(3)programmer Toolshardware setupusbblasterModeSJTAG 选文件 xx.sof(4)下载成功后,先拔电源VCC再拔USB下载线。注意事项:保证下载板载断电情况下进行ASP或JTAG借口

23、的插拔。引脚安装图:出租车计费器成功运行,软硬件之间衔接全无问题,我们成功调试出预想结果,并且增加一些附加功能,比如考虑出租车夜晚和白天计费不一样,设计了加速计费功能,除了软件方面,在硬件上设计了显示灯,便于观察哪个功能起作用。虽然再调试过程出现了一些问题,但经过讨论以及观察摆出故障,测试完软硬件的独立运行,我们的软硬件之间的衔接运行相当顺利。七 实验中出现问题在编写程序时出现了一些问题,例如编译错误,仿真结果不正确,但经过细心检查和查找资料,及时改正,尤其在实际顶层文件时出现一系列问题,但很大部分是由于更部分引脚接错造成问题。这大多由于粗心和不熟练造成的。在此过程中浪费了一些时间。并且在下载过程中,尽管操作不熟练,但还是顺利完成。再软硬件连接过程中,出现了一系列问题,刚开始出现乱码,经检查是数码管和FPGA引脚连错了,接着出现显示没有置数功能,经核查后发现为软硬件不协调,除此之外还有由于频率太快,造成显示太快,无法看清示数显示,经过一系列修改后终于达到预期要求,并增加附加功能。八、设计小结出租车计费器系统的设计已全部完成,能按预期的效果进行模拟汽车启动、停止、暂停等功能,并设计动态扫描电路显示车费数目,由动态扫描电路来完成。车暂时停止不计费,车费保

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论