Courses / Computer Science I
Basic Digital Design

Boolean Variables and Logic Gates

Computer Science I 237 words Free to read

The Alphabet of Hardware

Digital circuits compute with just two voltage levels, interpreted as boolean values 1 (true, high) and 0 (false, low). Every digital operation is built from logic gates, hardware elements computing a boolean function.

GateOutput is 1 when...
ANDall inputs are 1
ORat least one input is 1
NOTthe single input is 0
NANDinverse of AND (0 only if all are 1)
NORinverse of OR (1 only if all are 0)
XORthe inputs differ

NAND is universal: any boolean function can be built using only NAND gates (NOR is also universal). Gates are physical atoms; everything from an adder to a processor is built by wiring them together.

OR vs. XOR & Formula

Common pitfall: confusing OR with XOR. OR outputs 1 when at least one input is 1, including when both are 1. XOR (exclusive-OR) outputs 1 only when inputs differ (ABA \neq B).

For inputs (1, 1), OR glows (1) but XOR stays dark (0). Watch this "both are 1" edge case where they disagree.

The formal definition for XOR is:

AB=1    ABA \oplus B = 1 \iff A \neq B

where AA and BB are boolean variables, \oplus denotes XOR, and     \iff means "if and only if."

Boolean Variables and Logic Gates

Practise this lesson

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

11practice questions
2interactive scenes

Basic Digital Design