gpt4 book ai didi

compilation - 当一个实体上有多个架构时会发生什么?

转载 作者:行者123 更新时间:2023-12-04 00:29:11 25 4
gpt4 key购买 nike

假设一个实体定义了两个架构。这两种架构使用相同的实体(显然),随后两者将输出引脚设置为不同的值。我的问题是,程序(模拟器)如何确定输出应该是什么(即选择哪种架构)?

这是一个例子:

library ieee;
use ieee.std_logic_1164.all;

entity Exercise_4 is
generic (n : integer := 4);
port(
a, b : std_logic_vector (n-1 downto 0);
clk, rst : std_logic;
q, qn : buffer std_logic_vector (n-1 downto 0));
end;

architecture one of Exercise_4 is
begin
process (clk, rst)
begin
if rst = '0' then
q <= (others=>'0');
elsif (clk' event and clk = '0') then
q <= a ;
end if;
end process;

process (clk, rst)
begin
if rst = '0' then
qn <= (others=>'1');
elsif (clk' event and clk = '0') then
for i in a'range loop
qn(i) <= not q(i) ;
end loop;
end if;
end process;
end;

architecture two of Exercise_4 is
begin
process (clk,rst)
begin
if rst = '0' then
q <= (others=>'0');
qn <= (others=>'0');
elsif (clk' event and clk = '0') then
q <= a;
qn <= b ;
end if;
end process;
end;

我做了一个模拟,看到 q 得到了 a 分配的值和 strong>qn 获取分配的 b 值。看来编译器选择了第二种架构我不明白为什么程序决定这样做。

谢谢。

最佳答案

如果您没有指定自己选择哪种架构²,那么编译器将采用“与实体声明关联的最近分析的架构体”(假设编译器符合 IEEE 标准)[1]。

² 您可以选择您喜欢的架构,例如在更高设计级别的组件声明部分(您映射信号的地方):

entity topentity is 
end;

architecture toparch of topentity is

-- component instantiation
component Exercise_4 is
generic (n : integer := 4);
port(
a, b : std_logic_vector (n-1 downto 0);
clk, rst : std_logic;
q, qn : buffer std_logic_vector (n-1 downto 0));
end component Exercise_4;

begin

-- component mapping
E4: entity work.Exercise_4(one)
generic map ( .. )
port( .. );

end architecture toparch;

[1] IEEE Std 1076-2008 7.3.3 默认绑定(bind)指示,第 4 段。


免责声明:答案是在上述评论的帮助下构建的。无侵犯版权之意。 ;P

关于compilation - 当一个实体上有多个架构时会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29614349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com