|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jfrace.device.RAM
This class emulates the random access memory (RAM) of a
computer. By setting the readOnly
flag it can
be turned into a ROM.
Constructor Summary | |
RAM()
Create an empty memory. |
|
RAM(int numberOfBits)
Create an empty memory with a given size of the addressable unit. |
|
RAM(int numberOfBits,
int numberOfUnits,
boolean readOnlyFlag)
Create an empty memory with a given size of the addressable unit and a given number of addressable units. |
|
RAM(int numberOfBits,
java.net.URL source,
boolean readOnlyFlag)
Create a memory with a given size of the addressable unit and filled with raw data from a given source. |
Method Summary | |
void |
createMemory(int numberOfUnits)
Create memory of a given number of addressable units. |
static void |
createRAMAndAddToAS(AddressSpace as,
java.lang.String description,
java.net.URL documentBase)
Create an instance from a description string and add it to the given address space. |
byte |
getByte(int address)
Get the byte at the given address. |
byte[] |
getMemory()
Return the memory array. |
int |
getNumberOfBits()
Return the size of an addressable unit. |
int |
getNumberOfUnits()
Return the number of addressable units. |
int |
getValue(int address)
Get the value of the addressable unit at the given address. |
boolean |
isReadOnly()
Return true if read only. |
void |
reset()
Fill the memory with zeros. |
void |
setByte(int address,
byte value)
Set the byte at the given address. |
void |
setValue(int address,
int value)
Set the value of the addressable unit at the given address. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RAM()
public RAM(int numberOfBits)
numberOfBits
- the size of an addressable unit in number of bits.public RAM(int numberOfBits, int numberOfUnits, boolean readOnlyFlag)
numberOfBits
- The size of an addressable unit in number of bits.numberOfUnits
- Number of addressable units.readOnlyFlag
- readOnly
flag.public RAM(int numberOfBits, java.net.URL source, boolean readOnlyFlag) throws java.io.IOException
numberOfBytes
belong to an addressable unit.
numberOfBytes
is the number of bytes to cover
an addressable unit with numberOfBits
bits.
The data in a chunk is stored in big-endian form (i.e.,
the highest bytes come first).numberOfBits
- the size of an addressable unit in number of bits.source
- Source of the raw data.readOnlyFlag
- readOnly
flag.java.io.IOException
- is thrown when an error occured during
obtaining the raw data.Method Detail |
public static void createRAMAndAddToAS(AddressSpace as, java.lang.String description, java.net.URL documentBase) throws AddressBankOverlapException, java.lang.IllegalArgumentException
<number of bits> <first address>
{<size>|<raw data>}
[<mode mask>] [readOnly]
<number of bits>
<first address>
<size>
<raw data>
<mode mask>
readOnly
as
- Address space.description
- Description string.documentBase
- URL of the document base if
<raw data>
is a relative URL.java.lang.IllegalArgumentException
- is thrown when the
description string has some error.AddressBankOverlayException
- is thrown when
a collision between the RAM and other devices
in the address space occur.public boolean isReadOnly()
true
if read only. That is, all
invocations of setValue
and setByte
.
will be ignored.public void createMemory(int numberOfUnits)
numberOfUnits
- number of addressable units.public byte[] getMemory()
public void reset()
reset
in interface Hardware
public int getNumberOfBits()
getNumberOfBits
in interface Hardware
public int getNumberOfUnits()
getNumberOfUnits
in interface Device
public int getValue(int address)
getValue
in interface Device
address
- memory address.public void setValue(int address, int value)
setValue
in interface Device
address
- memory address.value
- the new value.public byte getByte(int address)
getValue
but has a better performance.
getByte
in interface Device
address
- memory address.address
.public void setByte(int address, byte value)
setValue
but has a better performance.
setByte
in interface Device
address
- memory address.value
- new value of the byte at address
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |