1
\$\begingroup\$

My cache can have 32 address bits with 2 bits for index and 3 bits for byte-offset.

Associativity 2, block size 8.

Of course, the the bits for index says which row of the cache the data is.

But how do I know which block when there are 2 blocks (associativity 2)?

The 3 bits byte-offset only tells which byte within a block and there are 2 blocks.

Is there a comparator that determines which of the blocks has the tag that matches the incoming request for data?

\$\endgroup\$
2
  • \$\begingroup\$ Which/what cache is 'yours'? \$\endgroup\$ Commented Jan 20, 2013 at 17:48
  • \$\begingroup\$ @jippie It's just a model that I'm counting on the learn MIPS. \$\endgroup\$ Commented Jan 20, 2013 at 23:50

1 Answer 1

3
\$\begingroup\$

Yes, that's exactly what the tag is for. With 2-way associativity, you have two comparators so that you can tell which of the two blocks (if any) contains the data you're looking for. Each tag and each comparator needs to be wide enough to handle all of the address bits left over after you remove the byte-index and cache-index bits. In your case that would be 32 – 3 – 2 = 27 bits.

\$\endgroup\$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.