OR Gate

Logic

Outputs true when at least one input is true.

The OR gate outputs 1 (true) when at least one of its inputs is 1. The output is 0 only when all inputs are 0. Along with AND and NOT, the OR gate is one of the three fundamental operations in Boolean algebra, originally described by George Boole in the mid-nineteenth century. When Claude Shannon showed in 1937 that Boolean algebra could be physically implemented with electrical relays, the OR gate gained its role as a core building block of digital computing systems that persists to this day.

Truth Table

ABA OR B
000
011
101
111

How It Works

The OR operation can be thought of as a parallel circuit — current flows if any switch is closed. If two light switches are wired in parallel to control a single light, flipping either switch on will illuminate the light. In Boolean algebra, OR is written as A + B. It is important not to confuse this with arithmetic addition; in Boolean algebra, 1 + 1 = 1, not 2. The OR operation extends naturally to any number of inputs: a multi-input OR gate outputs 1 if at least one input is 1, and outputs 0 only in the single case where every input is 0.

Circuit Implementation

In CMOS technology, an OR gate is typically built by combining a NOR gate with a NOT gate (inverter). A two-input NOR requires four transistors, and the inverter adds two more, bringing the total to six transistors. This is why, like the AND gate, the OR gate is actually more expensive in silicon than its negated counterpart. Circuit designers who optimize for transistor count and propagation delay often restructure their logic to use NOR or NAND gates directly. In the older TTL family, the 7432 integrated circuit provided four two-input OR gates in a single 14-pin package and was a staple component in digital electronics courses and prototyping labs throughout the 1970s and 1980s.

Properties

  • Identity: A OR 0 = A (ORing with 0 preserves the original value)
  • Annihilation: A OR 1 = 1 (ORing with 1 always produces 1)
  • Idempotent: A OR A = A (ORing a value with itself yields that value)
  • Commutative: A OR B = B OR A (input order does not matter)
  • Associative: (A OR B) OR C = A OR (B OR C) (grouping does not matter)
  • Distributive over AND: A OR (B AND C) = (A OR B) AND (A OR C)
  • Absorption: A OR (A AND B) = A

Relation to Other Gates

OR and AND exist in a beautiful duality expressed through De Morgan's Laws. The identity NOT(A OR B) = (NOT A) AND (NOT B) means that a NOR gate is equivalent to inverting both inputs and feeding them into an AND gate. This duality allows designers to freely convert between OR-based and AND-based logic representations depending on which gate type is cheaper or faster in a given technology. OR combined with NOT achieves functional completeness, just as AND combined with NOT does. The XOR gate can be understood as a specialized form of OR that excludes the case where both inputs are 1, which is why it is called "exclusive" OR.

When It's Used

OR gates are used for combining conditions, setting bits, implementing interrupt handling, and building multiplexers. In interrupt controllers, an OR gate combines multiple interrupt request lines so that if any device signals an interrupt, the processor is alerted. In bit-setting operations, ORing a register value with a mask sets specific bits to 1 while leaving others unchanged — the complement of the bit-clearing operation performed by AND with an inverted mask. Multiplexers use OR gates at their output stage to combine the selected data paths into a single output line. In programming, the | operator performs bitwise OR across every bit position of two integers, while the || operator performs logical OR with short-circuit evaluation, skipping the second operand if the first is already true. OR gates are also critical components in programmable logic arrays (PLAs), where a layer of AND gates followed by a layer of OR gates can implement any sum-of-products Boolean expression.

Historical Context

The inclusive OR has a long history in both logic and language. Logicians have debated the inclusive versus exclusive interpretation of "or" in natural language for centuries. In digital design, OR is always inclusive unless explicitly labeled XOR. The physical implementation of OR logic has progressed from mechanical relays in early telephone switching systems through vacuum tubes, discrete transistors, and integrated circuits. Today, OR operations execute billions of times per second inside every modern processor, forming part of the arithmetic logic unit's repertoire of bitwise operations. For students of computer science, understanding the OR gate and its interaction with AND and NOT through De Morgan's Laws is an essential foundation for mastering digital logic design, compiler optimization, and even database query planning, where OR conditions determine how queries are executed.