For example, the boolean AND function can be implemented with two switches, A and B. A power lead is connected to one switch, and a wire is connected between the two, such that both A and B have to be "on" in order for the circuit to conduct electricity. If the switches themselves are electronically controlled, the circuit can be considered a logic gate, in this instance an AND gate.
A B |out A B 0 0 | 0 _|_ _|_ 1 0 | 0 *__| |__| |__out 0 1 | 0 1 1 | 1The circuit symbol for an AND gate is:
Another important arrangement is an OR gate. It also has two switches, but they are arranged so that if either switch is "on", the output will also be "on".
A A B |out _|_ 0 0 | 0 __| |__ 1 0 | 1 *__| B |__out 0 1 | 1 | _|_ | 1 1 | 1 |__| |__|The circuit symbol for an OR gate is:
A simpler arrangement is the NOT gate. It can be constructed from a single switch, A, with the switch wired "backwards", such that if the switch is "on" the output is "off". We indicate these reversed switches by replacing the "|" in the diagram with a "o".
A |out A 0 | 1 _o_ 1 | 0 *__| |__outThe circuit symbol for a NOT gate is:
Using these reversed switches allows us to make alternate versions of the AND and OR gates, by virtue of DeMorgan's Law. Note that the layout of the switches in the two circuits is swapped when we turn the switches "backwards". Also note how the output of the first pair controls the operation of the NOT gate.
Alternate AND circuit Alternate OR circuit A _o_ A B __| |__ _o_ _o_ *__| B |______ *__| |__| |___ | _o_ | | | |__| |__| _o_ _o_ *__| |__out *__| |__out
This may seem like an unnecessary complication, but in fact this is very useful. By removing the NOT gate from these alternate circuits, we create the so-called NAND (for NOT-AND) and NOR (for NOT-OR) gates.
In practice, the cheapest gate to manufacture is usually the NAND gate. Additionally, Charles Peirce showed that NAND gates alone (as well as NOR gates alone) can be used to reproduce all the other logic gates.
Two more gates are the exclusive-OR or XOR function and its inverse, exclusive-NOR or XNOR. Exclusive-OR is true only when exactly one of its inputs is true. In practice, these gates are built from combinations of simpler logic gates.
The preceding simple logic gates can be combined to form more complicated boolean logic circuits. Logic circuits are often classified in two groups: combinatorial logic, in which the outputs are continuous-time functions of the inputs, and sequential logic, in which the outputs depend on information stored by the circuit as well as on the inputs.
In practice, the gates are made from field effect transistors (FETs), particularly metal-oxide-semiconductor FETs (MOSFETs).