Different types of gates
A valid question at this point is how many different kinds of gates there are, and what they are called.
Let us limit ourselves to gates with n inputs. The truth tables for such gates have 2n lines. Such a gate is completely defined by the output column in the truth table. The output column can be viewed as a string of 2n binary digits. How many different strings of binary digits of length 2n are there? The answer is 22n, since there are 2k different strings of k binary digits, and if k=2n, then there are 22n such strings. In particular, if n=2, we can see that there are 16 different types of gates with 2 inputs.
Most of these gates do not have any names, and indeed, most of them are quite useless. For completeness, let us look at all 16 and study the functions they compute. Each entry in the following table is specified by the output string:
* 0000 A gate that ignores both its inputs and always gives 0 on the output. This gate does not require any circuits. Just let the inputs hang and connect the output to a 0.
* 0001 This is the and-gate described above.
* 0010 This is like an and-gate with an inverter on the second input.
* 0011 This gate ignores its second input, and gives as output the value of its first input. It does not require any circuits. Just connect the output to the first input and let the second input hang.
* 0100 This is like an and-gate with an inverter on the first input.
* 0101 This gate ignores its first input, and gives as output the value of its second input. It does not require any circuits. Just connect the output to the second input and let the first input hang.
* 0110 This is the exclusive-or-gate described above.
* 0111 This is the or-gate described above.
* 1000 This is the nor-gate described above.
* 1001 This is like an exclusive-or-gate with an inverter on its output.
* 1010 This gate can be built with an inverter on the second input, and with the first input hanging.
* 1011 This is like an or-gate with an inverter on its second input.
* 1100 This gate can be built with an inverter on the first input, and with the second input hanging.
* 1101 This is like an or-gate with an inverter on its first input.
* 1110 This is the nand-gate described above.
* 1111 This is a gate that ignores both its inputs and always gives a 1 as output. This gate does not require any circuits. Just let the inputs hang and connect the output to a 1.
As you can see, most of the gates possible, are quite useless.
Doing it all with only one kind of gate
As it turns out, it is possible to build any kind of gate using only nand-gates. To see this, first observe that an inverter is just a nand-gate with only one input. Second, an and-gate can be built as a nand with an inverter on its output. Last, an or-gate can be build with a nand-gate with an inverter on each input.
In some circuit technology, it is actually easier to build a nand-gate than any of the other gates. In that case, the nand-gate is considered the most primitive building block, and everything else is built from it.
Similarly, all gates can be realized from only nor-gates. Again an inverter is just a nor-gate with only one input. An or-gate is a nor-gate with an inverter on its output, and an and-gate is just a nor-gate with an inverter on each input.
Posted in Computer Science, Information Technology, Computer Architecture, Computer Architecture |
