|
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 |
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, 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 |
---|
public MainMemory(int byteCapacity)
byteCapacity
- size of memory in bytesMethod Detail |
---|
protected boolean isAccessAligned(int address, int length)
isAccessAligned
in class AbstractMainMemory
address
- memory addresslength
- byte length
public int bytesToInteger(UnsignedByte byteAtAddrPlus0, UnsignedByte byteAtAddrPlus1, UnsignedByte byteAtAddrPlus2, UnsignedByte byteAtAddrPlus3)
bytesToInteger
in class AbstractMainMemory
byteAtAddrPlus0
- value of byte with lowest memory address (base address)byteAtAddrPlus1
- value of byte at base address plus 1byteAtAddrPlus2
- value of byte at base address plus 2byteAtAddrPlus3
- value of byte at base address plus 3 (highest memory address)
public UnsignedByte[] integerToBytes(int i)
integerToBytes
in class AbstractMainMemory
i
- an Big Endian integer
protected UnsignedByte[] get(int address, int length) throws AbstractMainMemory.InvalidAddressException
get
in class AbstractMainMemory
address
- address of the first byte to fetchlength
- 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 AbstractMainMemory
address
- address of the first byte in memory to receive the specified valuevalue
- 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 invalid
AbstractMainMemory.InvalidAddressException
public int length()
length
in class AbstractMainMemory
|
Simple Machine | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |