4.1.2 · D4Computer Architecture (Deep)

Exercises — Harvard architecture — separate instruction - data memory

2,525 words11 min readBack to topic

Level 1 — Recognition

Exercise 1.1

Which single problem does Harvard architecture exist to attack, and in one sentence, how does it attack it?

Recall Solution

Problem: the Von Neumann bottleneck — on a single shared bus the CPU must choose each cycle to either fetch an instruction or move data, never both. How Harvard attacks it: it gives instructions and data physically separate memories and buses, so one instruction fetch and one data access happen in the same cycle (in parallel). One wire carries one signal; two wires carry two.

Exercise 1.2

Label each item as living on the instruction path or the data path in a pure Harvard machine: (a) a load's fetched opcode, (b) the value a store writes to RAM, (c) the read-only program image, (d) a variable being incremented.

Recall Solution
  • (a) fetched opcode → instruction path (every instruction is fetched over the instruction bus).
  • (b) value written by storedata path (data bus, which is read and write).
  • (c) read-only program image → instruction path (instruction memory, usually read-only).
  • (d) variable being incremented → data path.

Cross-check against the figure above: the black boxes are the instruction-path traffic (a, c); the red boxes are the data-path traffic (b, d).


Level 2 — Application

Exercise 2.1

A loop runs instructions; of them are loads/stores. Compute , , and .

Recall Solution

What we do: plug into the carried formulas. Why: fetches on the shared bus, plus extra data turns that must wait their turn on that same bus. (In the s01 figure: extra red boxes stacked beside the black ones.) Why: the data accesses overlap the fetches on the second bus — they cost extra cycles. (In the s01 figure: those red boxes slide under the black ones.)

Exercise 2.2

On the same , what value of would make Harvard take cycles while von Neumann takes ? Interpret it.

Recall Solution

What we do: Harvard cost is always regardless of . Set von Neumann to : Interpretation: half the instructions touch data. Then — Harvard is faster. This is a memory-heavy workload, exactly where the second bus pays off.


Level 3 — Analysis

Exercise 3.1

Two workloads run on the same Harvard chip. Workload A: . Workload B: . Which benefits more from Harvard, and by how much (as a ratio of their speed-ups)?

Recall Solution

Workload B benefits more. Why: the speed-up scales with memory pressure . B does more data traffic fraction, so there is far more work for the second bus to hide. Register-bound A (little data traffic) leaves the data bus mostly idle.

Exercise 3.2

A designer claims: "Adding the second Harvard bus always at least doubles performance." Show the maximum possible from the ideal model and state when it is reached.

Recall Solution

and can be at most (you cannot have more than 100% of instructions touch data). So: reached only when every instruction accesses data (). The claim "always doubles" is false in two ways: (1) is a ceiling, not a guarantee; (2) it is reached only in the extreme case. For typical , .


Level 4 — Synthesis

Exercise 4.1

Design decision: your embedded target runs code with . Chip A is pure von Neumann costing 1 area-unit. Chip B is Harvard costing 1.6 area-units (two memory systems). Define performance-per-area as and decide which chip wins on this metric. (Von Neumann's own baseline is .)

Recall Solution

What we do: compute for each.

  • Von Neumann: , area .
  • Harvard: , area . Decision: on performance-per-area, von Neumann wins () at this low . Harvard buys speed but pays area — the extra hardware isn't "paid back" here. Insight: Harvard's advantage must clear its area cost. It wins on raw speed but can lose on efficiency when is small.

Exercise 4.2

Explain why real microcontrollers (AVR/PIC/ARM Cortex-M) use Modified Harvard rather than pure Harvard, and describe the mechanism in terms of the two paths.

Recall Solution

Problem with pure Harvard: instruction memory is separate and usually read-only, so you cannot easily write a program as data into it — loading firmware, running a compiler's output, or self-modifying code all break. Modified Harvard mechanism: a single unified main memory at the bottom (von Neumann-style, so programs load as ordinary data), but split L1 caches near the CPU — a separate I-cache on the instruction path and a D-cache on the data path. On the hot path the CPU fetches from I-cache and accesses D-cache in parallel (Harvard's win); the flat unified memory keeps flexibility (von Neumann's win). "Best of both."


Level 5 — Mastery

Exercise 5.1 — Refining the model

The base model assumes each data-touching instruction does one access. Now suppose the data-touching instructions do on average data accesses each (e.g. a memcpy-style op reading and writing). On a single bus these all serialize; on Harvard the data bus handles them while fetches proceed, but the data bus itself can carry only one access per cycle. Derive , , and . Then evaluate for , , .

Recall Solution

Von Neumann — one shared bus, everything serializes: Harvard — the instruction bus needs cycles for fetches. The data bus needs cycles for data (only one access per cycle). They run in parallel, so total time is the larger of the two (whichever bus is the bottleneck): Why and not sum: the two buses overlap, so the machine waits only for the slower stream to finish. Speed-up: Evaluate : here .

  • cycles.
  • , so the data bus is the bottleneck: cycles.
  • . Insight: because , the data bus is now busier than the instruction bus — the fetches hide "under" the data accesses instead of the reverse. Harvard still helps, but the ideal formula no longer applies once one bus saturates.

Exercise 5.2 — Degenerate cases

For the refined model , evaluate and interpret all boundary cases: (a) ; (b) (recover the base model); (c) exactly; (d) . Sketch against and mark where it peaks.

Recall Solution

(a) (pure register arithmetic): , so , giving No data traffic ⇒ nothing to overlap ⇒ no speed-up. The data bus sits idle. (b) : then , so , giving exactly the base-model formula — good, our refined model contains it as a special case. (c) (both buses equally loaded, perfectly balanced): , The maximum "balanced" speed-up — both buses fully busy, neither waiting. (d) (data completely dominates): , so As data traffic grows without bound, both machines are dominated by the same data stream, and Harvard's fixed instruction bus becomes negligible — the advantage shrinks back toward . Peak benefit is at the balance point , not at extreme data load.

The shape of these four cases is exactly the curve below — read it as the answer to "how does the speed-up move as I add data accesses?"

Figure — Harvard architecture — separate instruction - data memory

Follow the red curve left-to-right: it climbs from at (case a), rises linearly along the branch while the instruction bus is the bottleneck (case b region), hits its peak at the black dot (case c, balanced buses), then bends over and sinks back toward the dashed line as (case d, the data bus saturates and dominates both machines).


Connections

  • Parent: Harvard architecture (Hinglish) — the concepts these exercises drill.
  • Von Neumann architecture — the single-bus baseline used in the area/efficiency exercise.
  • Von Neumann bottleneck — the problem quantified by .
  • CPU instruction cycle — the fetch each instruction pays for on the instruction bus.
  • Cache memory — split I-cache/D-cache in the Modified Harvard exercise.
  • Pipelining — overlapping stages; parallels the "overlap" logic in these speed-up derivations.
  • Microcontrollers (AVR PIC ARM Cortex-M) — the real Modified-Harvard chips of Exercise 4.2.
  • Memory bus and bandwidth — why balanced two-bus bandwidth matters (Level 5).