I am reading a case study for Computer architecture, A Quantitative Approach 5th Edition. For reference, I am looking at the case study #1 in Chapter 5 and none of it is making any sense.

It says:

Each cache is direct-mapped, with four blocks each holding two words. To simplify the illustration, the cache-address tag contains the full address, and each word shows only two hex characters, with the least significant word on the right. The coherence states are denoted M, S, and I (Modified, Shared, and Invalid).

enter image description here

You are supposed to execute the following to operations:

  1. P1: read 110
  2. P0: write 130 <- 78

The solution manual makes things even more complicated as it presents the following solution:

  1. P1.B2: (S, 110, 0010) returns 0010

  2. P0.B2: (M, 130, 0078)

    M: 110 <- 0030 (writeback to memory)

My questions are:

  1. Why did the read to 110 not force a writeback from P0 into memory, and change the coherence state to S on P0.B2, then read into P1.B2? The protocol seems to describe this is what should happen. But the solution seems to discard the 00 30 value in 110.

  2. Why did 130 go to P0.B2 and replace 110? I tried every possible way of direct-mapped cache and I can't figure out, for the life of me, how any of it works. If it is double-word, and word size is 2-bytes, then 108 and 110 should be loaded together (bytes 108-111 are in the same block). If the address represents a block in the main memory, then 108 and 100 should never coexist in the cache since they are directly mapped to B0. How does any of it make sense?

I would greatly appreciate any help!

Edit: I tried to look closely on the figure, and it seems like they are mapped by the order they show up in:

  1. 100 -> B0
  2. 108 -> B1
  3. 110 -> B2
  4. 118 -> B3
  5. 120 -> B0
  6. 128 -> B1
  7. 130 -> B2

That should answer my second question (although it begs another question as to WHO ON EARTH THINKS THIS NONSENSE IS SIMPLER THAN A LEGIT DIRECT-MAPPED CACHE?). But the first question is one I still can't figure out.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.