1、EDA 出租汽车计费器文档 实 验 报 告课程名称: EDA 技 术 实验名称: 出 租 车 计 费 器 实验类型:设 计 学 时: 3 系 别:物 电 院 专 业:电子信息工程 年级班别: 开出学期:2008-2009(上 学生姓名: 学 号: 实验教师: 成 绩: 2008年 12 月 8 日出租车计费器一、实验任务及要求:15 Km起计价,起始价5元,每公里1.2元;2传感器输出脉冲为0.5Km/个;3每0.5km改变一次显示,且提前显示(显示路程和车费),车停止不计费。 4实现模拟功能:能模拟汽车启动、停止、加速等状态。 5设计动态扫描电路:将路程和车费显示出来,有两位小数。6.用VH
2、DL语言设计符合上述功能要求的出租车计费器,并用层次化设计方法设计该电路。7各计数器的计数状态用功能仿真的方法验证,并通过有关波形确认电路设计是否正确。8完成电路全部设计后,通过系统实验箱下载验证设计课题的正确性。二、实验总体框图: 出租车计费总体框图如图一所示。它由五个模块组成,JIFEI(计费电路) 、TRANS(转换电路) 、SE(扫描电路)、XIANSHI(显示电路) 、和DI(字形显示电路)。计费电路完成计费功能;转换电路把车费和路程转换成四位十进制数;显示电路实际上是八选一数据选择器,和扫描电路共同控制输出;字形显示电路输出09个字形。图一 总体框图三、各个模块的VHDL程序与仿真
3、波形如下:(1)计费模块(计费)计费模块如图二所示。输入端口START 、JS分别代表启动停止、加速。输出端口FARE、DISTANCE代表车费和路程。(程序中lc、chefei分别代表路程和车费)图二 计费模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jifei is port (clk,start,js:in std_logic; fare,distance:out integer range 0 to 8000);end jifei;architecture aa of
4、jifei is begin process(clk,start,js)variable chefei,lc:integer range 0 to 8000;begin if (clkevent and clk=1) then if (start=0) then chefei:=0; lc:=0; elsif (start=1 and js=0) then chefei:=500; lc:=0; end if; if(start=1 and js=1) then lc:=lc+50; end if; if(lc=500) then chefei:=chefei+60; end if; end
5、if; fare =chefei; distance =lc; end process ;end aa ;该模块的仿真波形如图二-1所示图二-1(2)转换模块(TRANS)转换模块如图三所示。DCLK的频率要比CLK的快很多。输入端口ASCORE 、BSCORE代表车费和路程,输出端口A0A3(B0B3) 分别代表车费(路程)的个、十、百、千。图三 转换模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity trans is po
6、rt (dclk: in std_logic; ascore,bscore:in integer range 0 to 8000; a0,a1,a2,a3,b0,b1,b2,b3:out std_logic_vector(3 downto 0);end trans;architecture mix of trans is signal com1: integer range 0 to 8000;begin process(dclk,ascore) variable com1a,com1b,com1c,com1d:std_logic_vector(3 downto 0); begin if (d
7、clkevent and dclk =1) then if (com1ascore) then if (com1a=9 and com1b=9 and com1c=9) then com1a:=0000; com1b:=0000; com1c:=0000; com1d:=com1d+1; elsif(com1a=9 and com1b=9) then com1a:=0000; com1b:=0000; com1c:=com1c+1; com1=com1+1; elsif(com1a=9) then com1a:=0000; com1b:=com1b+1; com1=com1+1; else c
8、om1a:=com1a+1; com1=com1+1; end if; else a0=com1a; a1=com1b; a2=com1c; a3=com1d; com1=0; com1a:=0000; com1b:=0000; com1c:=0000; com1d:=0000; end if; end if; end process;process (dclk,bscore)variable com2:integer range 0 to 8000;variable com2a,com2b,com2c,com2d:std_logic_vector (3 downto 0);begin if
9、(dclkevent and dclk =1) then if (com2bscore) then if (com2a=9 and com2b=9 and com2c=9) then com2a:=0000; com2b:=0000; com2c:=0000; com2d:=0000; com2d:=com2d+1; elsif (com2a=9 and com2b=9) then com2a:=0000; com2b:=0000; com2c:=com2c+1; com2:=com2+1; elsif(com2a=9) then com2a:=0000; com2b:=com2b+1; co
10、m2:=com2+1; else com2a:=com2a+1; com2:=com2+1; end if; else b0=com2a; b1=com2b; b2=com2c; b3d=a0;dpd=a1;dpd=a2;dpd=a3;dpd=b0;dpd=b1;dpd=b2;dpd=b3;dpnull; end case; end process;end mix;该模块的仿真波形如图四-1所示图四-1(4)选择模块(SE)选择模块如图五所示。图五 选择模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.
11、all;entity se is port(clk:in std_logic; a:out std_logic_vector(2 downto 0);end se;architecture mix of se 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 if; a=b;end process;end mix;该模块的仿真波形如图五-1所示图五-1(5)字形显
12、示模块(DI)字形显示模块如图六所示。图六 DI模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity di is port(d:in std_logic_vector(3 downto 0); q:out std_logic_vector(6 downto 0);end di;architecture mix of di isbegin with d select q=1111110when0000, 0110000when0001, 1101101when0010, 1111001when0011, 0110011when0100
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1