EDA技术(机械)实验报告--出租车计费器.docx
实验报告(计算机类)开课学院及实验室:机械学院工程实验中心实验时间:学生姓名学号成绩学生所在学院年级/专业/班课程名称EDA技术(机械)课程代码实验项目名称出租车计费器项目代码十一指导教师项目学分一、实验目的(I)学习并掌握QUartUSII开发系统的基本操作。(2)掌握用QUartUSII进行文本输入法进行电路设计、编译和仿真方法。(3)掌握CPLD/FPGA的开发流程。(4)掌握EDA实验开发系统的使用。(5)设计一个出租车计费器。二、内容与设计思想设计任务如下:(1)实现计费功能,计费标准为:暗行驶里程计费,起步价为7.OO元,并在车行3km后暗2.20元/加计费,当计费器达到或超过20元时,每千米加收50%的车费,车停止不计费。(2)现场模拟功能:能模拟汽车启动、停止、暂停以及加速等状态。(3)设计动态扫描电路,将车费和路程显示出来,各有两位小数。三、使用环境Pc计算机,quartusII软件环境四、核心代码及调试过程出租车计费器jfe模块Iibraryieee;useieee.std_Iogic_1164.aII;useieee.std_Iogic_unsigned.all;entityjifeiisport(elk,start,stop,pause,js:instd_logic;q:outstd_Iogic_vector(3downto0);chefei,luc:outintegerrange0to8000);endjifei;architecturearc_jifeiofjifeibegInprocess(cIkstart,stop,pause,js)variabIea,b:std_logic;variabIeaa:integerrange0to100;variabIechf,Ic:integerrange0to8000;variabIenum:integerrange0to9;beginifcIk,eventandcIk=,1,thenif(stop='0')thenchf:=0;num:=0;b:='1'aa:=0;Ic:=0;eIsif(start=10')thenb:='0'chf:=700;Ic:=0;eIsif(start=11,andjs=11'andpause='1')thenif(b=101)thennum:=num+1;endif;if(num=9)thenlc:=lc+5;num:=0;aa:=aa+5;endif;eIsif(start=11,andjs='0,andpause='1')thenlc:=lc+1;aa:-aa+1;endif;if(aa>=100)thena=,;aa:=0;eIsea:='0'endif;if(Ic<300)thennull;elsif(chf<2000anda=')thenchf:=chf+220;elsif(chf>=2000anda=')thenchf:=chf+330;endif;endif;chefei<=chf;Iuc<=lc;endprocess;endarc_jifei;X模块,将车费和路程转化成4位十进制Iibraryieee;useieee.std_Iogic_1164.aII;useieee.std_Iogic_unsigned.all;entityxisport(dacIk:instd_logic;ascore,bscore:inintegerrange0to8000;age,ashi,abai.aqian.bge,bshi,bbai,bqian:outstd_Iogic_vector(3downto0);endx;architecturearc_xofxisbeginp1:process(dacIk,ascore)variabIecomb1:integerrange0to8000;variabIecomb1a,comb1b,comb1cfcomb1d:std_Iogic_vector(3downto0);beginifdacIk,eventanddacIk='1'thenifcomb1<ascorethenifcomb1a=9andcomb1b=9andcomb1c=9thencomb1a:="0000"comb1b:="0000"ComblC:=”0000”;comb1d:-comb1d+1;comb1:=comb1+1;eIsifcomb1a=9andcomb1b=9thencomb1a:="0000"comb1b:="0000"comb1:-comb1+1;comb1c:=comb1c+1;eIsifcomb1a=9thencomb1a:="0000"comb1b:=comb1b+1;comb1:-comb1+1;eIseCOmbIa:=COmbIa+1;comb1:-comb1+1;endif;seashi<=comb1b;age<=comb1a;abai<=comb1c;aqian<=comb1d;comb1:=0;COmbla:="OOo0"COmbIb:="OOO0"comb1c:="0000',;comb1d="0000n;endif;endif;endprocessp1;p2:process(dacIk,bscore)variabIecomb2:integerrange0to8000;variabIecomb2a,comb2b,comb2c,comb2d:std_Iogic_vector(3downto0);beginifdaclk,eventanddacIk='1,thenifcomb2<bscorethenifcomb2a=9andcomb2b=9andcomb2c=9thencomb2a:="0000n;comb2b"OOOOn;comb2c:="0000"comb2d:=comb2d+1;comb2:=comb2+1;eIsifcomb2a=9andcomb2b-9thencomb2a:="0000"comb2b:=”0000”;comb2:-comb2+1;comb2c:-comb2c+1;eIsifcomb2a=9thencomb2a:=”0000”;comb2b:=comb2b+1;comb2:=comb2+1;eIsecomb2a:=comb2a+1;comb2:=comb2+1;endif;bshi<=comb2b;bge<-comb2a;bbai<-comb2c;bqian<-comb2d;comb2:-0;comb2a,0000;comb2b:="0000”;comb2c:="0000”;comb2d:="0000”;endif;endif;endprocessp2;endarc_x;1模块,八选一将车费和路程显示出来Iibraryieee;useieee.std_Iogic_1164.all;useieee.std_Iogic_unsigned.all;entityxx×1isport(c:instd_Iogic_vector(2downtoO);a1,a2,a3,a4,b1,b2,b3,b4:instd_Iogic_vector(3downtoO);dp:outstd_logic;d:outstd_Iogic_vector(3downtoO);endxxx1;architecturearc_xxx1ofxxx1isbeginprocess(c,a1,a2,a3,a4,b1,b2,b3,b4)variabIecomb:std_Iogic_vector(2downtoO);begincomb:=c;casecombiswhen,000,=>d<=a1;a13.0 d(3.0 a23.0 a33. .01J - a43.0 b13.0l b2(3 0淅 W(3.01 b43.0< Z; st< -dp<=,O'when-00,=>d<=a2;dp<=,O'when-010',=>d<=a3;dp<=,;when"011"=>d<=a4;dp<=,O'when,100,=>d<=b1;dp<=,O'when,10,=>d<=b2;dp<=,O'when-110',=>d<=b3;dp<=,;when,1111,=>d<=b4;dp<=,O'whenothers=>nuII;endcase;endprocess;endarc_xxx1;SE模块Iibraryieee;useieee.std_Iogic_1164.aII;useieee.std_Iogic_unsigned.all;entityseisport(elk:instd_logic;a:outstd_Iogic_vector(2downtoO);endse;architecturearc_seofseisbeginprocess(cIk)variabIeb:std_Iogic_vector(2downtoO);beginifcIk,eventandcIk=1,thenifb=1,11,thenb:="000"b:=b+1;endif;endif;a<=b;endprocess;endarc_se;D*万3一Iibraryieee;useieee.std_Iogic_1164.aII;entitydiisport(d:instd_Iogic_vector(3downtoO);q:outstd_Iogic_vector(6downtoO);enddi;architecturedi_arcofdiisbeginprocess(d)begincasedsend process;end di_arc;总体框由when"0000',=>q<=>,011111,when"000,=>q<=,0000110"when,10010,=>q<=,101101,whenn001,=>q<="100111,when"0100',=>q<=>>1100110"when-010,=>q<=>>110110,when'0110',=>q<=,111110,whenn011,=>q<=,000011,when"1000',=>q<=>>111111,whenothers=>q<="110111,endcase;«2.081PO435W03POJW01bH3.0)文3.0网3.0网3.OJ五、总结