4 输入与非门使用 2 输入与非

问题描述 投票:0回答:1

我正在尝试仅使用 2 个输入 nand 创建一个 4 输入 nand,而这个并没有给我正确的模拟。

entity NAND4_YourName is
    Port ( A, B, C, D : in STD_LOGIC;
           Y : out STD_LOGIC );
end NAND4_YourName;

architecture Behavioral of NAND4_YourName is
    signal AB_NAND, CD_NAND: STD_LOGIC;
begin
    -- First stage: NAND the pairs of inputs
    AB_NAND <= A nand B;
    CD_NAND <= C nand D;
    
    -- Second stage: NAND the results of the first stage together
    Y <= AB_NAND nand CD_NAND;
end Behavioral;
vhdl
1个回答
0
投票

您的子表达式 nand(nand(A, B), nand(C, D)) 不等于 nand(A, B, C, D)。

与非门的定义是,如果其所有输入均为 TRUE,则输出 FALSE,否则如果任何输入为 FALSE,则结果为 TRUE。您可能听说过 NAND 门是通用的,所以您可以这样做。

您需要做的是获取所有四个信号的与,然后将其反转。要制作 NAND 门的 AND 门,您只需对输入进行 NAND 运算,然后将输出 NAND 馈送到另一个 NAND 的两个输入中,从而反转输出。

architecture Behavioral of NAND4_YourName is
    signal AB_NAND, CD_NAND, AB_AND, CD_AND: STD_LOGIC;
begin
    -- First stage: NAND the pairs of inputs
    AB_NAND <= A nand B;
    CD_NAND <= C nand D;

    -- Second stange: invert the NAND outputs to make them AND
    AB_AND <= AB_NAND nand AB_NAND;
    CD_AND <= CD_NAND nand CD_NAND;
    
    -- Third stage: NAND the results of the second stage together
    Y <= AB_AND nand CD_AND;
end Behavioral;

FD 我没有编写任何 VHDL,因此这在语法上可能是无效的。但你明白了,对吧?

© www.soinside.com 2019 - 2024. All rights reserved.