Simple Machine

machine
Class AbstractMainMemory.Port

java.lang.Object
  extended by machine.AbstractMainMemory.Port
Enclosing class:
AbstractMainMemory

public class AbstractMainMemory.Port
extends Object

Memory's port for reading and writing. This is the interface the memory presents to the CPU.


Constructor Summary
AbstractMainMemory.Port(AbstractMainMemory.MMU mmu)
           
 
Method Summary
 UnsignedByte[] read(int address, int length)
          Read a sequence of bytes from memory using an aligned address.
 int readInteger(int address)
          Read a 4-byte integer from memory using an aligned address.
 int readIntegerUnaligned(int address)
          Read a 4-byte integer from memory using a possibly-unaligned address.
 UnsignedByte[] readUnaliged(int address, int length)
          Read a sequence of bytes from memory using a possibly-unaligned address.
 void write(int address, UnsignedByte[] value)
          Write a sequence of bytes to memory using an aligned address.
 void writeInteger(int address, int value)
          Write a 4-byte integer to memory using an aligned address.
 void writeIntegerUnaligned(int address, int value)
          Write a 4-byte integer to memory using a possibly-unaligned address.
 void writeUnaligned(int address, UnsignedByte[] value)
          Write a sequence of bytes to memory using a possibly-unaligned address.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMainMemory.Port

public AbstractMainMemory.Port(AbstractMainMemory.MMU mmu)
Method Detail

read

public UnsignedByte[] read(int address,
                           int length)
                    throws AbstractMainMemory.InvalidAddressException
Read a sequence of bytes from memory using an aligned address.

Parameters:
address - address of first byte.
length - number of bytes.
Returns:
array of memory value of the specified bytes.
Throws:
InvalidMemoryException - if any address in the range address to address+length-1 is out of range or if address % length != 0 (i.e., address is not aligned to length).
AbstractMainMemory.InvalidAddressException

readUnaliged

public UnsignedByte[] readUnaliged(int address,
                                   int length)
                            throws AbstractMainMemory.InvalidAddressException
Read a sequence of bytes from memory using a possibly-unaligned address.

Parameters:
address - address of first byte.
length - number of bytes.
Returns:
array of memory value of the specified bytes.
Throws:
InvalidMemoryException - if any address in the range address to address+length-1 is out of range.
AbstractMainMemory.InvalidAddressException

readInteger

public int readInteger(int address)
                throws AbstractMainMemory.InvalidAddressException
Read a 4-byte integer from memory using an aligned address.

Parameters:
address - address of first byte.
Returns:
integer value of the specified bytes.
Throws:
InvalidMemoryException - if any address in the range address to address+3 is out of range or if address % 4 != 0 (i.e., address is not aligned to length).
AbstractMainMemory.InvalidAddressException

readIntegerUnaligned

public int readIntegerUnaligned(int address)
                         throws AbstractMainMemory.InvalidAddressException
Read a 4-byte integer from memory using a possibly-unaligned address.

Parameters:
address - address of first byte.
Returns:
integer value of the specified bytes.
Throws:
InvalidMemoryException - if any address in the range address to address+3 is out of range.
AbstractMainMemory.InvalidAddressException

write

public void write(int address,
                  UnsignedByte[] value)
           throws AbstractMainMemory.InvalidAddressException
Write a sequence of bytes to memory using an aligned address.

Parameters:
address - address of first byte.
value - array of bytes to write into memory.
Throws:
InvalidMemoryException - if any address in the range address to address+value.length-1 is out of range or if address % length != 0 (i.e., address is not aligned to length).
AbstractMainMemory.InvalidAddressException

writeUnaligned

public void writeUnaligned(int address,
                           UnsignedByte[] value)
                    throws AbstractMainMemory.InvalidAddressException
Write a sequence of bytes to memory using a possibly-unaligned address.

Parameters:
address - address of first byte.
value - array of bytes to write into memory.
Throws:
InvalidMemoryException - if any address in the range address to address+value.length-1 is out of range.
AbstractMainMemory.InvalidAddressException

writeInteger

public void writeInteger(int address,
                         int value)
                  throws AbstractMainMemory.InvalidAddressException
Write a 4-byte integer to memory using an aligned address.

Parameters:
address - address of first byte.
value - integer to write into memory.
Throws:
InvalidMemoryException - if any address in the range address to address+3 is out of range or if address % 4 != 0 (i.e., address is not aligned to length).
AbstractMainMemory.InvalidAddressException

writeIntegerUnaligned

public void writeIntegerUnaligned(int address,
                                  int value)
                           throws AbstractMainMemory.InvalidAddressException
Write a 4-byte integer to memory using a possibly-unaligned address.

Parameters:
address - address of first byte.
value - integer to write into memory.
Throws:
InvalidMemoryException - if any address in the range address to address+3 is out of range.
AbstractMainMemory.InvalidAddressException

Simple Machine

Copyright © 2010, 2011 Mike Feeley. All Rights Reserved.