Vhdl 组件与实体的默认通用值

Vhdl 组件与实体的默认通用值,vhdl,Vhdl,考虑以下代码: entity foo is generic ( X : natural := 9 ); end entity foo; architecture behav of foo is begin process begin report foo'instance_name & " : " & integer'image(X) severity note; wait; end process; end architectu

考虑以下代码:

entity foo is
  generic
  (
    X : natural := 9
  );
end entity foo;

architecture behav of foo is
begin
  process
  begin
    report foo'instance_name & " : " & integer'image(X) severity note;
    wait;
  end process;
end architecture behav;

entity bar is
end entity bar;

architecture behav of bar is
  component foo is
  generic
  (
    X : natural := 3
  );
  end component foo;
begin
  foo1 : entity work.foo;
  foo2 : foo;
end architecture behav;
执行此代码,我们得到:

# ** Note: :bar(behav):foo2@foo(behav): : 3
#    Time: 0 ps  Iteration: 0  Instance: /bar/foo2
# ** Note: :bar(behav):foo1@foo(behav): : 9
#    Time: 0 ps  Iteration: 0  Instance: /bar/foo1
似乎未绑定泛型的默认值选择取决于实例化的类型。在一种特殊情况下,这已成为一个问题,其中泛型和实体不匹配。我们经常使用的用例如下

entity foo is
  generic
  (
    X : natural := 9
  );
end entity foo;

package foo_pkg is
  component foo is
  generic
  (
    X : natural
  );
  end component foo;
end package foo_pkg;
如果在使用间接实例化时未绑定
X
,则会导致编译错误,例如:

architecture rtl of bar is
begin
  foo_inst : foo;
end architecture rtl;

我想确认这是特定于VHDL的。我通读了标准(第5.2节),但很难确定这种行为是否正确。

请参阅@user1155120中的主题我的第一个示例只是为了证明输出的
X
值存在差异。问题在于,相对于1076标准,这种行为是否正确。如果是这样,则后面代码中看到的编译错误是有意义的。“第一个示例”行为和错误在6.5.6.2“中定义。泛型常量的值可以由泛型关联列表中相应的实际值指定。如果没有为给定的形式泛型常量指定此类实际值(因为正式泛型是非关联的,或者因为实际泛型是开放的),如果为该泛型指定了默认表达式,则此表达式的值就是泛型的值。如果未为给定的形式泛型常量指定实际值,并且相应的接口元素中不存在默认表达式,则为错误。“a可能是(带有use子句)对于您的问题前面的代码。在分析架构rtl of bar analysis期间发生错误,如果我想确认这是VHDL特有的,那么答案很明确,对未来的读者来说是肯定的,没有什么用处。感谢您的回答@user1155120。我只是想确定这是否正确根据1076,行为是正确的,而不是特定的工具错误。很明显,一些供应商的实现比其他供应商更松散。在更改了模拟器供应商之后,我们现在受到了这个特殊情况的影响。由于工具在行为上不同,我试图确定什么是合适的行为。