Class CPU

java.lang.Object
  |
  +--CPU

public class CPU
extends java.lang.Object

CPU simulates the central processing unit of SimpComp, which hosts and maintains registers, pc and ir. The primary functionality of CPU resides in its sequencer() in which each call to sequencer results in an execution of an instruction.


Constructor Summary
CPU()
           
 
Method Summary
 int getFlag()
          Returns the current flag status (includes ZNOC) as an integer.
 short[] getIR()
          Retrieves the instruction register (IR).
 java.lang.String getParams()
          Retrieves the parameters of the current instruction.
 int getPC()
          Retrieves the program counter (PC).
 int[] getRegister()
          Retrieves the register array.
 java.lang.String getStdOut()
          Returns the standard ouput.
 void reset()
          Resets all registers and flags to 0, program counter to 0x1000, stdI/O to empty.
 boolean sequencer(SCMainMem mm)
          Executes one instruction per call.
 java.lang.String toString()
          Overwrites the toString() inherited from Object Class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CPU

public CPU()
Method Detail

sequencer

public boolean sequencer(SCMainMem mm)
                  throws java.lang.IllegalArgumentException
Executes one instruction per call.

Returns:
run bit
java.lang.IllegalArgumentException

toString

public java.lang.String toString()
Overwrites the toString() inherited from Object Class. Output all registers and ir fields in the following format: "A [tab] B [tab] C [tab] D [tab] E [tab] IX [tab] BP[tab] SP [tab]" + "ir[0] [tab] ir[1] [tab] ir[2] [tab] ir[3] [tab]" + "PC [tab] Flag" The [tab] character is meant to be the deliminator for possible tokenization.

Overrides:
toString in class java.lang.Object
Returns:
String representation of cpu

getRegister

public int[] getRegister()
Retrieves the register array.

Returns:
register[]

getPC

public int getPC()
Retrieves the program counter (PC).

Returns:
program counter

getIR

public short[] getIR()
Retrieves the instruction register (IR).

Returns:
instruction register

reset

public void reset()
Resets all registers and flags to 0, program counter to 0x1000, stdI/O to empty.


getParams

public java.lang.String getParams()
Retrieves the parameters of the current instruction. Empty string if none.

Returns:
parameters

getStdOut

public java.lang.String getStdOut()
Returns the standard ouput. Note that this method simulates the standard output to console terminal. Since SimpComp Rev1.1 utilizes JAVA GUI's, the standard system.out is not desirable. As an alternative, any output generated by SimpComp is stored in a variable and is retrieved through this method, so that the output can be redirected to a GUI.

Returns:
output string

getFlag

public int getFlag()
Returns the current flag status (includes ZNOC) as an integer.