hades.models.rtl
Class ROM_1Kx8

java.lang.Object
  extended byhades.simulator.SimObject
      extended byhades.models.rtl.ROM_1Kx8
All Implemented Interfaces:
java.lang.Cloneable, ContextToolTip, Memory, java.io.Serializable, Simulatable
Direct Known Subclasses:
ROM_256x8, ROM_64Kx8, ROM_64x8, ROM_8Kx8

public class ROM_1Kx8
extends SimObject
implements Memory

ROM_1Kx8 - a static read-only memory components with 1024 words of 8 bit. Ports are single bits of type StdLogic1164.

See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable _listenerTable
           
protected  long[] data
           
static int DISABLED
           
protected  int index_a0
           
protected  int index_y0
           
protected  MemoryEditorFrame MEF
           
protected  int n_address_ports
           
protected  int n_words
           
protected  StdLogic1164 output_0
           
protected  StdLogic1164 output_1
           
protected  StdLogic1164 output_X
           
protected  StdLogic1164 output_Z
           
protected  Port port_nCS
           
protected  Port port_nOE
           
(package private)  java.lang.String resourcename
           
static double t_access
           
static double t_tristate
           
static double t_undefined
           
static int TRISTATED
           
static int UNDEFINED
           
 
Fields inherited from class hades.simulator.SimObject
classloader, console, debug, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
ROM_1Kx8()
          ROM_1Kx8 constructor
 
Method Summary
 void addMemoryListener(MemoryListener ML)
           
 boolean canChangeSize()
           
 void configure()
          create and display a 'ConfigDialog' to set the parameters for a SimObject.
 void createDataArray()
           
 void createPorts()
          create the ports of this ROM: first the nCS and nOE ports, then the eight data bits, and following the address bits.
 void dbg(java.lang.String msg)
           
 void elaborate(java.lang.Object arg)
          elaborate(): This method is called by the simulation engine to initialize the simulation object.
 void evaluate(java.lang.Object arg)
          evaluate(): called by the simulation engine on all events that concern this object.
 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)
           
 java.lang.String[] getExternalResources()
          return a String[] array of length 1 with our ROM initialization data file.
protected  java.lang.String getHexString(long value, int n_chars)
           
 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.
 boolean initialize(java.lang.String s)
          initialize a ROM_1Kx8 from a String.
 void initROM()
           
 boolean merge(java.io.BufferedReader reader)
           
 boolean needsExternalResources()
          we use one external resource: the data file to initialize the ROM contents.
 boolean parse(java.io.BufferedReader br)
          parse RAM data from a file specified via its Java 1.1 resourcename.
 void parseRAM(java.lang.String resourcename)
           
 void printSramContent()
           
 void removeMemoryListener(MemoryListener ML)
           
 boolean resize(int n_words, int n_bits_per_word)
           
 boolean save(java.io.PrintWriter PW)
           
 void setBitsPerWord(int n_bits)
           
 void setDataArray(long[] data)
           
 void setDataAt(int address, long value)
           
 void setResourcename(java.lang.String s)
           
 void setSize(int n_words)
           
 void setSizeConstants()
           
 java.lang.String toString()
          toString() - the usual info method
 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, getToolTip, 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

output_0

protected StdLogic1164 output_0

output_1

protected StdLogic1164 output_1

output_X

protected StdLogic1164 output_X

output_Z

protected StdLogic1164 output_Z

port_nCS

protected Port port_nCS

port_nOE

protected Port port_nOE

n_address_ports

protected int n_address_ports

n_words

protected int n_words

index_a0

protected int index_a0

index_y0

protected int index_y0

data

protected long[] data

DISABLED

public static final int DISABLED
See Also:
Constant Field Values

UNDEFINED

public static final int UNDEFINED
See Also:
Constant Field Values

TRISTATED

public static final int TRISTATED
See Also:
Constant Field Values

resourcename

java.lang.String resourcename

_listenerTable

protected java.util.Hashtable _listenerTable

MEF

protected MemoryEditorFrame MEF

t_access

public static final double t_access
See Also:
Constant Field Values

t_tristate

public static final double t_tristate
See Also:
Constant Field Values

t_undefined

public static final double t_undefined
See Also:
Constant Field Values
Constructor Detail

ROM_1Kx8

public ROM_1Kx8()
ROM_1Kx8 constructor

Method Detail

setSizeConstants

public void setSizeConstants()

createPorts

public void createPorts()
create the ports of this ROM: first the nCS and nOE ports, then the eight data bits, and following the address bits. This allows to reuse all of the elaborate()/evaluate() code for subclasses with different ROM size (like 8K or 64K words)


createDataArray

public void createDataArray()

needsExternalResources

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

Overrides:
needsExternalResources in class SimObject

getExternalResources

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

Overrides:
getExternalResources in class SimObject

initROM

public void initROM()

printSramContent

public void printSramContent()

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 ROM_1Kx8 from a String. Currently, the String should contain the following things: the ROM_1Kx8 versionId, and the Java resource-name of the RAM datafile to parse, e.g.
       1002 /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

parseRAM

public void parseRAM(java.lang.String resourcename)

parse

public boolean parse(java.io.BufferedReader br)
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:D3' or '03FF:20'.

The alternative DigLOG compact format, e.g. '0000:000102030405060708090A0B0C0D0E0F' is also accepted.

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

Specified by:
parse in interface Memory

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

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

canChangeSize

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

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

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

getHexString

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

save

public boolean save(java.io.PrintWriter PW)
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(): This method is called by the simulation engine to initialize the simulation object.

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

evaluate

public void evaluate(java.lang.Object arg)
evaluate(): called by the simulation engine on all events that concern this object. The object is responsible for updating its internal state and for scheduling all pending output events.

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

dbg

public void dbg(java.lang.String msg)

toString

public java.lang.String toString()
toString() - the usual info method

Overrides:
toString in class SimObject

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