hades.models.mips.mipsmemory
Class MemoryDispatcher

java.lang.Object
  extended byhades.models.mips.mipsmemory.MemoryDispatcher
All Implemented Interfaces:
Memory, MipsMemory, Resetable

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

This class seperates the physical address space into 64K segments each of 64K (bytes) size. Each segment can use a different MipsMemory. This implementation allows free assignment of internal and external memory segments: Some segments can be implemented internal (with TinyMemory) and some external (with the HADES interface). All the MipsMemory calls will be dispatched to the segments memory. The Memory interface provides a way to visualize the full physical address space. Additionally this class does the memory access serialization with read and write buffers and schedules the waitstates for the core. These two functions do occur in the same class because there will be performance benefits by mixing the functionalities.


Field Summary
protected  int currentAdr
           
protected  MipsMemory currentMem
           
protected  boolean debug
           
protected  EntryHandler entryHandler
           
protected  boolean entryHandlerInstalled
           
protected static int IDLE
           
protected  boolean lastFinished
           
protected  MipsMemory[] memoryVector
           
protected  int memVecSize
           
static int MEMVECSTARTSIZE
           
protected  int memVecUsed
           
protected  java.lang.String name
           
protected  int[] readBufAdr
           
protected  boolean[] readBufBurst
           
protected static int READBUFSIZE
           
protected  int readBufUsed
           
protected static int READNOWAIT
           
protected static int READTESTWAIT
           
protected  ResetHandler resetHandler
           
protected  int result
           
protected  boolean resultPresent
           
protected  MipsMemory[] segment
           
static int SEGMENTCOUNT
           
static int SEGMENTMASK
           
static int SEGMENTSHIFT
           
static int SEGMENTSIZE
           
protected  int state
           
protected  int[] writeBufAdr
           
protected  int[] writeBufData
           
protected static int WRITEBUFSIZE
           
protected  int writeBufUsed
           
protected static int WRITENOWAIT
           
protected static int WRITETESTWAIT
           
 
Constructor Summary
MemoryDispatcher(ResetHandler newResetHandler, java.lang.String newName)
           
 
Method Summary
 boolean beginCycle()
          beginCycle has to add waitstates for delayed accesses
 void endCycle()
          Launch read and write requests
 boolean finished()
          request end of read or write access
 java.util.Vector getAllMemories()
           
 boolean getHit(int adr)
          Is data present at the specified address?
 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
 ResetHandler getResetHandler()
           
 MipsMemory getSegment(int segmentnum)
           
 MipsMemory getSegmentForPhysAddress(int adr)
           
 MipsMemory getSegmentForVirtAddress(int adr)
           
protected  java.lang.String getStateString()
           
 int getWordWidth()
          Witdh of one word in bits
 void installEntryHandler(EntryHandler newEntryHandler)
          setEntry() calles this EntryHandler
protected  void memVecAddElement(MipsMemory memory)
           
protected  java.util.Vector memVecClone()
           
protected  boolean memVecContains(MipsMemory memory)
           
protected  int memVecGetIndex(MipsMemory memory)
           
protected  void memVecRemoveElement(MipsMemory memory)
           
 void por()
          Power on reset or hardware reset
 void read(int adr, boolean burst)
          Store read request.
 int readMemory(int address)
          Read a word from the memory
 void reset()
          software reset
protected  boolean searchMemory(MipsMemory mem)
           
 void setAllSegments(MipsMemory memory)
           
 void setEntry(int entry, int globalPointer)
          Set the entry address and the global pointer if memory contains a executable program
 void setLog(boolean newDebug)
          Enable or disable logging output
 void setName(java.lang.String newName)
          Set the name of this memory
 void setSegment(int segmentnum, MipsMemory memory)
           
 void setSegmentForPhysAddress(int adr, MipsMemory memory)
           
 void setSegmentForVirtAddress(int adr, MipsMemory memory)
           
 void write(int adr, int data)
          Store write request.
 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

resetHandler

protected ResetHandler resetHandler

name

protected java.lang.String name

entryHandler

protected EntryHandler entryHandler

entryHandlerInstalled

protected boolean entryHandlerInstalled

debug

protected boolean debug

SEGMENTCOUNT

public static final int SEGMENTCOUNT
See Also:
Constant Field Values

SEGMENTMASK

public static final int SEGMENTMASK
See Also:
Constant Field Values

SEGMENTSHIFT

public static final int SEGMENTSHIFT
See Also:
Constant Field Values

SEGMENTSIZE

public static final int SEGMENTSIZE
See Also:
Constant Field Values

MEMVECSTARTSIZE

public static final int MEMVECSTARTSIZE
See Also:
Constant Field Values

segment

protected MipsMemory[] segment

memoryVector

protected MipsMemory[] memoryVector

memVecUsed

protected int memVecUsed

memVecSize

protected int memVecSize

IDLE

protected static final int IDLE
See Also:
Constant Field Values

READNOWAIT

protected static final int READNOWAIT
See Also:
Constant Field Values

READTESTWAIT

protected static final int READTESTWAIT
See Also:
Constant Field Values

WRITENOWAIT

protected static final int WRITENOWAIT
See Also:
Constant Field Values

WRITETESTWAIT

protected static final int WRITETESTWAIT
See Also:
Constant Field Values

state

protected int state

currentAdr

protected int currentAdr

currentMem

protected MipsMemory currentMem

result

protected int result

resultPresent

protected boolean resultPresent

lastFinished

protected boolean lastFinished

WRITEBUFSIZE

protected static final int WRITEBUFSIZE
See Also:
Constant Field Values

writeBufAdr

protected int[] writeBufAdr

writeBufData

protected int[] writeBufData

writeBufUsed

protected int writeBufUsed

READBUFSIZE

protected static final int READBUFSIZE
See Also:
Constant Field Values

readBufAdr

protected int[] readBufAdr

readBufBurst

protected boolean[] readBufBurst

readBufUsed

protected int readBufUsed
Constructor Detail

MemoryDispatcher

public MemoryDispatcher(ResetHandler newResetHandler,
                        java.lang.String newName)
Method Detail

memVecGetIndex

protected int memVecGetIndex(MipsMemory memory)

memVecContains

protected boolean memVecContains(MipsMemory memory)

memVecAddElement

protected void memVecAddElement(MipsMemory memory)

memVecRemoveElement

protected void memVecRemoveElement(MipsMemory memory)

memVecClone

protected java.util.Vector memVecClone()

searchMemory

protected boolean searchMemory(MipsMemory mem)

setSegment

public void setSegment(int segmentnum,
                       MipsMemory memory)

setSegmentForPhysAddress

public void setSegmentForPhysAddress(int adr,
                                     MipsMemory memory)

setSegmentForVirtAddress

public void setSegmentForVirtAddress(int adr,
                                     MipsMemory memory)

getSegment

public MipsMemory getSegment(int segmentnum)

getSegmentForPhysAddress

public MipsMemory getSegmentForPhysAddress(int adr)

getSegmentForVirtAddress

public MipsMemory getSegmentForVirtAddress(int adr)

getAllMemories

public java.util.Vector getAllMemories()

setAllSegments

public void setAllSegments(MipsMemory memory)

getResetHandler

public ResetHandler getResetHandler()

por

public void por()
Power on reset or hardware reset

Specified by:
por in interface Resetable

reset

public void reset()
software reset

Specified by:
reset in interface Resetable

getStateString

protected java.lang.String getStateString()

beginCycle

public boolean beginCycle()
beginCycle has to add waitstates for delayed accesses

Specified by:
beginCycle in interface MipsMemory

endCycle

public void endCycle()
Launch read and write requests

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

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

write

public void write(int adr,
                  int data)
Store write request. Request will be launched from endCycle() if there is nothing else to do or the request buffers are full.

Specified by:
write in interface MipsMemory

read

public void read(int adr,
                 boolean burst)
Store read request. Request will be launched from endCycle() if the lower memory has finished the current operation.

Specified by:
read in interface MipsMemory

getReadResult

public int getReadResult()
get result

Specified by:
getReadResult in interface MipsMemory

getWordWidth

public int getWordWidth()
Description copied from interface: Memory
Witdh of one word in bits

Specified by:
getWordWidth in interface Memory

getMemorySize

public int getMemorySize()
Description copied from interface: Memory
Capacity of the memory in words

Specified by:
getMemorySize in interface Memory

readMemory

public int readMemory(int address)
Description copied from interface: Memory
Read a word from the memory

Specified by:
readMemory in interface Memory

writeMemory

public void writeMemory(int address,
                        int word)
Description copied from interface: Memory
Write a word into the memory

Specified by:
writeMemory in interface Memory

setEntry

public void setEntry(int entry,
                     int globalPointer)
Description copied from interface: Memory
Set the entry address and the global pointer if memory contains a executable program

Specified by:
setEntry in interface Memory

installEntryHandler

public void installEntryHandler(EntryHandler newEntryHandler)
Description copied from interface: Memory
setEntry() calles this EntryHandler

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