EDA技术(机械)实验报告--出租车计费器.docx
实验报告(计算机类)开课学院及实验室:机械学院工程实验中心实验时间:学生姓名学号成绩学生所在学院年级/专业/班课程名称EDA技术(机械)课程代码实验项目名称出租车计费器项目代码十一指导教师项目学分一、实验目的(I)学习并掌握QUartUSII开发系统的基本操作。(2)掌握用QUartUS进行文本输入法进行电路设计、编译和仿真方法。(3)掌握CP1D/FPGA的开发流程。(4)掌握EDA实验开发系统的使用。(5)设计一个出租车计费器。二、内容与设计思想设计任务如下:(1)实现计费功能,计费标准为:暗行驶里程计费,起步价为7.OO元,并在车行3km后暗2.20元km计费,当计费器达到或超过20元时,每千米加收50%的车费,车停止不计费。(2)现场模拟功能:能模拟汽车启动、停止、暂停以及加速等状态。(3)设计动态扫描电路,将车费和路程显示出来,各有两位小数。三、使用环境Pc计算机,quartusII软件环境四、核心代码及调试过程出租车计费器JIFEI模块Iibraryieee;useieee.std_Iogic_1164.aII;useieee.std_Iogic_unsigned.a11;entityjifeiisport(e1k,start,stop,pause,js:instd_1ogic;q:outstd_Iogic_vector(3downto0);chefei,Iuc:outintegerrange0to8000);endjifei;architecturearc_jifeiofjifeiisbeginprocess(cIk,start,stop,pause,js)variabIea,b:std_1ogic;variabIeaa:integerrange0to100;variabIechf,Ic:integerrange0to8000;variabIenum:integerrange0to9;beginifcIk,eventandCIk='1'thenif(StoP='0')thenchf:=0;num:=0;b:='r;aa:0;1c:=0;eIsif(start='0')thenb,0,;chf:=700;1c:=0;eIsif(start='1,andjs='andpause='1')thenif(b=,0,)thennum:=num+1;endif;if(num=9)thenIC:=Ic+5;num:=0;aa:=aa+5;endif;eIsif(start='1,andjs='0,andpause='1')then1c:=1c+1;aa:二aa+1;endif;if(aa>=100)thena:='r;aa:=0;eIsea:='O'endif;if(Ic<300)thennu11;eIsif(chf<2000anda=')thenchf:=chf+220;eIsif(chf>=2000anda=')thenchf:=chf+330;endif;endif;chefei<=chf;Iuc<=1c;endprocess;endarc_jifei;X模块,将车费和路程转化成4位十进制Iibraryieee;useieee.std_Iogic_1164.aII;useieee.std_Iogic_unsigned.a11;entityxisport(dacIk:instd_1ogic;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,comb1c,comb1d:std_Iogic_vector(3downto0);beginifdac1k'eventanddacIk,1,thenifcomb1<ascorethenifcomb1a=9andcomb1b=9andcomb1c=9thenCOmbIa:="0000”;COmbIb:="0000”;CombIC:=”0000”;comb1d:=comb1d+1;comb1:=comb1+1;eIsifcomb1a=9andcomb1b=9thenCOnIbIa:="0000”;comb1b:=,0000,1;comb1:=comb1+1;comb1c:=comb1c+1;eIsifcomb1a=9thenCombIa:=”0000”;comb1b:=comb1b+1;comb1:=comb1+1;eIsecomb1a:=comb1a+1;comb1:=comb1+1;endif;eIseashi<=comb1b;age<=comb1a;abai<=comb1c;aqian<=comb1d;comb1:=0;comb1a:="0000"comb1b:="0000"comb1c:="0000"CombId:=”0000”;endif;endif;endprocessp1;p2:process(dacIk,bscore)variabIecomb2:integerrange0to8000;variabIecomb2a,comb2b,comb2c,comb2d:std_Iogic_vector(3downto0);beginifdacIk,eventanddacIk='thenifcomb2<bscorethenifcomb2a=9andcomb2b=9andcomb2c=9thencomb2a:="0000"comb2b:="0000"comb2c:=,0000,1;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;eIsebshi<=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.aII;useieee.std_Iogic_unsigned.a11;entityxxx1isport(c: instd_Iogic_vector(2downtoO);a1,a2,a3,a4,b1,b2,b3,b4:instd_Iogic_vector(3downtoO);dp:outstd_1ogic;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;,衿F3.0d3.0a23.0J-a33.0-da43.0;;rt,衿bi3.q-b2(3.0/2网3.07-Z3.Odp<=,O'when-00,=>d<=a2;dp<=,O'when-010',=>d<=a3;dp<=,;when-01,=>d<=a4;dp<=,O'when-100',=>d<=b1;dp<=,O'when-10,=>d<=b2;dp<=,O'when-110',=>d<=b3;dp<=,;when"11'=>d<=b4;dp<=,O'whenothers=>nuII;endcase;endprocess;endarc_xxx1;se模块Iibraryieee;useieee.std_Iogic_1164.aII;useieee.std_Iogic_unsigned.a11;entityseisport(e1k:instd_1ogic;a:outstd_Iogic_vector(2downtoO);endse;architecturearc_seofseisbeginprocess(cIk)variabIeb:std_Iogic_vector(2downtoO);beginifcIk,eventandC1k='1'thenifb=1,11,thenb,000"eIseb:=b+1;endif;endif;a<=b;endprocess;endarc_se;d译码模块Iibraryieee;useieee.std_Iogic_1164.aII;entitydiisport(d:instd_Iogic_vector(3downtoO);q:outstd_Iogic_vector(6downtoO);enddi;architecturedi_arcofdiisbeginprocess(d)begincasediswhen,0000,=>q<=,>011111,;when,000,=>q<=,>0000110"when,0010,=>q<=,101101,;when-001,=>q<=,100111,;when,0100,=>q<=,1100110"when-010,=>q<=,110110,;when-0110',=>q<=,111110,;when-011,=>q<=,>000011,;when,1000,=>q<=,111111,;whenothers=>q<=,110111,;endcase;endprocess;enddi_arc;邓口.切a5hi3.Oabai3.0aqian3.Dge3.切bshi3.0bbai3.Oba43.0a13.0d3.02(3.0a33.