1 / 25

VHDL 中的结构设计:元件例化语句

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

ken
Télécharger la présentation

VHDL 中的结构设计:元件例化语句

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VHDL中的结构设计:元件例化语句 设计的要点:建立元件端口之间的连接; 元件:已经定义的电路模块(实体),可以来自标准库中,也可以是自己或他人以前编译过的实体; 元件的基本要点: 元件名输入/输出端口特点;

  2. VHDL中的结构设计的实例 entity butnot is port (x,y: in bit; z: out bit);end butnot; architecture str of butnot is signal 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;

  3. VHDL中的结构设计的实例 begin u1: kinv port map(y,temp); u2: kand2 port map(x,temp,z); end str;

  4. VHDL中的结构设计的特点 Architecture str of 实体名is 元件说明;--(电路设计中使用的元件及端口) 信号说明;--(电路设计中各中间连接点) begin 元件使用语句;--(端口与信号(中间连接点及输入/输出端点)的连接关系) end str;

  5. VHDL中的结构设计:元件说明 component 元件名 port(信号名:模式信号类型; ……. 信号名:模式信号类型); end component; 要点: 所用的电路实体应在work库或已说明的库中;模块名称和对应端口名称顺序应完全一致;

  6. 实体与元件说明的对比 entity kand2 is port(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;

  7. VHDL中的结构设计:元件使用 元件编号:元件名port map(信号对应表); 元件使用语句要点: 对每一元件应该指定唯一的编号; 元件名称应该与已经有的元件名称完全一致; 元件使用语句为并行语句,只能在结构体中使用,不能在子程序中(函数、过程、进程)使用。

  8. 信号对应表的格式 将本元件的各端口与外部的信号接点或端口建立连接;每个连接应该具有一个唯一的名称; 例:原来元件的端口: port(a, b: in std_logic;y: out std_logic); 顺序关联法:port(data,en,out); 名称关联法:port(a=>data,y=>out,b=>en);

  9. VHDL中的结构设计的实例 质数检测器的结构设计p.284 表4-43 architecture prime1_arch of prime is signal n3_l,n2_l,n1_l:std_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 port (a0,a1,a2,a3: in std_logic;y: out std_logic);end component;

  10. VHDL中的结构设计的实例 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,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;

  11. 相关元件程序 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<= 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;

  12. 相关元件程序 library ieee;use ieee.std_logic_1164.all; entity kand3 is port (a0,a1,a2: in std_logic; y: out std_logic);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<= a0 or a1 or a2 or a3;end dat;

  13. VHDL中的结构设计:generate 语句 编号:for 指标in 范围generate 元件编号:元件名port map(信号1,信号2,…);end generate generate语句对同一结构体中使用的多个相同元件进行说明;语句中,指标为整数,不需要定义,各元件对应的信号此时成为数组,其下标由指标范围决定;

  14. VHDL中的结构设计:generate 语句 也可以采用if-generate 语句的形式控制电路的结构变化: 编号:if 关系式generate 元件语句; end generate; 在关系式为true时生成相关的元件;

  15. generate 语句的使用实例 8位总线反相器 p.285 architecture str of inv8 is component kinv port (a: in std_logic; y: out std_logic); end component; begin g1: for b in 7 downto 0 generate u1: kinv port map (x(b),y(b)); end generate; end str;

  16. VHDL中的结构设计:generic 语句 在原有元件中的定义:p.285 表4-46 entity …. generic (参量名:参量类型;….); port ….. 在元件语句中赋值: 元件编号:元件名generic map(参量名=>常量值) port map(信号…); 赋值后,参量名由具体常量值所替代。

  17. generic 语句的使用实例 n位总线反相器设计 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;

  18. generic 语句的使用实例 architecture s of businv is component kinv port (a: in std_logic; 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;

  19. generic 语句的使用实例 16位总线反相器设计: architecture s of inv16 is component 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 component; begin u1: businv generic map(16) port map (x,y); end s;

  20. 元件语句的简化使用—宏调用 元件的使用通常需要在结构体中进行说明,可能使程序显得很长; 在很多综合工具中,允许将这种说明省略,只要进行了包含元件的资源说明,就可以在结构体中直接使用元件名称和相关的语句。

  21. 宏调用的使用实例 16位总线反相器设计: 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 is begin u1: businv generic map(16) port map (x,y); end s;

  22. 宏调用的使用实例 8选1数据选择器设计(altera数据库的使用) 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 is begin mux:a_74151b port map(c,b,a,d,gn,y,wn); end str;

  23. 宏调用的使用实例 24位寄存器的LPM设计(LPM库的使用) 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 is begin reg24: lpm_ff generic map (lpm_width =>24) port map (data=>d(23 downto 0),clock=>clk,q=>q(23 downto 0)); end str;

  24. 结构设计的小结 与图形输入设计法最接近,可以最直观地进行逻辑电路图的设计;电路直观,节点清楚,便于仿真分析调试; 直接进行人工优化,能实现最优化的电路; 使用语句种类最少,能够直接编译综合;

  25. 结构设计的小结 便于实现层次化模块化设计;尤其适合于系统高层的设计; 设计中人为干预较强,设计效果依赖经验,设计过程较长; 进行层次设计时,需要先有底层的元件,才能进行上层元件及电路的设计。

More Related