Example #1
0
void print_cache(Memory *m)
{
  Memory *next = m;
  while(next->isCache())
  {
    Cache *c = (Cache*)next;
    printf("%s CACHE CONTENTS\n",c->name().c_str());
    printf("a. number of accesses :%d\n",c->reads());
    printf("b. number of misses :%d\n",c->reads()-c->rhits());
    for(ui32 i=0; i<c->set(); i++)
    {
      TagSet &set = c->tags(i);
      cout<<"set "<<i<<": ";

      for (ui32 j=0; j<set.size(); j++)
      {
        cout<<"   "<<hex<<set[j].tag()<<dec;
      }
      cout<<endl;
    }
    next = next->next();
    cout<<endl;
  }
}