组件实例化错误



对于以下 VHDL 代码:

library ieee;
use ieee.std_logic_1164.all;
entity dff is
  port(
      d, clk: in std_logic;
      q: out std_logic);
end dff;
architecture behave of dff is
  begin
    process(clk)
      begin
      if(clk = '1') then
        q<= d;
    end if;
  end process;
end behave; 

---------------------------------------------------------------------

和一个测试平台:

library ieee;
use ieee.std_logic_1164.all;
entity dff is
end dff;
architecture behave of dff is
  component dff is
port(d, clk: in std_logic;
     q: out std_logic);

 end component;

    signal  d_in: std_logic;
    signal  clk_in: std_logic;
    signal  q_out: std_logic;
begin
  d_ff : dff port map( d_in, clk_in, q_out);
  process
    begin
      if(clk_in = '1') then
      q_out<= d_in;
      end if;
  end process;
end behave;  

尝试模拟模型时显示以下错误:

#Error 加载设计
以下组件端口不在实体上:    
q
     clk
     d

测试平台的实体名称也是dff 。您需要给它一个不同的名称(例如 dff_tb (。因此,当您编译测试平台时,它会覆盖其他dff实体。