|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object avrora.sim.Segment
The Segment
class represents a segment of byte-addressable memory that
supports probing. It is used to represent the SRAM, the flash, and the EEPROM. For
efficiency, it sharing of the underlying byte array representing the memory.
Nested Class Summary | |
class |
Segment.AddressOutOfBoundsException
The AddressOutOfBoundsException class represents an error when
using the get() and set() methods where the user
specifies an address that is out of the bounds of the segment. |
static interface |
Segment.ErrorReporter
The ErrorReporter class is used to intercept errors caused by trying to
either read or write outside the bounds of this segment. |
static interface |
Segment.Sharer
The Sharer interface must be implemented by a class that needs to
share the underlying data representation for efficiency reasons. |
Field Summary | |
protected Segment.ErrorReporter |
errorReporter
|
protected BaseInterpreter |
interpreter
|
protected java.lang.String |
name
|
protected byte[] |
segment_data
|
protected MulticastWatch[] |
segment_watches
|
protected Segment.Sharer |
sharer
|
protected int |
size
|
protected byte |
value
|
Constructor Summary | |
Segment(java.lang.String name,
int size,
byte defvalue,
BaseInterpreter bi,
Segment.ErrorReporter er)
The constructor for the Segment class creates an object that represents this segment.
|
Method Summary | |
byte |
get(int address)
The get() method simply retrieves the value of a byte at a particular location in the
segment. |
void |
insertWatch(int data_addr,
Simulator.Watch p)
The insertWatch() allows user code to insert a watch on a particular memory location.
|
byte |
read(int address)
The read() method of the segment reads a byte from a location in the segment,
firing any watches on the address before and after the read. |
void |
removeWatch(int data_addr,
Simulator.Watch p)
The removeWatch() removes a watch on a particular memory location.
|
void |
set(int address,
byte val)
The set() method simply sets the value of a byte at a particular location in the
segment. |
byte[] |
share(Segment.Sharer s)
The share() method allows sharing of the underlying array representing the values of
memory. |
void |
write(int address,
byte val)
The write() method of the segment writes a byte to a location in the segment,
firing any watches on the address before and after the write. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final BaseInterpreter interpreter
protected final java.lang.String name
protected final int size
protected final byte value
protected byte[] segment_data
protected final Segment.ErrorReporter errorReporter
protected MulticastWatch[] segment_watches
protected Segment.Sharer sharer
Constructor Detail |
public Segment(java.lang.String name, int size, byte defvalue, BaseInterpreter bi, Segment.ErrorReporter er)
Segment
class creates an object that represents this segment.
The segment is byte-addressable and allows watches to be placed on individual bytes in memory.
name
- the name of the segment as a stringsize
- the size of the segment in bytesdefvalue
- the default value of bytes in this segmenter
- an object that is notified when an attempt is made to read or write outside of the bounds
of this segmentMethod Detail |
public byte[] share(Segment.Sharer s)
share()
method allows sharing of the underlying array representing the values of
memory. This is used for performance.
s
- the sharer to allow access to this segment's internal data
public byte read(int address)
read()
method of the segment reads a byte from a location in the segment,
firing any watches on the address before and after the read. This is intended to be called
ONLY by the interpreter and device implementations, and NOT by other parts of the simulation
that simply want to inspect the state of simulation. A call to the read()
method
will result in a call to the readError()
method of the ErrorReporter
object associated with this segment if the access is not within the bounds of the segment.
address
- the address in the segment from which to read the byte
public byte get(int address)
get()
method simply retrieves the value of a byte at a particular location in the
segment. This method will NOT result in triggering any watches installed for this address. This method
is intended for use by user code outside of the simulation (such as probes and watches) to inspect
the values in this segment.
address
- the address in the segment for which to retrieve the value
Segment.AddressOutOfBoundsException
- if the specified address is not within the bounds of this segmentpublic void write(int address, byte val)
write()
method of the segment writes a byte to a location in the segment,
firing any watches on the address before and after the write. This is intended to be called
ONLY by the interpreter and device implementations, and NOT by other parts of the simulation
that want to alter the state of the simulation. A call to the write()
method
will result in a call to the writeError()
method of the ErrorReporter
object associated with this segment if the access is not within the bounds of the segment.
address
- the address in the segment which should be writtenval
- the value to write to the location in the segmentpublic void set(int address, byte val)
set()
method simply sets the value of a byte at a particular location in the
segment. This method will NOT result in triggering any watches installed for this address. This method
is intended for use by code outside of the simulation (such as probes and watches) to alter the
state of the memory segment, which should not be done by user code.
address
- the address in the segment which should be writtenval
- the value to write to this byte in memory
Segment.AddressOutOfBoundsException
- if the specified address is not within the bounds of this segmentpublic void insertWatch(int data_addr, Simulator.Watch p)
insertWatch()
allows user code to insert a watch on a particular memory location.
The watch will be triggered when a read()
or write()
to the memory location
occurs in during simulation.
data_addr
- the address of the byte in memory for which to insert the watchp
- the watch to insert on the memory bytepublic void removeWatch(int data_addr, Simulator.Watch p)
removeWatch()
removes a watch on a particular memory location.
The watch will no longer be triggered for subseqent read()
s or write()
s
occur in during simulation. Reference equality is used to match watches, and NOT Object.equals()
.
data_addr
- the address of the byte in memory for which to remove the watchp
- the watch to remove
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |