Courses / Computer Science I
Basic Digital Design

Boolean Variables and Logic Gates

Computer Science I 349 words Free to read

The Alphabet of Hardware

Digital circuits compute with just two voltage levels, interpreted as the boolean values 1 (true, high) and 0 (false, low). Every digital operation is built from tiny hardware elements called logic gates, each computing one boolean function of its inputs.

The three fundamental gates are:

From these, a few compound gates are so useful they get their own symbols:

GateOutput is 1 when...
ANDall inputs are 1
ORat least one input is 1
NOTthe single input is 0
XORthe inputs differ

A remarkable fact underlies all of digital design: NAND is universal — any boolean function whatsoever can be built using only NAND gates (NOR is universal too). This is why a single cheap gate type can, in principle, implement an entire computer. Gates are the physical atoms; everything from an adder to a processor is gates wired together.

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 the inputs differ — so for inputs 1 and 1, OR gives 1 but XOR gives 0. Watch the "both are 1" case, where they disagree.

The four basic gate symbols (AND, OR, NOT, XOR) each with input switches and an accent output LED, shown side by side lit for the inputs (1,1) so OR glows and XOR stays dark — the OR-vs-XOR distinction on the both-1.

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

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
Start Computer Science I free

Basic Digital Design