Logic gate
A logic gate is an arrangement of electronically-controlled switches arranged to calculate operations from boolean algebra. In practice, logic gates are built from a grouping of transistors.
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 electroncially controlled, the ciruit can be considered a logic gate, in this instance an AND gate.
A B |out A B 0 0 | 0 _o_ _o_ 1 0 | 0 *__| |__| |__out 0 1 | 0 1 1 | 1
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 _o_ 0 0 | 0 __| |__ 1 0 | 1 *__| B |__out 0 1 | 1 | _o_ | 1 1 | 1 |__| |__|
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 "o" in the diagram with a "|".
A |out A 0 | 1 _|_ 1 | 0 *__| |__out
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 _|_ A B __| |__ _|_ _|_ *__| B |______ *__| |__| |___ | _|_ | | | |__| |__| _|_ _|_ *__| |__out *__| |__out
This may seem like an unnecessary complication, but in fact this is very usefull. 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 Pierce showed that NAND gates alone (as well as NOR gates alone) can be used to reproduce all the other logic gates.
The preceeding simple logic gates can be combined to perform more complicated boolean functions, and other complex circuits such as multiplexers, registers, ALUs, and computer memory, all the way up through complete microprocessors which can contain billions of gates.
In practice, the gates are made from field effect transistors (FETs), particularly metal-oxide-semiconductor FETs (MOSFETs).
See also: digital circuit, NMOS, CMOS, Venn diagram, Karnaugh map