Binary And and Or
Your should have learn't AND and OR in PHIL 279. AND compares 2 values A and B (either 0 or 1)
and returns 1 if A and B are BOTH 1 and 0 otherwise. AND can be writen several different ways.
A*B
or
AB
Or compares 2 values and returns 1 IFF one or both of A or B has a value of 1. It is writen as:
A + B
There are 7 basic operations, they are AND, OR, INVERT, NAND, NOR, XOR and XNOR.
Their appearance as GATES can be seen on the Gates Page.
AND and OR are the simpliest since they are straightforward. INVERT just inverts an
input to its oposite. There are not values of TRUE in FALSE but instead 1 and 0 which
can be seen as TRUE and FALSE. So just like in logic, if A and B then C is really
just an AND gate, where C is true only when both A and B are, that is there is a
charge on C iff both A and B have a charge.
All gates can be seen in this way, an OR gate is just if A or B then C that is
C if true iff at least one of A or B is true.
NAND is a combination of AND and an inversion, that is NOT AND, or NAND, so NAND is
true iff AND is false, and NAND is false iff AND is true. NAND is a very important
gate since ALL other gates can be simulated with it.
Likewise NOR is a combination of OR and an inversion, NOT OR, or NOR. In this case since OR
was only false when the inputs were all false, NOR is only true when all of its inputs are
false.
XOR or Exclusive-OR, is true when given inputs A and B, exactly 1 is true, that is
if A or B and NOT(A and B) then C. So basilly it is true when EXACTLY 1 of its
inputs are true. XNOR is just the opposite of XOR.
Now if all of this isn't to confusing we can construct a table of all
possible combinations of 2 inputs.
----------------------------------------------------------------------------
x y | fo f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15
----------------------------------------------------------------------------
0 0 | 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 1 | 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
1 0 | 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
1 1 | 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
----------------------------------------------------------------------------
0 and x/y x y/x y xor or nor = !y !(y/x) !x !(x/y) nand 1
This is somewhat a complicated table to understand. Think of each fx as a
logical gate. And think of the different lines of x and y as different
possible inputs. So lets look at f7 and the possible inputs.
-----------
x y | f7
-----------
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 1
So what we have here is an unkown gate, f7, and when x and y are both 0
the output from the gate is 0. If either x or y has a charge then the
output of the gate is 1. This is an OR gate. So f7 is OR.
Likewise the other gates can be determined by looking at the outputs
for all possible inputs.