*This is entry #8 of my 52 Project 2012: Foundational Electronic Components Crash Course series.*

### What is a logic gate?

A **logic gate** is a simple semiconductor device that allows for specific conditional behavior control—namely, that the behavior of an output signal is dependent on the status of one or more input signals.

### How does a logic gate work?

There are a few different basic types of logic gates (**NOT**, **AND**, **OR**, and **XOR**), all of which are built simply by connecting transistors together in unique ways. By combining **NOT** gates with **AND**, **OR**, and **XOR** gates, these basic devices can be extended to a few more useful logic gates as well (**NAND**, **NOR**, and **XNOR**).

All of these devices work with electrical representations of logical **TRUE/FALSE** values, where **TRUE** is typically indicated by a positive voltage differential (e.g. +3v or +5v), and **FALSE** is typically indicated by zero voltage differential. The behavior of any logic gate can be clearly described by a truth table: a simple table which shows all possible input values with corresponding output values.

Diodes alone may be used to construct **AND** and **OR** gates, but that is all. Without the addition of a **NOT** gate, other types of Boolean logic are not possible using only diodes, and complex combinations of multiple diode-logic gates are impractical because of the rapid voltage drop that comes of using many diodes in a series.

Instead, the most current technological implementation of Boolean logic circuitry relies on transistors, or specifically what is known as Transistor-Transistor Logic (or TTL). By using transistors as the fundamental logic unit, extremely complex logical circuits can be created without loss, since transistors can also function as amplifiers. For a schematic of a TTL-based NAND gate (for a simple example), go here.

At a foundational level, a logic gate circuit has at least one input terminal, at least one output terminal, a FALSE (GND) reference terminal, and a TRUE (+V) reference terminal.

### NOT gates

The **NOT** gate is the simplest of all of these, as it has only a single input terminal and a single output terminal. Its function is to output the logical opposite of whatever is applied to the input terminal. The truth table for a **NOT** gate is therefore as follows:

Input | Output |
---|---|

FALSE | TRUE |

TRUE | FALSE |

### AND gates

The **AND** gate requires *both* inputs *A* and *B* to be TRUE to make the output TRUE. In all other cases, the output will be FALSE. The truth table for an **AND** gate is as follows:

A | B | Output |
---|---|---|

FALSE | FALSE | FALSE |

FALSE | TRUE | FALSE |

TRUE | FALSE | FALSE |

TRUE | TRUE | TRUE |

### OR gates

The **OR** gate requires *either* of the inputs *A* or *B* to be TRUE to make the output TRUE. In both are FALSE, then the output will be FALSE. The truth table for an **OR** gate is as follows:

A | B | Output |
---|---|---|

FALSE | FALSE | FALSE |

FALSE | TRUE | TRUE |

TRUE | FALSE | TRUE |

TRUE | TRUE | TRUE |

### XOR gates

The **XOR** (eXclusive-OR) gate requires that *only one* of the inputs *A* or *B* may be TRUE to make the output TRUE. If neither of them are TRUE, or both of them are TRUE, then the output will be FALSE. The truth table for an **XOR** gate is as follows:

A | B | Output |
---|---|---|

FALSE | FALSE | FALSE |

FALSE | TRUE | TRUE |

TRUE | FALSE | TRUE |

TRUE | TRUE | FALSE |

### NAND gates

The **NAND** gate is the negated AND gate—the output is identical to an AND gate, but inverted. It produces a TRUE output unless *both* inputs are TRUE. Electrically, a NAND gate is merely an AND gate with a NOT gate on the output. The truth table for an **AND** gate is as follows:

A | B | Output |
---|---|---|

FALSE | FALSE | TRUE |

FALSE | TRUE | TRUE |

TRUE | FALSE | TRUE |

TRUE | TRUE | FALSE |

### NOR gates

The **NOR** gate is the negated OR gate. It produces a TRUE output unless *either* input is TRUE. Electrically, a NOR gate is an OR gate with a NOT gate on the output. The truth table for a **NOR** gate is as follows:

A | B | Output |
---|---|---|

FALSE | FALSE | TRUE |

FALSE | TRUE | FALSE |

TRUE | FALSE | FALSE |

TRUE | TRUE | FALSE |

### XNOR gates

The **XNOR** gate (eXclusive Not OR) is the negated XOR gate. It produces a TRUE output whenever both inputs are the same. Electrically, an XNOR gate is an XOR gate with a NOT gate on the output. The truth table for a **NOR** gate is as follows:

A | B | Output |
---|---|---|

FALSE | FALSE | TRUE |

FALSE | TRUE | FALSE |

TRUE | FALSE | FALSE |

TRUE | TRUE | TRUE |

By combining these gates, literally any logical decision tree may be represented by an electrical circuit. It is also possible to use one single type of gate (usually either NAND or NOR) to mimic the behavior of any other gate. Doing this is usually less electrically efficient by some tiny amount, but often more financially efficient since one single gate may be purchased and implemented in bulk.

If you’re interested, read more information on logic gates at Wikipedia, or at The Electronics Club.

*For a description of this 52 Project series and links to the all existing entries, go to the 52 Project 2012: Foundational Electronic Components Crash Course page.*