|
Simple Machine | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.Observable
util.AbstractDataModel
machine.AbstractMainMemory
arch.sm213.machine.student.MainMemory
public class MainMemory
Main Memory of Simple CPU. Provides an abstraction of main memory (DRAM).
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class machine.AbstractMainMemory |
|---|
AbstractMainMemory.InvalidAddressException, AbstractMainMemory.Port |
| Constructor Summary | |
|---|---|
MainMemory(int byteCapacity)
Allocate memory. |
|
| Method Summary | |
|---|---|
int |
bytesToInteger(UnsignedByte byteAtAddrPlus0,
UnsignedByte byteAtAddrPlus1,
UnsignedByte byteAtAddrPlus2,
UnsignedByte byteAtAddrPlus3)
Convert an sequence of four bytes into a Big Endian integer. |
protected UnsignedByte[] |
get(int address,
int length)
Fetch a sequence of bytes from memory. |
UnsignedByte[] |
integerToBytes(int i)
Convert a Big Endian integer into an array of 4 bytes organized by memory address. |
protected boolean |
isAccessAligned(int address,
int length)
Determine whether an address is aligned to specified length. |
int |
length()
Determine the size of memory. |
protected void |
set(int address,
UnsignedByte[] value)
Store a sequence of bytes into memory. |
| Methods inherited from class machine.AbstractMainMemory |
|---|
getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, newInstance, read, readInteger, readIntegerUnaligned, readUnaligned, setValueAt, setValueAt, setValueAtByUser, setValueAtByUser, valueEquals, 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 |
|---|
public MainMemory(int byteCapacity)
byteCapacity - size of memory in bytes.| Method Detail |
|---|
protected boolean isAccessAligned(int address,
int length)
isAccessAligned in class AbstractMainMemoryaddress - memory address.length - byte length.
public int bytesToInteger(UnsignedByte byteAtAddrPlus0,
UnsignedByte byteAtAddrPlus1,
UnsignedByte byteAtAddrPlus2,
UnsignedByte byteAtAddrPlus3)
bytesToInteger in class AbstractMainMemorybyteAtAddrPlus0 - value of byte with lowest memory address (base address).byteAtAddrPlus1 - value of byte at base address plus 1.byteAtAddrPlus2 - value of byte at base address plus 2.byteAtAddrPlus3 - value of byte at base address plus 3 (highest memory address).
public UnsignedByte[] integerToBytes(int i)
integerToBytes in class AbstractMainMemoryi - an Big Endian integer.
protected UnsignedByte[] get(int address,
int length)
throws AbstractMainMemory.InvalidAddressException
get in class AbstractMainMemoryaddress - address of the first byte to fetch.length - number of bytes to fetch.
AbstractMainMemory.InvalidAddressException - if address is out of range.
protected void set(int address,
UnsignedByte[] value)
throws AbstractMainMemory.InvalidAddressException
set in class AbstractMainMemoryaddress - address of the first byte in memory to recieve the specified value.value - an array of UnsignedByte values to store in memory at the specified address.
InvalidAddressException - if any address in the range address to address+value.length-1 is invalide.
AbstractMainMemory.InvalidAddressExceptionpublic int length()
length in class AbstractMainMemory
|
Simple Machine | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||