hades.models.rtlib.memory
Class GenericMemory

java.lang.Object
  extended byhades.simulator.SimObject
      extended byhades.models.rtlib.memory.GenericMemory
All Implemented Interfaces:
java.lang.Cloneable, ContextToolTip, Memory, java.io.Serializable, Simulatable
Direct Known Subclasses:
DcoreRAM, DPRAM, MicroROM, MipsRegBank, MR, RAM, RAMoe, RealTimeClock, RegBank, ROM

public class GenericMemory
extends SimObject
implements Memory

GenericMemory - the base class for all Hades RTLIB memory components. Currently, the word size of the memory is limited to 63 bits.

See Also:
Serialized Form

Field Summary
protected  long bit_mask
           
protected  long[] data
           
protected  boolean enableAnimationFlag
           
protected  int last_read_addr
           
protected  long last_read_data
           
protected  int last_write_addr
           
protected  long last_write_data
           
protected  MemoryEditorFrame MEF
           
protected  int n_bits
           
protected  int n_words
           
protected  java.lang.String resourcename
           
static int TRISTATED
           
static int UNDEFINED
           
protected  StdLogicVector vector_000
           
protected  StdLogicVector vector_111
           
protected  StdLogicVector vector_UUU
           
protected  StdLogicVector vector_XXX
           
protected  StdLogicVector vector_ZZZ
           
 
Fields inherited from class hades.simulator.SimObject
classloader, console, debug, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
GenericMemory()
           
 
Method Summary
 void addMemoryListener(MemoryListener ML)
           
 void addMemoryListenerOld(MemoryListener ML)
           
 boolean canChangeSize()
           
 void checkInvalidateMemory()
          called from evaluate() when an illegal input value combination is detected, for example an undefined address during a write cycle.
 void configure()
          create and display a 'ConfigDialog' to set the parameters for a SimObject.
protected  void constructPorts()
           
protected  void constructStandardValues()
           
 void createMemory()
           
 boolean dataAtAddressIsUndefined(int addr)
           
 void dbg(java.lang.String msg)
           
 void elaborate(java.lang.Object arg)
          elaborate(): No use to call elaborate on a GenericMemory.
 void evaluate(java.lang.Object arg)
          evaluate(): No use to call elaborate on a GenericMemory.
 int getAddressBusWidth()
           
 int getAddrOffset()
          utility method to support systems with different memory components mapped into a single address space at different offsets.
 int getBitsPerWord()
          return the number of bits per word in this memory.
 PropertySheet getConfigDialog()
           
 long[] getDataArray()
           
 long getDataAt(int address)
           
 boolean getEnableAnimationFlag()
           
 java.lang.String[] getExternalResources()
          return a String[] array of length 1 with our memory initialization file.
 int getHexDigitsPerWord()
           
protected  java.lang.String getHexString(long value, int n_chars)
           
 InstructionDecoder getInstructionDecoder()
           
 java.awt.Component getPropertySheet()
          return a reference to the 'property sheet' or configuration window for this SimObject.
 java.lang.String getResourcename()
           
 int getSize()
          get the number of words in this memory.
 java.lang.String getToolTip(java.awt.Point position, long millis)
          construct a (not so short) tool tip message.
 boolean initialize(java.lang.String s)
          initialize a GenericMemory from a String.
 void initializeWithDefaultValues()
           
 void initializeWithRandomValues()
           
 void initializeWithX()
           
 void initializeWithZeroes()
           
 boolean isConnected()
           
static void main(java.lang.String[] argv)
           
 boolean merge(java.io.BufferedReader reader)
           
 boolean needsExternalResources()
          we use one external resource: the data file to initialize the memory.
protected  void notifyReadListeners(int address, long value)
           
protected  void notifyReadListenersOld(int address, long value)
           
protected  void notifyWriteListeners(int address, long old_value, long new_value)
           
protected  void notifyWriteListenersOld(int address, long old_value, long new_value)
           
 boolean parse(java.io.BufferedReader br)
          parse RAM data from a file specified via its Java 1.1 resourcename.
protected  void parseLabelLine(java.lang.String line)
           
 void parseRAM(java.lang.String resourcename)
           
 void removeMemoryListener(MemoryListener ML)
           
 void removeMemoryListenerOld(MemoryListener ML)
           
 boolean resize(int n_words, int n_bits_per_word)
           
 boolean save(java.io.PrintWriter PW)
          write the memory data in a trivial addr:data format, one address per line.
 void setBitsPerWord(int n_bits)
           
 void setDataArray(long[] data)
           
 void setDataAt(int address, long value)
           
 void setEnableAnimationFlag(boolean b)
           
 void setEnableAnimationFlag(java.lang.String s)
           
 void setInstructionDecoder(InstructionDecoder decoder)
           
 void setResourcename(java.lang.String s)
           
 void setSize(int n_words)
           
 java.lang.String toString()
          toString: generate a text description for this SimObject.
 void warning(java.lang.String s)
          print a warning message to the Hades console, consisting of the actual message 's', the full name of this memory component and the current simulation time.
 void write(java.io.PrintWriter ps)
           
 
Methods inherited from class hades.simulator.SimObject
constructDynamicSymbol, copy, getBindkey, getClassLoader, getDebug, getEditor, getFullName, getName, getParent, getPort, getPorts, getResourceAsStream, getSimulator, getSymbol, getSymbolResourceName, getVersionId, isVisible, keyPressed, message, mousePressed, needsDynamicSymbol, setClassLoader, setConsole, setDebug, setEditor, setName, setParent, setPorts, setSimulator, setSymbol, setVersionId, setVisible, tearDown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

resourcename

protected java.lang.String resourcename

n_words

protected int n_words

n_bits

protected int n_bits

data

protected long[] data

bit_mask

protected long bit_mask

last_read_data

protected long last_read_data

last_write_data

protected long last_write_data

last_read_addr

protected int last_read_addr

last_write_addr

protected int last_write_addr

vector_UUU

protected StdLogicVector vector_UUU

vector_XXX

protected StdLogicVector vector_XXX

vector_ZZZ

protected StdLogicVector vector_ZZZ

vector_000

protected StdLogicVector vector_000

vector_111

protected StdLogicVector vector_111

enableAnimationFlag

protected boolean enableAnimationFlag

UNDEFINED

public static final int UNDEFINED
See Also:
Constant Field Values

TRISTATED

public static final int TRISTATED
See Also:
Constant Field Values

MEF

protected MemoryEditorFrame MEF
Constructor Detail

GenericMemory

public GenericMemory()
Method Detail

needsExternalResources

public boolean needsExternalResources()
we use one external resource: the data file to initialize the memory.

Overrides:
needsExternalResources in class SimObject

getExternalResources

public java.lang.String[] getExternalResources()
return a String[] array of length 1 with our memory initialization file.

Overrides:
getExternalResources in class SimObject

constructPorts

protected void constructPorts()

constructStandardValues

protected void constructStandardValues()

getEnableAnimationFlag

public boolean getEnableAnimationFlag()

setEnableAnimationFlag

public void setEnableAnimationFlag(boolean b)

setEnableAnimationFlag

public void setEnableAnimationFlag(java.lang.String s)

setInstructionDecoder

public void setInstructionDecoder(InstructionDecoder decoder)

getInstructionDecoder

public InstructionDecoder getInstructionDecoder()

isConnected

public boolean isConnected()

createMemory

public void createMemory()

dataAtAddressIsUndefined

public boolean dataAtAddressIsUndefined(int addr)

initializeWithZeroes

public void initializeWithZeroes()

initializeWithDefaultValues

public void initializeWithDefaultValues()

initializeWithX

public void initializeWithX()

initializeWithRandomValues

public void initializeWithRandomValues()

getResourcename

public java.lang.String getResourcename()
Specified by:
getResourcename in interface Memory

setResourcename

public void setResourcename(java.lang.String s)
Specified by:
setResourcename in interface Memory

initialize

public boolean initialize(java.lang.String s)
initialize a GenericMemory from a String. Currently, the String should contain the following things: the GenericMemory versionId, and the Java resource-name of the ROM/RAM datafile to parse, e.g.
       1002 n_words n_bits /hades/examples/b-tutorial/ampel-43.rom
    

Overrides:
initialize in class SimObject

write

public void write(java.io.PrintWriter ps)
Overrides:
write in class SimObject

getSize

public int getSize()
Description copied from interface: Memory
get the number of words in this memory.

Specified by:
getSize in interface Memory

setSize

public void setSize(int n_words)
             throws java.lang.Exception
Specified by:
setSize in interface Memory
Throws:
java.lang.Exception

resize

public boolean resize(int n_words,
                      int n_bits_per_word)
               throws java.lang.Exception
Specified by:
resize in interface Memory
Throws:
java.lang.Exception

getAddressBusWidth

public int getAddressBusWidth()

setDataAt

public void setDataAt(int address,
                      long value)
Specified by:
setDataAt in interface Memory

getDataAt

public long getDataAt(int address)
Specified by:
getDataAt in interface Memory

getBitsPerWord

public int getBitsPerWord()
Description copied from interface: Memory
return the number of bits per word in this memory. This should typically be in the range 1 .. 64.

Specified by:
getBitsPerWord in interface Memory

setBitsPerWord

public void setBitsPerWord(int n_bits)
                    throws java.lang.Exception
Specified by:
setBitsPerWord in interface Memory
Throws:
java.lang.Exception

getHexDigitsPerWord

public int getHexDigitsPerWord()

canChangeSize

public boolean canChangeSize()
Specified by:
canChangeSize in interface Memory

getDataArray

public long[] getDataArray()
Specified by:
getDataArray in interface Memory

setDataArray

public void setDataArray(long[] data)
Specified by:
setDataArray in interface Memory

merge

public boolean merge(java.io.BufferedReader reader)
Specified by:
merge in interface Memory

addMemoryListener

public void addMemoryListener(MemoryListener ML)
Specified by:
addMemoryListener in interface Memory

removeMemoryListener

public void removeMemoryListener(MemoryListener ML)
Specified by:
removeMemoryListener in interface Memory

addMemoryListenerOld

public void addMemoryListenerOld(MemoryListener ML)

removeMemoryListenerOld

public void removeMemoryListenerOld(MemoryListener ML)

notifyWriteListenersOld

protected void notifyWriteListenersOld(int address,
                                       long old_value,
                                       long new_value)

notifyReadListenersOld

protected void notifyReadListenersOld(int address,
                                      long value)

parseRAM

public void parseRAM(java.lang.String resourcename)

parse

public boolean parse(java.io.BufferedReader br)
              throws java.lang.Exception
parse RAM data from a file specified via its Java 1.1 resourcename. If the file is not found or contains illegal data, the RAM is re-initialized to the all-invalid state.

Each line of the RAM data file should contain the address and the corresponding data in hex format, seperated by a colon, e.g. '0001:D300000000FF' or '03FF:FEDCBA9876543210'.

The alternative DigLOG compact format, e.g. '0000:000102030405060708090A0B0C0D0E0F' is NOT accepted, because this is useful only for byte-oriented memories.

Input file lines starting with a '#' or ';' character are interpreted as comment lines and are ignored.

The RAM model will issue a warning message, if the same location is written multiple times.

Specified by:
parse in interface Memory
Throws:
java.lang.Exception

parseLabelLine

protected void parseLabelLine(java.lang.String line)
                       throws java.lang.Exception
Throws:
java.lang.Exception

getHexString

protected java.lang.String getHexString(long value,
                                        int n_chars)

save

public boolean save(java.io.PrintWriter PW)
write the memory data in a trivial addr:data format, one address per line. Both address and data are hex-formatted and separated by a colon (and optionally, some blanks).

Specified by:
save in interface Memory

configure

public void configure()
Description copied from class: SimObject
create and display a 'ConfigDialog' to set the parameters for a SimObject. The default ConfigDialog for the base class (SimObject) itself is empty except for the 'instance name' of the SimObject.

Overrides:
configure in class SimObject

getPropertySheet

public java.awt.Component getPropertySheet()
Description copied from class: SimObject
return a reference to the 'property sheet' or configuration window for this SimObject. We cast the return value to an AWT Component, but typically you can expect either a hades.gui.PropertySheet or an java.awt.Window (Dialog or Frame).

Overrides:
getPropertySheet in class SimObject

elaborate

public void elaborate(java.lang.Object arg)
elaborate(): No use to call elaborate on a GenericMemory. This method should be overridden by subclasses.

Specified by:
elaborate in interface Simulatable
Overrides:
elaborate in class SimObject

evaluate

public void evaluate(java.lang.Object arg)
evaluate(): No use to call elaborate on a GenericMemory. This method should be overridden by subclasses.

Specified by:
evaluate in interface Simulatable
Overrides:
evaluate in class SimObject
Parameters:
arg - an arbitrary object argument

notifyWriteListeners

protected void notifyWriteListeners(int address,
                                    long old_value,
                                    long new_value)

notifyReadListeners

protected void notifyReadListeners(int address,
                                   long value)

dbg

public void dbg(java.lang.String msg)

warning

public void warning(java.lang.String s)
print a warning message to the Hades console, consisting of the actual message 's', the full name of this memory component and the current simulation time.


checkInvalidateMemory

public void checkInvalidateMemory()
called from evaluate() when an illegal input value combination is detected, for example an undefined address during a write cycle. We check the value of the boolean SetupManager property "Hades.Models.Memory.InvalidateOnUndefinedInputs". If it is set, we call initializWithX() which will invalidate the whole memory contents.


getToolTip

public java.lang.String getToolTip(java.awt.Point position,
                                   long millis)
construct a (not so short) tool tip message. We write the memory class, memory size, memory name, current output value, and last read and write addresses.

Specified by:
getToolTip in interface ContextToolTip
Overrides:
getToolTip in class SimObject

toString

public java.lang.String toString()
Description copied from class: SimObject
toString: generate a text description for this SimObject. This method currently combines the class name for the SimObject (or subclass) and its full name in the current Hades Design, e.g. "hades.models.gates.And2: /uut/adder16/adder1/i3".

Overrides:
toString in class SimObject

main

public static void main(java.lang.String[] argv)

getAddrOffset

public int getAddrOffset()
Description copied from interface: Memory
utility method to support systems with different memory components mapped into a single address space at different offsets. Note that the value returned is just used for displaying the addresses in the GUI (e.g. MemoryHexEditorField or MRCanvas), while the simulation uses the raw adresses (always starting at 0).

For example, the D*CORE processor used in our T3 practical course uses one ROM mapped to addresses 0x000..0x6FFF with address offset 0, a RAM mapped to addresses 0x8000..0xFFFF with address offset 0x8000, and IO components mapped to 0x7000..0x7FFF. Standard memory components will usually return 0 here.

Specified by:
getAddrOffset in interface Memory

getConfigDialog

public PropertySheet getConfigDialog()
Specified by:
getConfigDialog in interface Memory