Re: Help for Simplescalar's cache.c code




Just in case, I'm asking this question for a project at my university,
so is nothing commercial.

On 9 ene, 10:30, "globalsk" <jmilana...@xxxxxxxxx> wrote:
Hello,

I'm trying to understand this fragment of code in Simplescalar's
cache.c code (I've search and look over dozens sites, including
simplescalar.com and there's no help about the coding):

/* cache access macros */
#define CACHE_TAG(cp, addr) ((addr) >> (cp)->tag_shift)
#define CACHE_SET(cp, addr) (((addr) >> (cp)->set_shift) &
(cp)->set_mask)
#define CACHE_BLK(cp, addr) ((addr) & (cp)->blk_mask)
#define CACHE_TAGSET(cp, addr) ((addr) & (cp)->tagset_mask)

I know is about shifting and moving bits around, but don't know how and
specially why is done in this way and for what.

cp is an structure for a cache
addr is a typedef qword_t (64 bits)
md_addr_t blk_mask; idem, typedef qword_t
int set_shift;
md_addr_t set_mask; /* use *after* shift */
int tag_shift;
md_addr_t tag_mask; /* use *after* shift */
md_addr_t tagset_mask; /* used for fast hit detection */

Maybe this is little information, but maybe someone with the knowledge
about caches and this type of coding can help out. Please if someone
can give a helping hand about this and links where they explain in more
detail simplescalar's code will be very appreciated.

Please forgive my syntax mistakes, english is not my mother tongue.

.



Relevant Pages

  • Understanding << and & operators in cache code
    ... cache.h code (I've search and look over dozens sites, ... cp is an structure for a cache ... int set_shift; ... about caches and this type of coding can help out. ...
    (comp.lang.c)
  • Help for Simplescalars cache.c code
    ... cache.c code (I've search and look over dozens sites, ... cp is an structure for a cache ... int set_shift; ... about caches and this type of coding can help out. ...
    (comp.programming)
  • Re: Help for Simplescalars cache.c code
    ... Don't understand how this masking works. ... All this code is for cache simulation as you can see, ... int set_shift; ... about caches and this type of coding can help out. ...
    (comp.programming)
  • Re: Help for Simplescalars cache.c code
    ... Don't understand how this masking works. ... All this code is for cache simulation as you can see, ... int set_shift; ... about caches and this type of coding can help out. ...
    (comp.programming)
  • Faster getcpu() and sched_getcpu()
    ... there are two VDSO implementations: ... Call these GDT, TSCP, and SIDT. ... split the VDSO in to red-zone and no-red-zone areas, streamline cache ... static inline int gdt_limit{ ...
    (Linux-Kernel)