Hello,

I'm not sure I completely understand what you are suggesting, but shifting 
"log_base2(theBlockSize*assocs)" is wrong. To find the set, you need the 
log_base2(theNumSets) bits following the log_base2(theBlockSize) least 
significant bits, which is exactly what "return (addr >> blockShift) & 
blockSetMask" does. You cannot predict in which way of a set a block resides. 
In other words, tag comparison for all the blocks in the set cannot be avoided. 
The get_set function is correct.

Regards,
Alexandros

________________________________
From: zhangwuxiang [[email protected]]
Sent: Wednesday, August 21, 2013 9:39 AM
To: simflex
Subject: How to get the set no?

Hi,all
In the flexus-4.1/components/FastCache/StdCache.hpp file, we use this function 
to get the set no:
 int32_t get_set(uint64_t addr) {
    return (addr >> blockShift) & blockSetMask;
  }
and blockShift = log_base2(theBlockSize); blockSetMask = (theNumSets - 1);
For example, we set L1i cache's size 32KB, the block size is 64B, the assocs is 
2, and so blockShift is 6, blockSetMask is (32K/64/2-1)=255.
So we shift right of the addr for 6 position, and then get the last 8 bits of 
the shifted addr to get the set no?
I feel a bit confused about the blockShift. I think we should shift  
log_base2(theBlockSize*assocs) to get the set no. We find the set first, and 
then find the block in the set. If we used  log_base2(theBlockSize), the 
blockSetMask contains the way of a block, and there is no need to compare the 
tag to find the way in the set.
Does sth I misunderstand or is this a bug?
Look forward your reply. Thank you.
2013-08-21
________________________________
Best Regards!
MAIL: [email protected]<mailto:[email protected]>

Reply via email to