|
Simple Machine | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
machine.AbstractCPU
arch.sm213.machine.AbstractSM213CPU
public abstract class AbstractSM213CPU
Infrastructure for executing an SM213 CPU implementation.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class machine.AbstractCPU |
---|
AbstractCPU.ImplementationException, AbstractCPU.InternalState, AbstractCPU.InvalidInstructionException, AbstractCPU.MachineHaltException |
Field Summary | |
---|---|
protected Register.Port |
insOp0
Operand 0. |
protected Register.Port |
insOp1
Operand 1. |
protected Register.Port |
insOp2
Operand 2. |
protected Register.Port |
insOpCode
Opcode. |
protected Register.Port |
insOpExt
Extended operand (extra 4 bytes). |
protected Register.Port |
insOpImm
Immediate-value operand. |
protected Register.Port |
instruction
Value of current instruction (in its entirety). |
protected Register.Port |
pc
Program counter (address of next instruction). |
protected AbstractMainMemory.Port |
physMem
Physical memory (in case mem, is virtual memory) |
protected RegisterSet |
ps
Internal machine registers. |
protected Register.Port |
ptbr
|
Fields inherited from class machine.AbstractCPU |
---|
is, mem, reg |
Constructor Summary | |
---|---|
AbstractSM213CPU(String name,
AbstractMainMemory memory)
Create a new CPU. |
Method Summary | |
---|---|
protected void |
cycle()
Compute one cycle of the SM213 CPU |
void |
enableVirtualMemory()
Enable Virtual Memory address translation. |
protected abstract void |
execute()
Execute instruction currently loaded in processorState registers. |
protected abstract void |
fetch()
Fetch next instruction from memory into CPU processorState registers. |
void |
setPC(int aPC)
Set PC. |
int |
translateAddress(int va)
Translate address from virtual to physical. |
Methods inherited from class machine.AbstractCPU |
---|
getMainMemory, getName, getPC, getProcessorState, getRegisterFile, isInterrupt, newInstance, start, triggerInterrupt |
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 |
Field Detail |
---|
protected RegisterSet ps
protected Register.Port ptbr
protected Register.Port pc
protected Register.Port instruction
protected Register.Port insOpCode
protected Register.Port insOp0
protected Register.Port insOp1
protected Register.Port insOp2
protected Register.Port insOpImm
protected Register.Port insOpExt
protected AbstractMainMemory.Port physMem
Constructor Detail |
---|
public AbstractSM213CPU(String name, AbstractMainMemory memory)
name
- fully-qualified name of CPU implementation.memory
- main memory used by CPU.Method Detail |
---|
public void enableVirtualMemory()
public int translateAddress(int va) throws AbstractMainMemory.InvalidAddressException
va
- virtual address
AbstractMainMemory.InvalidAddressException
- if address is not validprotected void cycle() throws AbstractCPU.InvalidInstructionException, AbstractCPU.MachineHaltException, AbstractMainMemory.InvalidAddressException
cycle
in class AbstractCPU
AbstractCPU.InvalidInstructionException
- attempted to execute an invalid instruction.
AbstractCPU.MachineHaltException
- halt instruction executed.
AbstractMainMemory.InvalidAddressException
- attempted to execute an instruction that accesses an invalid memory address.public void setPC(int aPC)
setPC
in class AbstractCPU
aPC
- New memory address for PC.protected abstract void fetch() throws AbstractMainMemory.InvalidAddressException
AbstractMainMemory.InvalidAddressException
- Program counter stores an invalid memory address for fetching a new instruction.protected abstract void execute() throws AbstractCPU.InvalidInstructionException, AbstractCPU.MachineHaltException, RegisterSet.InvalidRegisterNumberException, AbstractMainMemory.InvalidAddressException
AbstractCPU.InvalidInstructionException
- instruction is invalid.
AbstractCPU.MachineHaltException
- instruction is the halt instruction.
RegisterSet.InvalidRegisterNumberException
- instruction encodes an invalid register number.
AbstractMainMemory.InvalidAddressException
- instruction encodes an invalid memory address.
|
Simple Machine | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |