vhdl例化.docx

上传人:小飞机 文档编号:3168416 上传时间:2023-03-11 格式:DOCX 页数:3 大小:37.44KB
返回 下载 相关 举报
vhdl例化.docx_第1页
第1页 / 共3页
vhdl例化.docx_第2页
第2页 / 共3页
vhdl例化.docx_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《vhdl例化.docx》由会员分享,可在线阅读,更多相关《vhdl例化.docx(3页珍藏版)》请在三一办公上搜索。

1、vhdl例化元件声明是对VHDL模块的说明,使之可在其他被调用,元件声明可放在程序包中,也可在某个设计的构造体中声明。 元件例化指元件的调用。元件声明及元件例化的语法分别如下: 元件声明: component元件实体名 prot; end compnent; 元件例化: 例化名:实体名,即元件名port map; 例如,在一个设计中调用一个模为10的计数器cntm10和一个七段译码器decode47构成如下电路,则该调用过程孥即元件例化。 VHDL描述如下: library ieee; use ieee.std_logic_1164.all; entity cntvh10 is port (r

2、d, ci, clk : in std_logic; co : out std_logic; qout : out std_logic_vector (6 downto 0); end cntvh10; architecture arch of cntvh10 is Component decode47 is port (adr : in std_logic_vector (3 downto 0); decodeout : out std_logic_vector (6 downto0); end Component; 元件声明 Component cntm10 is Port ( ci :

3、in std_logic; nreset : in std_logic; clk : in std_logic; co : out std_logic; qcnt : buffer std_logic_vector (3 downto 0); end Component; signal qa: std_logic_vector (3 downto 0); begin u1 : cntm10 port map (ci, rd, clk, co, qa); 元件例化 u2 : decode47 port map ( decodeout=qout, adr=qa); end arch; 元件例化时的

4、端口列表可按位置关联方法,如u1,这种方法要求的实参所映射的形参的位置同元件声明中的一样;元件例化时的端口列表也可按名称关联方法映射实参与形参,如u2。格式为。这种方法与位置无关。 参数化元件可增加元件例化的灵活性。所谓参数化元件是指元件的规模可以通过引用参数的形式指定的一类元件。例如,下面定义了一个位数可调的计数器: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; ues ieee.std_logic_unsigned.all; entity cntnbits is generic (cntwi

5、dth:integer:=4); 定义了一个可调参数 port ( ci : in std_logic; nreset : in std_logic; clk : in std_logic; co : out std_logic; qcnt : buffer std_logic_vector (3 downto 0); end cntmbits; architecture behave of antnbits is constant allis1 : std_logic_vector (cntwidth-1 downto 0) := (others=1); begin Co =1 when (

6、qcnt=all is 1 and ci=1) else0; Process (clk) Begin if (nreset=0) then Qcnt0); elsif (clkevent and clk=1) then if (ci=1) then Qcnt=qcnt+1; end if; end if; end process; end behave; 可以算出,该计数器同第1部分的四位计数器相比,改动不大,其中在实体处增加了一行: generic (cntwidth:integer:=4) 该行定义了一个整数cntwidth并赋初值4,用它代替原来的固定的计数器长度,若想设计的计数器位数8位,仅需将cntwidth初值赋为8: generic (cntwidth : integer :=8); 若以此计数器为元件,则元件声明为: Component cntnbit is generic (cntwidth:integer:=4); port ( ci : in std_logic; nreset : in std_logic; clk : in std_logic; co : out std_logic; qcnt : buffer std_logic_vector (cntwidth-1 downto 0); end Component;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号