# Unary Gates Inside Binary Gates

11/17/2001 Jeff Connelly - transformed to HTML

08/06/2001 Jeff Connelly - originally written

## 1. Unary Gates

```AB Q
00 a
01 b
```

ab form the unary gate's function number. Possible functions are:

```00  clear       - output 0 regardless of inputs
01  pass/buffer - output input
10  not         - output inverted input
11  mark        - output 1 regardless of inputs
```

## 2. What Truth Tables Tell

```If b == c then A[abcd]B = B[abcd]A          Commutativity
A[abcd]B = B[acbd]A                         Reversed inputs

0[abcd]B = [ab]B                            Unary gate inside binary gate
1[abcd]B = [cd]B                            "           "           "
A[abcd]A = [ad]A                            "           "           "
A[abcd]0 = [ac]A                            "           "           "
A[abcd]1 = [bd]A                            "           "           "
```

Rarely used unary gates: ba, bc, ca, cb, da, db, dc

Notation: abcd are bits of any truth table. A and B are arbitrary inputs. Square brackets indicate a binary function (four bits inside) or a unary function (two bits, prefixed to input). A question mark prefixing a variable indicates an unknown unary gate. Q is the output.

``` input output
00 a
01 b
10 c
11 d
```

## 3. Binary-Unary Gate Table

```Inputs  Output
A B     Q
0 0     a
0 1     b
1 0     c
1 1     d
```
```         Output same if                   When the inputs
inputs swapped?                  are reversed,
/      Unary functions that   gate becomes this
/        operate on B when:      /
Name   b=c?  abcd  A=0    A=1    A=B      /         Notes/Alternatives
clear   X    0000  clear  clear  clear |Rev. In  |
AND     X    0001  clear  pass   pass  |Reference|
---------------------------------------+---------+---------------------------
AB'          0010  clear  not    clear   BA'        use NOR     (inv B)
pass A       0011  clear  mark   pass    pass B
BA'          0100  pass   clear  clear   AB'        use AND     (inv B)
pass B       0101  pass   pass   pass    pass A
-----------------------------------------------------------------------------
XOR     X    0110  pass   not    clear
OR      X    0111  pass   mark   pass
NOR     X    1000  not    clear  not
XNOR    X    1001  not    pass   mark
-----------------------------------------------------------------------------
not B        1010  not    not    not     not A
B+A'         1011  not    mark   mark    A+B'       use NAND    (inv A)
not A        1100  mark   clear  not     not B
A+B'         1101  mark   pass   mark    B+A'       use OR      (inv A)
---------------------------------------+---------+---------------------------
NAND    X    1110  mark   not    not   |Rev. In  |
mark    X    1111  mark   mark   mark  |Reference|
```

## 4. Commutativity & How A[abcd]B = B[acbd]A

A function number (Q section of the truth table) tells us a lot about a binary gate. First of all, if the two inner bits are equal, the order of inputs does not effect the output of the gate. This happens because "b" is the output if A=0 and B=1, while the "c" bit is the output if A=1 and B=0:

```    AB Q
00 a
01 b      if b=c, gate is commutative
10 c
11 d
```

Therefore if b=c, the order of inputs does not affect output. Mathematically, this means:

```If b == c then A[abcd]B = B[abcd]A          Commutativity
A[abcd]B = A[acbd]B
```

To find the equivalent gate if the inputs are swapped, we can swap b and c. Take , the NAND gate. Swap b and c and you'll get  again, because b=c - the gate is commutative.

 is the A+B' gate. Swap the b and c to get , the B+A' gate. If we reverse the inputs of the A+B' gate, the output is same as if we used the B+A' gate on the swapped inputs:

```01 = A+B' = 0+1' = 0+0 = 0
10 = A'+B = 1'+0 = 0+0 = 0

10 = A+B' = 1+0' = 1+1 = 1
01 = A'+B = 0'+1 = 1+1 = 1
```

This is true for all gates.

## 5. Unary Gates Inside Binary Gates: X with constant

Gates are sometimes used as digital "filters"..for example, the XOR. According to the chart, when A=0, Q=B, and when A=1, Q=B'. So a circuit could have the output of another circuit (for example, an astable multivibrator) connected to A of an XOR gate, and B would be connected to a user-settable logic level. Normally B would be 0, so Q=0 xor A, which lets A pass through unchanged. However if B is set to 1, A will be inverted. XOR is like a controlled not, in fact in Quantum computing there is a CNOT gate. Other gates are like controlled other unary gates, which act as a one gate when A=0, another when A=1.

## 6. Unary Gates: X with X

--------------------- To find out the unary gate that produces X[....]X, the first and last digits are taken because the inputs will also be either 00 (a), or 11 (d), never 01 or 10. The pattern is half alternatating clear and pass, last half alternating not and mark. NOR, not B, not A, and NAND are the only gates which have a ad of not. Needless to say not B and not A are replaced with a unary NOT gate, leaving NOR and NAND the only useful ones with an ad of NOT. From the chart: NOR X 1000 not clear not NAND X 1110 mark not not Therefore both NOR and NAND can act as NOTs. This is essential to becoming a unversal gate. DeMorgan's theorem: A'B' = A+B A'+B' = AB So we can NOT the output of the gates to make either an OR or AND, which then the inputs may be inverted to make an OR from AND or vice versa, according to DeMorgan's theorem. No other gates have this property of being universal.

## 7. Complete Chart of Unary Gates in Binary Gates

This chart is less useful than the first one but more complete. Several unary gates can be formed from function number bits of a binary gate.

```TODO: complete this

ab = 0[abcd]B
ac = 1[abcd]B

ba
bc
bd = A[abcd]1

ca
cb
cd = 1[abcd]B

da
db
dc

0[abcd]B = [ab]B                            Unary gate inside binary gate
1[abcd]B = [cd]B                            "           "           "
A[abcd]A = [ad]A                            "           "           "
A[abcd]0 = [ac]A                            "           "           "
A[abcd]1 = [bd]A                            "           "           "
```

## 8. Looking Forward

Examining how exactly boolean gates work is helpful when dealing with trinary algebra because they're quite similar.

Valid HTML 4.0?

Modified Sun Mar 25 08:48:47 2007 generated Sun Mar 25 08:56:33 2007
http://jeff.tk/bingates/