首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用2输入xor代码实现4输入xor

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

Stack Overflow用户
提问于 2014-10-07 15:29:28
回答 1查看 1.2K关注 0票数 1

假设我下面只有一个2输入异或的实体来创建一个4输入异或。

代码语言:javascript
复制
entity exclusive_or is
 port(A,B: in BIT; S: out BIT);
end exclusive_or;

我知道我要宣布一些信号,但不知道怎么做。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-07 15:55:04

首先,让我们在纸上画出我们想要做的事情:

然后,我们将其转换为VHDL:

代码语言:javascript
复制
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;
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26239689

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档