Different types of Logic 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
Combined gates
Sometimes, it is practical to combine functions of the basic gates into more complex gates, for instance in order to save space in circuit diagrams. In this section, we show some such combined gates together with their truth tables.
The nand-gate
The nand-gate is an and-gate with an inverter on the output. So instead of drawing several gates like this:
![]()
We draw a single and-gate with a little ring on the output like this:
![]()
The nand-gate, like the and-gate can take an arbitrary number of inputs.
The truth table for the nand-gate is like the one for the and-gate, except that all output values have been inverted:
x y | z
——-
0 0 | 1
0 1 | 1
1 0 | 1
1 1 | 0
The nor-gate
The nor-gate is an or-gate with an inverter on the output. So instead of drawing several gates like this:
![]()
We draw a single or-gate with a little ring on the output like this:
![]()
The nor-gate, like the or-gate can take an arbitrary number of inputs.
The truth table for the nor-gate is like the one for the or-gate, except that all output values have been inverted:
x y | z
——-
0 0 | 1
0 1 | 0
1 0 | 0
1 1 | 0
The exclusive-or-gate
The exclusive-or-gate is similar to an or-gate. It can have an arbitrary number of inputs, and its output value is 1 if and only if exactly one input is 1 (and thus the others 0). Otherwise, the output is 0.
We draw an exclusive-or-gate like this:
![]()
The truth table for an exclusive-or-gate with two inputs looks like this:
x y | z
——-
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 0
Posted in Computer Science, Information Technology, Computer Architecture, Computer Architecture |
