Vhdl 使用2输入xor代码实现4输入xor

Vhdl 使用2输入xor代码实现4输入xor,vhdl,Vhdl,假设我只有2输入XOR下面的实体来创建4输入XOR entity exclusive_or is port(A,B: in BIT; S: out BIT); end exclusive_or; 我知道我必须声明一些信号,但不知道如何声明。首先,让我们在纸上画出我们想要做的事情: 然后,我们将其转换为VHDL: 首先,让我们在纸上画出我们想要做的事情: 然后,我们将其转换为VHDL: entity exclusive_or_4 is port( A,B,C,D: in BIT;

假设我只有2输入XOR下面的实体来创建4输入XOR

entity exclusive_or is
 port(A,B: in BIT; S: out BIT);
end exclusive_or;
我知道我必须声明一些信号,但不知道如何声明。

首先,让我们在纸上画出我们想要做的事情: 然后,我们将其转换为VHDL: 首先,让我们在纸上画出我们想要做的事情: 然后,我们将其转换为VHDL:
entity exclusive_or_4 is port(
    A,B,C,D: in BIT;
    S: out BIT
);
end entity;

architecture rtl of exclusive_or_4 is
    signal output : bit_vector(1 downto 0);
begin

    U0: component exclusive_or port map (
        A => A,
        B => B,
        S => output(0)
    );

    U1: component exclusive_or port map (
        A => C,
        B => D,
        S => output(1)
    );

    U2: component exclusive_or port map(
        A => output(0),
        B => output(1),
        S => S
    );

end architecture;