arch.sm213.machine.student
Class CPU
java.lang.Object
java.util.Observable
machine.AbstractCPU
arch.sm213.machine.AbstractSM213CPU
arch.sm213.machine.student.CPU
- Direct Known Subclasses:
- VirtualMemoryCPU
public class CPU
- extends AbstractSM213CPU
The Simple Machine CPU.
Simulate the execution of a single cycle of the Simple Machine SM213 CPU.
Fields inherited from class arch.sm213.machine.AbstractSM213CPU |
insOp0, insOp1, insOp2, insOpCode, insOpExt, insOpImm, instruction, pc, physMem, ps, ptbr |
Method Summary |
protected void |
execute()
Execution Stage of CPU Cycle. |
protected void |
fetch()
Fetch Stage of CPU Cycle. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CPU
public CPU(String name,
AbstractMainMemory memory)
- Create a new CPU.
- Parameters:
name
- fully-qualified name of CPU implementation.memory
- main memory used by CPU.
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
- Program counter stores an invalid memory address for fetching a new instruction.- 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 Cycle.
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
- instruction is invalid.
AbstractCPU.MachineHaltException
- instruction is the halt instruction.
AbstractMainMemory.InvalidAddressException
- instruction encodes an invalid memory address.- See Also:
for pc, instruction, insOpCode, insOp0, insOp1, insOp2, insOpImm, insOpExt
,
for mem
,
for reg
Copyright © 2010, 2011 Mike Feeley. All Rights Reserved.