|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.github.croesch.micro_debug.mic1.mem.Memory
public final class Memory
Represents the main memory of the processor.
| Field Summary | |
|---|---|
static int |
IJVM_MAGIC_NUMBER
the magic number that is needed at the begin of a binary ijvm-file |
static int |
MEMORY_MAPPED_IO_ADDRESS
address which isn't an address in the memory, but is connected to memory mapped io |
| Constructor Summary | |
|---|---|
Memory(int maxSize,
InputStream programStream)
Constructs a new memory containing the given number of words. |
|
| Method Summary | |
|---|---|
void |
doTick()
Tells the memory to do its work. |
void |
fillRegisters(Register wordRegister,
Register byteRegister)
If at least the signal read or fetch has been set in the memory. |
int |
getByte(int addr)
Returns a single byte, unsigned, read from the address in the memory. |
int |
getSize()
Returns the size of the memory. |
int |
getWord(int addr)
Returns the word value at the given address. |
void |
reset()
Resets the Memory so that it behaves as when started. |
void |
setByteAddress(int addr)
Sets the address of the byte, where to read from in the memory. |
void |
setFetch(boolean ft)
Sets the input signal fetch, that enforces the main memory to read a byte from the memory. |
void |
setRead(boolean rd)
Sets the input signal read, that enforces the main memory to read a word from the memory. |
void |
setWord(int addr,
int value)
Sets the word value at the given address to the given value. |
void |
setWordAddress(int addr)
Sets the address of the word, where to read from or write to in the memory. |
void |
setWordValue(int value)
Sets the value of the word to write to the memory. |
void |
setWrite(boolean wr)
Sets the input signal write, that enforces the main memory to write a word to the memory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MEMORY_MAPPED_IO_ADDRESS
public static final int IJVM_MAGIC_NUMBER
| Constructor Detail |
|---|
public Memory(int maxSize,
InputStream programStream)
throws FileFormatException
maxSize - the size of the memory in words (32-bit-values)programStream - the input stream
FileFormatException - if the stream doesn't provide valid data.| Method Detail |
|---|
public void reset()
Memory so that it behaves as when started.
public void setRead(boolean rd)
read, that enforces the main memory to read a word from the memory.
rd - true, if the memory should read a word.setWordAddress(int)public void setWrite(boolean wr)
write, that enforces the main memory to write a word to the memory.
wr - true, if the memory should write a word.setWordAddress(int),
setWordValue(int)public void setFetch(boolean ft)
fetch, that enforces the main memory to read a byte from the memory.
ft - true, if the memory should read a byte.setByteAddress(int)public void setWordAddress(int addr)
addr - 32-bit-value that defines the address where to read from or write to a word.setRead(boolean),
setWrite(boolean)public void setWordValue(int value)
value - the word value to write to the memory.setWrite(boolean),
setWordAddress(int)public void setByteAddress(int addr)
addr - 32-bit-value that defines the address where to read a byte from.setFetch(boolean)
public void fillRegisters(Register wordRegister,
Register byteRegister)
read or fetch has been set in the memory. The values read will be
stored in the given registers.doTick() before invoking this method.
wordRegister - if the signal read has been set, will be filled with the value read from the
memorybyteRegister - if the signal fetch has been set, will be filled with the value read from the
memorydoTick()public void doTick()
read, write and fetch
it will do some work. It will store the value to write into the memory and the values read from the memory into
variables.
fillRegisters(Register, Register)public int getByte(int addr)
getByte in interface IReadableMemoryaddr - the byte address of the byte to read from the memory
public int getWord(int addr)
getWord in interface IReadableMemoryaddr - the address, from where to fetch the word
public void setWord(int addr,
int value)
addr - the address, where to write the word tovalue - the word to write to the memorypublic int getSize()
getSize in interface IReadableMemory
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||