VHDL中元件(模块)的例化

**记录学习,记录成长

1.VHDL中元件的例化可分为两部分

第一部分:元件声明,声明要例化的元件。
第二部分:元件例化,声明结束之后就可以对元件进行例化或者说是调用了。
其中声明部分在结构体的说明语句部分(即architecture和begin之间)。而调用部分同一个结构体的电路描述部分(即begin之后)。

2.元件声明格式:

Component 元件名称 is
Port(元件端口信息);
End component;
提示:元件声明和实体声明一致,元件就是一个实体。

3.元件例化语句

例化名 :元件名称 port map 元件端口列表;

提示:port map为端口映射的意思。相互连接的两个端口,状态和数据类型必须一致。
端口连接方式有两种:一种是位置关联方式。一种是端口信号名称关联方式。

3.1 位置关联方式

位置关联方式下,端口的连接与端口列表中的顺序是一一对应的。
箭头的指向说明了信号间的连接关系,其连接方式是按顺序对应的

3.2 端口信号名称关联方式

端口信号名称关联方式比较直观,一般推荐使用此种关联方式。
名称关联方式比较直观,推荐使用

此外,通过查找发现还有事先不进行声明也可进行例化的方式:

例化格式:
例化名 : entity work . 元件名(端口列表)
(https://blog.csdn.net/wyf100/article/details/8616491)

test1 :entity work.test port map(clk2, o2 );

#学习代码1

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity test is
port(
	clk1 : out std_logic := '0';
	o1  : out integer := 2
	);
end test;

architecture teststr of test is
  begin

  process 
  begin
   wait for 10 ns;
    clk1 <= '1';
   wait for 10 ns;
    clk1 <= '0';
    end process;
end teststr;

#学习代码2

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity tb is 
port(
	clk2 : out std_logic;
	o2   : out integer 
	);
end tb;

architecture tb_str of tb is
component test is 
port(
	clk1 : out std_logic;
	o1   : out integer 
	);
end component;
begin
test1 : test port map(clk2, o2 );
end tb_str;

#学习代码3

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity tb is 
port(
	clk2 : out std_logic;
	o2   : out integer 
	);
end tb;

architecture tb_str of tb is

begin
test1 :entity work.test port map(clk2, o2 );
end tb_str;

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值