资源描述:
《EDA技术实用教程第9章.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、EDA技术实用教程第9章VHDL结构与要素9.1实体KX康芯科技9.1.1实体语句结构实体说明单元的一般语句结构:ENTITY实体名IS[GENERIC(参数名:数据类型);][PORT(端口表);]ENDENTITY实体名;9.1实体KX康芯科技9.1.2参数传递说明语句参数传递说明语句的一般书写格式如下:GENERIC([常数名:数据类型[:设定值]{;常数名:数据类型[:设定值]});9.1实体KX康芯科技9.1.2参数传递说明语句【例9-1】LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.AL
2、L;ENTITYandnISGENERIC(n:INTEGER);--定义类属参量及其数据类型PORT(a:INSTD_LOGIC_VECTOR(n-1DOWNTO0);--用类属参量限制矢量长度c:OUTSTD_LOGIC);END;ARCHITECTUREbehavOFandnISBEGINPROCESS(a)VARIABLEint:STD_LOGIC;BEGINint:='1';FORiINa'LENGTH-1DOWNTO0LOOP--循环语句IFa(i)='0'THENint:='0';ENDIF;ENDLOOP;
3、c<=int;ENDPROCESS;END;9.1实体KX康芯科技9.1.2参数传递说明语句【例9-2】LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYexnISPORT(d1,d2,d3,d4,d5,d6,d7:INSTD_LOGIC;q1,q2:OUTSTD_LOGIC);END;ARCHITECTUREexn_behavOFexnISCOMPONENTandn--调用例10-1的元件调用声明GENERIC(n:INTEGER);PORT(a:INSTD_LOGIC_VECTO
4、R(n-1DOWNTO0);C:OUTSTD_LOGIC);ENDCOMPONENT;BEGINu1:andnGENERICMAP(n=>2)--参数传递映射语句,定义类属变量,n赋值为2PORTMAP(a(0)=>d1,a(1)=>d2,c=>q1);u2:andnGENERICMAP(n=>5)--定义类属变量,n赋值为5PORTMAP(a(0)=>d3,a(1)=>d4,a(2)=>d5,a(3)=>d6,a(4)=>d7,c=>q2);END;9.1实体KX康芯科技9.1.3参数传递映射语句【例9-3】LIBRAR
5、YIEEE;--待例化元件USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_arith.ALL;USEIEEE.STD_LOGIC_unsigned.ALL;ENTITYaddernISPORT(a,b:INSTD_LOGIC_VECTOR;result:outSTD_LOGIC_VECTOR);ENDaddern;ARCHITECTUREbehaveOFaddernISBEGINresult<=a+b;END;KX康芯科技9.1.3参数传递映射语句【例9-4】LIBRARYIEEE
6、;--顶层设计USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_arith.ALL;USEIEEE.STD_LOGIC_unsigned.ALL;ENTITYaddersISGENERIC(msb_operand:INTEGER:=15;msb_sum:INTEGER:=15);PORT(b:INSTD_LOGIC_VECTOR(msb_operandDOWNTO0);result:OUTSTD_LOGIC_VECTOR(msb_sumDOWNTO0));ENDadders;ARCH
7、ITECTUREbehaveOFaddersISCOMPONENTaddernPORT(a,b:INSTD_LOGIC_VECTOR;result:OUTSTD_LOGIC_VECTOR);ENDCOMPONENT;SIGNALa:STD_LOGIC_VECTOR(msb_sum/2DOWNTO0);SIGNALtwoa:STD_LOGIC_VECTOR(msb_operandDOWNTO0);BEGINtwoa<=a&a;U1:addernPORTMAP(a=>twoa,b=>b,result=>result);U2:a
8、ddernPORTMAP(a=>b(msb_operanddowntomsb_operand/2+1),b=>b(msb_operand/2downto0),result=>a);ENDbehave;9.1实体KX康芯科技9.1.3参数传递映射语句图9-1例9-4的RTL电路图(Synplify综合)9