VHDL配置无法找到组件

时间:2014-09-16 21:41:27

标签: vhdl

以下代码无法正常运行。我一直收到以下错误:

** Error: HA_Config.vhd(38): Component instance "HA_Inst : HA_Comp" not found. ** Error: HA_Config.vhd(40): VHDL Compiler exiting

library ieee;
use ieee.std_logic_1164.all;

entity HA_Entity is
  port (
    i_bit1  : in std_logic;
    i_bit2  : in std_logic;
    --
    o_sum   : out std_logic;
    o_carry : out std_logic
    );
end HA_Entity;


architecture HA_Arch of HA_Entity is

  component HA_Comp is
    port (
      i_bit1  : in  std_logic;
      i_bit2  : in  std_logic;
      --
      o_sum   : out std_logic;
      o_carry : out std_logic
      );
  end component HA_Comp;

begin 

  o_sum   <= i_bit1 xor i_bit2;
  o_carry <= i_bit1 and i_bit2;

end HA_Arch;

configuration HA_Config of HA_Entity is
  for HA_Arch  
    for HA_Inst : HA_Comp
      use entity HA_Entity(HA_Arch);
    end for;
  end for;
end HA_Config;

1 个答案:

答案 0 :(得分:1)

配置将组件实例绑定到特定实体和 建筑。配置中的绑定部分是:

for HA_Inst : HA_Comp
  use entity HA_Entity(HA_Arch);
end for;

但是组件HA_Inst没有名为HA_Comp的组件实例, 因此,只是HA_Comp的体系结构部分中声明的组件HA_Arch 错误:

  

组件实例&#34; HA_Inst:HA_Comp&#34;没找到。

HA_Comp实际上并未在任何地方使用,因此可以删除它。它,它 看起来像循环引用,因为HA_Entity被指定在内部使用 本身有configuration ... HA_Entity ... use entity HA_Entity ...

如果打算允许HA_Arch的不同实现,那么它 可以看起来像:

library ieee;
use ieee.std_logic_1164.all;

entity HA_Entity is
  port (
    i_bit1  : in std_logic;
    i_bit2  : in std_logic;
    --
    o_sum   : out std_logic;
    o_carry : out std_logic
    );
end HA_Entity;


architecture HA_Arch of HA_Entity is

  component HA_Comp is
    port (
      i_bit1  : in  std_logic;
      i_bit2  : in  std_logic;
      --
      o_sum   : out std_logic;
      o_carry : out std_logic
      );
  end component HA_Comp;

begin

  HA_Inst : component HA_Comp
    port map(
      i_bit1 => i_bit1,
      i_bit2 => i_bit2,
      o_sum  => o_sum,
      o_carry => o_carry);

end HA_Arch;


library ieee;
use ieee.std_logic_1164.all;

entity HA_Comp_Entity is
  port (
    i_bit1  : in std_logic;
    i_bit2  : in std_logic;
    --
    o_sum   : out std_logic;
    o_carry : out std_logic
    );
end HA_Comp_Entity;

architecture HA_Comp_Arch_1 of HA_Comp_Entity is
begin

  o_sum   <= i_bit1 xor i_bit2;
  o_carry <= i_bit1 and i_bit2;

end HA_Comp_Arch_1;


use work.all;

configuration HA_Config of HA_Entity is
  for HA_Arch
    for HA_Inst : HA_Comp
      use entity HA_Comp_Entity(HA_Comp_Arch_1);
    end for;
  end for;
end HA_Config;