Wie konstruiere ich ein XOR-Gatter mit nur 4 NAND-Gattern?


15

xorTor, jetzt muss ich dieses Tor mit nur 4 nandTor bauen

a b out
0 0 0
0 1 1
1 0 1
1 1 0

das xor = (a and not b) or (not a and b), was

EIN¯B+EINB¯

Ich kenne die Antwort, aber wie komme ich aus der Formel zum Gate-Diagramm?

xor gate

BEARBEITEN

Ich meine intuitiv, für mich sollte ich dieses bekommen, wenn ich es Schritt für Schritt mache, gefolgt von der Definition xor = (a and not b) or (not a and b).

A¯B¯AB¯¯¯

und xorwird mit 5 nandToren gebaut (erstes # 1 Bild unten)

xoder Tor 2

Meine Frage ist eher wie folgt: Stellen Sie sich vor, die erste Person in der Geschichte könnte diese Formel herausfinden, wie sie (der nandDenkprozess) Schritt für Schritt die 4- Lösung aus dieser Formel erhalten kann.

A¯B+AB¯

Ich bin sicher, Sie wissen, wie man ein XOR (oder eine andere Funktion) nimmt und es in eine Ersatzschaltung umwandelt, die nur NAND verwendet (was immer möglich ist, da NAND vollständig ist ). Wenn Sie sich jedoch die Frage stellen, wie diese Formel auf die Verwendung von nur 4 NANDs oder allgemein weniger als NANDs reduziert werden kann und ob es überhaupt möglich ist, eine Ersatzschaltung mit k NANDs zu erhalten, bin ich mir nicht sicher, ob es eine einfache gibt antworte dafür. kk
Ran G.

Nachfolgend finden Sie zwei Antworten auf das Problem. Meins ist ganz offen darüber, dass Sie (a posteriori) einen Weg finden können, um die gewünschte Konstruktion zu finden, indem Sie das Endergebnis im Voraus kennen, das in der Frage angegeben wurde und im Internet verfügbar ist. Es ist eindeutig die einfachere Art, etwas zu tun, absurd, wie es scheinen mag, ohne ein allgemeines Verfahren anzugeben, das keine Antwort gibt. Daher interessiert mich, warum Wähler eine Antwort der anderen vorziehen, wenn sie dies tun ... wenn Sie sich die Zeit für einen kurzen Kommentar nehmen. Danke im Voraus.
Babou

Diese Frage muss als unklar abgeschlossen werden. Ich denke, es könnte ziemlich klar sein, was das OP verlangt, und noch interessanter, wenn sich das OP die Mühe macht, auf die verschiedenen Benutzer zu reagieren, die versuchen, ihm zu antworten,
babou

electronics.stackexchange.com/questions/84714/... - diese Frage ist allgemeiner, geben die Antworten mehr Informationen zu einem allgemeinen Ansatz , dieses Problem zu lösen, und diese Antwort electronics.stackexchange.com/a/84803 zeigt , wie herzuleiten NAND Darstellung für den XOR-Operator
Anton Trunov

Ich habe mit ähnlichen Problemen herumgespielt und gerade ein Programm geschrieben, das alles systematisch ausprobiert hat ... Gut für bis zu vier Eingänge, bei denen es nur 65.536 mögliche Funktionen gibt. Bei etwas komplizierteren Schaltungen konnte ich auch die Verzögerungen optimieren und optimale Schaltungen finden, wenn ein oder zwei Eingänge später als andere verfügbar waren. Schaltungen mit 5 Eingängen = 2 ^ 32 möglichen Funktionen wären wahrscheinlich mit brachialer Gewalt machbar.
gnasher729

Antworten:


11

Aus dieser Formel? Es kann getan werden. Aber es ist einfacher, mit diesem zu beginnen: (mit einer anderen Notation hier)

a ^ b = ~(a & b) & (a | b)

Ok, was jetzt? Schließlich sollten wir ableiten ~(~(~(a & b) & a) & ~(~(a & b) & b))(was aussieht, als hätte es 5 NANDs, aber genau wie das Schaltbild hat es einen Unterausdruck, der zweimal verwendet wird).

Also mach etwas, das aussieht ~(a & b) & a(und dasselbe, aber mit einem bam Ende) und hoffe, dass es dabei bleibt: ( andverteilt über or)

(~(a & b) & a) | (~(a & b) & b)

Wende einfach DeMorgan an, um diese Mitte orin eine zu verwandeln and:

~(~(~(a & b) & a) & ~(~(a & b) & b))

Und das ist es.


9

Ich denke, Sie fordern diesen Beweis:

A^B = (!A)B + A(!B)
    = !!((!A)B) + !!(A(!B))
    = !(!!A + !B) + !(!A + !!B)
    = !(A + !B) + !(!A + B)
    = !((A + !B)(!A + B))
    = !(A(!A) + AB + (!A)(!B) + B(!B))
    = !(AB + (!A)(!B))
    = !(AB)(!(!A)(!B))
    = !(AB)(!!A + !!B)
    = !(AB)(A+B)
    = !(AB)A + !(AB)B
    = !!(!(AB)A + !(AB)B)
    = !((!(!(AB)A))(!(!(AB)B)))

Obwohl anscheinend 5 NANDs in der resultierenden Gleichung verwendet werden, wird das Duplikat !(AB)nur einmal verwendet, wenn Sie seine Schaltung entwerfen.


Es tut mir leid, aber bedeutet A ^ B nicht A UND B? Es scheint, als wollten Sie XOR beweisen, welches Symbol ⊕ oder should sein soll. Aber dieser Beweis war genau das, wonach ich gesucht habe, danke!
Osiixy

5

Da Sie bereits die Diagrammantwort haben, die Sie in Wikipedia durch Eingabe des Fragentitels in Google leicht finden können , und zwar als .png-Diagramm, das mit Ihrem identisch ist, sollte es für Sie einfach sein, die Formel zu finden, indem Sie sie aus diesem Diagramm extrahieren. Angesichts der Definition als NAND - NAND(A,B)=AB¯:

  • Das am weitesten links liegende Gate ergibt ;C=AB¯

  • Das obere Gate gibt ;D1=AC¯

  • Das obere Gate gibt , da die NAND commutatve ist wie die UND - ;D2=BC¯

  • Das rechte Tor gibt .E=D1D2¯

Wenn wir alles zusammenfassen, bemerken wir das zuerst

C=AB¯=A¯+B¯

D1¯=AC=A(A¯+B¯)=AA¯+AB¯=0+AB¯=AB¯

Ähnlich: D2¯=BA¯

So ist
E=D1D2¯=D1¯+D2¯=AB¯+BA¯

Welches ist genau die Definition von XOR. Sie können dies alles einfach rückgängig machen, wenn Sie von Ihren ursprünglichen Daten ausgehen möchten, anstatt nur die Antwort zu überprüfen.

Die Antwort ohne Vorkenntnisse finden

Hiermit soll die explizite Anfrage beantwortet werden, die als Bearbeitung der Frage hinzugefügt wurde, um die Lösung von Grund auf zu finden. Da es sich bei der Frage um einen Denkprozess handelt, gebe ich alle Details an.

AB

XOR(A,B)=AB¯+BA¯.

Wir können also versuchen zu erraten, welche Art von Eingang zu diesem Gatter den gewünschten Ausgang erzeugen würde.

NAND(X,Y)=XY¯=X¯+Y¯

Wenn wir diese letzte Formel mit dem Ergebnis vereinen , das wir erhalten müssen, erhalten wir:

  • X¯=AB¯X=AB¯¯=A¯+B.

  • Y=A¯B¯=A+B¯.

Beachten Sie, dass dies nur die einfachste Möglichkeit ist. Es gibt andere Eingangspaare, die das gewünschte Ergebnis liefern würden, da wir keine freie Algebra vereinen, da NAND gleichwertige Eigenschaften hat. Aber das versuchen wir erst einmal.

XYAB

Wir könnten versuchen, die Vereinigungsprozedur zu wiederholen (ich tat es), aber dies wird uns natürlich dazu führen, vier weitere Tore zu verwenden, daher zu einer 5-Tore-Lösung.

XYZAB

XYZABAB

AB

Z=NAND(A,B)=AB¯=A¯+B¯

ZABXY

AB

Das ist leicht zu überprüfen

NAND(Z,A)=ZA¯=AB¯A¯=(A¯+B¯)A¯=A¯A+B¯A¯=0+B¯A¯=B¯A¯=AB¯¯=X

Similarly NAND(Z,B)=Y

Hence we can compose these four gates to get the desired result, i.e., the XOR function.


Not in a reverse way to prove that they are equal. But image that you don't know the diagram but to construct the gate using minimum nand gate.
Timeless

1
What do you expect as an answer? A systematic technique for doing that. I do not know that there is any that is tractable enough to be worth using in complex cases. Given that I know the answer I can just lie to you and pretend to have found by reasonning what I discovered by checking the answer. This said, looking at what I get with NAND(A,B) is all that seems useful for a start. Then NANDing the result with one argument A or B, is also one thing to look at, to get a view of where I am. From there, one is pretty close to the final answer.
babou

1
@Timeless Another way to go about it is backward from the answer, knowing that the answer is fron a NAND gate. If you assume that the solution is symmetrical in A and B, it gives you a likely form of the inputs to the last NAND gate. There are many way to go about it, either to find the answer, or to justify finding it a posteriory. But a proof is a proof, whether found by your ingenuity, or given by some oracle or a good friend. And at some point no one can tell the difference. Actually, the backward proof I give could be the best proof, even if the solution was found some other way.
babou

Actually, it is quite common in math to have an analysis part to find a solution, then a synthesis part where you prove it is the solution. One usually gives both, but only the second part is really necessary.
babou

@Timeless Both answers were based on the knowledge of a formula to obtain, deduced from the diagram to be obtained. Your edit asked for a plausible intuitive scenario to find the answer without any prior knowledge of the result. I did add that to my answer, but it would be nice to know whether it fits what you expected.
babou

0

I take the input (0,0) as an example.

For XOR, the desired output is 0. However, NAND(0,0)=1.

  • Because the only way to get a 0 using NAND is (at the last layer) NAND(1,1)=0, you should first produce two 1's.

    • According to NAND(0,1)=1 or NAND(1,0)=1, you produce a 1 using one NAND(0,0) at the first layer and feed it, along with one input 0, into a second layer NAND.

Only four NANDs are involved. But it is only correct for the input (0,0) so far. So you need to check other inputs (0,1),(1,0), and (1,1) against the solution and find that it just works. Lucky.


0

I tried my best to give the answer using formula as asked.Hope you appreciate it.
Z=AB'+A'B
Z=AA'+AB'+BB'+A'B --->BB'=AA'=0
Z=A(A'+B')+B(B'+A')
Z=A(AB)'+B(AB)' --> Hint
so now (AB)' can get through 1st NAND gate,then in 2nd and third NAND gate the output of 1st NAND gate pass through with one of the input as A and B.After this we need one more complement so use fourth NAND gate.
NAND(1st)=(AB)'=A'+B'
NAND(2nd)=(A(AB)')'=(A(A'+B'))'=(AB')'=A'+B
NAND(3rd)=(B(AB)')'=(B(A'+B'))'=(A'B)'=A+B'
NAND(4th)=[(A'+B)(A+B')]' =[A'B'+AB]'=(A+B)(A'+B')=AB'+A'B

Happy!


0

The formula: XOR = (a and not b) or (not a and b).

Thats' not what you want, you want a formula that is a NAND. Remember that not (a or b) = not a and not b, and therefore (a or b) = not (not a and not b). Therefore

(a and not b) or (not a and b) =

not (not (a and not b) and not (not a and b)) =

not ((not a or b) and (a or not b)) =

NAND (not a or b, a or not b).

So we used one NAND gate, and have to calculate (not a or b) and (a or not b) using three NANDs. We turn each expression into a NAND:

not a or b = not (a and not b) = NAND (a, not b)

a or not b = not (not a and b) = NAND (not a, b)

Nun stellen wir fest, dass (x und y) = x und (nicht x oder y): Wenn x falsch ist, dann sind beide Seiten falsch. Wenn x wahr ist, dann ist (nicht x oder y) = (falsch oder y) = y. Dies gilt für NAND genauso wie für AND. Deshalb

NAND (a, nicht b) = NAND (a, nicht a oder nicht b) = NAND (a, NAND (a, b))

NAND (b, nicht a) = NAND (b, nicht b oder nicht a) = NAND (b, NAND (a, b)).

Wir finden also zuerst mid = NAND (a, b), left = NAND (a, mid) und right = NAND (b, mid), schließlich XOR = NAND (left, right).


-2

* Von links nach rechts - D1, D2, D3, D4 ** D1 = (AB) 'ODER (A' + B ')

annehmen

(AB) '= C

D2 = (AC) '= A' + C '

D3 = (BC) '= B' + C 'dann

D4 = (D2.D3) '

D4 = ((AC) '. (BC)') '

D4 = (AC) '' + (BC) ''

D4 = (AC) + (BC)

D4=A.(A'+B')+B.(A'+B')

D4=AB'+BA' {A.A'=B.B'=0}**


2
I find it hard to follow this answer or understand what process you are using. Can you add some text sentences to explain the approach, so this isn't just a sequence of equations?
D.W.
Durch die Nutzung unserer Website bestätigen Sie, dass Sie unsere Cookie-Richtlinie und Datenschutzrichtlinie gelesen und verstanden haben.
Licensed under cc by-sa 3.0 with attribution required.