|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jfrace.AddressSpace
The address space is the backbone of the framework. CPU's and devices know from each other due to the address space. It is similar to the bus in a computer system. An address can be any non-negative integer below 231.
The address space is organized in non-overlapping address
banks. An address bank is defined when a Device
is attached (by the method addDevice
)
to a certain address.
The size of the Device
(obtained by the method
Device.getNumberOfUnits()
) defines the size of the
address bank. For Reading and writing the invokation of
the methods getValue(int, int)
/getByte(int, int)
and
setValue(int, int, int)
/setByte(int, int, byte)
, resp.,
are redirected to the corresponding methods of
Device
. Usually CPUs
will call
these methods. Reading from or writing to an address
outside any address bank may lead to a
BusErrorException
.
Also a CPU
can be added to an address
(by the method addCPU(int, jfrace.CPU)
).
CPU's are stored in a list. Devices interested in invoking
an interrupt on a CPU can get the corresponding instance
with the method getCPU(int)
.
Devices and CPU's (i.e., any Hardware
) can be
removed from the AddressSpace
.
If a Hardware
is added or removed all subscribed
AddressSpaceListener
will be notified.
Constructor Summary | |
AddressSpace()
Default constructor. |
|
AddressSpace(int aDefaultValue)
Constructor defining the default value which is returned when no address bank could be found in an access due to the getValue(int, int) or
getByte(int, int) method. |
Method Summary | |
void |
addAddressSpaceListener(AddressSpaceListener asl)
Add an AddressSpaceListener . |
void |
addCPU(int anAddressOffset,
CPU aCpu)
Add a CPU. |
void |
addDevice(int firstAddress,
int modeMask,
Device device)
Add a new device and thereby define a new address bank. |
byte |
getByte(int anAddress,
int mode)
Get the byte at the given address. |
CPU |
getCPU(int index)
Return the CPU for the given index. |
int |
getCPUAddressOffset(int index)
Return the address offset for the CPU of given index. |
Device |
getDevice(int index)
Return the device of a given address bank. |
int |
getFirstAddress(int index)
Return the first address of a given address bank. |
int |
getLastAddress(int index)
Return the address just following the last address of a given address bank. |
int |
getModeMask(int index)
Return the mode mask of a given address bank. |
int |
getNumberOfAddressBanks()
Return the number of address banks. |
int |
getNumberOfCPUs()
Return the number of attached CPUs. |
int |
getValue(int anAddress,
int mode)
Get the value of the addressable unit at the given address. |
void |
removeAddressSpaceListener(AddressSpaceListener asl)
Remove an AddressSpaceListener . |
void |
removeCPU(CPU aCpu)
Remove a CPU. |
void |
removeDevice(Device device)
Remove a device and the associated address bank. |
void |
setByte(int anAddress,
int mode,
byte value)
Set the byte at the given address. |
void |
setValue(int anAddress,
int mode,
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 AddressSpace()
AddressSpace(0)
.public AddressSpace(int aDefaultValue)
getValue(int, int)
or
getByte(int, int)
method.aDefaultValue
- Default value for nonsuccessful access.Method Detail |
public void addAddressSpaceListener(AddressSpaceListener asl)
AddressSpaceListener
. Does nothing if already
in the list.asl
- A new AddressSpaceListener
.public void removeAddressSpaceListener(AddressSpaceListener asl)
AddressSpaceListener
.asl
- AddressSpaceListener
to be removed.public int getNumberOfAddressBanks()
public int getFirstAddress(int index)
index
- Index of an address bank.public int getLastAddress(int index)
index
- Index of address bank.public int getModeMask(int index)
index
- Index of address bank.public Device getDevice(int index)
index
- Index of address bank.public void addDevice(int firstAddress, int modeMask, Device device) throws AddressBankOverlapException, java.lang.IllegalArgumentException
AddressSpaceListener
s.firstAddress
- First address of the added address bank.modeMask
- Mask for checking the access mode.device
- Device to be added.AddressBankOverlapException
- if an overlap with an
already existing address bank has been detected.java.lang.IllegalArgumentException
- if firstAddress < 0
or device.numberOfUnits() <= 0
.public void removeDevice(Device device)
AddressSpace
. Interested
AddressSpaceListener
s will be informed.device
- Device to be removed.public int getNumberOfCPUs()
public CPU getCPU(int index)
public int getCPUAddressOffset(int index)
public void addCPU(int anAddressOffset, CPU aCpu)
AddressSpaceListener
s will
be informed.anAddressOffset
- Address offset.aCpu
- CPU which will be added.public void removeCPU(CPU aCpu)
AddressSpace
. Interested
AddressSpaceListener
s will be informed.aCpu
- CPU to be removed.public final int getValue(int anAddress, int mode) throws BusErrorException
getByte(int, int)
should be
be used.anAddress
- Address in the address space.mode
- Access mode.BusErrorException
- will be thrown if
mode > 0
and
mode
masked with the
modeMask
attribute of the address
bank yields zero.public final void setValue(int anAddress, int mode, int value) throws BusErrorException
setByte(int, int, byte)
should be
be used.anAddress
- Address in the address space.mode
- Access mode.value
- Value.BusErrorException
- will be thrown if
mode > 0
and
mode
masked with the
modeMask
attribute of the address
bank yields zero.public final byte getByte(int anAddress, int mode) throws BusErrorException
getValue(int, int)
but has a better performance.
anAddress
- Address in the address space.mode
- Access mode.BusErrorException
- will be thrown if
mode > 0
and
mode
masked with the
modeMask
attribute of the address
bank yields zero.public final void setByte(int anAddress, int mode, byte value) throws BusErrorException
setValue(int, int, int)
but has a
better performance.
anAddress
- Address in the address space.mode
- Access mode.value
- Value.BusErrorException
- will be thrown if
mode > 0
and
mode
masked with the
modeMask
attribute of the address
bank yields zero.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |