15. Computer Architecture: Von Neumann Model, Memory Bottleneck, and Memory Hierarchy

Von Neumann Architecture and Instruction Execution

  • The Von Neumann Model serves as the foundational architectural blueprint for modern computing platforms, including laptops, mobile devices, and high-end enterprise servers.

  • System Architecture Structure:

    • Central Processing Unit (CPU): Executes operational instructions.

    • Memory Subsystem: Stores both program instructions and data operands (variables operated upon by instructions).

  • Phases of Instruction Execution:

    • Instruction Fetch (tfetcht_{\text{fetch}}): Retrieves the target instruction from memory.

    • Instruction Decode (tdecodet_{\text{decode}}): Interprets the instruction within the CPU to identify required operations and operand requirements.

    • Operand Fetch (tfetch_operandst_{\text{fetch\_operands}}): Retrieves required data variables from memory (e.g., fetching variables aa and bb for an addition operation).

    • Instruction Execution (texect_{\text{exec}}): Performs the decoded operation inside the CPU (e.g., adding aa and bb).

    • Result Writeback (twrite_resultt_{\text{write\_result}}): Stores the execution output back into memory (e.g., writing the result into variable cc).

  • Instruction Operand Variations:

    • Standard multi-operand instructions perform operations across multiple memory variables.

    • Single-operand or zero-operand control instructions (e.g., stop or halt) execute without needing operand fetch phases.

  • Timing Categorization of Execution Phases:

    • Memory Access Time (tmemt_{\text{mem}}): Aggregates memory-bound operations, where tmem=tfetch+tfetch_operands+twrite_resultt_{\text{mem}} = t_{\text{fetch}} + t_{\text{fetch\_operands}} + t_{\text{write\_result}}.

    • CPU Processing Time (tCPUt_{\text{CPU}}): Aggregates internal CPU operations, where tCPU=tdecode+texect_{\text{CPU}} = t_{\text{decode}} + t_{\text{exec}}.

    • Total Instruction Execution Time (tinstructiont_{\text{instruction}}): Evaluated as tinstruction=tCPU+tmemt_{\text{instruction}} = t_{\text{CPU}} + t_{\text{mem}}.

Memory Bottleneck and Amdahl's Law

  • The Von Neumann / Memory Bottleneck Principle:

    • As CPU hardware performance scales higher (tCPU→0 nst_{\text{CPU}} \rightarrow 0\,\text{ns}) through frequency scaling or multi-core integration (e.g., 4-core, 8-core, 16-core configurations), the overall execution time approaches memory latency (tinstruction→tmemt_{\text{instruction}} \rightarrow t_{\text{mem}}).

    • Total instruction execution speed shifts from being CPU-bound to being memory-bound.

  • Relationship to Amdahl's Law:

    • Optimizing CPU speed without optimizing memory latency causes the unoptimized memory subsystem to dominate total execution time.

  • Quantitative Acceleration Example:

    • Baseline system: tCPU=10 nst_{\text{CPU}} = 10\,\text{ns} and tmem=10 nst_{\text{mem}} = 10\,\text{ns}, yielding tinstruction=20 nst_{\text{instruction}} = 20\,\text{ns}.

    • CPU sped up by 10×10\times: tCPU=1 nst_{\text{CPU}} = 1\,\text{ns} and tmem=10 nst_{\text{mem}} = 10\,\text{ns}, yielding tinstruction=11 nst_{\text{instruction}} = 11\,\text{ns}.

    • CPU sped up by 100×100\times: tCPU=0.1 nst_{\text{CPU}} = 0.1\,\text{ns} and tmem=10 nst_{\text{mem}} = 10\,\text{ns}, yielding tinstruction=10.1 nst_{\text{instruction}} = 10.1\,\text{ns}.

    • CPU sped up by 1000×1000\times: tCPU=0.01 nst_{\text{CPU}} = 0.01\,\text{ns} and tmem=10 nst_{\text{mem}} = 10\,\text{ns}, yielding tinstruction=10.01 nst_{\text{instruction}} = 10.01\,\text{ns}.

    • Limit: Instruction execution time cannot drop below the 10 ns10\,\text{ns} memory floor regardless of CPU speed improvements.

  • Multi-Core Performance Implications:

    • Adding CPU cores turns the processor into a larger, higher-throughput compute engine that requires data and instruction delivery at proportional speeds.

    • Neglecting memory latency starves multi-core processors, turning memory bandwidth into a primary bottleneck.

Cost-Performance Analysis of All-SRAM Memory

  • Pure Static RAM (SRAM) Memory System Feasibility:

    • Fabricating main memory using the fast transistor technology of CPUs eliminates memory latency bottlenecks but introduces severe financial constraints.

  • Back-of-the-Envelope Cost Derivation:

    • High-end microprocessor chip retail price: $500\$500 to $1,000\$1,000 (evaluated at $1,000\$1,000 for order-of-magnitude analysis).

    • Microprocessor transistor density: ≈109\approx 10^9 transistors (1 billion1\,\text{billion}).

    • Cost per CPU transistor: $1,000109=$10−6\frac{\$1,000}{10^9} = \$10^{-6} per transistor.

    • SRAM cell design constraints: Requires ≈10\approx 10 transistors per bit cell (comprising 4 transistors across 2 cross-coupled NOR gates, plus clocking/access logic gates).

    • Cost per bit of SRAM: 10×$10−6=$10−510 \times \$10^{-6} = \$10^{-5} per bit.

    • Storage cost calculation for 1 GB1\,\text{GB} SRAM:

    • 1 GB≈8×109 bits1\,\text{GB} \approx 8 \times 10^9\,\text{bits}.

    • Cost of 1 GB1\,\text{GB} SRAM: 8×109×$10−5=$80,0008 \times 10^9 \times \$10^{-5} = \$80,000

    • System cost scale for a typical 16 GB16\,\text{GB} system memory: 16×$80,000=$1,280,00016 \times \$80,000 = \$1,280,000 (approaching $500,000\$500,000 to $1,000,000\$1,000,000).

  • System Cost Balance Principle:

    • Balanced computer engineering allocates system budgets across three equal tiers:

    1. Central Processing Unit (CPU).

    2. Memory and Storage systems.

    3. Input/Output (I/O) interfaces (displays, keyboards, joysticks, VR/AI goggles).

    • Spending $1,000\$1,000 on a CPU and $80,000\$80,000 to $1,000,000\$1,000,000 on memory destroys balanced economic trade-offs.

Locality Principles and Working Set Hypothesis

  • Optimal Design Goal:

    • Construct a memory system delivering an effective latency matching fast SRAM (0.5 ns−2.5 ns0.5\,\text{ns} - 2.5\,\text{ns}) while maintaining a cost per bit matching dynamic RAM (DRAM, ≈$1\approx \$1 per GB).

  • The Principle of Locality:

    • Execution locality dictates memory system throughput, analogous to how geographic location dictates real estate value.

  • Spatial Locality:

    • Definition: If a program accesses memory address mm at time tt, memory accesses during a small subsequent time window t+Δtt + \Delta t will be clustered in the address range m±Δmm \pm \Delta m in memory space.

    • Causes: Sequential program instruction execution (I,I+1,I+2I, I+1, I+2) and linear traversal of continuous data structures (such as arrays and matrices).

  • Temporal Locality:

    • Definition: If a program accesses memory address mm at time tt, the same address mm is highly likely to be accessed repeatedly within time interval t+Δtt + \Delta t.

    • Causes: Program execution loops repeating code blocks, reused variables, and induction variables inside loop conditions.

  • Destruction of Locality and System Stress Testing:

    • Unstructured programs containing random goto jumps continuously branch across non-contiguous memory locations, destroying spatial and temporal locality.

    • Synthetic stress-test workloads purposefully inject random jump operations to force worst-case memory latency performance.

  • The Working Set Hypothesis:

    • Although a program's total address space (all instructions and data) spans gigabytes, the program actively accesses only a localized subset—the working set (kilobytes to megabytes)—during any given phase of execution t+Δtt + \Delta t.

    • Operational Analogies:

    • Home Library vs. Nightstand: A reader owns 1,000 books in a library, but keeps only 2 active books on a nightstand for immediate bed-time reading.

    • Pantry vs. Kitchen Counter: A cook keeps bulk goods in a pantry, but places active tools and ingredients directly on the counter.

    • Web Browser Caches: Browsers pre-fetch pages hyperlinked off an active web page and store them locally to accelerate navigation.

Memory Hierarchy Architecture

  • Hierarchy Levels (Ordered by Speed, Capacity, and Cost):

    • Registers and Caching Layer (SRAM): On-chip integration; latency of 0.5 ns−2.5 ns0.5\,\text{ns} - 2.5\,\text{ns}; cost of thousands of dollars per GB; capacity in KB to MB.

    • Main Memory Layer (DRAM): System motherboard board integration; latency of 50 ns−100 ns50\,\text{ns} - 100\,\text{ns} (50−10050 - 100 clock cycles); cost of ≈$1\approx \$1 per GB; capacity in GB.

    • Solid State Storage (SSD / Flash Memory): Intermediate non-volatile storage layer situated between DRAM and mechanical media.

    • Magnetic Disk Storage: Secondary bulk media; high latency; high capacity in TB; used for archiving in servers and desktops.

    • Cloud / Network Storage: Remote server farms accessible via network interfaces; infinite scale; used purely for long-term archiving.

  • Physical Proximity Rule:

    • Memory levels with the lowest latency are positioned physically closest to the processor (e.g., registers and cache on the CPU die, DRAM on the main system board).

  • System Virtualization and Memory Transparency:

    • Multi-tiered hardware structures operate transparently to software developers.

    • Applications operate across a unified virtual memory space without needing manual instructions to move variables between registers, cache, DRAM, or secondary storage.

Cache Operations and Average Memory Access Time

  • Line/Block Transfer Units:

    • Data transfers between main memory (DRAM) and cache (SRAM) occur in multi-word units called blocks or cache lines.

    • Transferring complete blocks exploits spatial locality by prefetching adjacent code and data operands.

  • Cache Operational Terminology:

    • Cache Hit: Requested memory location exists in cache; access completes in fast hit time tcachet_{\text{cache}}.

    • Cache Miss: Requested memory location is absent; triggers a miss penalty tDRAMt_{\text{DRAM}} while transferring the containing block from DRAM into cache.

    • Hit Rate (hh): The proportion of memory accesses satisfied directly by the cache:     h=Cache HitsTotal Memory Accessesh = \frac{\text{Cache Hits}}{\text{Total Memory Accesses}}

    • Miss Rate (mm): The proportion of memory accesses that miss the cache:     m=Cache MissesTotal Memory Accesses=1−hm = \frac{\text{Cache Misses}}{\text{Total Memory Accesses}} = 1 - h

  • Average Memory Access Time (AMAT) Equation:   tmem=h×tcache+(1−h)×tDRAMt_{\text{mem}} = h \times t_{\text{cache}} + (1 - h) \times t_{\text{DRAM}}

  • Latency Performance Limits:

    • System designs target hit rates of h≥0.95h \ge 0.95 (95%95\% or higher).

    • A hit rate of 100%100\% (h=1h = 1) is impossible because working sets dynamically shift over execution time (such as exiting a loop phase), triggering unavoidable transient miss spikes.

CPU Stall Calculations and Effective CPI

  • CPU Miss Handling Sequence:

    • On a cache miss, the CPU pipeline stalls (waits) while the required block transfers from DRAM into cache.

    • Instruction Cache Miss: Fetches the missing code block into the instruction cache (ICache) and restarts instruction fetch.

    • Data Cache Miss: Fetches the missing operand block into the data cache (DCache) and completes the pending load/store operation.

  • Total CPU Execution Time Formulation:   CPU Time=(CPU Program Execution Cycles+Memory Stall Cycles)×Clock Cycle Time\text{CPU Time} = (\text{CPU Program Execution Cycles} + \text{Memory Stall Cycles}) \times \text{Clock Cycle Time}

  • Memory Stall Cycle Breakdown:   Memory Stall Cycles=Read Stall Cycles+Write Stall Cycles\text{Memory Stall Cycles} = \text{Read Stall Cycles} + \text{Write Stall Cycles}   Read Stall Cycles=Read Accesses×Read Miss Rate×Read Penalty\text{Read Stall Cycles} = \text{Read Accesses} \times \text{Read Miss Rate} \times \text{Read Penalty}   \text{Write Stall Cycles} = \text{Write Accesses} \times \text{Write Miss Rate} \n\times \text{Write Penalty}

  • Simplified Memory Stall Cycle Equations:

    • Assuming equivalent read and write penalties/miss rates:     Memory Stall Cycles=Total Memory Accesses×Miss Rate×Miss Penalty\text{Memory Stall Cycles} = \text{Total Memory Accesses} \times \text{Miss Rate} \times \text{Miss Penalty}

    • Expressed via Instruction Count (IC):     Memory Stall Cycles=IC×(MissesInstruction)×Miss Penalty\text{Memory Stall Cycles} = \text{IC} \times \left(\frac{\text{Misses}}{\text{Instruction}}\right) \times \text{Miss Penalty}

  • Effective Cycles Per Instruction (CPI):   CPIeffective=CPIideal+CPIstalls\text{CPI}_{\text{effective}} = \text{CPI}_{\text{ideal}} + \text{CPI}_{\text{stalls}}   CPIstalls=(ICache AccessesInstruction×ICache Miss Rate×ICache Miss Penalty)+(DCache AccessesInstruction×DCache Miss Rate×DCache Miss Penalty)\text{CPI}_{\text{stalls}} = \left(\frac{\text{ICache Accesses}}{\text{Instruction}} \times \text{ICache Miss Rate} \times \text{ICache Miss Penalty}\right) + \left(\frac{\text{DCache Accesses}}{\text{Instruction}} \times \text{DCache Miss Rate} \times \text{DCache Miss Penalty}\right)

  • ICache Access Ratios:

    • Accesses per instruction equal 11 under standard designs where instruction width matches cache bus width.

    • Requires multiple accesses per instruction (e.g., 22 accesses) if instruction width exceeds cache width (e.g., fetching a 64-bit64\text{-bit} instruction across a 32-bit32\text{-bit} cache bus).