0

コンピューター構造の問題、

2 つの 4:2:1 MUX と定数 0 と 1 を使用して全加算器を構築します。最小限の定数を使用します。

明らかに、この質問は not ゲートを使用しても解決できますが、ゲートを使用しない質問に興味があります。

4

4 に答える 4

2

考えられるすべての入力の組み合わせをチェックする単純な小さな C# プログラムを作成したところ、解決策を見つけることができませんでした。したがって、なんらかのプログラム エラーを起こさない限り、この問題の解決策はありません。

using System;

class Program
{
    static void Main(string[] args)
    {
        bool[] aValues = new bool[] { false, false, false, false, true, true, true, true };
        bool[] bValues = new bool[] { false, false, true, true, false, false, true, true };
        bool[] cValues = new bool[] { false, true, false, true, false, true, false, true };
        bool[] carryValues = new bool[] { false, false, false, true, false, true, true, true };
        bool[] constantFalse = new bool[] { false, false, false, false, false, false, false, false };
        bool[] constantTrue = new bool[] { true, true, true, true, true, true, true, true };

        bool[] sumValues = new bool[] { false, true, true, false, true, false, false, true };

        bool[][] allInputs = new bool[][] { aValues, bValues, cValues, carryValues, constantFalse, constantTrue };

        for (int controlOneIndex = 0; controlOneIndex < allInputs.Length; controlOneIndex++)
            for (int controlTwoIndex = 0; controlTwoIndex < allInputs.Length; controlTwoIndex++)
                for (int inputOneIndex = 0; inputOneIndex < allInputs.Length; inputOneIndex++)
                    for (int inputTwoIndex = 0; inputTwoIndex < allInputs.Length; inputTwoIndex++)
                        for (int inputThreeIndex = 0; inputThreeIndex < allInputs.Length; inputThreeIndex++)
                            for (int inputFourIndex = 0; inputFourIndex < allInputs.Length; inputFourIndex++)
                            {
                                for (int calculationIndex = 0; calculationIndex < sumValues.Length; calculationIndex++)
                                {
                                    if (MuxResult(allInputs[controlOneIndex][calculationIndex],
                                                allInputs[controlTwoIndex][calculationIndex],
                                                allInputs[inputOneIndex][calculationIndex],
                                                allInputs[inputTwoIndex][calculationIndex],
                                                allInputs[inputThreeIndex][calculationIndex],
                                                allInputs[inputFourIndex][calculationIndex]) != sumValues[calculationIndex])
                                    {
                                        goto tryNextValue;
                                    }
                                }
                                Console.WriteLine("Success: controls: {0} {1}   inputs: {2} {3} {4} {5}",
                                    controlOneIndex, controlTwoIndex, inputOneIndex, inputTwoIndex, inputThreeIndex, inputFourIndex);
                            tryNextValue: ;
                            }
        Console.WriteLine("done");
        Console.ReadLine();
    }

    private static bool MuxResult(bool controlOne, bool controlTwo, bool inputOne, bool inputTwo, bool inputThree, bool inputFour)
    {
        if (controlOne)
        {
            if (controlTwo)
                return inputFour;
            else
                return inputTwo;
        }
        else
        {
            if (controlTwo)
                return inputThree;
            else
                return inputOne;
        }
    }
}
于 2011-03-10T17:25:23.260 に答える
2

4 入力マルチプレクサを意味する場合は、( ab、およびを追加するc) ことができます。

carry = mux(/* controls */ a, b, /* inputs */ 0, c, c, 1);

sum他のゲートなしで取得する方法がわかりません。1 つのオプションは (AND と OR を使用):

sum = mux(/* controls */ carry, a, /* inputs */ b|c, 0, 1, b&c);

XOR を使用する場合 (おそらく明らかです):

sum = mux(/* controls */ a, b^c, /* inputs */ 0, 1, 1, 0);

2 つのマルチプレクサでそれができない理由のスケッチを次に示します。

2 つのマルチプレクサと 2 つの出力があるため、各マルチプレクサは 1 つの出力を生成する必要があります。したがって、から計算するか、sumから計算する必要があります。NOT ゲートなしでは 3 つの入力だけでは計算できないため、最初に計算する必要があります。出来るよ; 次に、入力とから取得する必要があります。入力が対称であるため、マルチプレクサのコントロールは 2 つの入力または 1 つの入力と のいずれかになります。最初のケースは、最初に計算できないのと同じ理由で失敗します。真理値表とと 1 つの入力 ( と呼ぶ) のすべての可能な組み合わせを見ると、 との場合を一意に計算する方法はありません。carrycarrysumsumcarrysumcarrysumcarrysumcarryasumcarryasumマルチプレクサの各データ入力への入力として 1 つの変数または定数のみを使用して同じです。

于 2011-03-10T16:21:54.777 に答える
1
A B Cin S cout
0 0 0   0 0
0 0 1   1 0
0 1 0   1 0
0 1 1   0 1
1 0 0   1 0
1 0 1   0 1
1 1 0   0 1
1 1 1   1 1

A2 つの 2*1 マルチプレクサへの選択ラインとして、入力番号 1 の入力番号 0 の最初のマルチプレクサにあるB XOR Cin- > 入力番号 0 の 2 番目のマルチプレクサにあるB XNOR Cinこのマルチプレクサは、入力番号 1 にある ->このため。SB AND CinB OR CinCout

于 2012-03-18T16:58:44.320 に答える
-1

VB の全加算器

Class fullAdder

    Private _A As Boolean
    Private _B As Boolean
    Private _Cin As Boolean
    Private _Sum As Boolean
    Private _Cout As Boolean

    Public Sub New()
        Me.A = False
        Me.B = False
        Me.Cin = False
    End Sub

    Public Sub SetInputs(a As Boolean, b As Boolean, cIn As Boolean)
        Me.A = a
        Me.B = b
        Me.Cin = cIn
    End Sub

    'Inputs           Outputs
    'A  B  Cin        Cout  S
    '0  0   0         0     0
    '1  0   0         0     1
    '0  1   0         0     1
    '1  1   0         1     0
    '0  0   1         0     1
    '1  0   1         1     0
    '0  1   1         1     0
    '1  1   1         1     1 

    Public Sub DoAdd()
        'debugIn()
        Dim ABxor As Boolean = Me.A Xor Me.B
        Me.Sum = ABxor Xor Me.Cin
        Dim ABxorAndCin As Boolean = ABxor And Me.Cin
        Dim ABand As Boolean = Me.A And Me.B
        Me.Cout = ABxorAndCin Or ABand
        'debugOut()
    End Sub

    Private Sub debugIn()
        Debug.WriteLine("'I {0} {1} {2}", Me.A, Me.B, Me.Cin)
    End Sub

    Private Sub debugOut()
        Debug.WriteLine("'O {0} {1}", Me.Cout, Me.Sum)
        Debug.WriteLine("")
    End Sub

    Public Property Sum() As Boolean
        Get
            Return Me._Sum
        End Get
        Set(ByVal value As Boolean)
            Me._Sum = value
        End Set
    End Property

    Public Property Cout() As Boolean
        Get
            Return Me._Cout
        End Get
        Set(ByVal value As Boolean)
            Me._Cout = value
        End Set
    End Property

    Public Property A() As Boolean
        Get
            Return Me._A
        End Get
        Set(ByVal value As Boolean)
            Me._A = value
        End Set
    End Property

    Public Property B() As Boolean
        Get
            Return Me._B
        End Get
        Set(ByVal value As Boolean)
            Me._B = value
        End Set
    End Property

    Public Property Cin() As Boolean
        Get
            Return Me._Cin
        End Get
        Set(ByVal value As Boolean)
            Me._Cin = value
        End Set
    End Property

End Class
于 2011-03-14T21:59:37.703 に答える