/** * Should be called if address is not in cache * and needs to be paged in */ public void pageBlock(int address, MainMemory memory) { int frameLoc = randomFrame(setSize); Frame oldFrame = sets[findSet(address)].getFrameFromIndex(frameLoc); Frame frame = new Frame(address); frame.data = memory.addresses[address]; //Old frame was written to and needs to be written back if(null != oldFrame && oldFrame.dirty) { memory.addresses[oldFrame.getTag()] = oldFrame.data; } sets[findSet(address)].replaceFrame(frameLoc, frame); }
public Memory(String cacheType, int cacheSize, List<short> instructions) { memory = new MainMemory(256); this.instructions = instructions; this.cache = InitCache(cacheType, cacheSize); }