hicosim.control
Class Engine

java.lang.Object
  extended by hicosim.control.Engine

public class Engine
extends java.lang.Object

This class is the interface between the front- and backend and is used by clients(such as commandProcessor) to call methods in the backend.

Author:
Michael Wager, Andreas Weber, Luca Calchera 29th May 2009

Constructor Summary
Engine()
          Setup processorConfiguration, processor and memory and the utils.
 
Method Summary
 void addListener(iListenerFrontend listener)
           
 void addPlugin(IPlugin newPlugin)
           
 void checkNumerativeFlagAndDisplay(char regFlag, int value)
          This method checks the Numerative flags and displays the registervalues on the gui depending on the flags.
 void checkNumerativeFlagAndDisplayAll()
          This method is used to display All registers in the new setted Numerative
 void deleteAllBr()
          This method delete all breakpoints
 void deleteBreakpointAtDisascodeline(int index)
           
 void deleteBreakpointAtSourcecodeline(int index)
           
 boolean delWatchPoint(int adr)
           
 java.lang.String disas()
           
 void displayBreakpointAtDisascodeline(int index)
           
 void displayBreakpointAtSourcecodeline(int index)
           
 void displayConsole(java.lang.String message, boolean error)
          This method is used by backend to show messages(like next instruction to execute) in the GUI Konsole or in the commandline.
 void displayCpuConfiguration(java.util.HashMap<java.lang.String,java.lang.String> config)
          This method is used to display the changed configuration in the GUI.
 void displayInstructionPointer(int ip)
           
 void displayScalarRegChanges(java.lang.Object valOfA, java.lang.Object valOfX, java.lang.Object valOfY)
           
 void displaySingleVecValue(int i, int j, java.lang.Object value)
           
 void displayStatusRegister(int carry, boolean zero)
          display status register content
 void displayVectorRegChanges(int[][] vRegs)
           
 java.lang.String execute(java.lang.String cmd)
          execute an external process.
 void focusAtCommandline()
           
 java.lang.String getAboutMessage()
           
 int getAddressOfLabel(java.lang.String label)
           
 java.util.HashSet<java.lang.Integer> getAllWatchPoints()
           
 java.util.Vector<java.lang.Integer> getBreakpoints()
           
 java.lang.String getConfig()
          String representation of all processor configuration.
 java.util.HashMap<java.lang.String,java.lang.String> getCPUConfiguration()
           
 int getIP()
          Get current program counter.
 Labels getLabels()
          String representation of all labels.
 iListenerFrontend getListener()
           
 Memory getMemory()
           
 int getMemoryContentAt(int address)
           
 Processor getProcessor()
           
 ProcessorConfig getProcessorConfiguration()
           
 java.lang.String getRegs()
          String representation of all registers.
 java.lang.String getSourceCodeLines()
           
 java.lang.String getSourceCodePATH()
           
 Sourcefile getSourcefile()
           
 void highlightDisascodeline(int index)
           
 void highlightSourcecodeline(int index)
           
 void interrupt()
           
 boolean isObjectFileLoaded()
           
 boolean isProcessorRunning()
           
 boolean isWatchPoint(int adr)
           
 java.lang.String loadObjectFile(java.lang.String PATH)
          This method uses the memoryReference to load the objectfile.
 java.lang.String readSourcefile(java.lang.String PATH)
           
 void reset()
           
 void resetMemory()
           
 void run()
           
 java.lang.String setBreakpoint(java.lang.String paramBreak, boolean deletebr)
          This method interprets the parameter to the setBreakpoint-command and returns an InfoString or throws an Exception if this fails.
 java.lang.String setConfiguration(java.lang.String paramsConfig)
          This method sets the given Configuration Parameter.
 void setJTableVectorCpuRegisterOverviewSize(int rows, int columns)
           
 void setMemory(int address, int value)
           
 void setNumerative(char numerative)
          This method is used by GUI to set a flag to know in which Numerative the value of registers should be displayed.
 void setProcessorRunning(boolean running)
          This method is used to know if the processor is running or not.
 java.lang.String setRegister(java.lang.String paramSetR)
          This method is used to set the value of a register.
 boolean setWatchPoint(int adr)
           
 void step(boolean run)
          This method makes executes one single instruction.
 void writeToSourcefile(java.lang.String PATH, java.lang.String text)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Engine

public Engine()
Setup processorConfiguration, processor and memory and the utils.

Method Detail

getProcessor

public Processor getProcessor()

getMemory

public Memory getMemory()

getListener

public iListenerFrontend getListener()

focusAtCommandline

public void focusAtCommandline()

addListener

public void addListener(iListenerFrontend listener)
                 throws java.lang.Exception
Throws:
java.lang.Exception

displayConsole

public void displayConsole(java.lang.String message,
                           boolean error)
This method is used by backend to show messages(like next instruction to execute) in the GUI Konsole or in the commandline. ---> CALLBACK

Parameters:
message - - String - the message to display.
error - - boolean - if the message is an errorMessage or not.

setJTableVectorCpuRegisterOverviewSize

public void setJTableVectorCpuRegisterOverviewSize(int rows,
                                                   int columns)

displayInstructionPointer

public void displayInstructionPointer(int ip)

displayScalarRegChanges

public void displayScalarRegChanges(java.lang.Object valOfA,
                                    java.lang.Object valOfX,
                                    java.lang.Object valOfY)

displayVectorRegChanges

public void displayVectorRegChanges(int[][] vRegs)

displaySingleVecValue

public void displaySingleVecValue(int i,
                                  int j,
                                  java.lang.Object value)

displayStatusRegister

public void displayStatusRegister(int carry,
                                  boolean zero)
display status register content


displayCpuConfiguration

public void displayCpuConfiguration(java.util.HashMap<java.lang.String,java.lang.String> config)
This method is used to display the changed configuration in the GUI.


getCPUConfiguration

public java.util.HashMap<java.lang.String,java.lang.String> getCPUConfiguration()

displayBreakpointAtSourcecodeline

public void displayBreakpointAtSourcecodeline(int index)

displayBreakpointAtDisascodeline

public void displayBreakpointAtDisascodeline(int index)

deleteBreakpointAtSourcecodeline

public void deleteBreakpointAtSourcecodeline(int index)

deleteBreakpointAtDisascodeline

public void deleteBreakpointAtDisascodeline(int index)

highlightSourcecodeline

public void highlightSourcecodeline(int index)

highlightDisascodeline

public void highlightDisascodeline(int index)

addPlugin

public void addPlugin(IPlugin newPlugin)

loadObjectFile

public java.lang.String loadObjectFile(java.lang.String PATH)
                                throws java.lang.Exception
This method uses the memoryReference to load the objectfile. It also tries to read in the sourcefile.

Parameters:
PATH - - PATH to the objectFile
Returns:
- InfoString == "" if everything is OK.
Throws:
java.lang.Exception

setProcessorRunning

public void setProcessorRunning(boolean running)
This method is used to know if the processor is running or not.


isProcessorRunning

public boolean isProcessorRunning()

reset

public void reset()
           throws java.lang.Exception
Throws:
java.lang.Exception

resetMemory

public void resetMemory()
                 throws java.lang.Exception
Throws:
java.lang.Exception

run

public void run()
         throws java.lang.Exception
Throws:
java.lang.Exception

step

public void step(boolean run)
          throws java.lang.Exception
This method makes executes one single instruction.

Parameters:
run - - if client wants to execute just one instruction, run has to be false. This also shows the disassembly output of executed instruction. Else it can be used to run in a loop.
Throws:
java.lang.Exception

interrupt

public void interrupt()
               throws java.lang.Exception
Throws:
java.lang.Exception

isObjectFileLoaded

public boolean isObjectFileLoaded()

setWatchPoint

public boolean setWatchPoint(int adr)

isWatchPoint

public boolean isWatchPoint(int adr)

delWatchPoint

public boolean delWatchPoint(int adr)

getAllWatchPoints

public java.util.HashSet<java.lang.Integer> getAllWatchPoints()

deleteAllBr

public void deleteAllBr()
This method delete all breakpoints


getBreakpoints

public java.util.Vector<java.lang.Integer> getBreakpoints()

setBreakpoint

public java.lang.String setBreakpoint(java.lang.String paramBreak,
                                      boolean deletebr)
                               throws java.lang.Exception
This method interprets the parameter to the setBreakpoint-command and returns an InfoString or throws an Exception if this fails.

Parameters:
paramBreak - - parameter to set breakpoint command (decimal, 0xhex, label/+offset)
Returns:
String - InfoString
Throws:
java.lang.Exception

getAddressOfLabel

public int getAddressOfLabel(java.lang.String label)
                      throws java.lang.Exception
Throws:
java.lang.Exception

getRegs

public java.lang.String getRegs()
                         throws java.lang.Exception
String representation of all registers.

Throws:
java.lang.Exception

getIP

public int getIP()
Get current program counter.


getLabels

public Labels getLabels()
                 throws java.lang.Exception
String representation of all labels.

Throws:
java.lang.Exception

getConfig

public java.lang.String getConfig()
                           throws java.lang.Exception
String representation of all processor configuration.

Throws:
java.lang.Exception

getAboutMessage

public java.lang.String getAboutMessage()

readSourcefile

public java.lang.String readSourcefile(java.lang.String PATH)
                                throws java.lang.Exception
Throws:
java.lang.Exception

getSourceCodeLines

public java.lang.String getSourceCodeLines()
                                    throws java.lang.Exception
Throws:
java.lang.Exception

getSourceCodePATH

public java.lang.String getSourceCodePATH()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

getSourcefile

public Sourcefile getSourcefile()

writeToSourcefile

public void writeToSourcefile(java.lang.String PATH,
                              java.lang.String text)
                       throws java.lang.Exception
Throws:
java.lang.Exception

getMemoryContentAt

public int getMemoryContentAt(int address)
                       throws java.lang.Exception
Throws:
java.lang.Exception

setMemory

public void setMemory(int address,
                      int value)
               throws java.lang.Exception
Throws:
java.lang.Exception

getProcessorConfiguration

public ProcessorConfig getProcessorConfiguration()
                                          throws java.lang.Exception
Throws:
java.lang.Exception

setConfiguration

public java.lang.String setConfiguration(java.lang.String paramsConfig)
                                  throws java.lang.Exception
This method sets the given Configuration Parameter. the parameter has to be given like: e.g. "N 4" or "use_scalar_mult 1"

Throws:
java.lang.Exception

disas

public java.lang.String disas()
                       throws java.lang.Exception
Throws:
java.lang.Exception

execute

public java.lang.String execute(java.lang.String cmd)
                         throws java.lang.Exception
execute an external process. This method is used by HICOSIM to execute "clear" and "scotchas"

Throws:
java.lang.Exception

setNumerative

public void setNumerative(char numerative)
                   throws java.lang.Exception
This method is used by GUI to set a flag to know in which Numerative the value of registers should be displayed.

Parameters:
numerative - - 'd' = decimal; 'b' = binary; 'h' = hexadecimal else throw Exception
Throws:
java.lang.Exception

checkNumerativeFlagAndDisplayAll

public void checkNumerativeFlagAndDisplayAll()
This method is used to display All registers in the new setted Numerative


checkNumerativeFlagAndDisplay

public void checkNumerativeFlagAndDisplay(char regFlag,
                                          int value)
This method checks the Numerative flags and displays the registervalues on the gui depending on the flags. Registervalues are for A,X,Y, /*IP is ignored// and VectorRegs.

Parameters:
regFlag - - to know which reg should be updated
value -

setRegister

public java.lang.String setRegister(java.lang.String paramSetR)
                             throws java.lang.Exception
This method is used to set the value of a register. It is possible to set statusregister, scalarRegister and vectorRegister. for example: paramSetR=="carry 1" set carry=1 or paramSetR=="R12(5) 1234" set word 5 in R12 = 1234, or "A 7" : set content of reg A = 7. or "ip 12" : set ip = 12.

Parameters:
paramSetR -
Returns:
String
Throws:
java.lang.Exception