EDA技术(机械)实验报告--三层电梯控制器.docx
实验报告(计算机类)开课学院及实验室:实验时间:年月曰学生姓名学号成绩学生所在学院年级/专业/班课程名称EDA技术(机械)课程代码实验项目名称三层电梯控制器项目代码指导教师项目学分一、实验目的1 .了解VHDL语言编程方法,学会熟练运用quartus软件2 .了解三层电梯运作原理3 .了解如何使用VHDL设计一个三层电梯控制器二、内容与设计思想1 .电梯控制器是控制电梯按顾客的要求自动上下的装置2 .设计一个三层电梯控制器:(1)每层电梯入口设有上下请求开关,电梯内设有乘客到达层次的停站请求开关。(2)设有电梯所处位置及运作模式(上、下)指示装置。3 3)电梯每秒升(降)一层楼。(4)电梯到达有停站请求窗楼层后,经1秒电梯门打开,开门指示灯亮,开门4秒后,电梯门关闭(开门指示灯灭),电梯继续运行,直到执行完最后一个指令后停在当前层。(5)能记忆电梯内外的所有请求信号,并按照电梯运行规则秩序响应,每个指令保留至执行后消除。(6)电梯运行规则是:当电梯处于上升模式时,至响应比电梯所在位置高的上楼请求信号,由下而上逐个执行,直到最后一个上楼请求执行完毕,如更高层有下楼请求,则直接升到有下楼请求的最高层接客,然后进入下降模式。当电梯处于下降模式时,与上升相反。(7)电梯初始状态为一层开门。三、使用环境WinXP或Win7QUartUSii编程环境四、核心代码及调试过程三层电梯控制器一-Veryhardd模块Iibraryieee;useieee.std_Iogic_1164.aII;entityveryharddisport(up1,up2,cIk,down2,down3,k1,k2,k3:instd_logic;site:outstd_Iogic_vector(3downto1);a1,a2.a3:outstd_logic;mode,door:outstd_logic);endveryhardd;architectureveryhard_arcofveryharddistypestate_typeis(d,c2,c3,kai);beginprocess(cIk)variabIeupI,downI,tingI,cengI:std_Iogic_vector(3downto1);variabIemo,x,y,z:std_logic;variabIecnt1,cnt2:integer;variabIestate:state_type;beginifcIk,eventandcIk=,1'thenifup1='O'thenupl(1):='1'endif;ifup2='O'thenupl(2)='endif;ifdown3='O'thendownI(3):=T;endif;ifdown2-'0'thendownI(2):='1'endif;ifk1='0'thentingl(1):='endif;ifk2=,0,thentingl(2)=,;endif;ifk3='0'thentingl(3)=,;endif;ifcnt1<1000thencnt1:=cnt1+1;eIsecasestateiswhend=>cengl:="001',;mo:=,O'ifupI/="000"orcengl=,000"ortingl=,000"thenz:二';endif;ifz='O'thendoor<='11;eIsedoor<='0'iftingl(1)=,1"orupl(1)=,1"thenstate:=kai;tingl(1):='0'upl(1)='0'elsifupl(2)='1'ortingl(2)='1'thenstate:=c2;or ting I (3) = , 1, thenthenIsifdownI(3)='1,state:=c2;x:='1'IsifdownI(2)='1,state:=c2;mo:='11;endif;endif;whenc2=>cengl:="010"ifmo=10'theniftingl(2)='1'orstate:=kai;tingl(2):='O'upl(2)=,0'elsifdownI(3)=,state:=c3;x:='0'elsifdownI(2)=,1,mo:=,1,;endif;eIseiftingl(2)='1,orstate:=kai;tingl(2):='O'downI(2):二'0'upI(2)=,1,thenortingI(3)='1'orx='1,thenorupl(1)=,1,ortingl(1)=,1,thendownI(2)=,1'thenelsifupl(1)=,ortingl(1)=,ory='thenstate:-c1;y:='0,;elsifupl(2)=,ordownI(3)=,ortingl(3)=,thenmo:=,O'endif;endif;whenc3=>cengl:="1OO"mo:='1'iftingl(3)='1'ordownI(3)='1'thenstate:=kai;tingl(3):='O'downI(3):='0'eIsifdownI(2)=,1'ortingl(2)='1"thenstate:=c2;eIsifupl(1)=,1,ortingl(1)=,1,thenstate:=c2;y:=,r;eIsifupl(2)=,1'thenstate:=c2;mo:=,0,;endif;whenkai=>door<='11;ifcnt2<3thenCnt2:=Cnt2+1;eIsedoor<='01;Cnt2:=0;ifcengl="001"thenstate:=c1;eIsifcengl="010"thenstate:=c2;eIsestate:-c3;endif;endif;endcase;cnt1:=0;endif;endif;site<=cengl;a1<=tingl(1);a2<=tingI(2);a3<=tingl(3);endprocess;endveryhard_arc;SEG数码管显示模块Iibraryieee;useieee.std_Iogic_1164.aII;entitysegisport(elk:instd_logic;a:instd_Iogic_vector(3downto1);q:outstd_Iogic_vector(6downtoO);endseg;architectureseg_arcofsegisbeginprocess(cIk)beginifcIk,eventandcIk=,1,thencaseaiswhen-00,=>q<=,0000110"when-010',=>q<=,101101,when"100',=>q<="100111,whenothers=>nuII;endcase;elk06.0-3.nst1endif;endprocess;endseg_arc;DIAN模块Iibraryieee;useieee.std_Iogic_1164.aII;useieee.std_Iogic_unsigned.all;entitydianisport(cIk,mode:instd_logic;seI:outstd_Iogic_vector(3downtoO);q:outstd_Iogic_vector(Oto15);enddian;architecturedian_arcofdianisbeginprocess(cIk)vartableseeI:std_Iogic_vector(3downtoO);beginifcIk'eventandcIk='1'thenseeI:-see1+1;ifmode-'O'thencaseseeIswhen"0011',=>q<=,0000110000000000"when"0100"=>q<="0001100000000000"when"0101"=>q<="0011000000000000"whenn0110"=>q<=,0110000000000000"when"0111',=>q<=,1111111111111111"when"1000"=>q<="1111111111111111"when"1001"=>q<="0110000000000000"when"1010"=>q<=,0011000000000000"when"1011',=>q<=,0001100000000000"when"1100"=>q<="0000110000000000"whenothers=>q<=,>0000000000000000"endcase;eIsecaseseeIwhen"0011',=>q<=,0000000000110000"when"0100',=>q<=>,0000000000011000"when"0101',=>q<=,0000000000001100"when-0110',=>q<=>,0000000000000110"when"0111',=>q<=>>111111111111111,when"1000',=>q<="111111111111111,when"1001',=>q<=,0000000000000110"when"1010',=>q<=>,0000000000001100"when"1011',=>q<=,0000000000011000"when"1100',=>q<=>,0000000000110000"whenothers=>q<=,0000000000000000"endcase;endif;endif;I oksel1.0, modeq0.15:nstsel<=seel;endprocess;enddian_arc;总体框图:'rt'.Srrrf嗨三三j3心嚏-=>>oowndown3sel3.0qO-l5五、总结六、附录(仿真结果)19.175nselkAUPlAup2AIdown2AIdowx3AIklAIk2AIk3AdoorAI1屹AAa3AI,¾QAJ_n_n_TLrLrLrLnJTJTJTLrLrJLTJLLLLLrLn_T-JIoT>20s(1OXCU2X3JX4X5X6X7X8X9)10lljil213Mlfej0X1X2X3X4X5X6021-.3AI-:I/22-.2AIIIIII-323.iAIIIII_1IIIII-D24L.oAIJ_I_I_I_I_I_II_II_I_I_I_I_I_I_II_I_I_I_I_>2SEJd*gOI326-0JAI:II二327AIIIIf>2-2A-1I-Q29-.31AII_III-1II_IC>30-.4AIIIII_IIIII31-.5a«IIII_IIIIt>32-.ftAIII>30-.4AI_J1I1_IIIII31-5AI_J_1Il_J_II_I032-.6AIII_C>33-.7AIII_J砂34-.8)AIII_r4>35-9AIII_r>36-0AI_II_r<J37-1AIII>38-.2JKIII_r339-3AIIIri三<L>40-.4AIII041-.5AI_II_411f4Im,