sim
Class Cache

java.lang.Object
  |
  +--sim.Cache

public class Cache
extends java.lang.Object

Implements a very simple cache simulation.

Version:
$Id: Cache.java,v 1.4 2002/07/01 22:49:08 dugan Exp $

Nested Class Summary
(package private)  class Cache.Line
           
(package private)  class Cache.Set
           
 
Field Summary
(package private)  int assoc
           
(package private)  int lineSize
           
(package private)  java.lang.String name
           
(package private) static java.util.Random rand
           
(package private)  int readHits
           
(package private)  int readMisses
           
(package private)  Cache.Set[] sets
           
(package private)  int writeHits
           
(package private)  int writeMisses
           
 
Constructor Summary
Cache(java.lang.String name, int numSets, int assoc, int lineSize)
          Make a new cache with the given number of lines, associativity, and the given linesize.
 
Method Summary
 void dumpStats()
          Dump the stats that have been collected thus far.
 void initialize()
           
 boolean isHit(int addr)
          Is the given address mapped in the cache?
 void read(int addr)
          Do a read access of the cache.
 void write(int addr)
          Implements a write-around policy on misses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

java.lang.String name

sets

Cache.Set[] sets

readHits

int readHits

readMisses

int readMisses

writeHits

int writeHits

writeMisses

int writeMisses

lineSize

int lineSize

assoc

int assoc

rand

static final java.util.Random rand
Constructor Detail

Cache

public Cache(java.lang.String name,
             int numSets,
             int assoc,
             int lineSize)
Make a new cache with the given number of lines, associativity, and the given linesize. Parameters should be powers of two.

Method Detail

isHit

public boolean isHit(int addr)
Is the given address mapped in the cache?


read

public void read(int addr)
Do a read access of the cache.


write

public void write(int addr)
Implements a write-around policy on misses.


initialize

public void initialize()

dumpStats

public void dumpStats()
Dump the stats that have been collected thus far.