Basic gates
The and-gate
An and-gate has an arbitrary number of inputs. The output value is 1 if and only if all of the inputs are 1. Otherwise the output value is 0. The name has been chosen because the output is 1 if and only if the first input and the second input, and, ..., and the nth input are all 1.
It is often useful to draw diagrams of gates and their interconnections. In such diagrams, the and-gate is drawn like this:
The truth table for an and-gate with two inputs looks like this:
x y | z
-------
0 0 | 0
0 1 | 0
1 0 | 0
1 1 | 1
The or-gate
Like the and-gate, the or-gate can have an arbitrary number of inputs. The output value is 1 if and only of at least one of the input values are 1. Otherwise the output is 0. In other words, the output value is 0 only if all inputs are 0. The name has been chosen because the output is 1 if and only if the first input or the second input, or, ..., or the nth input is 1.
In circuit diagrams, we draw the or-gate like this:
The truth table for an or-gate with two inputs looks like this:
x y | z
-------
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 1
The inverter
An inverter has exactly one input and one output. The value of the output is 1 if and only if the input is 0. Otherwise, the output is 0. In other words, the value of the output is the exact opposite of the value of the input.
In circuit diagrams, we draw the inverter like this:
The truth table for an inverter looks like this:
x | y
-----
0 | 1
1 | 0