如何在VHDL中实现n位输入,1位输出的异或门

How to implement xor gate which has n bits input, 1 bit output in the VHDL

作为标题, 实体代码如:

entity n_in_1_out_xor_gate is
    generic(
       bits                 : integer
    );
    port (
        n_in                : in  std_logic(bits-1 downto 0);
        xor_gate_out        : out std_logic
    ); 
end n_in_1_out_xor_gate;

如何实现body的代码? body 对我有帮助吗? 谢谢!

使用vhdl 2008,你可以简单地写:

xor_gate_out <= xor n_in;

如果您坚持使用 vhdl '93,我使用过的所有编译器都支持 std_logic_misc 包含缩减函数的非标准库:

xor_gate_out <= xor_reduce(n_in);