DEV Community

Milena
Milena

Posted on

Logic gates (AND, OR, XOR, NAND, NOR, XNOR)

Computers use logic gates to transform the 1s and 0s from input wires. A logic gate accepts inputs and then outputs a result based on their state.

And gate
The AND gate is named so because, if 0 is false and 1 is true, the gate acts in the same way as the logical "and" operator. The following illustration and table show the circuit symbol and logic combinations for an AND gate. The output is "true" when both inputs are "true." Otherwise, the output is "false." In other words, the output is 1 only when both inputs are 1.

Image description

Or gate
The OR gate behave like the logical inclusive "or." The output is true if one or both of the inputs are true. If both inputs are false, then the output is false. In other words, for the output to be 1, at least one input must be 1.

Image description

XOR gate
The XOR (exclusive-OR) gate acts in the same way as the logical "either/or." The output is 1 if the inputs are different but 0 if the inputs are the same.

Image description

NOT gate
A NOT gate reverses the logic state. If the input is 1, then the output is 0. If the input is 0, then the output is 1.

Image description

NAND gate
The NAND (Negated AND) gate operates as an AND gate followed by a NOT gate. The output is false if both inputs are true. Otherwise, the output is true.

Image description

NOR gate
The NOR (NOT OR) gate is a combination OR gate followed by a NOT. Its output is true if both inputs are false. Otherwise, the output is false.

Image description

XNOR gate
The XNOR (exclusive-NOR) gate is a combination of an XOR gate followed by a NOT. Its output is true if the inputs are the same and false if the inputs are different.

Image description

Top comments (0)