Simple Machine

Arch.SM213.Machine.Student
Class CPU

java.lang.Object
  extended by java.util.Observable
      extended by Machine.AbstractCPU
          extended by Arch.SM213.Machine.AbstractSM213CPU
              extended by Arch.SM213.Machine.Student.CPU

public class CPU
extends AbstractSM213CPU

The Simple Machine CPU. Simulate the execution of a single cycle of the Simple Machine CPU.

See Also:
AbstractSM213CPU

Nested Class Summary
 
Nested classes/interfaces inherited from class Machine.AbstractCPU
AbstractCPU.InvalidInstructionException, AbstractCPU.MachineHaltException
 
Field Summary
 
Fields inherited from class Arch.SM213.Machine.AbstractSM213CPU
curInst, insOp0, insOp1, insOp2, insOpCode, insOpExt, insOpImm, instruction, pc, ps
 
Fields inherited from class Machine.AbstractCPU
CURRENT_INSTRUCTION_ADDRESS, isInterrupt, mem, PC, processorState, reg
 
Constructor Summary
CPU(MainMemory aMem)
           
 
Method Summary
protected  void execute()
          Execution Stage of CPU Cucle.
protected  void fetch()
          Fetch Stage of CPU Cycle.
 
Methods inherited from class Arch.SM213.Machine.AbstractSM213CPU
cycle, setPC
 
Methods inherited from class Machine.AbstractCPU
getMainMemory, getName, getPC, getProcessorState, getRegisterFile, 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
 

Constructor Detail

CPU

public CPU(MainMemory aMem)
Method Detail

fetch

protected void fetch()
              throws AbstractMainMemory.InvalidAddressException
Fetch Stage of CPU Cycle. Fetch instruction at address stored in "pc" register from memory into instruction register and set "pc" to point to the next instruction to execute. Input register: pc. Output registers: pc, instruction, insOpCode, insOp0, insOp1, insOp2, insOpImm, insOpExt

Specified by:
fetch in class AbstractSM213CPU
Throws:
MainMemory.InvalidAddressException - when program counter contains an invalid memory address
AbstractMainMemory.InvalidAddressException
See Also:
for pc, instruction, insOpCode, insOp0, insOp1, insOp2, insOpImm, insOpExt

execute

protected void execute()
                throws AbstractCPU.InvalidInstructionException,
                       AbstractCPU.MachineHaltException,
                       RegisterSet.InvalidRegisterNumberException,
                       AbstractMainMemory.InvalidAddressException
Execution Stage of CPU Cucle. Execute instruction that was fetched by Fetch stage. Input state: pc, instruction, insOpCode, insOp0, insOp1, insOp2, insOpImm, insOpExt, reg, mem Ouput state: pc, reg, mem

Specified by:
execute in class AbstractSM213CPU
Throws:
InvalidInstructionException - when instruction format is invalid
MachineHaltException - when instruction is the HALT instruction
RegisterSet.InvalidRegisterNumberException - when instruction references an invalid register (i.e, not 0-7)
MainMemory.InvalidAddressException - when instruction references an invalid memory address
AbstractCPU.InvalidInstructionException
AbstractCPU.MachineHaltException
AbstractMainMemory.InvalidAddressException
See Also:
for pc, instruction, insOpCode, insOp0, insOp1, insOp2, insOpImm, insOpExt, for mem, for reg

Simple Machine