Computer with Single Processor and Cache

Cache

  • CPUs became much faster at processing instructions
  • However, RAM access speed did not improve very much
  • The CPU could not process instructions during data transfers
    • The CPU spent a lot of time waiting for RAM to respond
    • Memory latency became a problem
  • Computers started using small amounts of "cache" memory

Cache Memory

  • Cache Memory

    • Physically close to the CPU
    • Stores copies of current and recently used data
    • Reduces the time spent communicating with main memory
  • Uses "static" RAM

    • This is faster than the "dynamic" RAM used in main memory
    • More expensive
    • Uses more power
    • Usually much smaller than main memory

Cache Fetch

  • The CPU wants to fetch data
  • Does the cache have a copy of the data?
  • Yes
    • There is a "cache hit"
    • The CPU uses that copy
  • No
    • There is a "cache miss"
    • The data is fetched from main memory

Cache Write

  • The CPU wants to store data
  • It writes the data to the cache
  • The data in the cache is written to main memory
    • The CPU can continue working while this happens

Cache Controller

  • The process is managed by a "cache controller"
  • The data is transferred in fixed-size blocks
    • Known as "cache lines"
    • Typically 64 bytes on modern hardware (8 words)
  • Each cache line relates to an address in main memory