GHDL testbench 构建错误 - 我该如何解决?

GHDL testbench build error - how can I fix it?

我是 VHDL 的初学者。我正在使用 GHDL 来实现我的 VHDL 代码并对其进行测试。我为异或门编写了一个简单的 VHDL 行为代码。我正在尝试编写一个测试平台来测试异或门。

异或VHDL代码:

library ieee;
use ieee.std_logic_1164.all;

entity XORGate is
port(
    xora, xorb : in std_logic;
    xorout : out std_logic
);
end XORGate;

architecture behave of XORGate is
begin
   process(xora, xorb)
   begin
       xorout <= xora xor xorb;
   end process;
end behave;

异或测试平台 VHDL 代码:

library ieee;
use ieee.std_logic_1164.all;

entity XORGate_tb is
end XORGate_tb;

architecture structural of XORGate_tb is
component XORGate
   port(
      xa, xb : in std_logic;
      xout : out std_logic
   );
end component;

signal xa, xb, xout : std_ulogic;

begin
xorgate1 : XORGate port map(xa, xb, xout);
process
  begin
     xa <= '0';
     xb <= '0';
     wait for 100 ns;

     xa <= '0';
     xb <= '1';
     wait for 100 ns;

     xa <= '1';
     xb <= '0';
     wait for 100 ns;

     xa <= '1';
     xb <= '1';
     wait for 100 ns;

     assert false report "Reached end of test";
     wait;
end process;
end structural;

当我使用以下命令时: “ghdl -s XORGate_tb.vhdl”检查语法 "ghdl -a XORGate_tb.vhdl" 分析文件 没有给出错误。当我使用以下命令时 “ghdl -e XORGate_tb” 我收到以下错误

XORGate_tb.vhdl:18:1:error: for default port binding of component instance "xorgate1":
XORGate_tb.vhdl:18:1:error: signal interface "xa" has no association in entity "xorgate"
XORGate_tb.vhdl:18:1:error: signal interface "xb" has no association in entity "xorgate"
XORGate_tb.vhdl:18:1:error: signal interface "xout" has no association in entity "xorgate"

我无法修复错误。尝试更改信号名称,但仍然出现相同的错误。我该如何解决上述错误?

实体中的端口名称与组件不匹配。在组件中,您有 xaxbxout。但在实体中它们是 xoraxorbxorout.

为了避免这样的问题,我建议使用直接实例化,因为实例化和实体之间的不匹配是语法错误,您可以简单地删除组件,而不是在两个不同的地方使用实际上相同的代码:

xorgate1 : entity work.XORGate port map(xa, xb, xout);