VHDL中的结构设计元件例化语句_第1页
VHDL中的结构设计元件例化语句_第2页
VHDL中的结构设计元件例化语句_第3页
VHDL中的结构设计元件例化语句_第4页
VHDL中的结构设计元件例化语句_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

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

文档简介

1、VHDLVHDL中的结构设计:元件例化语句中的结构设计:元件例化语句设计的要点:建立元件端口之间的连接;设计的要点:建立元件端口之间的连接;元件:已经定义的电路模块(实体),可以元件:已经定义的电路模块(实体),可以来自标准库中,也可以是自己或他人以前编来自标准库中,也可以是自己或他人以前编译过的实体;译过的实体;元件的基本要点:元件的基本要点: 元件名元件名 输入输入/ /输出端口特点;输出端口特点;VHDLVHDL中的结构设计的实例中的结构设计的实例entity butnot is port (x,y: in bit; z: out bit); end butnot;architectur

2、e str of butnot issignal temp: bit;component kinv port (a: in bit; y: out bit);end component;component kand2 port (a,b: in bit; y: out bit);end component;VHDLVHDL中的结构设计的实例中的结构设计的实例begin u1: kinv port map(y,temp); u2: kand2 port map(x,temp,z);end str;VHDLVHDL中的结构设计的特点中的结构设计的特点Architecture str of Arch

3、itecture str of 实体名实体名 is is元件说明;元件说明;-(电路设计中使用的元件及端口)(电路设计中使用的元件及端口)信号说明;信号说明;-(电路设计中各中间连接点)(电路设计中各中间连接点)beginbegin元件使用语句;元件使用语句;-(端口与信号(中间连接点(端口与信号(中间连接点及输入及输入/ /输出端点)的连接关系)输出端点)的连接关系)end strend str;VHDLVHDL中的结构设计:元件说明中的结构设计:元件说明component component 元件名元件名portport(信号名:模式(信号名:模式 信号类型;信号类型; . . 信号名:模

4、式信号名:模式 信号类型);信号类型);end componentend component;要点:要点:所用的电路实体应在所用的电路实体应在workwork库或已说明的库中;库或已说明的库中;模块名称和对应端口名称顺序应完全一致;模块名称和对应端口名称顺序应完全一致;实体与元件说明的对比实体与元件说明的对比entity kand2 isport(a, b: in std_logic; y: out std_logic);end kand2;component kand2 port(a, b: in std_logic;y: out std_logic);end component;VHDLV

5、HDL中的结构设计:元件使用中的结构设计:元件使用元件编号:元件名元件编号:元件名 port map port map(信号对应表);(信号对应表);元件使用语句要点:元件使用语句要点:对每一元件应该指定唯一的编号;对每一元件应该指定唯一的编号;元件名称应该与已经有的元件名称完全一致;元件名称应该与已经有的元件名称完全一致;元件使用语句为并行语句,只能在结构体中使元件使用语句为并行语句,只能在结构体中使用,不能在子程序中(函数、过程、进程)使用,不能在子程序中(函数、过程、进程)使用。用。信号对应表的格式信号对应表的格式将本元件的各端口与外部的信号接点或端口建将本元件的各端口与外部的信号接点或

6、端口建立连接;每个连接应该具有一个唯一的名称;立连接;每个连接应该具有一个唯一的名称;例:原来元件的端口:例:原来元件的端口: port(a, b: in std_logic;y: out std_logic);顺序关联法:顺序关联法:port(data,en,out);名称关联法:名称关联法:port(a=data,y=out,b=en);VHDLVHDL中的结构设计的实例中的结构设计的实例质数检测器的结构设计质数检测器的结构设计p.284 p.284 表表4-434-43architecture prime1_arch of prime issignal n3_l,n2_l,n1_l:st

7、d_logic;signal n3l_n0,n3l_n2l_n1,n2l_n1_n0 ,n2_n1l_n0:std_logic;component kinv port (a: in std_logic;y: out std_logic);end component;component kand2 port (a0,a1: in std_logic;y: out std_logic);end component;component kand3 port (a0,a1,a2: in std_logic;y: out std_logic);end component;component kor4 p

8、ort (a0,a1,a2,a3: in std_logic;y: out std_logic);end component;VHDLVHDL中的结构设计的实例中的结构设计的实例begin u1: kinv port map (n(3),n3_l); u2: kinv port map (n(2),n2_l); u3: kinv port map (n(1),n1_l); u4: kand2 port map (n3_l,n(0),n3l_n0); u5: kand3 port map (n3_l,n2_l,n(1),n3l_n2l_n1); u6: kand3 port map (n2_l,

9、n(1),n(0),n2l_n1_n0); u7: kand3 port map (n(2),n1_l,n(0),n2_n1l_n0); u8: kor4 port map (n3l_n0,n3l_n2l_n1,n2l_n1_n0,n2_n1l_n0,f);end prime1_arch;相关元件程序相关元件程序library ieee;use ieee.std_logic_1164.all;entity kinv is port (a: in std_logic; y: out std_logic);end kinv;architecture dat of kinv is begin y=

10、not a;end dat; library ieee;use ieee.std_logic_1164.all;entity kand2 is port (a0,a1: in std_logic; y: out std_logic);end kand2;architecture dat of kand2 is begin y= a0 and a1;end dat;相关元件程序相关元件程序library ieee;use ieee.std_logic_1164.all;entity kand3 is port (a0,a1,a2: in std_logic; y: out std_logic);

11、end kand3;architecture dat of kand3 is begin y= a0 and a1 and a2;end dat; library ieee;use ieee.std_logic_1164.all;entity kor4 is port (a0,a1,a2,a3: in std_logic; y: out std_logic);end kor4;architecture dat of kor4 is begin y=常常量值)量值)port mapport map(信号(信号););赋值后,参量名由具体常量值所替代。赋值后,参量名由具体常量值所替代。generi

12、c generic 语句的使用实例语句的使用实例n n位总线反相器设计位总线反相器设计 p.285 p.285 entity businv is generic (width:positive:=4); port (x: in std_logic_vector (width-1 downto 0); y:out std_logic_vector (width-1 downto 0) ); end businv; generic generic 语句的使用实例语句的使用实例architecture s of businv iscomponent kinv port (a: in std_logi

13、c; y: out std_logic); end component;begin g1: for b in width-1 downto 0 generate u1: kinv port map (x(b),y(b); end generate;end s;generic generic 语句的使用实例语句的使用实例1616位总线反相器设计:位总线反相器设计:architecture s of inv16 iscomponent businv is generic (width:positive:=4); port (x: in std_logic_vector (width-1 downt

14、o 0); y:out std_logic_vector (width-1 downto 0) ); end component;begin u1: businv generic map(16) port map (x,y);end s;元件语句的简化使用元件语句的简化使用宏调用宏调用元件的使用通常需要在结构体中进行说明,可元件的使用通常需要在结构体中进行说明,可能使程序显得很长;能使程序显得很长;在很多综合工具中,允许将这种说明省略,只在很多综合工具中,允许将这种说明省略,只要进行了包含元件的资源说明,就可以在结构要进行了包含元件的资源说明,就可以在结构体中直接使用元件名称和相关的语句。体中

15、直接使用元件名称和相关的语句。宏调用的使用实例宏调用的使用实例1616位总线反相器设计:位总线反相器设计:library ieee;use ieee.std_logic_1164.all;use work.all; entity inv16 is port (x: in std_logic_vector (15 downto 0); y:out std_logic_vector (15 downto 0) ); end inv16; architecture s of inv16 isbegin u1: businv generic map(16) port map (x,y);end s;宏

16、调用的使用实例宏调用的使用实例8 8选选1 1数据选择器设计(数据选择器设计(alteraaltera数据库的使用)数据库的使用)library ieee;use ieee.std_logic_1164.all;library altera;use altera.maxplus2.all; entity mux8_alt is port(a,b,c,gn:in std_logic; d:in std_logic_vector(7 downto 0); y,wn:out std_logic);end mux8_alt; architecture str of mux8_alt isbegin m

17、ux:a_74151b port map(c,b,a,d,gn,y,wn);end str;宏调用的使用实例宏调用的使用实例2424位寄存器的位寄存器的LPMLPM设计(设计(LPMLPM库的使用)库的使用)library ieee; use ieee.std_logic_1164.all;library lpm; use lpm.lpm_components.all;entity reg24lpm is port(clk: in std_logic; d:in std_logic_vector(23 downto 0); q: out std_logic_vector(23 downto 0);end reg24lpm;architecture str of reg24lpm isbegin reg24: lpm_ff generic map (lpm_width =24) port map (data=d(23 downto 0),clock=clk,q=q(23 downto 0);end str;结构设计的小结结构设计的小结与图形输入设计法最接近,可以最直观地进与图形输入设计法最接近,可以最直观地进行逻辑电路图的设计;电路直观,节点清楚,行逻辑电路图的设计;电路直观,

温馨提示

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

评论

0/150

提交评论