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
| Gate | Function | Key question | Math notation | Programming |
| AND | Output 1 only if ALL inputs are 1. | Are both inputs on? | A AND B | A && B |
| OR | Output 1 if AT LEAST ONE input is 1. | Is either input on? | A OR B | A || B |
| NOT | Inverts the input. 0→1, 1→0. | Is A off? | NOT B | !B |
| NAND | Inverse of AND. Output 0 only if ALL inputs are 1. | Is either input off? | NOT (A AND B) | !(A && B) |
| NOR | Inverse of OR. Output 1 only if ALL inputs are 0. | Are both inputs off? | NOT (A OR B) | !(A || B) |
| XOR | Output 1 if inputs are DIFFERENT. | Are the inputs different? | A XOR B | A ^ B |
| XNOR | Output 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
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.