⚑ ELT 102 · Digital Logic & Solid State Devices Lesson 5 of 8
Unit 3 Β· Digital Foundations

Number Systems, Logic Gates & Boolean Algebra

Binary, octal, decimal, and hexadecimal conversions, arithmetic in base-N, signed binary (2's complement), and the fundamental laws of Boolean algebra β€” plus AND, OR, NOT, NAND, and NOR gates with truth table analysis.

⏱ 3 Hours Study πŸ“‹ 9 Core Topics πŸ“ Gate Symbol Library πŸ“ˆ 3-Mode Digital Lab πŸ§ͺ Companion Simulators

Learning Objectives

By the end of this lesson, you will be able to:

  • Convert values among binary, octal, decimal, and hexadecimal using weighted place value, repeated division, and the 3-bit/4-bit grouping shortcuts.
  • Perform addition and subtraction directly in base-2 and base-16, managing carries and borrows correctly.
  • Represent signed numbers in 2's complement form, negate values by invert-and-add-one, and recognize overflow.
  • Identify the ANSI schematic symbols for AND, OR, NOT, NAND, and NOR gates and state each gate's Boolean expression.
  • Construct and interpret truth tables for individual gates and simple gate combinations.
  • Explain why NAND and NOR are called universal gates and sketch how each builds the three basic functions.
  • Apply the fundamental Boolean laws β€” identity, null, idempotent, complement, commutative, associative, and distributive β€” to simplify expressions.
  • Use DeMorgan's theorems to convert between AND-based and OR-based forms and to "push bubbles" through a logic diagram.
  • Verify every concept hands-on in the embedded 3-mode Digital Lab and the companion binary and gate simulators.

Key Terms & Concepts

Click any card to reveal its definition.

Number Systems
Base (Radix)
Number Systems
πŸ”„ Click to reveal definition
Definition
The number of unique digits a system uses: decimal is base-10 (0–9), binary base-2 (0–1), octal base-8 (0–7), hexadecimal base-16 (0–9, A–F). Each column's weight is the base raised to the column's position.
Bit, Nibble, Byte
Number Systems
πŸ”„ Click to reveal definition
Definition
Bit: one binary digit (0 or 1). Nibble: 4 bits β€” exactly one hex digit. Byte: 8 bits β€” two hex digits, values 0–255 unsigned. The vocabulary of every datasheet and memory map.
Weighted Place Value
Number Systems
πŸ”„ Click to reveal definition
Definition
A number's value is the sum of each digit times its column weight. Binary 1011 = 1Γ—8 + 0Γ—4 + 1Γ—2 + 1Γ—1 = 11. The single idea from which every conversion method follows.
MSB / LSB
Number Systems
πŸ”„ Click to reveal definition
Definition
Most Significant Bit: the leftmost, highest-weight bit (128 in a byte) β€” also the sign bit in 2's complement. Least Significant Bit: the rightmost, weight-1 bit that decides odd or even.
Hexadecimal
Number Systems
πŸ”„ Click to reveal definition
Definition
Base-16, digits 0–9 then A=10 … F=15. One hex digit encodes exactly one nibble, so a byte is always two hex characters β€” the reason memory addresses, MAC addresses, and color codes are written in hex.
Octal
Number Systems
πŸ”„ Click to reveal definition
Definition
Base-8, digits 0–7. One octal digit encodes exactly 3 bits. Largely historical in hardware but still alive in Unix/Linux file permissions (chmod 755).
Repeated Division Method
Number Systems
πŸ”„ Click to reveal definition
Definition
Decimal β†’ any base: divide by the base, record the remainder, repeat with the quotient until zero, then read the remainders bottom-up. 25Γ·2 chain gives remainders 1,0,0,1,1 β†’ 11001β‚‚.
Binary Arithmetic & Signed Numbers
Carry
Binary Arithmetic
πŸ”„ Click to reveal definition
Definition
The overflow of a column sum into the next column. In binary: 1+1 = 0 carry 1, and 1+1+1 = 1 carry 1. Only four addition facts exist in base-2 β€” memorize them and you can add anything.
2's Complement
Binary Arithmetic
πŸ”„ Click to reveal definition
Definition
The standard representation for signed binary: to negate a number, invert every bit and add 1. Subtraction becomes addition of the complement, so one adder circuit handles both operations.
Sign Bit
Binary Arithmetic
πŸ”„ Click to reveal definition
Definition
The MSB in a signed number: 0 = positive, 1 = negative. In 2's complement it carries a negative weight: for 8 bits, βˆ’128. Hence the asymmetric range βˆ’128 to +127.
Overflow
Binary Arithmetic
πŸ”„ Click to reveal definition
Definition
A result too large for the available bits β€” two positives summing to an apparent negative (127+1 = βˆ’128 in 8 bits). Detected when the carry into the sign bit differs from the carry out.
Signed vs. Unsigned
Binary Arithmetic
πŸ”„ Click to reveal definition
Definition
The same 8 bits mean different values by interpretation: 1111 1111 is 255 unsigned but βˆ’1 signed. The bits don't change β€” the reading rule does. The Digital Lab's SIGNED toggle makes this visceral.
Logic Gates
Logic Gate
Logic Gates
πŸ”„ Click to reveal definition
Definition
A circuit (built from Lesson 3's transistors) whose output is a Boolean function of its inputs. HIGH β‰ˆ supply voltage represents 1; LOW β‰ˆ 0 V represents 0. The atoms of every digital system.
Truth Table
Logic Gates
πŸ”„ Click to reveal definition
Definition
The complete specification of a logic function: every input combination (2ⁿ rows for n inputs) and its output. Two circuits with identical truth tables are interchangeable, no matter how different they look.
AND Β· OR Β· NOT
Logic Gates
πŸ”„ Click to reveal definition
Definition
The three primitives. AND (X=AΒ·B): 1 only if all inputs are 1. OR (X=A+B): 1 if any input is 1. NOT (X=AΜ…): the inverter β€” output is the input flipped.
NAND & NOR
Logic Gates
πŸ”„ Click to reveal definition
Definition
AND and OR with inverted outputs (the bubble on the symbol). NAND: 0 only when all inputs are 1. NOR: 1 only when all inputs are 0. Cheaper to build in silicon than their plain versions.
Universal Gate
Logic Gates
πŸ”„ Click to reveal definition
Definition
A gate from which every other logic function can be constructed. NAND and NOR each qualify β€” tie a NAND's inputs together and it becomes a NOT; add that inverter to another NAND and you have AND.
Bubble (Inversion Circle)
Logic Gates
πŸ”„ Click to reveal definition
Definition
The small circle on a gate symbol meaning "invert here." AND + bubble = NAND. Reading and mentally "pushing" bubbles through a diagram (via DeMorgan) is a core schematic-reading skill.
Boolean Algebra
Boolean Algebra
Boolean Algebra
πŸ”„ Click to reveal definition
Definition
The mathematics of two-valued logic (George Boole, 1854): variables are 0 or 1, operations are AND (Β·), OR (+), and NOT (overbar). Its laws let you simplify circuits before building them β€” fewer gates, same truth table.
Identity & Null Laws
Boolean Algebra
πŸ”„ Click to reveal definition
Definition
Identity: AΒ·1 = A and A+0 = A (the neutral elements). Null: AΒ·0 = 0 and A+1 = 1 (the dominating elements). Four one-line rules that collapse many expressions on sight.
Complement & Idempotent Laws
Boolean Algebra
πŸ”„ Click to reveal definition
Definition
Complement: AΒ·AΜ… = 0 and A+AΜ… = 1 (a variable and its inverse). Idempotent: AΒ·A = A and A+A = A (repetition changes nothing β€” there are no exponents or coefficients in Boolean algebra).
Commutative Β· Associative Β· Distributive
Boolean Algebra
πŸ”„ Click to reveal definition
Definition
Order doesn't matter (AΒ·B = BΒ·A), grouping doesn't matter (AΒ·(BΒ·C) = (AΒ·B)Β·C), and AND distributes over OR: AΒ·(B+C) = AΒ·B + AΒ·C β€” just like ordinary algebra, plus the surprising dual A+(BΒ·C) = (A+B)Β·(A+C).
DeMorgan's Theorems
Boolean Algebra
πŸ”„ Click to reveal definition
Definition
The bridge between AND and OR worlds: (AΒ·B)Μ… = AΜ…+BΜ… and (A+B)Μ… = AΜ…Β·BΜ…. In words: break the bar, change the operator. The reason NAND can impersonate every other gate β€” prove it live in the Lab's DeMorgan mode.
Logic Levels (HIGH / LOW)
Boolean Algebra
πŸ”„ Click to reveal definition
Definition
The physical voltages representing 1 and 0 β€” e.g., TTL reads anything above 2.0 V as HIGH and below 0.8 V as LOW. Lesson 4's comparator output slamming between rails was already speaking this language.

πŸ“ Logic Gate Symbol Library

Five gates (plus one preview) that build every digital system ever made. Learn the ANSI shapes cold: the flat-backed D is AND-family, the curved shield is OR-family, and a bubble on the output means invert. Each card shows the Boolean expression and full truth table.

ABX
AND
X = A Β· B
ABX
000
010
100
111
ABX
OR
X = A + B
ABX
000
011
101
111
AX
NOT (Inverter)
X = A̅
AX
01
10
ABX
NAND Β· universal
X = (AΒ·B)̅
ABX
001
011
101
110
ABX
NOR Β· universal
X = (A+B)̅
ABX
001
010
100
110
ABX
XOR Β· Lesson 6 preview
X = A βŠ• B
ABX
000
011
101
110

Core Lesson Content

Crossing the Digital Bridge

Lesson 4 ended with a comparator slamming between two rails β€” an analog circuit producing only two answers. This lesson makes those two answers a complete language. Half the lesson is how digital systems count (number systems and binary arithmetic); the other half is how they decide (gates and Boolean algebra). Both halves rest on the same premise:

πŸ’‘ The Premise of All Digital Electronics
Two reliably distinguishable voltage levels β€” HIGH and LOW, 1 and 0 β€” are enough to represent any number and compute any logical function. Everything from a thermostat to a datacenter is that one idea, repeated billions of times.

The transistor connection matters: a MOSFET (Lesson 3) driven fully on or fully off is a logic level. Wire a few of them together and you get the gates in this lesson; wire a few billion and you get a processor.

Try It Live

Decimal and Binary: One Idea, Two Bases

You already know the only concept required: place value. In decimal, 347 means 3Γ—100 + 4Γ—10 + 7Γ—1 β€” each column weighs ten times its neighbor. Binary works identically with columns weighing two times their neighbor:

Weights (8-bit): 128 Β· 64 Β· 32 Β· 16 Β· 8 Β· 4 Β· 2 Β· 1   β†’   1011 0010β‚‚ = 128+32+16+2 = 178₁₀

Binary β†’ Decimal: Add the Weights

Write the weights over the bits and sum wherever a 1 appears. That's the entire method β€” and exactly what the Digital Lab's Binary Explorer animates as you click bits.

Decimal β†’ Binary: Two Methods

  • Repeated division by 2: divide, keep the remainder, repeat; read remainders bottom-up. 25 β†’ 12 r1 β†’ 6 r0 β†’ 3 r0 β†’ 1 r1 β†’ 0 r1 gives 11001β‚‚.
  • Greatest-weight subtraction: subtract the largest power of 2 that fits, mark that bit 1, repeat. 25 βˆ’ 16 = 9, βˆ’ 8 = 1, βˆ’ 1 = 0 β†’ 11001β‚‚. Faster mentally once the weights are memorized.
🎯 Memorize These Nine Numbers
1, 2, 4, 8, 16, 32, 64, 128, 256. Every conversion, address calculation, and subnet mask in your career reduces to these powers of two. (Notice 2ⁿ βˆ’ 1 patterns too: 255 = all eight bits set.)

Octal and Hexadecimal: Binary Shorthand

Nobody enjoys reading 1010111101101001. Octal and hex exist to compress binary for humans, and both work by the same beautiful accident of powers: 8 = 2³ and 16 = 2⁴, so one octal digit is exactly 3 bits and one hex digit is exactly 4 bits (a nibble).

The Grouping Shortcut (no arithmetic required)

1010 1111 0110 1001β‚‚ β†’ group by 4 β†’ A F 6 9 β†’ AF69₁₆
1 010 111 101 101 001β‚‚ β†’ group by 3 β†’ 1 2 7 5 5 1 β†’ 127551β‚ˆ

Grouping starts from the right (LSB). Convert hex→binary by expanding each digit back to its 4 bits. Between octal and hex? Go through binary — it's the common language.

DecBinOctHexDecBinOctHex
000000081000108
100011191001119
200102210101012A
300113311101113B
401004412110014C
501015513110115D
601106614111016E
701117715111117F
πŸ’‘ Where You'll Meet Them
Hex is everywhere a technician looks: memory addresses (0x7FFC), MAC addresses (00:1A:2B:…), color codes (#0047AB β€” this course's navy!), error codes, firmware dumps, and network packet captures. Octal survives chiefly in Unix file permissions (chmod 755 = rwxr-xr-x). Fluency here is fluency with real equipment.

Arithmetic in Base-N

Binary Addition: Four Facts Total

0+0 = 0  |  0+1 = 1  |  1+1 = 0, carry 1  |  1+1+1 = 1, carry 1

Worked example:

  1111  β† carries
  1011  (11)
+ 0111  (7)
β€”β€”β€”β€”β€”β€”
 1 0010  (18) βœ“

The rhythm is identical to decimal addition β€” you just carry at 2 instead of at 10. The same is true in any base: hex carries at 16 (9 + 8 = 11₁₆, i.e., "one-one": 1 carry, 1 down).

Binary Subtraction

Borrowing works (0 βˆ’ 1 borrows a 2 from the next column), but real hardware doesn't bother: it adds the 2's complement instead β€” one adder circuit, both operations. That trick is the whole next tab.

Hex Arithmetic

  3A₁₆ (58)
+ 2C₁₆ (44)
β€”β€”β€”β€”β€”
  66₁₆ (102) βœ“   (A+C = 10+12 = 22 = 16+6 β†’ write 6, carry 1)
🎯 Quiz Tip
Always sanity-check base-N arithmetic by converting to decimal: if the decimal versions of your operands don't sum to the decimal version of your answer, hunt for a dropped carry. The Digital Lab's +1 button lets you watch carries ripple through a live binary counter.

Signed Binary: 2's Complement

Bits have no minus sign, so we spend one bit to encode it. The naive approach (sign-magnitude) creates two zeros and breaks the adder. The universal solution is 2's complement, where the MSB carries negative weight:

8-bit signed weights: βˆ’128 Β· 64 Β· 32 Β· 16 Β· 8 Β· 4 Β· 2 Β· 1  β†’  range βˆ’128 … +127

Negating a Number: Invert and Add One

+25 = 0001 1001  β†’ invert β†’ 1110 0110  β†’ +1 β†’ 1110 0111 = βˆ’25
Check: βˆ’128+64+32+4+2+1 = βˆ’25 βœ“

Why Hardware Loves It

  • Subtraction = addition: A βˆ’ B is computed as A + (βˆ’B). One adder does everything; the carry out of the top bit is simply discarded.
  • One zero, instant sign test: MSB = 1 means negative, full stop.
  • Overflow is detectable: add two positives and get a negative (0111 1111 + 1 = 1000 0000, i.e., 127+1 = βˆ’128) β€” the classic wraparound. Watch it live in the Lab with the SIGNED toggle on.
⚠️ Watch Out: Interpretation, Not Bits
1111 1111 is 255 to an unsigned reader and βˆ’1 to a signed reader β€” same byte, same voltages. Countless real bugs (and more than a few security exploits) trace to code reading a value with the wrong rule. The Lab's SIGNED/UNSIGNED toggle exists to burn this into memory.

The Five Fundamental Gates

A logic gate is a transistor circuit that computes one Boolean operation. Its complete personality fits in a truth table β€” list every input combination (2ⁿ rows) and the output for each. Master these five tables and you can read any digital schematic:

GateExpressionOutput is 1 when…Memory Hook
ANDX = AΒ·BALL inputs are 1Series switches β€” both must close
ORX = A+BANY input is 1Parallel switches β€” either path works
NOTX = A̅Input is 0The flip β€” one in, opposite out
NANDX = (AΒ·B)̅NOT all inputs are 1AND flipped β€” 0 only at 1,1
NORX = (A+B)̅ALL inputs are 0OR flipped β€” 1 only at 0,0

Reading the Symbols

  • Shape carries meaning: flat-backed D = AND family; curved shield = OR family; triangle = buffer/inverter.
  • The bubble is a NOT: NAND is literally the AND symbol wearing a bubble. No bubble, no inversion.
  • The dot and plus are operators, not arithmetic: AΒ·B reads "A AND B"; A+B reads "A OR B". In Boolean land 1+1 = 1.
🎯 Quiz Tip
Two-input truth tables always list inputs in binary counting order: 00, 01, 10, 11 β€” connecting this tab to Tab 2. For n inputs expect 2ⁿ rows; a question showing 8 rows is telling you there are 3 inputs.

NAND and NOR: The Universal Gates

Here is one of digital design's most elegant facts: you don't need five gate types. NAND alone can build everything β€” and so can NOR. A gate with this property is called universal.

Building the Basics from NAND

  • NOT: tie both NAND inputs together. (AΒ·A)̅ = A̅ β€” the idempotent law in action.
  • AND: NAND followed by that NAND-inverter. Two gates.
  • OR: invert each input, then NAND them: A̅ NAND B̅ = (A̅Β·B̅)̅ = A + B β€” which is DeMorgan's theorem doing the heavy lifting. Three gates.

The NOR story is the perfect mirror (swap the roles of AND and OR throughout β€” Boolean algebra's duality principle).

Why This Matters Beyond Elegance

  • Silicon economics: in CMOS, NAND is the cheapest, fastest gate to fabricate β€” so real chips are seas of NAND with everything else synthesized from it. ("NAND flash" memory earned its name honestly.)
  • Inventory reality: a technician with a tube of 7400 quad-NAND ICs can prototype any logic function on the bench.
  • Historical proof: the Apollo Guidance Computer was built entirely from one gate type β€” 3-input NOR β€” about 5,600 of them, navigating to the Moon.
πŸ’‘ See It, Don't Take It on Faith
The Digital Lab's DeMorgan mode places a NAND gate beside an OR-with-inverted-inputs and drives both from the same switches. Step through all four input combinations and watch the outputs agree every single time β€” that agreement is universality.

The Laws of Boolean Algebra

Boolean algebra lets you simplify a circuit on paper before spending gates on it. Fewer gates means lower cost, less power, and fewer failure points. The laws come in memorable pairs β€” every AND rule has an OR twin (duality):

LawAND formOR formPlain English
IdentityA Β· 1 = AA + 0 = ANeutral elements change nothing
NullA Β· 0 = 0A + 1 = 1Dominating elements decide everything
IdempotentA Β· A = AA + A = ARepetition is redundant
ComplementA Β· A̅ = 0A + A̅ = 1A thing and its opposite
CommutativeAΒ·B = BΒ·AA+B = B+AOrder doesn't matter
AssociativeAΒ·(BΒ·C) = (AΒ·B)Β·CA+(B+C) = (A+B)+CGrouping doesn't matter
DistributiveAΒ·(B+C) = AΒ·B + AΒ·CA+(BΒ·C) = (A+B)Β·(A+C)The second form has no decimal twin!
InvolutionA̅̅ = ADouble negation cancels

Worked Simplification

X = AΒ·B + AΒ·B̅
  = AΒ·(B + B̅)   β† distributive (factor A)
  = AΒ·(1)        β† complement law
  = A           β† identity law

Three gates collapsed to a piece of wire β€” and the truth tables of the original and simplified expressions are identical, which is the only test that matters.

🎯 Quiz Tip
When a simplification stalls, build the truth table instead β€” 2ⁿ rows of brute force always works, and comparing tables proves (or disproves) any claimed identity. Algebra is the shortcut; the table is the referee.

DeMorgan's Theorems and Truth Table Analysis

Augustus DeMorgan's two theorems are the master keys of gate-level reasoning β€” they convert freely between the AND world and the OR world:

(A Β· B)̅ = A̅ + B̅    NAND = OR of inverted inputs
(A + B)̅ = A̅ Β· B̅    NOR  = AND of inverted inputs

The verbal rule: break the bar, change the operator (Β· ↔ +), and complement each term. The schematic rule: a bubble on a gate's output can be "pushed" to its inputs if you also swap the gate's shape β€” invaluable when a schematic is drawn in mixed logic.

Proof by Truth Table

ABAΒ·B(AΒ·B)̅A̅+B̅
0001111
0101101
1001011
1110000

Columns four and seven match on every row β€” the theorem is proven, no algebra required. This column-by-column construction is the general method for analyzing any combinational circuit: work from the inputs through each intermediate signal to the output, one column per node.

Analysis Procedure for Any Gate Network

  1. Label every internal node on the schematic.
  2. Build a truth table with a column for each node, filling left to right.
  3. The final column is the circuit's function β€” compare it against the five standard tables (or a required spec).
  4. Optionally, write the Boolean expression by composing gate expressions from output back to inputs, then simplify with Tab 8's laws and re-verify by table.
πŸ’‘ Course Thread
Comparator decisions (L4) became logic levels; logic levels became numbers and gates (this lesson). Next, gates combine into adders, encoders, and multiplexers β€” combinational circuits that compute β€” before flip-flops give digital systems a memory.

πŸ“ˆ Interactive 3-Mode Digital Lab

Three instruments in one panel. Binary Explorer: click bits directly on the canvas and watch decimal, hex, octal, and 2's-complement readings update live β€” then press +1 repeatedly to watch carries ripple. Gate Lab: pick a gate, flip the input switches, and see the truth-table row light up. DeMorgan Prover: two different circuits, one pair of switches, identical outputs on every row β€” the theorem proven before your eyes.

πŸ’‘ The canvas is clickable β€” toggle bits and switches directly.

πŸ’‘ Guided Explorations
1. Weights are everything: in Binary Explorer, build 178 by clicking only the bits whose weights sum to it (128+32+16+2). 2. Ripple carry: set 0111 1111 (127) and press +1 β€” watch eight bits flip in one step, and with SIGNED on, watch +127 wrap to βˆ’128 (overflow!). 3. Shifts are arithmetic: set 0000 0110 (6) and press << twice β€” doubling each time. 4. Invert-plus-one: set 25, press Invert, then +1, switch to SIGNED: βˆ’25. You just executed 2's complement by hand. 5. Gate fingerprints: in Gate Lab, find the single input combination that makes AND output 1 and the single one that makes NOR output 1. 6. The proof: in DeMorgan mode press Step Row four times β€” the two outputs agree on every row, for both theorems.

πŸ§ͺ Companion Simulators

Key Facts Reference Box

Binary Weights (8-bit)
128 Β· 64 Β· 32 Β· 16 Β· 8 Β· 4 Β· 2 Β· 1
Grouping Shortcuts
Hex = 4 bits/digit Β· Octal = 3 bits/digit
Hex Digits
0–9 then A=10 … F=15
One Byte
8 bits = 2 hex digits = 0–255
Binary Addition Facts
1+1 = 0 c1 Β· 1+1+1 = 1 c1
Negate (2's Complement)
Invert all bits, then add 1
Signed 8-bit Range
βˆ’128 to +127 (MSB weighs βˆ’128)
Same Bits, Two Readings
1111 1111 = 255 unsigned = βˆ’1 signed
AND / OR Rules
AND: all 1s Β· OR: any 1
NAND / NOR Rules
NAND: 0 only at all-1s Β· NOR: 1 only at all-0s
Universal Gates
NAND and NOR each build everything
Truth Table Size
n inputs β†’ 2ⁿ rows
Identity / Null
AΒ·1=A, A+0=A Β· AΒ·0=0, A+1=1
Complement Law
AΒ·A̅=0 Β· A+A̅=1
DeMorgan #1
(AΒ·B)̅ = A̅ + B̅
DeMorgan #2
(A+B)̅ = A̅ Β· B̅

Interactive Knowledge Check

Test your understanding with ten questions. Select your answers and click "Submit Answers" for your score and detailed feedback.

Score: 0 / 10

Please complete all questions to view your results.

← Lesson 4: Amplifiers & Op-Amps 🏠 ELT 102 Home Next: Lesson 6 β†’