void prefetch (struct cache_t *cp, md_addr_t addr) {
  md_addr_t set = CACHE_SET(cp, addr);
  md_addr_t tag = CACHE_TAG(cp, addr);
  md_addr_t baddr = CACHE_MK_BADDR(cp, tag, set);
  if (!cache_probe(cp, baddr)) {
    cache_access(cp, Read, baddr, NULL, cp->bsize, NULL, NULL, NULL, 1);
  }
}
Exemple #2
0
/* Next Line Prefetcher */
void next_line_prefetcher(struct cache_t *cp, md_addr_t addr) {
    //prefetch logic
    //get the next block of data from the addr 
    assert(cp != NULL);

    md_addr_t new_addr = addr + cp->bsize;
    new_addr -= new_addr % cp->bsize;

    if(cache_probe(cp, new_addr) == 0){

        cache_access(cp,	        /* cache to access */
	                 Read,		/* access type, Read or Write */
	                 new_addr,		/* address of access */
	                 NULL,		/* ptr to buffer for input/output */
	                 cp->bsize,		/* number of bytes to access */
	                 0,		        /* time of access */
	                 NULL,		/* for return of user data ptr */
	                 NULL,	        /* for address of replaced block */
	                 1);
    }
}