hades.models.mips.mipsmemory
Class Cache

java.lang.Object
  extended byhades.models.mips.mipsmemory.Cache
All Implemented Interfaces:
Memory, MipsMemory, Resetable
Direct Known Subclasses:
DataCache, InstrCache

public class Cache
extends java.lang.Object
implements Resetable, MipsMemory

Implementation of the data cache, non associative, line size of 1 word, variable cache size. No write instructions


Field Summary
protected  int adrMask
           
protected  boolean burstAllowed
           
protected  int cacheSize
           
protected  boolean debug
           
protected  int hits
           
protected  boolean isolated
           
protected  MipsMemory lowerMem
           
protected  int[] mem
           
protected  int misses
           
protected  java.lang.String name
           
protected  int nextAdr
           
protected  int nextData
           
protected  int readAdr
           
protected  int readResult
           
protected  boolean readResultPresent
           
protected  int result
           
protected  int[] tag
           
protected  int tagMask
           
protected  boolean[] valid
           
protected  boolean waiting
           
 
Constructor Summary
Cache(ResetHandler resetHandler, MipsMemory newLowerMem, int newCacheSize, java.lang.String newName, boolean newBurstAllowed)
           
 
Method Summary
 boolean beginCycle()
          Only when there was a request and there is no result present, then lowerMem.finished will be asked
 void endCycle()
          end of a cycle, all core actions are done, memory actions can complete
 boolean finished()
          request end of read or write access
 boolean getBurstAllowed()
           
 boolean getHit(int adr)
          Is data present at the specified address?
 boolean getIsolated()
           
 boolean getLog()
          Get debug mode
 int getMemorySize()
          Capacity of the memory in words
 java.lang.String getName()
          get the name of this memory
 int getReadResult()
          get result
 int getWordWidth()
          Witdh of one word in bits
 void installEntryHandler(EntryHandler entryHandler)
          Not needed for a cache
 void invalidate()
          clear the cache (set all entries to invalid)
 void por()
          Power in reset or hardware reset
 void read(int adr, boolean burst)
          Drive busses for read access
 int readMemory(int address)
          Read a word from the memory
 void reset()
          software reset
 void setBurstAllowed(boolean newBurstAllowed)
           
 void setEntry(int entry, int globalPointer)
          Not needed for a cache
 void setIsolated(boolean newIsolated)
           
 void setLog(boolean newDebug)
          Enable or disable logging output
 void setName(java.lang.String newName)
          Set the name of this memory
 java.lang.String statistics()
           
 void write(int adr, int data)
          Drive busses for write access
 void writeMemory(int address, int word)
          Write a word into the memory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mem

protected int[] mem

tag

protected int[] tag

valid

protected boolean[] valid

cacheSize

protected int cacheSize

adrMask

protected int adrMask

tagMask

protected int tagMask

nextAdr

protected int nextAdr

nextData

protected int nextData

result

protected int result

lowerMem

protected MipsMemory lowerMem

waiting

protected boolean waiting

readResultPresent

protected boolean readResultPresent

readResult

protected int readResult

readAdr

protected int readAdr

hits

protected int hits

misses

protected int misses

name

protected java.lang.String name

debug

protected boolean debug

isolated

protected boolean isolated

burstAllowed

protected boolean burstAllowed
Constructor Detail

Cache

public Cache(ResetHandler resetHandler,
             MipsMemory newLowerMem,
             int newCacheSize,
             java.lang.String newName,
             boolean newBurstAllowed)
Method Detail

por

public void por()
Power in reset or hardware reset

Specified by:
por in interface Resetable

reset

public void reset()
software reset

Specified by:
reset in interface Resetable

invalidate

public void invalidate()
clear the cache (set all entries to invalid)


beginCycle

public boolean beginCycle()
Only when there was a request and there is no result present, then lowerMem.finished will be asked

Specified by:
beginCycle in interface MipsMemory

endCycle

public void endCycle()
Description copied from interface: MipsMemory
end of a cycle, all core actions are done, memory actions can complete

Specified by:
endCycle in interface MipsMemory

finished

public boolean finished()
Description copied from interface: MipsMemory
request end of read or write access

Specified by:
finished in interface MipsMemory

statistics

public java.lang.String statistics()

getHit

public boolean getHit(int adr)
Description copied from interface: MipsMemory
Is data present at the specified address?

Specified by:
getHit in interface MipsMemory

getName

public java.lang.String getName()
Description copied from interface: MipsMemory
get the name of this memory

Specified by:
getName in interface MipsMemory

setName

public void setName(java.lang.String newName)
Description copied from interface: MipsMemory
Set the name of this memory

Specified by:
setName in interface MipsMemory

setIsolated

public void setIsolated(boolean newIsolated)

getIsolated

public boolean getIsolated()

write

public void write(int adr,
                  int data)
Drive busses for write access

Specified by:
write in interface MipsMemory

read

public void read(int adr,
                 boolean burst)
Drive busses for read access

Specified by:
read in interface MipsMemory

getReadResult

public int getReadResult()
get result

Specified by:
getReadResult in interface MipsMemory

getWordWidth

public int getWordWidth()
Witdh of one word in bits

Specified by:
getWordWidth in interface Memory

getMemorySize

public int getMemorySize()
Capacity of the memory in words

Specified by:
getMemorySize in interface Memory

readMemory

public int readMemory(int address)
Read a word from the memory

Specified by:
readMemory in interface Memory

writeMemory

public void writeMemory(int address,
                        int word)
Write a word into the memory

Specified by:
writeMemory in interface Memory

setEntry

public void setEntry(int entry,
                     int globalPointer)
Not needed for a cache

Specified by:
setEntry in interface Memory

installEntryHandler

public void installEntryHandler(EntryHandler entryHandler)
Not needed for a cache

Specified by:
installEntryHandler in interface Memory

setLog

public void setLog(boolean newDebug)
Description copied from interface: Memory
Enable or disable logging output

Specified by:
setLog in interface Memory

getLog

public boolean getLog()
Description copied from interface: Memory
Get debug mode

Specified by:
getLog in interface Memory

setBurstAllowed

public void setBurstAllowed(boolean newBurstAllowed)

getBurstAllowed

public boolean getBurstAllowed()