4.1.2Computer Architecture (Deep)

Harvard architecture — separate instruction - data memory

1,859 words8 min readdifficulty · medium1 backlinks

WHY does Harvard exist?


WHAT is it, precisely?

Figure — Harvard architecture — separate instruction - data memory

HOW does the speed-up arise? (Derive it from first principles)

We model a memory access as taking 1 cycle. Consider executing NN instructions where a fraction ff of them also touch data (loads/stores).

Von Neumann — each shared-bus cycle does either fetch or data:

  • Every instruction needs 1 fetch cycle: NN cycles.
  • Each of the fNfN data-touching instructions needs another cycle on the same bus: fNfN cycles.

TvN=N+fN=N(1+f)T_{\text{vN}} = N + fN = N(1+f)

Why this step? The single bus serializes fetch and data, so their cycle costs add.

Harvard — fetch (instruction bus) and data (data bus) run in parallel:

  • All NN fetches happen on the instruction bus: NN cycles.
  • The fNfN data accesses overlap inside those same cycles on the data bus → cost 0 extra (when they don't collide).

TH=NT_{\text{H}} = N

Why this step? Two buses → the data access is "hidden under" the fetch. Costs don't add, they overlap (max, not sum).

Speed-up: S=TvNTH=N(1+f)N=1+f\boxed{S = \frac{T_{\text{vN}}}{T_{\text{H}}} = \frac{N(1+f)}{N} = 1+f}


The "Modified Harvard" twist (what real chips do)


Worked Examples


Common Mistakes (Steel-manned)


Recall Feynman: explain to a 12-year-old

Imagine a chef (the CPU). He needs recipes (instructions) and ingredients (data). In one kitchen (von Neumann) there's a single door to the pantry, so he must walk out for a recipe, come back, then walk out again for ingredients — one thing per trip. In the Harvard kitchen there are two doors: one always brings recipes, one always brings ingredients. Two helpers run at the same time, so the chef never waits. The catch: the recipe-door is usually one-way (you can't easily shove new recipes back in), which is why most real kitchens use a clever mix — separate doors near the chef, but one big shared storeroom in the back.


Active-Recall Flashcards

#flashcards/coding

What single problem does Harvard architecture attack?
The von Neumann bottleneck — instruction fetch and data access competing for one shared bus.
In Harvard architecture, what is physically separate?
Instruction memory + bus and data memory + bus (and often the caches).
What can a Harvard CPU do in one cycle that a von Neumann CPU cannot?
Fetch an instruction AND access data simultaneously.
Idealized Harvard speed-up formula, with symbol meaning?
S=1+fS = 1+f, where ff is the fraction of instructions that access data memory.
If f=0f=0, what is the speed-up and why?
S=1S=1 (none); with no data traffic there's nothing for the second bus to overlap.
What is Modified Harvard architecture?
Unified main memory (von Neumann-like) but separate L1 instruction and data caches — flexible like vN, fast like Harvard near the CPU.
Why is pure Harvard awkward for loading programs / self-modifying code?
Instruction memory is separate (often read-only), so you can't easily write a program as data into it.
Give one practical advantage of separate memories besides speed.
Different word widths / address sizes for instructions vs data (cheaper, tighter embedded designs).
Name real chip families that use Modified Harvard.
AVR, PIC, ARM Cortex-M microcontrollers.
Steel-man: why might someone think Harvard means two CPUs, and the fix?
"Separate + parallel" sounds like multiprocessing; fix — it's ONE CPU with TWO memory paths.

Connections

  • Von Neumann architecture — the single-bus design Harvard contrasts with.
  • Von Neumann bottleneck — the exact problem Harvard targets.
  • CPU instruction cycle — fetch/decode/execute; Harvard parallelizes fetch with data access.
  • Cache memory — split I-cache/D-cache = Modified Harvard in modern CPUs.
  • Pipelining — overlapping stages; Harvard removes structural hazards on memory.
  • Microcontrollers (AVR PIC ARM Cortex-M) — real-world Harvard/Modified-Harvard users.
  • Memory bus and bandwidth — why two buses double effective memory throughput.

Concept Map

shares one bus, causes

motivates

has

has

enables

enables

serializes, cost adds to

overlaps, cost is

divided by

divided by

relaxed into

allows load code as data

Von Neumann single bus

von Neumann bottleneck

Harvard architecture

Instruction memory + bus

Data memory + bus

Fetch and data in parallel

T_vN = N times 1+f

T_H = N

Speed-up S = 1+f

Modified Harvard

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, CPU ko do cheezein chahiye hoti hain: instructions (kya karna hai) aur data (kis par karna hai). Von Neumann design mein dono ek hi memory aur ek hi bus (taar) se aate hain. Problem yeh hai ki ek time pe bus se sirf ek hi cheez aa sakti hai — ya toh instruction fetch karo, ya data lao. Isi ko von Neumann bottleneck kehte hain, CPU bekar mein wait karta rehta hai.

Harvard architecture ka idea simple hai: do alag memory aur do alag bus banao — ek sirf instructions ke liye, ek sirf data ke liye. Ab CPU ek hi clock cycle mein dono kaam saath kar sakta hai: instruction bhi fetch, aur data bhi access. Ek chef ke do darwaaze samjho — ek se recipe aati hai, doosre se ingredients, dono ek saath. Isliye speed badh jaati hai.

Kitni badhti hai? Formula hai S=1+fS = 1+f, jahan ff woh fraction hai jo instructions data ko touch karte hain (loads/stores). Agar har instruction data use kare (f=1f=1) toh 2×2\times fast; normal programs mein f0.3f \approx 0.30.40.4, yaani 1.31.31.4×1.4\times. Agar program sirf register arithmetic kare (f=0f=0), toh koi fayda nahi — kyunki overlap karne ko kuch hai hi nahi.

Real-world mein pure Harvard kam milta hai, kyunki program ko load karna mushkil ho jaata hai (instruction memory alag aur read-only). Isliye modern CPUs Modified Harvard use karte hain: neeche ek hi badi shared memory (von Neumann jaisa, flexible), lekin CPU ke paas alag I-cache aur D-cache. Best of both — AVR, PIC, ARM Cortex-M microcontrollers sab yahi use karte hain.

Go deeper — visual, from zero

Test yourself — Computer Architecture (Deep)

Connections