Simple Machine

Arch.Y86.Machine
Class MainMemory

java.lang.Object
  extended by java.util.Observable
      extended by Util.AbstractDataModel
          extended by Machine.AbstractMainMemory
              extended by Arch.Y86.Machine.MainMemory
All Implemented Interfaces:
DataModel

public class MainMemory
extends AbstractMainMemory


Nested Class Summary
 
Nested classes/interfaces inherited from class Machine.AbstractMainMemory
AbstractMainMemory.InvalidAddressException
 
Constructor Summary
MainMemory(int byteCapacity)
           
 
Method Summary
 int bytesToInteger(UnsignedByte byteAtAddrPlus0, UnsignedByte byteAtAddrPlus1, UnsignedByte byteAtAddrPlus2, UnsignedByte byteAtAddrPlus3)
          Convert a byte array to an integer.
protected  UnsignedByte[] get(int address, int length)
          Read a sequence of bytes from memory.
 UnsignedByte[] integerToBytes(int i)
          Convert an integer to a byte array.
protected  boolean isAccessAligned(int address, int length)
          Determine whether specified address and length represent an ALIGNED access.
 int length()
           
protected  void set(int address, UnsignedByte[] value)
          Write a sequence of bytes to memory.
 
Methods inherited from class Machine.AbstractMainMemory
getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, read, readInteger, readIntegerUnaligned, readUnaligned, setValueAt, setValueAt, setValueAtByUser, setValueAtByUser, write, writeInteger, writeIntegerUnaligned, writeUnaligned
 
Methods inherited from class Util.AbstractDataModel
addUndoableEditListener, canDeleteRow, canInsertRow, deleteRow, insertRow, tellObservers, tellObservers
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Util.DataModel
addObserver
 

Constructor Detail

MainMemory

public MainMemory(int byteCapacity)
Method Detail

isAccessAligned

protected boolean isAccessAligned(int address,
                                  int length)
Description copied from class: AbstractMainMemory
Determine whether specified address and length represent an ALIGNED access. Protected method called by public read and write methods. An address is aligned if and only if the address modulo value.length is 0 (i.e., the low order log 2 (length) bits are 0. Aligned memory access is faster than unaligned access and so compilers should attempt to used aligned access whenever possible. It is sometimes not possible, however, particularlly for reading instructions in architectures that support variable instruction lengths such as SM213 and Y86, for example.

Specified by:
isAccessAligned in class AbstractMainMemory
Returns:
true iff access to address of length bytes is an aligned access

bytesToInteger

public int bytesToInteger(UnsignedByte byteAtAddrPlus0,
                          UnsignedByte byteAtAddrPlus1,
                          UnsignedByte byteAtAddrPlus2,
                          UnsignedByte byteAtAddrPlus3)
Description copied from class: AbstractMainMemory
Convert a byte array to an integer.

Specified by:
bytesToInteger in class AbstractMainMemory
Parameters:
byteAtAddrPlus0 - value of byte at some memory address addr
byteAtAddrPlus1 - value of byte at some memory address addr + 1
byteAtAddrPlus2 - value of byte at some memory address addr + 2
byteAtAddrPlus3 - value of byte at some memory address addr + 3
Returns:
integer comprised of this four bytes organized according to the Endianness of the target ISA

integerToBytes

public UnsignedByte[] integerToBytes(int i)
Description copied from class: AbstractMainMemory
Convert an integer to a byte array.

Specified by:
integerToBytes in class AbstractMainMemory
Parameters:
i - an 32-bit integer value
Returns:
an array of bytes that comprise the integer in address order according to the Endianness of the target ISA

get

protected UnsignedByte[] get(int address,
                             int length)
                      throws AbstractMainMemory.InvalidAddressException
Description copied from class: AbstractMainMemory
Read a sequence of bytes from memory. Protected method called by public read method.

Specified by:
get in class AbstractMainMemory
Parameters:
address - byte address of first byte to read.
length - number of bytes to read.
Throws:
AbstractMainMemory.InvalidAddressException - if address is out of range.

set

protected void set(int address,
                   UnsignedByte[] value)
            throws AbstractMainMemory.InvalidAddressException
Description copied from class: AbstractMainMemory
Write a sequence of bytes to memory. Protected method called by public write method.

Specified by:
set in class AbstractMainMemory
Parameters:
address - byte address of first byte to write.
value - array of unsigned bytes to write to memory at this address.
Throws:
AbstractMainMemory.InvalidAddressException - if address is out of range.

length

public int length()
Specified by:
length in class AbstractMainMemory

Simple Machine