Logic gates are the basic decision-making elements of digital circuits. Each gate receives one or more binary inputs and produces a binary output according to a fixed rule. By connecting many simple gates, engineers build adders, processors, memory controllers, communication hardware, and nearly every other digital system.
This guide covers the seven common types of logic gates: NOT, AND, OR, NAND, NOR, XOR, and XNOR. It explains their Boolean expressions, recognizable logic gate symbols, and complete truth tables, then shows how gates combine into useful circuits.
Logic Gates Truth Table at a Glance
For two inputs A and B, the six two-input gates produce these results:
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
The NOT gate is different because it has a single input:
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
A truth table lists every possible input combination and the resulting output. Two binary inputs create 2^2 = 4 rows. Three inputs would create 2^3 = 8 rows. This predictable structure makes a truth table a reliable way to specify or verify digital logic.
Binary Inputs and Boolean Logic
The values 0 and 1 can describe voltage ranges, switch positions, or abstract false and true states. Hardware does not need a perfect zero volts or a single exact high voltage. A digital technology defines acceptable low and high ranges, and circuits interpret those ranges as logic 0 and logic 1.
Boolean expressions give the same rules a compact mathematical form. In the expressions below:
¬AorA'means NOT A.A · Bmeans A AND B.A + Bmeans A OR B in Boolean notation, not ordinary addition.A ⊕ Bmeans A XOR B.
The notation describes a logical relationship. A physical implementation may use transistors, relays, optical devices, or another technology. To review how positional binary values work before studying circuits, see the binary number system guide.
NOT Gate
A NOT gate, also called an inverter, has one input and produces its opposite.
Y = ¬AWhen A = 0, the output is 1. When A = 1, the output is 0. Its traditional logic gate symbol is a triangle with a small circle at the output. The circle is called an inversion bubble and indicates that the signal is complemented.
NOT gates reverse conditions. If a sensor signal is 1 when a door is closed, an inverter can create a signal that is 1 when the door is not closed. In timing and control circuits, an inverter can also restore signal levels or provide a deliberately inverted control line.
AND Gate
An AND gate outputs 1 only when every input is 1.
Y = A · B| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Think of two required permissions. A machine may run only if a guard is closed and the start button is active. If either condition is false, the AND output remains 0. An AND gate can have more than two inputs; its output becomes 1 only when all of them are 1.
The conventional AND symbol has a flat left side and a rounded right side. Its rule also appears in binary arithmetic: when adding one-bit values, an AND gate produces the carry bit for a half-adder.
OR Gate
An OR gate outputs 1 when at least one input is 1.
Y = A + B| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
An alarm that should activate when a smoke detector or a heat detector reports danger can use an OR relationship. Both inputs may be 1 at the same time; the output is still one binary 1, not the arithmetic sum 2.
The OR symbol has a curved input side and a pointed output side. A multi-input OR gate remains 0 only when all inputs are 0.
NAND Gate
A NAND gate is an AND gate followed by inversion. Its name means NOT-AND.
Y = ¬(A · B)| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
The output is 0 only when every input is 1. Its logic gate symbol is the AND shape with an inversion bubble on the output.
NAND is a universal gate: a circuit built exclusively from NAND gates can reproduce NOT, AND, OR, and therefore any Boolean function. Connecting both inputs of a NAND gate to A creates ¬A. Inverting a NAND output with another NAND produces AND. Applying De Morgan's relationship lets NAND gates form OR as well. This universality is valuable when a design benefits from using fewer component types.
NOR Gate
A NOR gate is an OR gate followed by inversion. Its name means NOT-OR.
Y = ¬(A + B)| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
NOR outputs 1 only when all inputs are 0. Its symbol is the OR shape with an output bubble. Like NAND, NOR is universal: combinations of NOR gates can implement every other logic operation. Cross-coupled NOR gates also form a basic SR latch, an important example of using feedback to retain one bit of state.
XOR Gate
An XOR gate, or exclusive-OR gate, outputs 1 when its two inputs are different.
Y = A ⊕ B| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
For two inputs, XOR can be read as “one or the other, but not both.” Its symbol resembles an OR gate with an extra curved line on the input side. This extra line is the easiest visual way to distinguish XOR from OR.
XOR is central to binary addition. It produces a 1 when exactly one input bit is 1, which matches the sum bit when adding two bits without an incoming carry. XOR is also used for parity generation, controlled bit toggling, and comparing whether two bits differ.
For more than two inputs, XOR is best defined by parity: the output is 1 when an odd number of inputs are 1. That definition avoids the ambiguity of casually saying “exactly one” for a multi-input gate.
XNOR Gate
An XNOR gate, or exclusive-NOR gate, is the inverse of XOR. It outputs 1 when the two inputs are equal.
Y = ¬(A ⊕ B)| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Its symbol is the XOR shape with an inversion bubble at the output. Because it recognizes equality for one-bit inputs, XNOR is useful in digital comparators. A multi-bit equality circuit can XNOR each corresponding bit and then AND all the results.
For multiple inputs, XNOR is the complement of parity XOR: it outputs 1 when an even number of inputs are 1, assuming the gate is defined as the inversion of a multi-input XOR.
How to Recognize Logic Gate Symbols
Symbol recognition becomes easier when you look for a few consistent features:
| Gate | Shape clue | Output bubble? |
|---|---|---|
| NOT | Triangle | Yes |
| AND | Flat input, rounded output | No |
| NAND | AND shape | Yes |
| OR | Curved input, pointed output | No |
| NOR | OR shape | Yes |
| XOR | OR shape plus extra input curve | No |
| XNOR | XOR shape | Yes |
An inversion bubble changes the meaning at the terminal where it appears. A bubble on an output means the entire gate result is inverted. Schematics may also show bubbles on inputs to indicate active-low signals, so follow the bubble rather than relying only on the gate's text label.
Different standards draw some gate symbols differently. The familiar distinctive shapes are common in ANSI-style schematics, while IEC diagrams may use rectangular blocks with function markings. The truth table, signal names, and Boolean expression remain the definitive description when a drawing style is unfamiliar.
Universal Gates: Why NAND and NOR Matter
A functionally complete gate set can express any Boolean function. NAND alone and NOR alone each meet that condition. Here is the NAND construction concept:
NOT A = A NAND A
A AND B = (A NAND B) NAND (A NAND B)
A OR B = (A NAND A) NAND (B NAND B)Equivalent constructions exist using only NOR gates. Universal gates do not mean every real circuit should contain only one type. Engineers also consider delay, power, silicon area, fan-out, available integrated circuits, and clarity. Universality proves logical capability; implementation constraints determine the best actual design.
Combining Logic Gates into a Half-Adder
A half-adder adds two one-bit inputs. It produces a sum bit and a carry bit:
Sum = A XOR B
Carry = A AND B| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
The final row represents 1 + 1 = 10₂: the sum position is 0 and the carry into the next position is 1. A full-adder extends this idea by accepting an incoming carry. Chains of full-adders can add multi-bit numbers. Try the binary addition calculator to see those carries across a complete value.
Subtraction circuits similarly combine XOR, inversion, AND, and OR relationships to generate difference and borrow signals. The binary subtraction calculator shows the numerical borrow process, while gate-level hardware implements that rule across bits.
Logic Gates and Bitwise Operations
Logic gates operate on electrical or abstract binary signals. Bitwise operators apply the same truth-table rules independently to corresponding bits in software integers. For example:
1010
AND 1100
---------
1000Each output position is calculated by one AND relationship. OR would produce 1110, while XOR would produce 0110. A binary calculator can check arithmetic values, but remember that arithmetic addition is not identical to OR or XOR. Addition must propagate carry bits; a bitwise operation treats each position independently.
Logical operators in programming languages can behave differently again. They may convert entire values to true or false and may stop evaluating once the result is known. Always distinguish a physical gate, a bitwise integer operator, and a high-level Boolean operator even when they share names.
Where Digital Logic Gates Are Used
Basic logic gates become useful when arranged into larger functional blocks:
- Adders and arithmetic logic units calculate sums and other processor operations.
- Comparators detect equality or determine which binary value is greater.
- Multiplexers select one of several input signals under the control of selector bits.
- Decoders activate one output for a particular binary input pattern.
- Latches and flip-flops retain state and form registers, counters, and memory interfaces.
- Control logic decides which operation a processor or device performs next.
- Parity circuits use XOR relationships to detect some transmission errors.
A modern processor contains enormous numbers of transistors, and its implementation uses optimized cell libraries rather than manually placing classroom gate drawings. The conceptual hierarchy still applies: transistor networks implement gate-like functions, gates form combinational and sequential blocks, and those blocks form complete systems.
Combinational and Sequential Logic
In combinational logic, the current outputs depend only on the current inputs. A basic AND gate, decoder, or adder fits this category. A truth table can fully specify a combinational block.
In sequential logic, outputs also depend on stored state from earlier events. Latches, flip-flops, registers, and counters are sequential elements. They introduce feedback and usually operate with timing constraints or clock signals. The same basic gates participate, but a simple input-output truth table is no longer enough to describe the entire behavior over time.
This distinction explains why connecting gates is more than choosing the right Boolean expression. Real circuits must also account for propagation delay: signals take time to travel through gates. Multiple paths can settle at different moments, creating temporary glitches even when the final truth-table result is correct.
Common Mistakes When Learning Logic Gates
Do not read Boolean OR as arithmetic addition. 1 OR 1 equals 1. Do not call XOR “either input is 1” without adding “but not both” for the two-input case. Do not forget that a bubble means inversion; an AND outline with an output bubble is NAND, not AND.
Another mistake is assuming a truth table shows timing. It defines stable logical outcomes, not how quickly they appear. Physical circuits have propagation delay, voltage limits, drive strength, power use, and noise margins.
Finally, keep number representation separate from gate behavior. A bit pattern can be interpreted as unsigned, signed, text, or another format. Gates manipulate bits without knowing what the complete pattern means. The interpretation comes from the surrounding circuit or software type. The introductory what is binary guide explains this distinction at the number-system level.
Frequently Asked Questions
What are the seven basic logic gates?
The commonly taught set is NOT, AND, OR, NAND, NOR, XOR, and XNOR. NOT uses one input; the others are commonly introduced with two inputs, although most can support additional inputs.
Which logic gates are universal?
NAND and NOR are each universal. Any Boolean function can be built using only NAND gates or only NOR gates. Designers may still combine gate types to improve speed, area, power, or readability.
What is the difference between OR and XOR?
OR outputs 1 when one or both inputs are 1. Two-input XOR outputs 1 when the inputs differ, so its result is 0 when both inputs are 1. Their truth tables differ only for the A = 1, B = 1 row.
What is the difference between XOR and XNOR?
XNOR is the inverse of XOR. XOR reports difference for two inputs, while XNOR reports equality. This makes XNOR useful as the one-bit building block of an equality comparator.
Why are truth tables useful?
A truth table enumerates every possible input combination and the required output. It provides a compact, testable specification that does not depend on a particular circuit drawing or hardware technology.
Can logic gates store data?
An isolated combinational gate does not retain data after its inputs change. Gates connected with feedback can form latches and flip-flops that store state. Those state elements are the foundation of registers and sequential digital systems.
Are logic gates the same as transistors?
No. A transistor is an electronic device used as a switch or amplifier. Multiple transistors can implement a logic gate, and many gates combine into larger circuits. Gate symbols provide a useful functional abstraction above transistor-level details.
Summary
Logic gates turn binary input conditions into predictable outputs. NOT inverts, AND requires every input, OR accepts any input, NAND and NOR invert those results, XOR detects difference or odd parity, and XNOR detects equality or even parity. Their truth tables are small, but combinations of these rules create arithmetic, comparison, storage, and control systems. Once you can read the symbols and derive the outputs row by row, larger digital circuits become networks of familiar decisions rather than opaque diagrams.
