Logic gates are the basis of decision making for electronic devices. In essence, a logic gate takes input and produces a single output by performing operations on the input. In this way, logic gates are analogous to functions in mathematics. The input and output for a logic gate is in the form of bits (binary digits) which are either 1s or 0s. The most basic logic gates have two inputs and one output with the exception of the NOT gate, which has only one input. These basic gates are the building blocks of more advanced circuits. For example, a single microprocessor may have millions of logic gates and is capable of performing thousands of calculations per second.
Logic gates implement Boolean logic, which can be represented through a Truth Table. A Truth Table is a tabular representation of the inputs and the output of a logical operation. On the left hand side, all the possible combinations of the input are written and on the right hand side, the output of the Boolean operation performed on the given inputs is written.
Click "Choose Gate" to see its corresponding Truth Table. The second diagram shows a simplified circuit that represents the selected gate. In this circuit, the switches act as the input and the light acts as the output. Click on the green buttons to turn the switches on and off.
Types of Gates
The AND gate functions the same way as a logical "and" operator. Thinking about 0 as false and 1 as true, the AND gate only outputs true if both inputs are true, otherwise it outputs false.
The OR gate functions as a logical "or" operator. It outputs true if one or more of the inputs are true, and false otherwise.
The NOT gate is known as the inverter because it outputs the invert of the input (ex. if the input is true, it outputs false).
The NAND gate is the AND gate followed by the NOT gate. As a result, the outputs are the inverses of what the outputs would have been for the AND gate. The output of a NAND gate is true if any of the inputs are false, and false otherwise.
Similar to an NAND gate, a NOR gate is an OR gate followed by a NOT gate. The outputs of a NOR gate are false if any of the inputs are true, and true otherwise.
The XOR gate (exclusive-OR) gives an output of true if either of the inputs are true, but not if both inputs are true. If both inputs are false, then the output is false.
The XNOR gate (exclusive-NOR) is the opposite of the XOR gate. If either, but not both, of the inputs are true, then the output is false, and true otherwise.
Download Help Document