AHDL语法入门(Altera公司提供).ppt_第1页
AHDL语法入门(Altera公司提供).ppt_第2页
AHDL语法入门(Altera公司提供).ppt_第3页
AHDL语法入门(Altera公司提供).ppt_第4页
AHDL语法入门(Altera公司提供).ppt_第5页
已阅读5页,还剩46页未读 继续免费阅读

下载本文档

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

文档简介

5/31/20205/31/2020P.1,AHDLTrainingClass,DannyMokAlteraHKFAE(dmok),5/31/20205/31/2020P.2,WhatisAHDL,AlteraHardwareDescriptionLanguagedevelopbyAlteraintegrateintotheAlterasoftwareMax+PlusIIdescriptionthehardwareinlanguageinsteadofgraphiceasytomodifyeasytomaintaneverygoodforcomplexcombinationallogicBCDto7Segmentconverteraddressdecodingstatemachinemorethanyouwant.,5/31/20205/31/2020P.3,continue.,AseasyasGraphicEntryAspowerfulasHDL(HardwareDescriptionLanguage)VHDL,VerilogHDLetc.,5/31/20205/31/2020P.4,HowtousetheADHL,useanytexteditortocreatethefileAlteraSoftwareMax+PlusIIprovidetexteditor,TypeinyourAHDLdesignfile,5/31/20205/31/2020P.5,continue.,CreateyourAHDLfile,5/31/20205/31/2020P.6,continue.,saveyourADHLfileasname.TDF,5/31/20205/31/2020P.7,continue.,5/31/20205/31/2020P.8,ErrorLocationduringCompilation,Easytolocatetheerror,5/31/20205/31/2020P.9,AHDLTemplate,5/31/20205/31/2020P.10,GeneralAHDLFormat,SUBDESIGNdecode1(input_pin_name:INPUT;input_bus_name15.0:INPUT;output_pin_name:OUTPUT;output_bus_name:OUTPUT;)BEGINouptut_pin_name=input_pin_name;output_bus_name=input_bus_name;END;,KeyWord,DefienI/Oport,Logic,AHDLformat,5/31/20205/31/2020P.11,YourFirstAHDLdesign-AddressDecoder,Chip_enable=a0chip_enable:output;)beginchip_enable=(a3.0=H7);end;,5/31/20205/31/2020P.12,WhyIuseAHDLinsteadofGraphic,EasytoModifyDocumentduringthecodingIwanttodecodeH”A”notH”7”,SUBDESIGNdecode1(a3.0:input;chip_enable:output;)beginchip_enable=(a3.0=HA);end;,SelfExplaintheFunction,Onlythingtochange,Needmoreefforttomodify,Chip_enable=!a0chip_enable:output;)beginchip_enable=(a3.0=B1x0 x);end;,Somebitcanbeignoreforcomparsion,5/31/20205/31/2020P.14,Somethingyouneedtoknow,Addition:+Subtraction:-NumericEquality:=Notequalto:!=Greaterthan:Greaterthanorequalto:=Lessthan:highest_level=B”0100”;when1=highest_level=B”0010”;whenothers=highest_level=B”0001”;endcase;end;,Whatistheusageofthisstatement,5/31/20205/31/2020P.26,5/31/20205/31/2020P.27,ForLoop,CONSTANTnum_of_bit=8;SUBDESIGNnumbit(anum_of_bit.0:input;bnum_of_bit.0:output;)beginb8=a0;b7=a1;b6=a2;b5=a3;b4=a4;b3=a5;b2=a6;b1=a7;b0=a8;end;,5/31/20205/31/2020P.28,AHDLwithGraphic,UsetheFilemenutocreateSymbolfortheAHDLdesignThesymbolcanbeusedforgraphicentry,5/31/20205/31/2020P.29,RegisterLogic,SUBDESIGNflip_flop(d,clk:input;q:output;)beginq=dff(d,clk,);end;,5/31/20205/31/2020P.30,MoreDetail,5/31/20205/31/2020P.31,MoreonRegister,HowtodotheBuswithRegisterHowtodotheothertypeofRegisterDFFE(D-FFwithenable)TFF/TFFEJKFF/JKFFESRFF/SRFFE,5/31/20205/31/2020P.32,RegisterBuses,SUBDESIGNbus_reg(clk,d7.0:input;q7.0:output;)variableff7.0:dff;beginff.clk=clk;ff.d=d;q=ff.q;end;,5/31/20205/31/2020P.33,D-Flip-FlopwithEnable/Preset/Clear,SUBDESIGNflip_flop_enable(clock,data,enable,preset,clear:input;qout:output;)variabletemp:dffe;begintemp.d=data;temp.clk=clock;temp.clrn=clear;temp.prn=preset;temp.ena=enable;qout=temp.q;end;,D,CLK,CLRN,PRN,ENA,Q,5/31/20205/31/2020P.34,OtherTypeofFlip-Flop,5/31/20205/31/2020P.35,HowtouseHelpMenu,Q:IdontknowhowtouseAlteraDFF/JKFFE,whatcanIdo?A:AlteraHelpMenuisagoodplacetofindinformationQ:HowdoIusetheHelpMenu?A:ItiseasyandFun,DFFE,5/31/20205/31/2020P.36,HowtouseHelpMenu,5/31/20205/31/2020P.37,Tri-stateBuffer,SUBDESIGNtri_state(a,enable:input;b:output;)beginb=tri(a,enable);end;,SUBDESIGNtri_state(a,enable:input;b:output;)variabletemp:tri;begintemp.in=a;temp.oe=enable;b=temp.out;end;,5/31/20205/31/2020P.38,MoreDetail,5/31/20205/31/2020P.39,OPNDRN-OpenDrainBuffer,SUBDESIGNopn_drn(enable:input;b:output;)beginb=opndrn(enable);end;,SUBDESIGNtri_state(enable:input;b:output;)variabletemp:opndrn;begintemp.in=enable;b=temp.out;end;,5/31/20205/31/2020P.40,MoreDetail,5/31/20205/31/2020P.41,UsingAHDLasEASYasSchematicbutUsingAHDLismorePOWERFUL,5/31/20205/31/2020P.42,Exercise,AHDL,input,bidir,clk,enable:input;io:bidir;,5/31/20205/31/2020P.43,Design8bitsCounterisEasy,SUBDESIGN8bits(clk:input;q7.0:output;)variabletemp7.0:dff;begintemp.clk=clk;temp.d=temp.q+1;q=temp.q;end;,5/31/20205/31/2020P.44,StateMachine,SUBDESIGNsimple(clk,reset,jump:input;q:output;)variabless:MACHINEWITHSTATES(S0,S1);beginss.clk=clk;ss.reset=reset;casessiswhens0=q=gnd;if(jump)thenss=s1;endif;whens1=q=vcc;if(jump)thenss=s0;endif;endcase;end;,StateMachineDiagram,Note:AllStateMachineVariablemustbeassociatedwithaCLOCK,jump=1,jump=1,q=0,q=1,jump=0,jump=0,5/31/20205/31/2020P.45,5/31/20205/31/2020P.46,MoreaboutStateMachine,SUBDESIGNstepper(reset,ccw,cw,clk:input;phase3.0:output;)variabless:MACHINEOFBITS(temp3.0)WITHSTATES(s0=B”0001”,s1=B”0010”,s2=B”0100”,s3=B”1000”);beginss.clk=clk;if(reset)thenss=s2;endif;phase=temp;,TABLEss,ccw,cw=ss;s0,1,x=s3;s0,x,1=s1;s1,1,x=s0;s1,x,1=s2;s2,1,x=s1;s2,x,1=s3;s3,1,x=s2;s3,x,1=s0;ENDTABLE;end;,Note:NoneedtodeclarewhatisTEMPItisautomaticdeclareasDFF,5/31/20205/31/2020P.47,UsercancontroltheStateBit,5/31/20205/31/2020P.48,Exercise,SUBDESIGNstepper(reset,ccw,cw,clk:input;phase3.0:output;)variabless:MACHINEOFBITS(temp3.0)WITHSTATES(s0=B”0001”,s1=B”0010”,s2=B”0100”,s3=B”1000”);beginss.clk=clk;if(reset)thenss=s2;endif;phase=temp;,TABLEss,ccw,cw=ss;s0,1,x=s3;s0,x,1=s1;s1,1,x=s0;s1,x,1=s2;s2,1,x=s1;s2,x,1=s3;s3,1,x=s2;s3,x,1=s0;ENDTABLE;end;,CanyouModifythisTruthTabletoCASEstatement,5/31/20205/31/2020P.49,StateMachinewithoutRecoverState,SUBDESIGNrecover(clk,go:input;ok:output;)variablesequence:MACHINEOFBITS(q2.0)withSTATES(idle,one,two,three,four,illegal1,illegal2,illegal3);beginsequence.clk=clk;casesequenceiswhenidle=if(go)thensequence=one;endif;whenone=sequence=two;whentwo=sequence=three;whenthree=sequence=four;endcase;ok=(sequence=four);end;,5/31/20205/31/2020P.50,BetterhaveRecoverwithinStateMachine,SUBDESIGNrecover(clk,go:input;ok:output;)vari

温馨提示

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

最新文档

评论

0/150

提交评论