A1.2.3 � Logic Gates

? Back to A1.2 overview

What is a Logic Gate?

A logic gate is an electronic circuit that takes one or more binary inputs and produces a single binary output based on a specific logical function. Gates implement Boolean operations. They are built from transistors inide the CPU

1 = True / On. 0 = False / Off. The final output of a circuit is always labelled Q.

The Gates

GateFunctionKey questionMath notationProgramming
ANDOutput 1 only if ALL inputs are 1.Are both inputs on?A AND BA && B
OROutput 1 if AT LEAST ONE input is 1.Is either input on?A OR BA || B
NOTInverts the input. 0→1, 1→0.Is A off?NOT B!B
NANDInverse of AND. Output 0 only if ALL inputs are 1.Is either input off?NOT (A AND B)!(A && B)
NORInverse of OR. Output 1 only if ALL inputs are 0.Are both inputs off?NOT (A OR B)!(A || B)
XOROutput 1 if inputs are DIFFERENT.Are the inputs different?A XOR BA ^ B
XNOROutput 1 if inputs are THE SAME. Inverse of XOR.Are the inputs the same?NOT (A XOR B)!(A ^ B)

Truth Tables for Each Gate

A B Q

AND

ABQ
000
010
100
111
A B Q

OR

ABQ
000
011
101
111
A Q

NOT

AQ
01
10
A B Q

NAND

ABQ
001
011
101
110
A B Q

NOR

ABQ
001
010
100
110
A B Q

XOR

ABQ
000
011
101
110
A B Q

XNOR

ABQ
001
010
100
111

Real-World Uses of Logic Gates

  • Data processing & decision making: Implement conditional logic in hardware (if/else, switch statements at the circuit level).
  • Digital displays: Control which segments of a display are on to show numbers/symbols.
  • Control systems: Elevators, automated doors
  • Timing circuits: Clocks and timers.
  • Communication systems: Processing and transmission of digital signals.
  • Safety systems: Alarm systems , sensors feed into logic gates to trigger responses.
  • Arithmetic (ALU): Adder circuits built from AND, OR, XOR gates perform binary addition and all other arithmetic.
  • Memory storage: Flip-flops (circuits of logic gates) store a single bit by maintaining a stable state.