|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbyucc.jhdl.platforms.util.GenericMemory
This class is used to help create memory models for board models. It uses a "chunky" memory model, meaning that the user (board model designer) can set the block size. A block is only constructed if a memory space in that block is written. Also, the model will keep track of which addresses have valid data (data has been written to that address) and will throw and exception if the data is not valid.
Field Summary | |
static int |
HUGE
HUGE block size. |
static int |
LARGE
LARGE block size. |
static int |
MEDIUM
MEDIUM block size. |
static int |
SMALL
SMALL block size. |
static int |
TINY
TINY block size. |
Constructor Summary | |
GenericMemory(int addr_bits,
int chunk_size,
int width)
Constructor used to create the GenericMemory object. |
|
GenericMemory(int addr_bits,
int chunk_size,
int width,
JHDLOutput jout)
Constructor used to create the GenericMemory object. |
Method Summary | |
void |
addMemoryElement(BV value)
Called when a line is parsed which contains a value to be placed in the memory. |
void |
endParse(java.lang.String filename)
|
java.io.Serializable |
getData()
Since GenericMemory is not a cell, these functions will need to be called in the getData and setData (respectively) of the Cells who use GenericMemory |
BV |
getEmpty()
Returns a copy of the "empty" value. |
BV |
getMemoryElement(int address,
BV ret)
Return the given memory position |
BV[] |
getMemoryRange(int sIndex,
int elements,
BV[] ret)
Return the given memory range |
int |
getMemoryWidth()
Returns the memory width |
long |
getSize()
Returns the memory size |
boolean |
loadMemoryFile(java.lang.String filename)
Loads memory from a file. |
static void |
main(java.lang.String[] args)
|
BV |
readMemoryLocation(int address)
Reads an entry in the memory and returns it as a BV (Bit Vector). |
BV |
readMemoryLocation(int address,
BV output)
Reads an entry in the memory and returns it as a BV (Bit Vector). |
void |
setAddressPointer(BV value)
|
void |
setData(java.io.Serializable data)
Since GenericMemory is not a cell, these functions will need to be called in the getData and setData (respectively) of the Cells who use GenericMemory |
void |
setEmpty(BV value)
Sets the empty value. |
void |
setEmpty(java.lang.String value)
Sets the empty value. |
void |
setJHDLOutput(JHDLOutput jout)
Sets the JHDLOutput object that will be used by this memory. |
void |
startParse(java.lang.String filename)
|
void |
writeMemoryElement(int address,
BV value)
|
void |
writeMemoryLocation(int address,
BV value)
Writes a value to the specified address. |
void |
writeMemoryRange(int address,
int elements,
BV[] values)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int TINY
public static final int SMALL
public static final int MEDIUM
public static final int LARGE
public static final int HUGE
Constructor Detail |
public GenericMemory(int addr_bits, int chunk_size, int width)
addr_bits
- Number of address bits for this memory. This number is used to compute the
depth of the memory.chunk_size
- Number of address bits represented in each chunk.width
- Width of the data in the memory.public GenericMemory(int addr_bits, int chunk_size, int width, JHDLOutput jout)
addr_bits
- Number of address bits for this memory. This number is used to compute the
depth of the memory.chunk_size
- Number of address bits represented in each chunk.width
- Width of the data in the memory.jout
- JHDLOutput stream to use when printing messages. If null, then it will default to
the "platforms" output stream.Method Detail |
public void setJHDLOutput(JHDLOutput jout)
jout
- JHDLOutput to be set as the output stream.public void setEmpty(BV value)
public void setEmpty(java.lang.String value)
public BV getEmpty()
public BV readMemoryLocation(int address) throws UtilMemoryReadException
address
- Address to be read.
UtilMemoryReadException
- The exception is thrown if an attempt is made to read from
an uninitialized 0r non-existent memory location. The board model writer is forced to catch
this exception and can decide whether to report it as an error, a warning, not at all, or allow
the user to choose.public boolean loadMemoryFile(java.lang.String filename)
loadMemoryFile
in interface LargeWritableMemory
filename
- Name of the file to load.public BV readMemoryLocation(int address, BV output) throws UtilMemoryReadException
address
- Address to be read.output
- BV to which the result should be written.
UtilMemoryReadException
- The exception is thrown if an attempt is made to read from
an uninitialized 0r non-existent memory location. The board model writer is forced to catch
this exception and can decide whether to report it as an error, a warning, not at all, or allow
the user to choose.public void writeMemoryLocation(int address, BV value)
address
- Address to be written.value
- Value to write to the address.public void writeMemoryRange(int address, int elements, BV[] values)
writeMemoryRange
in interface LargeWritableMemory
public void writeMemoryElement(int address, BV value)
writeMemoryElement
in interface LargeWritableMemory
public BV[] getMemoryRange(int sIndex, int elements, BV[] ret)
LargeMemoryInterface
getMemoryRange
in interface LargeMemoryInterface
sIndex
- the starting indexelements
- how many entries to getret
- where to stick the results
public BV getMemoryElement(int address, BV ret)
LargeMemoryInterface
getMemoryElement
in interface LargeMemoryInterface
address
- the memory address to getret
- where to stick the results
public long getSize()
LargeMemoryInterface
getSize
in interface LargeMemoryInterface
public int getMemoryWidth()
LargeMemoryInterface
getMemoryWidth
in interface LargeMemoryInterface
public java.io.Serializable getData()
getData
in interface Checkpointable
public void setData(java.io.Serializable data)
setData
in interface Checkpointable
data
- the state that was saved earlierpublic void startParse(java.lang.String filename)
startParse
in interface MemoryFileParserInterface
public void endParse(java.lang.String filename)
endParse
in interface MemoryFileParserInterface
public void setAddressPointer(BV value)
setAddressPointer
in interface MemoryFileParserInterface
public void addMemoryElement(BV value)
MemoryFileParserInterface
addMemoryElement
in interface MemoryFileParserInterface
value
- Value to be added to the memory. Please note that
this BV will be altered during subsequent parsing. The user is
responsible to keep a copy of the BV if it is needed.public static void main(java.lang.String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |