Back Next
Direct cache access
  Parse the main memory address to be accessed.

  Determine which cache line is being accessed
  Determine segment ID of line of interest.
  Determine the offset into the line to byte of interest.

  If cache line is in use (valid flag - for initial access).
  Then
    If current tag in cache line matches tag of main memory.
    Then
      Use offset to access byte[s] in cache line. (Hit).
    
    Else (Miss)
      If data cache and dirty flag set
          Write out current cache line.

      Endif
      #code cache isn't modified.

      Fetch line of bytes from memory and over-write cache line. 
      Use byte/block offset to access data in cache line.
    
    Endif

  Else  (Unused cache line).
    Fetch line from main memory into cache. (Miss).
    Mark as valid.
    Use offset to access data in cache line.

  Endif