Hi...im new to this website..and i really need some help on my java..
I will need to write a class of direct mapped,associative and fully associative cache, which implements the class given below. Then they will be tested on a trace file. Please can anybody give me some help??
public abstract class Cache{ int size,line_size; //sizes in bytes initialised by constructor of subclass // counters used to generate performance statistics int total_accesses, read_accesses, write_accesses; //all total numbers hit or miss // read includes read and fetch int read_misses, write_misses, rejections, main_mem_accesses; // rejections is when a valid line in the cache is replaced by a new line
Cache(){ //initialise statistics when new cache created total_accesses = 0; read_accesses = 0; //read and fetch accesses write_accesses = 0; read_misses = 0; write_misses = 0; rejections = 0; main_mem_accesses = 0; }
public void write(int addr, Object indata) { // You must write this code for ex1 total_accesses++; write_accesses++;
if(search(addr)!= null){
putData(indata);
}
else{ write_misses++; }
}
public Object read(int addr) { 1 total_accesses++; read_accesses++;
public int totalAccesses() { return total_accesses; } public int readAccesses() { return read_accesses; } public int writeAccesses() { return write_accesses; } public int readMisses() { return read_misses; } public int writeMisses() { return write_misses; } public int numRejections() { return rejections; } public int mainMemAccesses() { return main_mem_accesses; } }