Computer Science · Topic Cheatsheet
Topic 2 · Computer Organisation
33 key results accumulated across 4 chapters.
Place value
Ch 1
Binary `1010` = 8+2 = 10.
Denary → binary
Ch 1
Divide by 2; remainders read bottom-up.
Binary → hex
Ch 1
Group bits in 4s from the right; each nibble is one hex digit.
Hex digits
Ch 1
A=10, B=11, C=12, D=13, E=14, F=15.
Fractions
Ch 1
Multiply by 2; carries read top-down. May repeat → inexact floats.
Two's complement
Ch 2
−x = flip every bit of x, then add 1. Subtraction becomes addition.
Sign bit
Ch 2
Leading bit: 0 = non-negative, 1 = negative.
n-bit range
Ch 2
−2^(n−1) to 2^(n−1)−1. 8 bits → −128 to +127.
Gates
Ch 2
AND (both), OR (either), NOT (flip); NAND/NOR/XOR built from these.
Truth table
Ch 2
n inputs → 2ⁿ rows; precedence NOT → AND → OR.
De Morgan
Ch 2
NOT(A AND B) = NOT A OR NOT B.
CPU
Ch 3
Central Processing Unit. The chip that runs every instruction. Brain of every computer.
Three CPU parts
Ch 3
Control Unit (manager, fetches + decodes) + ALU (worker, does maths/logic) + Registers (tiny notebooks, hold current values).
Fetch–Decode–Execute
Ch 3
Eternal loop. FETCH instruction from RAM (using PC) → DECODE (CU) → EXECUTE (ALU/etc) → PC advances → repeat.
Program Counter (PC)
Ch 3
Special register holding the ADDRESS of the next instruction. JUMP instructions overwrite it.
Instruction Set (ISA)
Ch 3
The fixed list of operations a CPU understands (LOAD, ADD, JUMP). x86 (Intel/AMD), ARM (phones/Apple).
Clock speed (GHz)
Ch 3
Cycles per second. 3 GHz = 3 billion. Higher = more work + more heat + more power.
Cores
Ch 3
Multiple complete CPUs on one chip. Each runs independently. 4-core 3 GHz can do up to 12 GHz of total work — IF the program is parallel.
Memory hierarchy
Ch 3
Register (~1 ns) → L1 (~1 ns) → L2 (~3 ns) → L3 (~12 ns) → RAM (~100 ns) → SSD (~100 μs) → HDD (~10 ms). Each step ~10× larger + slower.
Cache hit / miss
Ch 3
HIT: data is in cache, ~1 ns. MISS: data not in cache, ~100 ns + CPU stall = ~300 wasted cycles.
Locality of reference
Ch 3
Why caches work. Temporal: recent addresses likely reused. Spatial: nearby addresses likely accessed next.
RAM vs storage
Ch 3
RAM = working memory, fast, VOLATILE (lost on power off). Storage (SSD/HDD) = permanent, slow, non-volatile.
Exam trap
Ch 3
CU ≠ ALU. CU manages, ALU computes. RAM ≠ Cache. Cache is smaller, on-CPU, ~100× faster.
Binary addition
Ch 4
Bit rules: 0+0=0, 0+1=1, 1+1=10 (write 0 carry 1), 1+1+1=11 (write 1 carry 1).
Subtraction = addition
Ch 4
Subtract X by adding the two's-complement negation of X. One adder circuit does both.
Overflow
Ch 4
Result outside the representable range. In n-bit two's complement: max +2^(n-1)−1, min −2^(n-1). Overflow gives a SILENTLY wrong result.
Hex ↔ binary
Ch 4
Each hex digit = exactly 4 bits. Convert digit-by-digit. Hex is binary in compact form.
De Morgan's Laws
Ch 4
NOT(A AND B) = (NOT A) OR (NOT B). NOT(A OR B) = (NOT A) AND (NOT B).
Absorption Law
Ch 4
X OR (X AND Y) = X. X AND (X OR Y) = X. Used to simplify expressions and reduce gate count.
XOR
Ch 4
Exclusive OR: true when inputs DIFFER. Standard form: (A AND NOT B) OR (NOT A AND B).
Floating-point trap
Ch 4
0.1 + 0.2 ≠ 0.3 exactly. Most decimal fractions cannot be represented in binary precisely → rounding errors.
Bit width matters
Ch 4
Always pick a type wide enough for your value range. 16-bit signed → ±32767. Ariane 5: $370M lost to one overflow.
Cache-friendly code
Ch 4
Iterate data in MEMORY ORDER (row-major in C/Python). Same algorithm, 10× speed difference is realistic.